@elliemae/ds-treeview 2.2.0-alpha.5 → 2.2.0-beta.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.
- package/cjs/TreeView.js +31 -49
- package/cjs/TreeViewContext.js +35 -53
- package/cjs/config/cssClassesConstants.js +13 -41
- package/cjs/config/useTreeview.js +80 -108
- package/cjs/index.js +27 -37
- package/cjs/parts/CheckboxSelectable.js +59 -70
- package/cjs/parts/ChildrenCountDisplayer.js +28 -45
- package/cjs/parts/ExpandCaret.js +83 -85
- package/cjs/parts/Icon.js +31 -46
- package/cjs/parts/NestingSpace.js +35 -43
- package/cjs/parts/RadioSelectable.js +37 -52
- package/cjs/parts/TreeItem.js +147 -128
- package/cjs/parts/TreeItemText.js +95 -88
- package/cjs/parts/TreeList.js +130 -117
- package/cjs/plugins/dnd/TreeDndPlugin.js +36 -51
- package/cjs/plugins/dnd/index.js +10 -28
- package/cjs/plugins/index.js +22 -34
- package/cjs/plugins/roving/TreeRovingPlugin.js +7 -35
- package/cjs/plugins/roving/index.js +9 -28
- package/cjs/plugins/searchable/SearchableTreePlugin.js +7 -35
- package/cjs/plugins/searchable/index.js +9 -28
- package/cjs/plugins/selectable/SelectablePluginTree.js +7 -35
- package/cjs/plugins/selectable/index.js +9 -28
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js +7 -35
- package/cjs/plugins/toolbar/index.js +9 -28
- package/cjs/plugins/tree/TreeDataPlugin.js +7 -35
- package/cjs/plugins/tree/index.js +9 -28
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +7 -35
- package/cjs/plugins/virtualization/index.js +9 -28
- package/cjs/react-desc-prop-types.js +53 -82
- package/cjs/related-components/TreeViewSearchBar.js +40 -42
- package/cjs/sharedTypes.js +2 -27
- package/cjs/utils/array-helpers.js +11 -35
- package/cjs/utils/dnd-helpers.js +84 -90
- package/cjs/utils/group-expands-helpers.js +59 -86
- package/cjs/utils/keyboard-helpers.js +88 -84
- package/cjs/utils/object-helpers.js +36 -43
- package/cjs/utils/refs-helpers.js +22 -43
- package/cjs/utils/selectable-helper.js +53 -61
- package/cjs/utils/string-helpers.js +7 -35
- package/cjs/utils/tree-helpers.js +135 -105
- package/cjs/utils/useDnDHelpers.js +118 -97
- package/cjs/utils/useInstanceRefActions.js +43 -54
- package/cjs/utils/useTree.js +78 -76
- package/esm/TreeView.js +20 -18
- package/esm/TreeViewContext.js +29 -24
- package/esm/config/cssClassesConstants.js +6 -12
- package/esm/config/useTreeview.js +54 -61
- package/esm/index.js +9 -8
- package/esm/parts/CheckboxSelectable.js +46 -36
- package/esm/parts/ChildrenCountDisplayer.js +20 -16
- package/esm/parts/ExpandCaret.js +72 -54
- package/esm/parts/Icon.js +22 -16
- package/esm/parts/NestingSpace.js +27 -14
- package/esm/parts/RadioSelectable.js +28 -20
- package/esm/parts/TreeItem.js +127 -91
- package/esm/parts/TreeItemText.js +85 -58
- package/esm/parts/TreeList.js +117 -88
- package/esm/plugins/dnd/TreeDndPlugin.js +26 -21
- package/esm/plugins/dnd/index.js +1 -3
- package/esm/plugins/index.js +7 -9
- package/esm/plugins/roving/TreeRovingPlugin.js +3 -6
- package/esm/plugins/roving/index.js +1 -3
- package/esm/plugins/searchable/SearchableTreePlugin.js +3 -6
- package/esm/plugins/searchable/index.js +1 -3
- package/esm/plugins/selectable/SelectablePluginTree.js +3 -6
- package/esm/plugins/selectable/index.js +1 -3
- package/esm/plugins/toolbar/TreeToolbarPlugin.js +3 -6
- package/esm/plugins/toolbar/index.js +1 -3
- package/esm/plugins/tree/TreeDataPlugin.js +3 -6
- package/esm/plugins/tree/index.js +1 -3
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +3 -6
- package/esm/plugins/virtualization/index.js +1 -3
- package/esm/react-desc-prop-types.js +43 -47
- package/esm/related-components/TreeViewSearchBar.js +32 -13
- package/esm/sharedTypes.js +1 -2
- package/esm/utils/array-helpers.js +6 -6
- package/esm/utils/dnd-helpers.js +73 -58
- package/esm/utils/group-expands-helpers.js +46 -56
- package/esm/utils/keyboard-helpers.js +72 -45
- package/esm/utils/object-helpers.js +31 -14
- package/esm/utils/refs-helpers.js +19 -15
- package/esm/utils/selectable-helper.js +43 -32
- package/esm/utils/string-helpers.js +3 -6
- package/esm/utils/tree-helpers.js +119 -74
- package/esm/utils/useDnDHelpers.js +106 -60
- package/esm/utils/useInstanceRefActions.js +35 -21
- package/esm/utils/useTree.js +57 -35
- package/package.json +10 -10
- package/types/TreeView.d.ts +1 -1
- package/cjs/TreeView.js.map +0 -7
- package/cjs/TreeViewContext.js.map +0 -7
- package/cjs/config/cssClassesConstants.js.map +0 -7
- package/cjs/config/useTreeview.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/parts/CheckboxSelectable.js.map +0 -7
- package/cjs/parts/ChildrenCountDisplayer.js.map +0 -7
- package/cjs/parts/ExpandCaret.js.map +0 -7
- package/cjs/parts/Icon.js.map +0 -7
- package/cjs/parts/NestingSpace.js.map +0 -7
- package/cjs/parts/RadioSelectable.js.map +0 -7
- package/cjs/parts/TreeItem.js.map +0 -7
- package/cjs/parts/TreeItemText.js.map +0 -7
- package/cjs/parts/TreeList.js.map +0 -7
- package/cjs/plugins/dnd/TreeDndPlugin.js.map +0 -7
- package/cjs/plugins/dnd/index.js.map +0 -7
- package/cjs/plugins/index.js.map +0 -7
- package/cjs/plugins/roving/TreeRovingPlugin.js.map +0 -7
- package/cjs/plugins/roving/index.js.map +0 -7
- package/cjs/plugins/searchable/SearchableTreePlugin.js.map +0 -7
- package/cjs/plugins/searchable/index.js.map +0 -7
- package/cjs/plugins/selectable/SelectablePluginTree.js.map +0 -7
- package/cjs/plugins/selectable/index.js.map +0 -7
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
- package/cjs/plugins/toolbar/index.js.map +0 -7
- package/cjs/plugins/tree/TreeDataPlugin.js.map +0 -7
- package/cjs/plugins/tree/index.js.map +0 -7
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
- package/cjs/plugins/virtualization/index.js.map +0 -7
- package/cjs/react-desc-prop-types.js.map +0 -7
- package/cjs/related-components/TreeViewSearchBar.js.map +0 -7
- package/cjs/sharedTypes.js.map +0 -7
- package/cjs/utils/array-helpers.js.map +0 -7
- package/cjs/utils/dnd-helpers.js.map +0 -7
- package/cjs/utils/group-expands-helpers.js.map +0 -7
- package/cjs/utils/keyboard-helpers.js.map +0 -7
- package/cjs/utils/object-helpers.js.map +0 -7
- package/cjs/utils/refs-helpers.js.map +0 -7
- package/cjs/utils/selectable-helper.js.map +0 -7
- package/cjs/utils/string-helpers.js.map +0 -7
- package/cjs/utils/tree-helpers.js.map +0 -7
- package/cjs/utils/useDnDHelpers.js.map +0 -7
- package/cjs/utils/useInstanceRefActions.js.map +0 -7
- package/cjs/utils/useTree.js.map +0 -7
- package/esm/TreeView.js.map +0 -7
- package/esm/TreeViewContext.js.map +0 -7
- package/esm/config/cssClassesConstants.js.map +0 -7
- package/esm/config/useTreeview.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/parts/CheckboxSelectable.js.map +0 -7
- package/esm/parts/ChildrenCountDisplayer.js.map +0 -7
- package/esm/parts/ExpandCaret.js.map +0 -7
- package/esm/parts/Icon.js.map +0 -7
- package/esm/parts/NestingSpace.js.map +0 -7
- package/esm/parts/RadioSelectable.js.map +0 -7
- package/esm/parts/TreeItem.js.map +0 -7
- package/esm/parts/TreeItemText.js.map +0 -7
- package/esm/parts/TreeList.js.map +0 -7
- package/esm/plugins/dnd/TreeDndPlugin.js.map +0 -7
- package/esm/plugins/dnd/index.js.map +0 -7
- package/esm/plugins/index.js.map +0 -7
- package/esm/plugins/roving/TreeRovingPlugin.js.map +0 -7
- package/esm/plugins/roving/index.js.map +0 -7
- package/esm/plugins/searchable/SearchableTreePlugin.js.map +0 -7
- package/esm/plugins/searchable/index.js.map +0 -7
- package/esm/plugins/selectable/SelectablePluginTree.js.map +0 -7
- package/esm/plugins/selectable/index.js.map +0 -7
- package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
- package/esm/plugins/toolbar/index.js.map +0 -7
- package/esm/plugins/tree/TreeDataPlugin.js.map +0 -7
- package/esm/plugins/tree/index.js.map +0 -7
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
- package/esm/plugins/virtualization/index.js.map +0 -7
- package/esm/react-desc-prop-types.js.map +0 -7
- package/esm/related-components/TreeViewSearchBar.js.map +0 -7
- package/esm/sharedTypes.js.map +0 -7
- package/esm/utils/array-helpers.js.map +0 -7
- package/esm/utils/dnd-helpers.js.map +0 -7
- package/esm/utils/group-expands-helpers.js.map +0 -7
- package/esm/utils/keyboard-helpers.js.map +0 -7
- package/esm/utils/object-helpers.js.map +0 -7
- package/esm/utils/refs-helpers.js.map +0 -7
- package/esm/utils/selectable-helper.js.map +0 -7
- package/esm/utils/string-helpers.js.map +0 -7
- package/esm/utils/tree-helpers.js.map +0 -7
- package/esm/utils/useDnDHelpers.js.map +0 -7
- package/esm/utils/useInstanceRefActions.js.map +0 -7
- package/esm/utils/useTree.js.map +0 -7
package/esm/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
1
|
+
export { TreeView, TreeViewWithSchema } from './TreeView.js';
|
|
2
|
+
export { TreeDnD, TreeDndPlugin } from './plugins/dnd/TreeDndPlugin.js';
|
|
3
|
+
export { TreeRovingPlugin } from './plugins/roving/TreeRovingPlugin.js';
|
|
4
|
+
export { SelectablePluginTree } from './plugins/selectable/SelectablePluginTree.js';
|
|
5
|
+
export { TreeToolbarPlugin } from './plugins/toolbar/TreeToolbarPlugin.js';
|
|
6
|
+
export { TreePluginList } from './plugins/tree/TreeDataPlugin.js';
|
|
7
|
+
export { TreeVirtualizationPlugin } from './plugins/virtualization/TreeVirtualizationPlugin.js';
|
|
8
|
+
export { SearchableTreePlugin } from './plugins/searchable/SearchableTreePlugin.js';
|
|
9
|
+
export { TreeViewSearchBar } from './related-components/TreeViewSearchBar.js';
|
|
@@ -1,58 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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, useCallback, useMemo } from 'react';
|
|
9
|
+
import { DSCheckbox } from '@elliemae/ds-form';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
import TreeViewContext from '../TreeViewContext.js';
|
|
12
|
+
import { toggleCheckboxItem } from '../utils/selectable-helper.js';
|
|
13
|
+
import { filterObject } from '../utils/object-helpers.js';
|
|
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 StyledCheckboxWrapper = /*#__PURE__*/styled.span.withConfig({
|
|
19
|
+
componentId: "sc-1tyhs3t-0"
|
|
20
|
+
})(["padding-top:3px;"]);
|
|
21
|
+
|
|
11
22
|
function CheckboxSelectable(props) {
|
|
12
|
-
const {
|
|
13
|
-
|
|
23
|
+
const {
|
|
24
|
+
item,
|
|
25
|
+
itemIndex
|
|
26
|
+
} = props;
|
|
27
|
+
const {
|
|
28
|
+
id
|
|
29
|
+
} = item;
|
|
14
30
|
const ctx = useContext(TreeViewContext);
|
|
15
31
|
const {
|
|
16
|
-
props: {
|
|
17
|
-
|
|
32
|
+
props: {
|
|
33
|
+
onSelectionChange,
|
|
34
|
+
isItemDisabled
|
|
35
|
+
},
|
|
36
|
+
virtualListHelpers: {
|
|
37
|
+
scrollToIndex
|
|
38
|
+
},
|
|
18
39
|
triggerTreeRerender,
|
|
19
40
|
selectedCheckboxes,
|
|
20
41
|
setSelectedCheckboxes
|
|
21
42
|
} = ctx;
|
|
22
43
|
const onCheckboxChange = useCallback(() => {
|
|
23
44
|
const newSelections = toggleCheckboxItem(item);
|
|
24
|
-
const newSelectionHasmap = filterObject({
|
|
45
|
+
const newSelectionHasmap = filterObject(_objectSpread(_objectSpread({}, selectedCheckboxes), newSelections), value => value !== false);
|
|
25
46
|
setSelectedCheckboxes(newSelectionHasmap);
|
|
26
47
|
triggerTreeRerender();
|
|
27
48
|
const indexAndScrollTo = {
|
|
28
49
|
scrollToItem: () => {
|
|
29
|
-
if (typeof item.virtualIndex ===
|
|
30
|
-
scrollToIndex(item.virtualIndex);
|
|
50
|
+
if (typeof item.virtualIndex === 'number') scrollToIndex(item.virtualIndex);
|
|
31
51
|
},
|
|
32
52
|
itemIndex
|
|
33
53
|
};
|
|
34
|
-
if (onSelectionChange)
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
item,
|
|
38
|
-
triggerTreeRerender,
|
|
39
|
-
onSelectionChange,
|
|
40
|
-
itemIndex,
|
|
41
|
-
scrollToIndex,
|
|
42
|
-
selectedCheckboxes,
|
|
43
|
-
setSelectedCheckboxes
|
|
44
|
-
]);
|
|
54
|
+
if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
|
|
55
|
+
}, [item, triggerTreeRerender, onSelectionChange, itemIndex, scrollToIndex, selectedCheckboxes, setSelectedCheckboxes]);
|
|
45
56
|
const isChecked = useMemo(() => {
|
|
46
|
-
if (selectedCheckboxes[id] ===
|
|
47
|
-
return
|
|
57
|
+
if (selectedCheckboxes[id] === 'mixed') {
|
|
58
|
+
return 'mixed';
|
|
48
59
|
}
|
|
60
|
+
|
|
49
61
|
if (selectedCheckboxes[id] === true) {
|
|
50
62
|
return true;
|
|
51
63
|
}
|
|
64
|
+
|
|
52
65
|
return false;
|
|
53
66
|
}, [selectedCheckboxes, id]);
|
|
54
67
|
const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
|
|
55
|
-
return
|
|
68
|
+
return /*#__PURE__*/_jsx(StyledCheckboxWrapper, {}, void 0, /*#__PURE__*/_jsx(DSCheckbox, {
|
|
56
69
|
checked: isChecked,
|
|
57
70
|
disabled: isDisabled,
|
|
58
71
|
className: "em-ds-tree-item-checkbox",
|
|
@@ -61,8 +74,5 @@ function CheckboxSelectable(props) {
|
|
|
61
74
|
tabIndex: "0"
|
|
62
75
|
}));
|
|
63
76
|
}
|
|
64
|
-
|
|
65
|
-
export {
|
|
66
|
-
CheckboxSelectable_default as default
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=CheckboxSelectable.js.map
|
|
77
|
+
|
|
78
|
+
export { CheckboxSelectable as default };
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { DSTreeViewPrefix, treeItemBlockName } from
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { DSTreeViewPrefix, treeItemBlockName } from '../config/cssClassesConstants.js';
|
|
4
|
+
|
|
5
|
+
const className = "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "-children-count-displayer");
|
|
6
|
+
const ChildrenCountDisplayer = props => {
|
|
7
|
+
const {
|
|
8
|
+
item
|
|
9
|
+
} = props;
|
|
10
|
+
const {
|
|
11
|
+
isGroup,
|
|
12
|
+
children
|
|
13
|
+
} = item;
|
|
14
|
+
if (!isGroup) return null; // return ` | ${children.length} Items`;
|
|
15
|
+
|
|
16
|
+
return /*#__PURE__*/_jsx("span", {
|
|
11
17
|
"data-testid": "tree-item-children-count-displayer",
|
|
12
|
-
className
|
|
13
|
-
},
|
|
18
|
+
className: className
|
|
19
|
+
}, void 0, " | ".concat(children.length, " Items"));
|
|
14
20
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=ChildrenCountDisplayer.js.map
|
|
21
|
+
|
|
22
|
+
export { ChildrenCountDisplayer };
|
package/esm/parts/ExpandCaret.js
CHANGED
|
@@ -1,67 +1,85 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import Button from
|
|
4
|
-
import { ArrowheadDown, ArrowheadRight } from
|
|
5
|
-
import { toggleItemExpand } from
|
|
6
|
-
import { focusItem } from
|
|
7
|
-
import TreeViewContext from
|
|
8
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { useCallback, useContext } from 'react';
|
|
3
|
+
import Button from '@elliemae/ds-button';
|
|
4
|
+
import { ArrowheadDown, ArrowheadRight } from '@elliemae/ds-icons';
|
|
5
|
+
import { toggleItemExpand } from '../utils/group-expands-helpers.js';
|
|
6
|
+
import { focusItem } from '../utils/tree-helpers.js';
|
|
7
|
+
import TreeViewContext from '../TreeViewContext.js';
|
|
8
|
+
|
|
9
|
+
var _ArrowheadDown, _ArrowheadRight;
|
|
10
|
+
const ExpandCaret = props => {
|
|
9
11
|
const defaultHandleExpandGroup = useCallback(toggleItemExpand, []);
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
+
const {
|
|
13
|
+
item
|
|
14
|
+
} = props;
|
|
15
|
+
const {
|
|
16
|
+
id,
|
|
17
|
+
isExpanded,
|
|
18
|
+
isGroup,
|
|
19
|
+
children
|
|
20
|
+
} = item;
|
|
12
21
|
const isGroupOrHasChildrens = isGroup || Array.isArray(children) && children.length > 0;
|
|
13
22
|
const ctx = useContext(TreeViewContext);
|
|
14
23
|
const {
|
|
15
|
-
props: {
|
|
24
|
+
props: {
|
|
25
|
+
onItemFocus
|
|
26
|
+
},
|
|
16
27
|
handleExpandGroup = defaultHandleExpandGroup,
|
|
17
28
|
triggerTreeRerender,
|
|
18
29
|
updateUserExpandedState,
|
|
19
30
|
setLatestToggledItem,
|
|
20
31
|
setFocusedItem,
|
|
21
|
-
virtualListHelpers: {
|
|
32
|
+
virtualListHelpers: {
|
|
33
|
+
scrollToIndex
|
|
34
|
+
}
|
|
22
35
|
} = ctx;
|
|
23
|
-
if (isGroupOrHasChildrens)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
key: `${id}-expand-addon`,
|
|
29
|
-
icon: isExpanded ? /* @__PURE__ */ React2.createElement(ArrowheadDown, {
|
|
30
|
-
size: "s",
|
|
31
|
-
"data-testid": "ic-arrow-head-down"
|
|
32
|
-
}) : /* @__PURE__ */ React2.createElement(ArrowheadRight, {
|
|
33
|
-
size: "s",
|
|
34
|
-
"data-testid": "ic-arrow-head-right"
|
|
35
|
-
}),
|
|
36
|
-
onMouseDown: (e) => {
|
|
37
|
-
if (e) {
|
|
38
|
-
e.preventDefault();
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
onClick: (e) => {
|
|
42
|
-
e.stopPropagation();
|
|
43
|
-
if (e)
|
|
44
|
-
handleExpandGroup(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex, e);
|
|
45
|
-
setLatestToggledItem(item);
|
|
46
|
-
const itemVitualIndex = item.virtualIndex;
|
|
47
|
-
if (typeof itemVitualIndex === "number") {
|
|
48
|
-
onItemFocus({
|
|
49
|
-
itemIndex: itemVitualIndex,
|
|
50
|
-
scrollToItem: (opts = { align: "start" }) => scrollToIndex(itemVitualIndex, opts),
|
|
51
|
-
item
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
setFocusedItem(item);
|
|
55
|
-
focusItem(item);
|
|
56
|
-
},
|
|
36
|
+
if (isGroupOrHasChildrens) return /*#__PURE__*/_jsx(Button, {
|
|
37
|
+
buttonType: "text",
|
|
38
|
+
className: "expandable-arrow",
|
|
39
|
+
"data-testid": "tree-item-expand-toggle",
|
|
40
|
+
icon: isExpanded ? _ArrowheadDown || (_ArrowheadDown = /*#__PURE__*/_jsx(ArrowheadDown, {
|
|
57
41
|
size: "s",
|
|
58
|
-
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
"data-testid": "ic-arrow-head-down"
|
|
43
|
+
})) : _ArrowheadRight || (_ArrowheadRight = /*#__PURE__*/_jsx(ArrowheadRight, {
|
|
44
|
+
size: "s",
|
|
45
|
+
"data-testid": "ic-arrow-head-right"
|
|
46
|
+
})),
|
|
47
|
+
onMouseDown: e => {
|
|
48
|
+
// prevent focusing the caret
|
|
49
|
+
if (e) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
onClick: e => {
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
if (e) handleExpandGroup(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex, e);
|
|
56
|
+
setLatestToggledItem(item);
|
|
57
|
+
const itemVitualIndex = item.virtualIndex;
|
|
58
|
+
|
|
59
|
+
if (typeof itemVitualIndex === 'number') {
|
|
60
|
+
onItemFocus({
|
|
61
|
+
itemIndex: itemVitualIndex,
|
|
62
|
+
scrollToItem: function () {
|
|
63
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
64
|
+
align: 'start'
|
|
65
|
+
};
|
|
66
|
+
return scrollToIndex(itemVitualIndex, opts);
|
|
67
|
+
},
|
|
68
|
+
item
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setFocusedItem(item);
|
|
73
|
+
focusItem(item);
|
|
74
|
+
},
|
|
75
|
+
size: "s",
|
|
76
|
+
tabIndex: -1
|
|
77
|
+
}, "".concat(id, "-expand-addon"));
|
|
78
|
+
return /*#__PURE__*/_jsx("div", {
|
|
79
|
+
style: {
|
|
80
|
+
width: '24px'
|
|
81
|
+
}
|
|
62
82
|
});
|
|
63
83
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=ExpandCaret.js.map
|
|
84
|
+
|
|
85
|
+
export { ExpandCaret };
|
package/esm/parts/Icon.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const Icon =
|
|
6
|
-
const {
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { cx } from '@elliemae/ds-utilities';
|
|
3
|
+
import TreeViewContext from '../TreeViewContext.js';
|
|
4
|
+
|
|
5
|
+
const Icon = props => {
|
|
6
|
+
const {
|
|
7
|
+
item
|
|
8
|
+
} = props;
|
|
7
9
|
const isGroupOrHasChildrens = item.isGroup || Array.isArray(item.children) && item.children.length > 0;
|
|
8
10
|
const ctx = useContext(TreeViewContext);
|
|
9
11
|
const {
|
|
10
|
-
props: {
|
|
12
|
+
props: {
|
|
13
|
+
groupIcon,
|
|
14
|
+
itemIcon
|
|
15
|
+
}
|
|
11
16
|
} = ctx;
|
|
12
17
|
const icon = isGroupOrHasChildrens ? groupIcon : itemIcon;
|
|
13
|
-
if (!icon)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
if (!icon) return null;
|
|
19
|
+
return /*#__PURE__*/React.cloneElement(icon, {
|
|
20
|
+
'data-testid': isGroupOrHasChildrens ? 'tree-item-group-icon' : 'tree-item-icon',
|
|
21
|
+
// legacy class-name way of handling things,
|
|
22
|
+
// this will eventually be deprecated in favor of styled components
|
|
23
|
+
// untill then, just eslint-ignore and move on
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
25
|
+
className: cx(icon.props.className, 'tree-item-icon')
|
|
18
26
|
});
|
|
19
27
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=Icon.js.map
|
|
28
|
+
|
|
29
|
+
export { Icon };
|
|
@@ -1,26 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
3
4
|
const getItemNestingLeftPadding = (level, opts) => {
|
|
4
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
spaceForNestingLevel = 1.5
|
|
7
|
+
} = opts;
|
|
5
8
|
const groupLeftPadding = spaceForNestingLevel * (level - 1);
|
|
6
|
-
const finalLeftPadding = groupLeftPadding + spaceForNestingLevel - 0.1;
|
|
7
|
-
|
|
9
|
+
const finalLeftPadding = groupLeftPadding + spaceForNestingLevel - 0.1; // root level left-padding would be negative and would not be applied
|
|
10
|
+
// if "root-level" nesting, then defaults to 0 left-padding.
|
|
11
|
+
|
|
12
|
+
return finalLeftPadding > 0 ? "".concat(finalLeftPadding, "em") : '0';
|
|
8
13
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const {
|
|
14
|
+
|
|
15
|
+
const NestingSpace = props => {
|
|
16
|
+
const {
|
|
17
|
+
item,
|
|
18
|
+
spaceForNestingLevel
|
|
19
|
+
} = props;
|
|
20
|
+
const {
|
|
21
|
+
treeDepth
|
|
22
|
+
} = item;
|
|
23
|
+
|
|
12
24
|
if (treeDepth) {
|
|
13
25
|
const itemNestingLeftPadding = getItemNestingLeftPadding(treeDepth - 1, {
|
|
14
26
|
spaceForNestingLevel
|
|
15
27
|
});
|
|
16
|
-
return
|
|
28
|
+
return /*#__PURE__*/_jsx("div", {
|
|
17
29
|
"data-testid": "tree-item-nested-space",
|
|
18
|
-
style: {
|
|
30
|
+
style: {
|
|
31
|
+
width: itemNestingLeftPadding
|
|
32
|
+
}
|
|
19
33
|
});
|
|
20
34
|
}
|
|
35
|
+
|
|
21
36
|
return null;
|
|
22
37
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=NestingSpace.js.map
|
|
38
|
+
|
|
39
|
+
export { NestingSpace };
|
|
@@ -1,34 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { DSRadio } from
|
|
4
|
-
import TreeViewContext from
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { useContext, useCallback, useMemo } from 'react';
|
|
3
|
+
import { DSRadio } from '@elliemae/ds-form';
|
|
4
|
+
import TreeViewContext from '../TreeViewContext.js';
|
|
5
|
+
|
|
5
6
|
function RadioSelectable(props) {
|
|
6
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
item,
|
|
9
|
+
itemIndex
|
|
10
|
+
} = props;
|
|
7
11
|
const ctx = useContext(TreeViewContext);
|
|
8
12
|
const {
|
|
9
|
-
props: {
|
|
10
|
-
|
|
13
|
+
props: {
|
|
14
|
+
onSelectionChange,
|
|
15
|
+
isItemDisabled
|
|
16
|
+
},
|
|
17
|
+
virtualListHelpers: {
|
|
18
|
+
scrollToIndex
|
|
19
|
+
},
|
|
11
20
|
uniqueTreeViewUUID,
|
|
12
21
|
selectedCheckboxes,
|
|
13
22
|
setSelectedCheckboxes
|
|
14
23
|
} = ctx;
|
|
15
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
id
|
|
26
|
+
} = item;
|
|
16
27
|
const onRadioChange = useCallback(() => {
|
|
17
|
-
const newSelectionHasmap = {
|
|
28
|
+
const newSelectionHasmap = {
|
|
29
|
+
[id]: true
|
|
30
|
+
};
|
|
18
31
|
setSelectedCheckboxes(newSelectionHasmap);
|
|
19
32
|
const indexAndScrollTo = {
|
|
20
33
|
scrollToItem: () => {
|
|
21
|
-
if (item.virtualIndex)
|
|
22
|
-
scrollToIndex(item.virtualIndex);
|
|
34
|
+
if (item.virtualIndex) scrollToIndex(item.virtualIndex);
|
|
23
35
|
},
|
|
24
36
|
itemIndex
|
|
25
37
|
};
|
|
26
|
-
if (onSelectionChange)
|
|
27
|
-
onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
|
|
38
|
+
if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
|
|
28
39
|
}, [id, setSelectedCheckboxes, itemIndex, onSelectionChange, item, scrollToIndex]);
|
|
29
|
-
const radioName = useMemo(() =>
|
|
40
|
+
const radioName = useMemo(() => "radios-".concat(uniqueTreeViewUUID), [uniqueTreeViewUUID]);
|
|
30
41
|
const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
|
|
31
|
-
return
|
|
42
|
+
return /*#__PURE__*/_jsx(DSRadio, {
|
|
32
43
|
checked: selectedCheckboxes[id] === true,
|
|
33
44
|
name: radioName,
|
|
34
45
|
disabled: isDisabled,
|
|
@@ -38,8 +49,5 @@ function RadioSelectable(props) {
|
|
|
38
49
|
tabIndex: 0
|
|
39
50
|
});
|
|
40
51
|
}
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
RadioSelectable_default as default
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=RadioSelectable.js.map
|
|
52
|
+
|
|
53
|
+
export { RadioSelectable as default };
|