@elliemae/ds-treeview 2.2.0-alpha.3 → 2.2.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/TreeView.js +27 -49
- package/cjs/TreeViewContext.js +37 -61
- package/cjs/config/cssClassesConstants.js +13 -41
- package/cjs/config/useTreeview.js +78 -116
- package/cjs/hoc/DnDTreeContext.js +18 -0
- package/cjs/hoc/SortableItemContext.js +21 -0
- package/cjs/hoc/WithConditionalDnDContext.js +138 -0
- package/cjs/hoc/WithDnDSortableItemContext.js +70 -0
- package/cjs/index.js +26 -37
- package/cjs/parts/CheckboxSelectable.js +59 -70
- package/cjs/parts/ChildrenCountDisplayer.js +28 -45
- package/cjs/parts/DnDHandle.js +46 -0
- package/cjs/parts/DropIndicator.js +75 -0
- 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 +141 -147
- package/cjs/parts/TreeItemText.js +95 -88
- package/cjs/parts/TreeList.js +130 -119
- package/cjs/plugins/dnd/TreeDndPlugin.js +7 -59
- package/cjs/plugins/dnd/index.js +9 -28
- package/cjs/plugins/index.js +21 -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 +54 -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/group-expands-helpers.js +59 -86
- package/cjs/utils/keyboard-helpers.js +90 -85
- 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 +161 -105
- package/cjs/utils/useInstanceRefActions.js +43 -54
- package/cjs/utils/useTree.js +80 -76
- package/esm/TreeView.js +16 -18
- package/esm/TreeViewContext.js +31 -32
- package/esm/config/cssClassesConstants.js +6 -12
- package/esm/config/useTreeview.js +56 -73
- package/esm/hoc/DnDTreeContext.js +14 -0
- package/esm/hoc/SortableItemContext.js +17 -0
- package/esm/hoc/WithConditionalDnDContext.js +128 -0
- package/esm/hoc/WithDnDSortableItemContext.js +61 -0
- package/esm/index.js +9 -8
- package/esm/parts/CheckboxSelectable.js +46 -36
- package/esm/parts/ChildrenCountDisplayer.js +20 -16
- package/esm/parts/DnDHandle.js +38 -0
- package/esm/parts/DropIndicator.js +68 -0
- 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 +125 -114
- package/esm/parts/TreeItemText.js +85 -58
- package/esm/parts/TreeList.js +119 -91
- package/esm/plugins/dnd/TreeDndPlugin.js +3 -30
- 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 +44 -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/group-expands-helpers.js +46 -56
- package/esm/utils/keyboard-helpers.js +74 -46
- 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 +143 -73
- package/esm/utils/useInstanceRefActions.js +35 -21
- package/esm/utils/useTree.js +59 -35
- package/package.json +35 -19
- package/types/hoc/DnDTreeContext.d.ts +14 -0
- package/types/hoc/SortableItemContext.d.ts +19 -0
- package/types/hoc/WithConditionalDnDContext.d.ts +4 -0
- package/types/hoc/WithDnDSortableItemContext.d.ts +4 -0
- package/types/parts/DnDHandle.d.ts +6 -0
- package/types/parts/DropIndicator.d.ts +10 -0
- package/types/parts/TreeItem.d.ts +4 -11
- package/types/parts/TreeList.d.ts +0 -4
- package/types/plugins/dnd/TreeDndPlugin.d.ts +0 -2
- package/types/react-desc-prop-types.d.ts +17 -3
- package/types/sharedTypes.d.ts +1 -8
- package/types/utils/keyboard-helpers.d.ts +2 -1
- package/types/utils/refs-helpers.d.ts +1 -1
- package/types/utils/tree-helpers.d.ts +4 -1
- package/types/utils/useTree.d.ts +1 -0
- 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 +0 -146
- 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 +0 -199
- 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 +0 -117
- 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 +0 -170
- 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/types/utils/dnd-helpers.d.ts +0 -39
- package/types/utils/useDnDHelpers.d.ts +0 -26
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { DropIndicatorPosition } from '../hoc/SortableItemContext.js';
|
|
5
|
+
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
const getPositionStyles = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
dropIndicatorPosition
|
|
10
|
+
} = _ref;
|
|
11
|
+
return "\n top: ".concat(dropIndicatorPosition === DropIndicatorPosition.Before ? '0' : 'unset', ";\n bottom: ").concat(dropIndicatorPosition === DropIndicatorPosition.After ? '0' : 'unset', ";\n left: -2px;\n ");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const getCircleStyles = _ref2 => {
|
|
15
|
+
let {
|
|
16
|
+
dropIndicatorPosition
|
|
17
|
+
} = _ref2;
|
|
18
|
+
return {
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
zIndex: 20,
|
|
21
|
+
top: dropIndicatorPosition === DropIndicatorPosition.After ? 'unset' : '-2px',
|
|
22
|
+
bottom: dropIndicatorPosition === DropIndicatorPosition.Before ? 'unset' : '-2px',
|
|
23
|
+
left: '0px',
|
|
24
|
+
opacity: 1
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const StyledIndicator = /*#__PURE__*/styled.div.withConfig({
|
|
29
|
+
componentId: "sc-1812zh0-0"
|
|
30
|
+
})(["position:absolute;", " box-sizing:border-box;width:", ";height:", ";background-color:", ";z-index:20;"], getPositionStyles, props => props.vertical ? '2px' : '100%', props => props.vertical ? '100%' : '2px', _ref3 => {
|
|
31
|
+
let {
|
|
32
|
+
isDropValid,
|
|
33
|
+
theme
|
|
34
|
+
} = _ref3;
|
|
35
|
+
return isDropValid ? theme.colors.brand[600] : theme.colors.danger[900];
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const CircleIndicator = (style, isDropValid) => /*#__PURE__*/_jsx("svg", {
|
|
39
|
+
height: "6",
|
|
40
|
+
width: "6",
|
|
41
|
+
style: style
|
|
42
|
+
}, void 0, /*#__PURE__*/_jsx("circle", {
|
|
43
|
+
cx: "3",
|
|
44
|
+
cy: "3",
|
|
45
|
+
r: "3",
|
|
46
|
+
strokeWidth: "0",
|
|
47
|
+
fill: isDropValid ? '#1E79C2' : '#C64252'
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
const DropIndicator = _ref4 => {
|
|
51
|
+
let {
|
|
52
|
+
dropIndicatorPosition,
|
|
53
|
+
isLast,
|
|
54
|
+
isDropValid
|
|
55
|
+
} = _ref4;
|
|
56
|
+
if (![DropIndicatorPosition.After, DropIndicatorPosition.Before].includes(dropIndicatorPosition)) return null;
|
|
57
|
+
const safeDropIndicatorPosition = isLast ? DropIndicatorPosition.Before : dropIndicatorPosition;
|
|
58
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
59
|
+
children: [CircleIndicator(getCircleStyles({
|
|
60
|
+
dropIndicatorPosition: safeDropIndicatorPosition
|
|
61
|
+
}), isDropValid), /*#__PURE__*/_jsx(StyledIndicator, {
|
|
62
|
+
dropIndicatorPosition: safeDropIndicatorPosition,
|
|
63
|
+
isDropValid: isDropValid
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { DropIndicator as default };
|
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 };
|