@elliemae/ds-treeview 2.0.0-alpha.1 → 2.0.0-alpha.13
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/TreeView.js +9 -3
- package/cjs/TreeViewContext.js +1 -1
- package/cjs/config/cssClassesConstants.js +1 -1
- package/cjs/deprecated/TreeView.js +11 -5
- package/cjs/deprecated/__testUtils__/utils.js +13 -4
- package/cjs/deprecated/plugins/dnd/TreeDndPlugin.js +17 -10
- package/cjs/deprecated/plugins/dnd/renderers/DraggableItem.js +13 -8
- package/cjs/deprecated/plugins/dnd/renderers/DroppableList.js +26 -20
- package/cjs/deprecated/plugins/dnd/utils.js +43 -35
- package/cjs/deprecated/plugins/roving/TreeRovingPlugin.js +18 -8
- package/cjs/deprecated/plugins/searchable/SearchableTreePlugin.js +7 -5
- package/cjs/deprecated/plugins/searchable/utils.js +1 -1
- package/cjs/deprecated/plugins/selectable/SelectablePluginTree.js +55 -35
- package/cjs/deprecated/plugins/toolbar/TreeToolbarPlugin.js +18 -14
- package/cjs/deprecated/plugins/tree/TreeDataPlugin.js +51 -40
- package/cjs/deprecated/plugins/tree/useExpandTreeState.js +10 -6
- package/cjs/deprecated/plugins/tree/utils.js +21 -8
- package/cjs/deprecated/plugins/tree/walkTreeStrategy.js +13 -9
- package/cjs/deprecated/plugins/virtualization/TreeVirtualizationPlugin.js +27 -13
- package/cjs/deprecated/renderers.js +19 -11
- package/cjs/parts/CheckboxSelectable.js +10 -6
- package/cjs/parts/ChildrenCountDisplayer.js +3 -3
- package/cjs/parts/ExpandCaret.js +14 -14
- package/cjs/parts/Icon.js +4 -4
- package/cjs/parts/NestingSpace.js +8 -3
- package/cjs/parts/RadioSelectable.js +4 -5
- package/cjs/parts/TreeItem.js +44 -33
- package/cjs/parts/TreeItemText.js +27 -24
- package/cjs/parts/TreeList.js +30 -20
- package/cjs/plugins/dnd/TreeDndPlugin.js +2 -2
- package/cjs/prop-types.js +20 -20
- package/cjs/related-components/TreeViewSearchBar.js +2 -2
- package/cjs/utils/array-helpers.js +2 -0
- package/cjs/utils/dnd-helpers.js +29 -25
- package/cjs/utils/group-expands-helpers.js +7 -5
- package/cjs/utils/keyboard-helpers.js +7 -4
- package/cjs/utils/object-helpers.js +8 -0
- package/cjs/utils/refs-helpers.js +11 -1
- package/cjs/utils/selectable-helper.js +10 -3
- package/cjs/utils/tree-helpers.js +27 -9
- package/cjs/utils/useDnDHelpers.js +22 -15
- package/cjs/utils/useInstanceRefActions.js +14 -10
- package/cjs/utils/useTree.js +8 -2
- package/esm/TreeView.js +6 -0
- package/esm/config/cssClassesConstants.js +1 -1
- package/esm/deprecated/TreeView.js +7 -1
- package/esm/deprecated/__testUtils__/utils.js +10 -1
- package/esm/deprecated/plugins/dnd/TreeDndPlugin.js +14 -7
- package/esm/deprecated/plugins/dnd/renderers/DraggableItem.js +9 -3
- package/esm/deprecated/plugins/dnd/renderers/DroppableList.js +18 -11
- package/esm/deprecated/plugins/dnd/utils.js +35 -27
- package/esm/deprecated/plugins/roving/TreeRovingPlugin.js +12 -2
- package/esm/deprecated/plugins/searchable/SearchableTreePlugin.js +4 -1
- package/esm/deprecated/plugins/searchable/utils.js +1 -1
- package/esm/deprecated/plugins/selectable/SelectablePluginTree.js +45 -22
- package/esm/deprecated/plugins/toolbar/TreeToolbarPlugin.js +8 -3
- package/esm/deprecated/plugins/tree/TreeDataPlugin.js +35 -22
- package/esm/deprecated/plugins/tree/useExpandTreeState.js +7 -2
- package/esm/deprecated/plugins/tree/utils.js +19 -6
- package/esm/deprecated/plugins/tree/walkTreeStrategy.js +13 -9
- package/esm/deprecated/plugins/virtualization/TreeVirtualizationPlugin.js +24 -10
- package/esm/deprecated/renderers.js +17 -9
- package/esm/parts/CheckboxSelectable.js +7 -2
- package/esm/parts/ChildrenCountDisplayer.js +2 -2
- package/esm/parts/ExpandCaret.js +9 -7
- package/esm/parts/Icon.js +1 -1
- package/esm/parts/NestingSpace.js +6 -1
- package/esm/parts/RadioSelectable.js +3 -3
- package/esm/parts/TreeItem.js +34 -22
- package/esm/parts/TreeItemText.js +16 -13
- package/esm/parts/TreeList.js +25 -15
- package/esm/related-components/TreeViewSearchBar.js +1 -1
- package/esm/utils/array-helpers.js +2 -0
- package/esm/utils/dnd-helpers.js +29 -25
- package/esm/utils/group-expands-helpers.js +7 -5
- package/esm/utils/keyboard-helpers.js +6 -3
- package/esm/utils/object-helpers.js +8 -0
- package/esm/utils/refs-helpers.js +11 -1
- package/esm/utils/selectable-helper.js +9 -2
- package/esm/utils/tree-helpers.js +27 -9
- package/esm/utils/useDnDHelpers.js +21 -14
- package/esm/utils/useInstanceRefActions.js +14 -10
- package/esm/utils/useTree.js +6 -0
- package/package.json +14 -13
- package/types/TreeView.d.ts +118 -28
- package/types/deprecated/__testUtils__/utils.d.ts +49 -49
- package/types/deprecated/plugins/tree/useExpandTreeState.d.ts +12 -2
- package/types/react-desc-prop-types.d.ts +113 -27
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
3
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
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.reduce.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
11
|
import { useMemo, useCallback } from 'react';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { cx, isFunction } from '@elliemae/ds-utilities/utils';
|
|
7
|
-
import useDerivedStateFromProps from '@elliemae/ds-utilities/hooks/useDerivedStateFromProps';
|
|
12
|
+
import { DSCheckbox, DSRadio } from '@elliemae/ds-form';
|
|
13
|
+
import { cx, useDerivedStateFromProps, isFunction } from '@elliemae/ds-utilities';
|
|
8
14
|
import createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';
|
|
9
15
|
import { walkTreeStrategy } from '../tree/walkTreeStrategy.js';
|
|
10
16
|
import { getParentId, getParentChildren } from '../tree/utils.js';
|
|
@@ -15,12 +21,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
15
21
|
|
|
16
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
23
|
|
|
18
|
-
const updateParentState =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
const updateParentState = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
node,
|
|
27
|
+
checked,
|
|
28
|
+
selectionState,
|
|
29
|
+
isCurrentParentChildren = true
|
|
30
|
+
} = _ref;
|
|
24
31
|
const {
|
|
25
32
|
parentNode
|
|
26
33
|
} = node;
|
|
@@ -72,10 +79,16 @@ const useSelectableTreeState = instance => {
|
|
|
72
79
|
|
|
73
80
|
return 'mixed';
|
|
74
81
|
}, [selection]);
|
|
75
|
-
const select = useCallback((record
|
|
82
|
+
const select = useCallback(function (record) {
|
|
83
|
+
let additionalActions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
84
|
+
|
|
76
85
|
if (isFunction(onSelect)) {
|
|
77
86
|
onSelect(record.data, {
|
|
78
|
-
scrollToItem: (
|
|
87
|
+
scrollToItem: function () {
|
|
88
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
89
|
+
args[_key] = arguments[_key];
|
|
90
|
+
}
|
|
91
|
+
|
|
79
92
|
if (additionalActions.scrollToItem) additionalActions.scrollToItem(args);
|
|
80
93
|
},
|
|
81
94
|
itemIndex: additionalActions === null || additionalActions === void 0 ? void 0 : additionalActions.itemIndex
|
|
@@ -117,7 +130,11 @@ const useSelectableTreeState = instance => {
|
|
|
117
130
|
}
|
|
118
131
|
|
|
119
132
|
onSelectionChange(nextSelectionState, record.data, {
|
|
120
|
-
scrollToItem: (
|
|
133
|
+
scrollToItem: function () {
|
|
134
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
135
|
+
args[_key2] = arguments[_key2];
|
|
136
|
+
}
|
|
137
|
+
|
|
121
138
|
if (additionalActions.scrollToItem) additionalActions.scrollToItem(args);
|
|
122
139
|
},
|
|
123
140
|
itemIndex: additionalActions === null || additionalActions === void 0 ? void 0 : additionalActions.itemIndex
|
|
@@ -179,9 +196,10 @@ const SelectablePluginTree = createInstancePlugin('selectable', {
|
|
|
179
196
|
return record;
|
|
180
197
|
},
|
|
181
198
|
|
|
182
|
-
getItemProps(props, instance, {
|
|
183
|
-
|
|
184
|
-
|
|
199
|
+
getItemProps(props, instance, _ref3) {
|
|
200
|
+
let {
|
|
201
|
+
record
|
|
202
|
+
} = _ref3;
|
|
185
203
|
const {
|
|
186
204
|
actions: {
|
|
187
205
|
select
|
|
@@ -195,15 +213,19 @@ const SelectablePluginTree = createInstancePlugin('selectable', {
|
|
|
195
213
|
} = instance.getInstance();
|
|
196
214
|
|
|
197
215
|
const handleSelect = () => select(record, {
|
|
198
|
-
scrollToItem: (
|
|
216
|
+
scrollToItem: function () {
|
|
199
217
|
var _props$listRef, _props$listRef$curren;
|
|
200
218
|
|
|
219
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
220
|
+
args[_key3] = arguments[_key3];
|
|
221
|
+
}
|
|
222
|
+
|
|
201
223
|
return props === null || props === void 0 ? void 0 : (_props$listRef = props.listRef) === null || _props$listRef === void 0 ? void 0 : (_props$listRef$curren = _props$listRef.current) === null || _props$listRef$curren === void 0 ? void 0 : _props$listRef$curren.scrollToItem(args);
|
|
202
224
|
},
|
|
203
225
|
itemIndex: props === null || props === void 0 ? void 0 : props.index
|
|
204
226
|
});
|
|
205
227
|
|
|
206
|
-
const checkboxAddon = isMultiSelect && /*#__PURE__*/_jsx(
|
|
228
|
+
const checkboxAddon = isMultiSelect && /*#__PURE__*/_jsx(DSCheckbox, {
|
|
207
229
|
checked: record.checked,
|
|
208
230
|
disabled: record.isGroup ? disableGroups : disableLeafs,
|
|
209
231
|
className: "tree-item-checkbox",
|
|
@@ -212,7 +234,7 @@ const SelectablePluginTree = createInstancePlugin('selectable', {
|
|
|
212
234
|
tabIndex: -1
|
|
213
235
|
});
|
|
214
236
|
|
|
215
|
-
const radioAddon = isSingleSelect && !isMultiSelect && /*#__PURE__*/_jsx(
|
|
237
|
+
const radioAddon = isSingleSelect && !isMultiSelect && /*#__PURE__*/_jsx(DSRadio, {
|
|
216
238
|
checked: !!record.checked,
|
|
217
239
|
disabled: record.isGroup ? disableGroups : disableLeafs,
|
|
218
240
|
className: "tree-item-radio",
|
|
@@ -238,9 +260,10 @@ const SelectablePluginTree = createInstancePlugin('selectable', {
|
|
|
238
260
|
hotKeys(grid) {
|
|
239
261
|
return {
|
|
240
262
|
key: 'space',
|
|
241
|
-
handler:
|
|
242
|
-
|
|
243
|
-
|
|
263
|
+
handler: _ref4 => {
|
|
264
|
+
let {
|
|
265
|
+
index
|
|
266
|
+
} = _ref4;
|
|
244
267
|
const {
|
|
245
268
|
records,
|
|
246
269
|
actions: {
|
|
@@ -1,10 +1,15 @@
|
|
|
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';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
8
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
9
|
import { useMemo, useContext, useRef } from 'react';
|
|
5
|
-
import MoreOptionsVert from '@elliemae/ds-icons
|
|
6
|
-
import Button from '@elliemae/ds-
|
|
7
|
-
import { runAll } from '@elliemae/ds-utilities
|
|
10
|
+
import { MoreOptionsVert } from '@elliemae/ds-icons';
|
|
11
|
+
import Button from '@elliemae/ds-button';
|
|
12
|
+
import { runAll } from '@elliemae/ds-utilities';
|
|
8
13
|
import createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';
|
|
9
14
|
import ToolbarProvider, { ToolbarContext } from '@elliemae/ds-shared/toolbar/ToolbarProvider';
|
|
10
15
|
import FocusGroupContext from '@elliemae/ds-shared/FocusGroup/FocusGroupContext';
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
5
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.some.js';
|
|
10
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
11
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
12
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
3
13
|
import React, { useCallback } from 'react';
|
|
4
|
-
import { cx, isFunction } from '@elliemae/ds-utilities
|
|
5
|
-
import Button from '@elliemae/ds-
|
|
6
|
-
import ArrowheadDown from '@elliemae/ds-icons
|
|
7
|
-
import ArrowheadRight from '@elliemae/ds-icons/ArrowheadRight';
|
|
14
|
+
import { cx, isFunction } from '@elliemae/ds-utilities';
|
|
15
|
+
import Button from '@elliemae/ds-button';
|
|
16
|
+
import { ArrowheadDown, ArrowheadRight } from '@elliemae/ds-icons';
|
|
8
17
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
9
18
|
import createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';
|
|
10
19
|
import { walkTreeStrategy } from './walkTreeStrategy.js';
|
|
@@ -17,7 +26,7 @@ var _ArrowheadDown, _ArrowheadRight;
|
|
|
17
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
18
27
|
|
|
19
28
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
20
|
-
const ItemContent = aggregatedClasses('div')(
|
|
29
|
+
const ItemContent = aggregatedClasses('div')("".concat(treeItemBlockName, "-content"));
|
|
21
30
|
const ItemValue = aggregatedClasses('span')(treeItemBlockName, 'value');
|
|
22
31
|
|
|
23
32
|
const noop = () => null;
|
|
@@ -31,7 +40,7 @@ const getItemNestingLeftPadding = (level, opts) => {
|
|
|
31
40
|
}, opts);
|
|
32
41
|
|
|
33
42
|
const groupLeftPadding = spaceForNestingLevel * (level - 1);
|
|
34
|
-
return isChild ?
|
|
43
|
+
return isChild ? "".concat(groupLeftPadding + spaceForNestingLevel - 0.1, "em") : "".concat(groupLeftPadding, "em");
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
const itemRenderer = (value, itemProps, instance) => {
|
|
@@ -52,9 +61,9 @@ const itemRenderer = (value, itemProps, instance) => {
|
|
|
52
61
|
const amountChildren = Number(getItemChildrenLength(record));
|
|
53
62
|
const renderedLabel = isFunction(labelRenderer) && labelRenderer(value, itemProps) || value;
|
|
54
63
|
return /*#__PURE__*/_jsx(ItemContent, {
|
|
55
|
-
"data-testid":
|
|
64
|
+
"data-testid": "".concat(treeItemBlockName, "-content"),
|
|
56
65
|
onClick: handleItemClick
|
|
57
|
-
}, void 0, /*#__PURE__*/_jsx(ItemValue, {}, void 0, renderedLabel, showChildrenAmount && record.isGroup &&
|
|
66
|
+
}, void 0, /*#__PURE__*/_jsx(ItemValue, {}, void 0, renderedLabel, showChildrenAmount && record.isGroup && " (".concat(amountChildren, ")")));
|
|
58
67
|
};
|
|
59
68
|
|
|
60
69
|
itemRenderer.order = 100;
|
|
@@ -79,9 +88,10 @@ const TreePluginList = createInstancePlugin('tree-data', {
|
|
|
79
88
|
}));
|
|
80
89
|
},
|
|
81
90
|
|
|
82
|
-
getItemProps(props, instance, {
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
getItemProps(props, instance, _ref) {
|
|
92
|
+
let {
|
|
93
|
+
record
|
|
94
|
+
} = _ref;
|
|
85
95
|
const {
|
|
86
96
|
nestingLevel
|
|
87
97
|
} = record;
|
|
@@ -120,7 +130,7 @@ const TreePluginList = createInstancePlugin('tree-data', {
|
|
|
120
130
|
size: "s",
|
|
121
131
|
tabIndex: -1 // eslint-disable-next-line max-lines
|
|
122
132
|
|
|
123
|
-
},
|
|
133
|
+
}, "".concat(record.id, "-expand-addon"));
|
|
124
134
|
|
|
125
135
|
const iconAddon = icon && /*#__PURE__*/React.cloneElement(icon, {
|
|
126
136
|
'data-testid': record.isGroup ? 'tree-item-group-icon' : 'tree-item-icon',
|
|
@@ -132,7 +142,7 @@ const TreePluginList = createInstancePlugin('tree-data', {
|
|
|
132
142
|
style: {
|
|
133
143
|
width: itemNestingLeftPadding
|
|
134
144
|
}
|
|
135
|
-
},
|
|
145
|
+
}, "".concat(record.id, "-space-addon"));
|
|
136
146
|
|
|
137
147
|
return _objectSpread(_objectSpread({}, props), {}, {
|
|
138
148
|
'data-id': record.id,
|
|
@@ -158,9 +168,10 @@ const TreePluginList = createInstancePlugin('tree-data', {
|
|
|
158
168
|
},
|
|
159
169
|
|
|
160
170
|
hotKeys(instance) {
|
|
161
|
-
function handleExpand({
|
|
162
|
-
|
|
163
|
-
|
|
171
|
+
function handleExpand(_ref2) {
|
|
172
|
+
let {
|
|
173
|
+
index
|
|
174
|
+
} = _ref2;
|
|
164
175
|
const {
|
|
165
176
|
records,
|
|
166
177
|
actions: {
|
|
@@ -171,9 +182,10 @@ const TreePluginList = createInstancePlugin('tree-data', {
|
|
|
171
182
|
if (record && record.data.children.length > 0) _toggleExpand(record.data);
|
|
172
183
|
}
|
|
173
184
|
|
|
174
|
-
function handleCollapse({
|
|
175
|
-
|
|
176
|
-
|
|
185
|
+
function handleCollapse(_ref3) {
|
|
186
|
+
let {
|
|
187
|
+
index
|
|
188
|
+
} = _ref3;
|
|
177
189
|
const {
|
|
178
190
|
records,
|
|
179
191
|
actions: {
|
|
@@ -225,9 +237,10 @@ const TreePluginList = createInstancePlugin('tree-data', {
|
|
|
225
237
|
handler: handleCollapse
|
|
226
238
|
}, {
|
|
227
239
|
key: 'enter',
|
|
228
|
-
handler:
|
|
229
|
-
|
|
230
|
-
|
|
240
|
+
handler: _ref4 => {
|
|
241
|
+
let {
|
|
242
|
+
index
|
|
243
|
+
} = _ref4;
|
|
231
244
|
const {
|
|
232
245
|
records,
|
|
233
246
|
actions: {
|
|
@@ -1,7 +1,12 @@
|
|
|
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';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
8
|
import { useRef, useState, useEffect } from 'react';
|
|
3
|
-
import useExpandState from '@elliemae/ds-utilities
|
|
4
|
-
import { isFunction } from '@elliemae/ds-utilities/utils';
|
|
9
|
+
import { useExpandState, isFunction } from '@elliemae/ds-utilities';
|
|
5
10
|
import { walkTreeStrategy } from './walkTreeStrategy.js';
|
|
6
11
|
|
|
7
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
1
4
|
import get from 'lodash/get';
|
|
2
5
|
|
|
3
6
|
const getParentId = record => get(record, ['parentNode', 'id']);
|
|
4
|
-
const findItemOnDocument = id => document.querySelector(
|
|
5
|
-
const getListFromDocument = () => document.querySelector(
|
|
6
|
-
const getParentChildren = (record
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const findItemOnDocument = id => document.querySelector("[data-id=\"".concat(id, "\"]"));
|
|
8
|
+
const getListFromDocument = () => document.querySelector("[data-testid=\"tree-list\"]");
|
|
9
|
+
const getParentChildren = function (record) {
|
|
10
|
+
let childrenKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'children';
|
|
11
|
+
return get(record, ['parentNode', 'data', childrenKey]);
|
|
12
|
+
};
|
|
13
|
+
const getItemLabel = function (record) {
|
|
14
|
+
let nameKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'name';
|
|
15
|
+
return get(record, ['data', nameKey]);
|
|
16
|
+
};
|
|
17
|
+
const getItemChildren = function (record) {
|
|
18
|
+
let childrenKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'children';
|
|
19
|
+
return get(record, ['data', childrenKey]);
|
|
20
|
+
};
|
|
21
|
+
const getItemChildrenLength = function (record) {
|
|
22
|
+
let childrenKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'children';
|
|
10
23
|
const children = get(record, ['data', childrenKey]);
|
|
11
24
|
return children && children.length;
|
|
12
25
|
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
|
|
1
3
|
function getPath(parentNode, index, childrenKey) {
|
|
2
4
|
if (!parentNode) return [index];
|
|
3
5
|
return [...parentNode.path, childrenKey, index];
|
|
4
6
|
}
|
|
5
7
|
|
|
6
|
-
function walkTreeStrategy({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
function walkTreeStrategy(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
data,
|
|
11
|
+
childrenKey = 'children',
|
|
12
|
+
level = 0,
|
|
13
|
+
getId = item => item.id,
|
|
14
|
+
parentNode,
|
|
15
|
+
shouldWalkChildren = () => true,
|
|
16
|
+
cb
|
|
17
|
+
} = _ref;
|
|
18
|
+
|
|
15
19
|
// eslint-disable-next-line no-plusplus
|
|
16
20
|
for (let i = 0; i < data.length; i++) {
|
|
17
21
|
const currLevel = level + 1;
|
|
@@ -1,3 +1,8 @@
|
|
|
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';
|
|
1
6
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
7
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
8
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
@@ -49,11 +54,12 @@ function areEqualRecords(prevProps, nextProps) {
|
|
|
49
54
|
// https://react-window.now.sh/#/examples/list/memoized-list-items
|
|
50
55
|
|
|
51
56
|
|
|
52
|
-
const VirtualizedTreeItem = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
const VirtualizedTreeItem = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
58
|
+
let {
|
|
59
|
+
index,
|
|
60
|
+
style,
|
|
61
|
+
data
|
|
62
|
+
} = _ref;
|
|
57
63
|
const {
|
|
58
64
|
instance,
|
|
59
65
|
records,
|
|
@@ -84,13 +90,13 @@ const VirtualizedTreeItem = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardR
|
|
|
84
90
|
}));
|
|
85
91
|
}), areEqualRecords); // eslint-disable-next-line react/display-name
|
|
86
92
|
|
|
87
|
-
const VirtualizedTree = (renderers, instance) =>
|
|
93
|
+
const VirtualizedTree = (renderers, instance) => _ref2 => {
|
|
88
94
|
let {
|
|
89
95
|
records,
|
|
90
96
|
itemRenderer,
|
|
91
97
|
innerRef
|
|
92
|
-
} =
|
|
93
|
-
rest = _objectWithoutProperties(
|
|
98
|
+
} = _ref2,
|
|
99
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
94
100
|
|
|
95
101
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
96
102
|
const {
|
|
@@ -152,17 +158,25 @@ const TreeVirtualizationPlugin = createInstancePlugin('tree-virtualization', {
|
|
|
152
158
|
listRef
|
|
153
159
|
},
|
|
154
160
|
actions: {
|
|
155
|
-
scrollTo: (
|
|
161
|
+
scrollTo: function () {
|
|
156
162
|
var _listRef$current;
|
|
157
163
|
|
|
158
164
|
if (listRef !== null && listRef !== void 0 && (_listRef$current = listRef.current) !== null && _listRef$current !== void 0 && _listRef$current.scrollTo) {
|
|
165
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
166
|
+
args[_key] = arguments[_key];
|
|
167
|
+
}
|
|
168
|
+
|
|
159
169
|
listRef.current.scrollTo(args);
|
|
160
170
|
}
|
|
161
171
|
},
|
|
162
|
-
scrollToItem: (
|
|
172
|
+
scrollToItem: function () {
|
|
163
173
|
var _listRef$current2;
|
|
164
174
|
|
|
165
175
|
if (listRef !== null && listRef !== void 0 && (_listRef$current2 = listRef.current) !== null && _listRef$current2 !== void 0 && _listRef$current2.scrollToItem) {
|
|
176
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
177
|
+
args[_key2] = arguments[_key2];
|
|
178
|
+
}
|
|
179
|
+
|
|
166
180
|
listRef.current.scrollToItem(args);
|
|
167
181
|
}
|
|
168
182
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
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';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
8
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
@@ -12,7 +17,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
12
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
13
18
|
const treeListBlockName = 'tree-list';
|
|
14
19
|
const treeItemBlockName = 'tree-item';
|
|
15
|
-
const treeListNoItemsBn =
|
|
20
|
+
const treeListNoItemsBn = "".concat(treeListBlockName, "-no-items");
|
|
16
21
|
const TreeListItem = aggregatedClasses('li', {
|
|
17
22
|
'data-testid': treeItemBlockName,
|
|
18
23
|
role: 'treeitem'
|
|
@@ -21,22 +26,25 @@ const TreeListItemAddonsWrapper = aggregatedClasses('div')(treeItemBlockName, 'a
|
|
|
21
26
|
const TreeList = aggregatedClasses('ul', {
|
|
22
27
|
'data-testid': treeListBlockName,
|
|
23
28
|
role: 'tree'
|
|
24
|
-
})(treeListBlockName, null,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
})(treeListBlockName, null, _ref => {
|
|
30
|
+
let {
|
|
31
|
+
rowSize
|
|
32
|
+
} = _ref;
|
|
33
|
+
return {
|
|
34
|
+
["rowsize-".concat(rowSize)]: rowSize
|
|
35
|
+
};
|
|
36
|
+
});
|
|
29
37
|
const TreeListNoItems = aggregatedClasses('div', {
|
|
30
38
|
'data-testid': treeListNoItemsBn
|
|
31
39
|
})(treeListNoItemsBn);
|
|
32
40
|
|
|
33
|
-
function TreeItem(
|
|
41
|
+
function TreeItem(_ref2) {
|
|
34
42
|
let {
|
|
35
43
|
leftAddons,
|
|
36
44
|
rightAddons,
|
|
37
45
|
children
|
|
38
|
-
} =
|
|
39
|
-
rest = _objectWithoutProperties(
|
|
46
|
+
} = _ref2,
|
|
47
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
40
48
|
|
|
41
49
|
return /*#__PURE__*/jsxs(TreeListItem, _objectSpread(_objectSpread({}, rest), {}, {
|
|
42
50
|
children: [leftAddons && /*#__PURE__*/_jsx(TreeListItemAddonsWrapper, {}, void 0, leftAddons), children, rightAddons && /*#__PURE__*/_jsx(TreeListItemAddonsWrapper, {}, void 0, rightAddons)]
|
|
@@ -1,7 +1,12 @@
|
|
|
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';
|
|
1
6
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
8
|
import { useContext, useCallback, useMemo } from 'react';
|
|
4
|
-
import
|
|
9
|
+
import { DSCheckbox } from '@elliemae/ds-form';
|
|
5
10
|
import styled from 'styled-components';
|
|
6
11
|
import TreeViewContext from '../TreeViewContext.js';
|
|
7
12
|
import { toggleCheckboxItem } from '../utils/selectable-helper.js';
|
|
@@ -62,7 +67,7 @@ function CheckboxSelectable(props) {
|
|
|
62
67
|
|
|
63
68
|
return false;
|
|
64
69
|
}, [selectedCheckboxes, id]);
|
|
65
|
-
return /*#__PURE__*/_jsx(StyledCheckboxWrapper, {}, void 0, /*#__PURE__*/_jsx(
|
|
70
|
+
return /*#__PURE__*/_jsx(StyledCheckboxWrapper, {}, void 0, /*#__PURE__*/_jsx(DSCheckbox, {
|
|
66
71
|
checked: isChecked,
|
|
67
72
|
disabled: item.isGroup ? disableGroups : disableLeafs,
|
|
68
73
|
className: "em-ds-tree-item-checkbox",
|
|
@@ -2,7 +2,7 @@ import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
|
2
2
|
import 'react';
|
|
3
3
|
import { DSTreeViewPrefix, treeItemBlockName } from '../config/cssClassesConstants.js';
|
|
4
4
|
|
|
5
|
-
const className =
|
|
5
|
+
const className = "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "-children-count-displayer");
|
|
6
6
|
const ChildrenCountDisplayer = props => {
|
|
7
7
|
const {
|
|
8
8
|
item
|
|
@@ -16,7 +16,7 @@ const ChildrenCountDisplayer = props => {
|
|
|
16
16
|
return /*#__PURE__*/_jsx("span", {
|
|
17
17
|
"data-testid": "tree-item-children-count-displayer",
|
|
18
18
|
className: className
|
|
19
|
-
}, void 0,
|
|
19
|
+
}, void 0, " | ".concat(children.length, " Items"));
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export { ChildrenCountDisplayer };
|
package/esm/parts/ExpandCaret.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import { useCallback, useContext } from 'react';
|
|
3
|
-
import Button from '@elliemae/ds-
|
|
4
|
-
import ArrowheadDown from '@elliemae/ds-icons
|
|
5
|
-
import ArrowheadRight from '@elliemae/ds-icons/ArrowheadRight';
|
|
3
|
+
import Button from '@elliemae/ds-button';
|
|
4
|
+
import { ArrowheadDown, ArrowheadRight } from '@elliemae/ds-icons';
|
|
6
5
|
import { toggleItemExpand } from '../utils/group-expands-helpers.js';
|
|
7
6
|
import { focusItem } from '../utils/tree-helpers.js';
|
|
8
7
|
import TreeViewContext from '../TreeViewContext.js';
|
|
@@ -56,9 +55,12 @@ const ExpandCaret = props => {
|
|
|
56
55
|
setLatestToggledItem(item);
|
|
57
56
|
onItemFocus({
|
|
58
57
|
itemIndex: item.virtualIndex,
|
|
59
|
-
scrollToItem: (
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
scrollToItem: function () {
|
|
59
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
60
|
+
align: 'start'
|
|
61
|
+
};
|
|
62
|
+
return scrollToIndex(item.virtualIndex, opts);
|
|
63
|
+
},
|
|
62
64
|
item
|
|
63
65
|
});
|
|
64
66
|
setFocusedItem(item);
|
|
@@ -66,7 +68,7 @@ const ExpandCaret = props => {
|
|
|
66
68
|
},
|
|
67
69
|
size: "s",
|
|
68
70
|
tabIndex: -1
|
|
69
|
-
},
|
|
71
|
+
}, "".concat(id, "-expand-addon"));
|
|
70
72
|
return /*#__PURE__*/_jsx("div", {
|
|
71
73
|
style: {
|
|
72
74
|
width: '24px'
|
package/esm/parts/Icon.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
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';
|
|
1
6
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
8
|
import 'react';
|
|
@@ -15,7 +20,7 @@ const getItemNestingLeftPadding = (level, opts) => {
|
|
|
15
20
|
const finalLeftPadding = groupLeftPadding + spaceForNestingLevel - 0.1; // root level left-padding would be negative and would not be applied
|
|
16
21
|
// if "root-level" nesting, then defaults to 0 left-padding.
|
|
17
22
|
|
|
18
|
-
return finalLeftPadding > 0 ?
|
|
23
|
+
return finalLeftPadding > 0 ? "".concat(finalLeftPadding, "em") : '0';
|
|
19
24
|
};
|
|
20
25
|
|
|
21
26
|
const NestingSpace = props => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import { useContext, useCallback, useMemo } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { DSRadio } from '@elliemae/ds-form';
|
|
4
4
|
import TreeViewContext from '../TreeViewContext.js';
|
|
5
5
|
|
|
6
6
|
function RadioSelectable(props) {
|
|
@@ -40,8 +40,8 @@ function RadioSelectable(props) {
|
|
|
40
40
|
};
|
|
41
41
|
if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
|
|
42
42
|
}, [item, id, onSelectionChange, scrollToIndex]);
|
|
43
|
-
const radioName = useMemo(() =>
|
|
44
|
-
return /*#__PURE__*/_jsx(
|
|
43
|
+
const radioName = useMemo(() => "radios-".concat(uniqueTreeViewUUID), [uniqueTreeViewUUID]);
|
|
44
|
+
return /*#__PURE__*/_jsx(DSRadio, {
|
|
45
45
|
checked: selectedCheckboxes[id] === true,
|
|
46
46
|
name: radioName,
|
|
47
47
|
disabled: item.isGroup ? disableGroups : disableLeafs,
|