@elliemae/ds-treeview 2.3.0-alpha.8 → 2.3.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 +30 -0
- package/cjs/TreeViewContext.js +98 -0
- package/cjs/config/cssClassesConstants.js +13 -0
- package/cjs/config/useTreeview.js +127 -0
- 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 -0
- package/cjs/parts/CheckboxSelectable.js +86 -0
- package/cjs/parts/ChildrenCountDisplayer.js +30 -0
- package/cjs/parts/DnDHandle.js +46 -0
- package/cjs/parts/DropIndicator.js +75 -0
- package/cjs/parts/ExpandCaret.js +94 -0
- package/cjs/parts/Icon.js +37 -0
- package/cjs/parts/NestingSpace.js +47 -0
- package/cjs/parts/RadioSelectable.js +59 -0
- package/cjs/parts/TreeItem.js +185 -0
- package/cjs/parts/TreeItemText.js +108 -0
- package/cjs/parts/TreeList.js +139 -0
- package/cjs/plugins/dnd/TreeDndPlugin.js +7 -0
- package/cjs/plugins/dnd/index.js +9 -0
- package/cjs/plugins/index.js +21 -0
- package/cjs/plugins/roving/TreeRovingPlugin.js +7 -0
- package/cjs/plugins/roving/index.js +9 -0
- package/cjs/plugins/searchable/SearchableTreePlugin.js +7 -0
- package/cjs/plugins/searchable/index.js +9 -0
- package/cjs/plugins/selectable/SelectablePluginTree.js +7 -0
- package/cjs/plugins/selectable/index.js +9 -0
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js +7 -0
- package/cjs/plugins/toolbar/index.js +9 -0
- package/cjs/plugins/tree/TreeDataPlugin.js +7 -0
- package/cjs/plugins/tree/index.js +9 -0
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +7 -0
- package/cjs/plugins/virtualization/index.js +9 -0
- package/cjs/react-desc-prop-types.js +56 -0
- package/cjs/related-components/TreeViewSearchBar.js +48 -0
- package/cjs/sharedTypes.js +2 -0
- package/cjs/utils/array-helpers.js +24 -0
- package/cjs/utils/group-expands-helpers.js +111 -0
- package/cjs/utils/keyboard-helpers.js +175 -0
- package/cjs/utils/object-helpers.js +69 -0
- package/cjs/utils/refs-helpers.js +31 -0
- package/cjs/utils/selectable-helper.js +80 -0
- package/cjs/utils/string-helpers.js +7 -0
- package/cjs/utils/tree-helpers.js +220 -0
- package/cjs/utils/useInstanceRefActions.js +87 -0
- package/cjs/utils/useTree.js +108 -0
- package/esm/TreeView.js +21 -0
- package/{dist/esm → esm}/TreeViewContext.js +29 -24
- package/esm/config/cssClassesConstants.js +6 -0
- package/esm/config/useTreeview.js +119 -0
- 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 -0
- package/esm/parts/CheckboxSelectable.js +78 -0
- package/esm/parts/ChildrenCountDisplayer.js +22 -0
- package/esm/parts/DnDHandle.js +38 -0
- package/esm/parts/DropIndicator.js +68 -0
- package/esm/parts/ExpandCaret.js +85 -0
- package/esm/parts/Icon.js +29 -0
- package/esm/parts/NestingSpace.js +39 -0
- package/esm/parts/RadioSelectable.js +53 -0
- package/esm/parts/TreeItem.js +173 -0
- package/esm/parts/TreeItemText.js +99 -0
- package/esm/parts/TreeList.js +127 -0
- package/esm/plugins/dnd/TreeDndPlugin.js +3 -0
- package/esm/plugins/dnd/index.js +1 -0
- package/esm/plugins/index.js +7 -0
- package/esm/plugins/roving/TreeRovingPlugin.js +3 -0
- package/esm/plugins/roving/index.js +1 -0
- package/esm/plugins/searchable/SearchableTreePlugin.js +3 -0
- package/esm/plugins/searchable/index.js +1 -0
- package/esm/plugins/selectable/SelectablePluginTree.js +3 -0
- package/esm/plugins/selectable/index.js +1 -0
- package/esm/plugins/toolbar/TreeToolbarPlugin.js +3 -0
- package/esm/plugins/toolbar/index.js +1 -0
- package/esm/plugins/tree/TreeDataPlugin.js +3 -0
- package/esm/plugins/tree/index.js +1 -0
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +3 -0
- package/esm/plugins/virtualization/index.js +1 -0
- package/esm/react-desc-prop-types.js +52 -0
- package/esm/related-components/TreeViewSearchBar.js +40 -0
- package/esm/sharedTypes.js +1 -0
- package/{dist/esm → esm}/utils/array-helpers.js +6 -6
- package/esm/utils/group-expands-helpers.js +99 -0
- package/{dist/esm → esm}/utils/keyboard-helpers.js +71 -43
- package/esm/utils/object-helpers.js +64 -0
- package/esm/utils/refs-helpers.js +27 -0
- package/esm/utils/selectable-helper.js +70 -0
- package/esm/utils/string-helpers.js +3 -0
- package/esm/utils/tree-helpers.js +205 -0
- package/{dist/esm → esm}/utils/useInstanceRefActions.js +35 -21
- package/esm/utils/useTree.js +99 -0
- package/package.json +121 -124
- package/types/TreeView.d.ts +13 -0
- package/types/TreeViewContext.d.ts +17 -0
- package/types/config/cssClassesConstants.d.ts +4 -0
- package/types/config/useTreeview.d.ts +7 -0
- 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/index.d.ts +3 -0
- package/types/parts/CheckboxSelectable.d.ts +8 -0
- package/types/parts/ChildrenCountDisplayer.d.ts +7 -0
- package/types/parts/DnDHandle.d.ts +6 -0
- package/types/parts/DropIndicator.d.ts +10 -0
- package/types/parts/ExpandCaret.d.ts +7 -0
- package/types/parts/Icon.d.ts +7 -0
- package/types/parts/NestingSpace.d.ts +8 -0
- package/types/parts/RadioSelectable.d.ts +8 -0
- package/types/parts/TreeItem.d.ts +17 -0
- package/types/parts/TreeItemText.d.ts +7 -0
- package/types/parts/TreeList.d.ts +20 -0
- package/types/plugins/dnd/TreeDndPlugin.d.ts +1 -0
- package/types/plugins/dnd/index.d.ts +1 -0
- package/types/plugins/index.d.ts +7 -0
- package/types/plugins/roving/TreeRovingPlugin.d.ts +1 -0
- package/types/plugins/roving/index.d.ts +1 -0
- package/types/plugins/searchable/SearchableTreePlugin.d.ts +1 -0
- package/types/plugins/searchable/index.d.ts +1 -0
- package/types/plugins/selectable/SelectablePluginTree.d.ts +1 -0
- package/types/plugins/selectable/index.d.ts +1 -0
- package/types/plugins/toolbar/TreeToolbarPlugin.d.ts +1 -0
- package/types/plugins/toolbar/index.d.ts +1 -0
- package/types/plugins/tree/TreeDataPlugin.d.ts +1 -0
- package/types/plugins/tree/index.d.ts +1 -0
- package/types/plugins/virtualization/TreeVirtualizationPlugin.d.ts +1 -0
- package/types/plugins/virtualization/index.d.ts +1 -0
- package/types/react-desc-prop-types.d.ts +210 -0
- package/types/related-components/TreeViewSearchBar.d.ts +16 -0
- package/types/sharedTypes.d.ts +47 -0
- package/types/utils/array-helpers.d.ts +2 -0
- package/types/utils/group-expands-helpers.d.ts +14 -0
- package/types/utils/keyboard-helpers.d.ts +6 -0
- package/types/utils/object-helpers.d.ts +6 -0
- package/types/utils/refs-helpers.d.ts +4 -0
- package/types/utils/selectable-helper.d.ts +7 -0
- package/types/utils/string-helpers.d.ts +1 -0
- package/types/utils/tree-helpers.d.ts +28 -0
- package/types/utils/useInstanceRefActions.d.ts +3 -0
- package/types/utils/useTree.d.ts +14 -0
- package/dist/cjs/TreeView.js +0 -50
- package/dist/cjs/TreeView.js.map +0 -7
- package/dist/cjs/TreeViewContext.js +0 -116
- package/dist/cjs/TreeViewContext.js.map +0 -7
- package/dist/cjs/config/cssClassesConstants.js +0 -41
- package/dist/cjs/config/cssClassesConstants.js.map +0 -7
- package/dist/cjs/config/useTreeview.js +0 -151
- package/dist/cjs/config/useTreeview.js.map +0 -7
- package/dist/cjs/hoc/DnDTreeContext.js +0 -45
- package/dist/cjs/hoc/DnDTreeContext.js.map +0 -7
- package/dist/cjs/hoc/SortableItemContext.js +0 -46
- package/dist/cjs/hoc/SortableItemContext.js.map +0 -7
- package/dist/cjs/hoc/WithConditionalDnDContext.js +0 -128
- package/dist/cjs/hoc/WithConditionalDnDContext.js.map +0 -7
- package/dist/cjs/hoc/WithDnDSortableItemContext.js +0 -69
- package/dist/cjs/hoc/WithDnDSortableItemContext.js.map +0 -7
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/parts/CheckboxSelectable.js +0 -97
- package/dist/cjs/parts/CheckboxSelectable.js.map +0 -7
- package/dist/cjs/parts/ChildrenCountDisplayer.js +0 -47
- package/dist/cjs/parts/ChildrenCountDisplayer.js.map +0 -7
- package/dist/cjs/parts/DnDHandle.js +0 -57
- package/dist/cjs/parts/DnDHandle.js.map +0 -7
- package/dist/cjs/parts/DropIndicator.js +0 -80
- package/dist/cjs/parts/DropIndicator.js.map +0 -7
- package/dist/cjs/parts/ExpandCaret.js +0 -96
- package/dist/cjs/parts/ExpandCaret.js.map +0 -7
- package/dist/cjs/parts/Icon.js +0 -52
- package/dist/cjs/parts/Icon.js.map +0 -7
- package/dist/cjs/parts/NestingSpace.js +0 -55
- package/dist/cjs/parts/NestingSpace.js.map +0 -7
- package/dist/cjs/parts/RadioSelectable.js +0 -74
- package/dist/cjs/parts/RadioSelectable.js.map +0 -7
- package/dist/cjs/parts/TreeItem.js +0 -166
- package/dist/cjs/parts/TreeItem.js.map +0 -7
- package/dist/cjs/parts/TreeItemText.js +0 -101
- package/dist/cjs/parts/TreeItemText.js.map +0 -7
- package/dist/cjs/parts/TreeList.js +0 -123
- package/dist/cjs/parts/TreeList.js.map +0 -7
- package/dist/cjs/plugins/dnd/TreeDndPlugin.js +0 -35
- package/dist/cjs/plugins/dnd/TreeDndPlugin.js.map +0 -7
- package/dist/cjs/plugins/dnd/index.js +0 -28
- package/dist/cjs/plugins/dnd/index.js.map +0 -7
- package/dist/cjs/plugins/index.js +0 -34
- package/dist/cjs/plugins/index.js.map +0 -7
- package/dist/cjs/plugins/roving/TreeRovingPlugin.js +0 -35
- package/dist/cjs/plugins/roving/TreeRovingPlugin.js.map +0 -7
- package/dist/cjs/plugins/roving/index.js +0 -28
- package/dist/cjs/plugins/roving/index.js.map +0 -7
- package/dist/cjs/plugins/searchable/SearchableTreePlugin.js +0 -35
- package/dist/cjs/plugins/searchable/SearchableTreePlugin.js.map +0 -7
- package/dist/cjs/plugins/searchable/index.js +0 -28
- package/dist/cjs/plugins/searchable/index.js.map +0 -7
- package/dist/cjs/plugins/selectable/SelectablePluginTree.js +0 -35
- package/dist/cjs/plugins/selectable/SelectablePluginTree.js.map +0 -7
- package/dist/cjs/plugins/selectable/index.js +0 -28
- package/dist/cjs/plugins/selectable/index.js.map +0 -7
- package/dist/cjs/plugins/toolbar/TreeToolbarPlugin.js +0 -35
- package/dist/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
- package/dist/cjs/plugins/toolbar/index.js +0 -28
- package/dist/cjs/plugins/toolbar/index.js.map +0 -7
- package/dist/cjs/plugins/tree/TreeDataPlugin.js +0 -35
- package/dist/cjs/plugins/tree/TreeDataPlugin.js.map +0 -7
- package/dist/cjs/plugins/tree/index.js +0 -28
- package/dist/cjs/plugins/tree/index.js.map +0 -7
- package/dist/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +0 -35
- package/dist/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
- package/dist/cjs/plugins/virtualization/index.js +0 -28
- package/dist/cjs/plugins/virtualization/index.js.map +0 -7
- package/dist/cjs/react-desc-prop-types.js +0 -85
- package/dist/cjs/react-desc-prop-types.js.map +0 -7
- package/dist/cjs/related-components/TreeViewSearchBar.js +0 -50
- package/dist/cjs/related-components/TreeViewSearchBar.js.map +0 -7
- package/dist/cjs/sharedTypes.js +0 -27
- package/dist/cjs/sharedTypes.js.map +0 -7
- package/dist/cjs/utils/array-helpers.js +0 -48
- package/dist/cjs/utils/array-helpers.js.map +0 -7
- package/dist/cjs/utils/group-expands-helpers.js +0 -138
- package/dist/cjs/utils/group-expands-helpers.js.map +0 -7
- package/dist/cjs/utils/keyboard-helpers.js +0 -170
- package/dist/cjs/utils/keyboard-helpers.js.map +0 -7
- package/dist/cjs/utils/object-helpers.js +0 -76
- package/dist/cjs/utils/object-helpers.js.map +0 -7
- package/dist/cjs/utils/refs-helpers.js +0 -52
- package/dist/cjs/utils/refs-helpers.js.map +0 -7
- package/dist/cjs/utils/selectable-helper.js +0 -88
- package/dist/cjs/utils/selectable-helper.js.map +0 -7
- package/dist/cjs/utils/string-helpers.js +0 -35
- package/dist/cjs/utils/string-helpers.js.map +0 -7
- package/dist/cjs/utils/tree-helpers.js +0 -184
- package/dist/cjs/utils/tree-helpers.js.map +0 -7
- package/dist/cjs/utils/useInstanceRefActions.js +0 -98
- package/dist/cjs/utils/useInstanceRefActions.js.map +0 -7
- package/dist/cjs/utils/useTree.js +0 -106
- package/dist/cjs/utils/useTree.js.map +0 -7
- package/dist/esm/TreeView.js +0 -21
- package/dist/esm/TreeView.js.map +0 -7
- package/dist/esm/TreeViewContext.js.map +0 -7
- package/dist/esm/config/cssClassesConstants.js +0 -12
- package/dist/esm/config/cssClassesConstants.js.map +0 -7
- package/dist/esm/config/useTreeview.js +0 -122
- package/dist/esm/config/useTreeview.js.map +0 -7
- package/dist/esm/hoc/DnDTreeContext.js +0 -16
- package/dist/esm/hoc/DnDTreeContext.js.map +0 -7
- package/dist/esm/hoc/SortableItemContext.js +0 -17
- package/dist/esm/hoc/SortableItemContext.js.map +0 -7
- package/dist/esm/hoc/WithConditionalDnDContext.js +0 -99
- package/dist/esm/hoc/WithConditionalDnDContext.js.map +0 -7
- package/dist/esm/hoc/WithDnDSortableItemContext.js +0 -40
- package/dist/esm/hoc/WithDnDSortableItemContext.js.map +0 -7
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/parts/CheckboxSelectable.js +0 -68
- package/dist/esm/parts/CheckboxSelectable.js.map +0 -7
- package/dist/esm/parts/ChildrenCountDisplayer.js +0 -18
- package/dist/esm/parts/ChildrenCountDisplayer.js.map +0 -7
- package/dist/esm/parts/DnDHandle.js +0 -28
- package/dist/esm/parts/DnDHandle.js.map +0 -7
- package/dist/esm/parts/DropIndicator.js +0 -51
- package/dist/esm/parts/DropIndicator.js.map +0 -7
- package/dist/esm/parts/ExpandCaret.js +0 -67
- package/dist/esm/parts/ExpandCaret.js.map +0 -7
- package/dist/esm/parts/Icon.js +0 -23
- package/dist/esm/parts/Icon.js.map +0 -7
- package/dist/esm/parts/NestingSpace.js +0 -26
- package/dist/esm/parts/NestingSpace.js.map +0 -7
- package/dist/esm/parts/RadioSelectable.js +0 -45
- package/dist/esm/parts/RadioSelectable.js.map +0 -7
- package/dist/esm/parts/TreeItem.js +0 -137
- package/dist/esm/parts/TreeItem.js.map +0 -7
- package/dist/esm/parts/TreeItemText.js +0 -72
- package/dist/esm/parts/TreeItemText.js.map +0 -7
- package/dist/esm/parts/TreeList.js +0 -94
- package/dist/esm/parts/TreeList.js.map +0 -7
- package/dist/esm/plugins/dnd/TreeDndPlugin.js +0 -6
- package/dist/esm/plugins/dnd/TreeDndPlugin.js.map +0 -7
- package/dist/esm/plugins/dnd/index.js +0 -3
- package/dist/esm/plugins/dnd/index.js.map +0 -7
- package/dist/esm/plugins/index.js +0 -9
- package/dist/esm/plugins/index.js.map +0 -7
- package/dist/esm/plugins/roving/TreeRovingPlugin.js +0 -6
- package/dist/esm/plugins/roving/TreeRovingPlugin.js.map +0 -7
- package/dist/esm/plugins/roving/index.js +0 -3
- package/dist/esm/plugins/roving/index.js.map +0 -7
- package/dist/esm/plugins/searchable/SearchableTreePlugin.js +0 -6
- package/dist/esm/plugins/searchable/SearchableTreePlugin.js.map +0 -7
- package/dist/esm/plugins/searchable/index.js +0 -3
- package/dist/esm/plugins/searchable/index.js.map +0 -7
- package/dist/esm/plugins/selectable/SelectablePluginTree.js +0 -6
- package/dist/esm/plugins/selectable/SelectablePluginTree.js.map +0 -7
- package/dist/esm/plugins/selectable/index.js +0 -3
- package/dist/esm/plugins/selectable/index.js.map +0 -7
- package/dist/esm/plugins/toolbar/TreeToolbarPlugin.js +0 -6
- package/dist/esm/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
- package/dist/esm/plugins/toolbar/index.js +0 -3
- package/dist/esm/plugins/toolbar/index.js.map +0 -7
- package/dist/esm/plugins/tree/TreeDataPlugin.js +0 -6
- package/dist/esm/plugins/tree/TreeDataPlugin.js.map +0 -7
- package/dist/esm/plugins/tree/index.js +0 -3
- package/dist/esm/plugins/tree/index.js.map +0 -7
- package/dist/esm/plugins/virtualization/TreeVirtualizationPlugin.js +0 -6
- package/dist/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
- package/dist/esm/plugins/virtualization/index.js +0 -3
- package/dist/esm/plugins/virtualization/index.js.map +0 -7
- package/dist/esm/react-desc-prop-types.js +0 -56
- package/dist/esm/react-desc-prop-types.js.map +0 -7
- package/dist/esm/related-components/TreeViewSearchBar.js +0 -21
- package/dist/esm/related-components/TreeViewSearchBar.js.map +0 -7
- package/dist/esm/sharedTypes.js +0 -2
- package/dist/esm/sharedTypes.js.map +0 -7
- package/dist/esm/utils/array-helpers.js.map +0 -7
- package/dist/esm/utils/group-expands-helpers.js +0 -109
- package/dist/esm/utils/group-expands-helpers.js.map +0 -7
- package/dist/esm/utils/keyboard-helpers.js.map +0 -7
- package/dist/esm/utils/object-helpers.js +0 -47
- package/dist/esm/utils/object-helpers.js.map +0 -7
- package/dist/esm/utils/refs-helpers.js +0 -23
- package/dist/esm/utils/refs-helpers.js.map +0 -7
- package/dist/esm/utils/selectable-helper.js +0 -59
- package/dist/esm/utils/selectable-helper.js.map +0 -7
- package/dist/esm/utils/string-helpers.js +0 -6
- package/dist/esm/utils/string-helpers.js.map +0 -7
- package/dist/esm/utils/tree-helpers.js +0 -155
- package/dist/esm/utils/tree-helpers.js.map +0 -7
- package/dist/esm/utils/useInstanceRefActions.js.map +0 -7
- package/dist/esm/utils/useTree.js +0 -77
- package/dist/esm/utils/useTree.js.map +0 -7
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useTree_exports = {};
|
|
29
|
-
__export(useTree_exports, {
|
|
30
|
-
useTree: () => useTree
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = require("react");
|
|
34
|
-
var import_tree_model = __toESM(require("tree-model"));
|
|
35
|
-
var import_lodash = require("lodash");
|
|
36
|
-
var import_tree_helpers = require("./tree-helpers");
|
|
37
|
-
var import_group_expands_helpers = require("./group-expands-helpers");
|
|
38
|
-
const useTree = (data, props, states) => {
|
|
39
|
-
const { setExpandedGroups } = states;
|
|
40
|
-
const unfrozenData = (0, import_react.useMemo)(() => (0, import_lodash.cloneDeep)(data), [data]);
|
|
41
|
-
const tree = (0, import_react.useMemo)(() => new import_tree_model.default(), []);
|
|
42
|
-
const [treeData, setTreeData] = (0, import_react.useState)({
|
|
43
|
-
id: "__ds_tree_root",
|
|
44
|
-
name: "__root",
|
|
45
|
-
isExpanded: true,
|
|
46
|
-
children: unfrozenData
|
|
47
|
-
});
|
|
48
|
-
(0, import_react.useEffect)(() => {
|
|
49
|
-
setTreeData({
|
|
50
|
-
id: "__ds_tree_root",
|
|
51
|
-
name: "__root",
|
|
52
|
-
isExpanded: true,
|
|
53
|
-
children: unfrozenData
|
|
54
|
-
});
|
|
55
|
-
}, [unfrozenData]);
|
|
56
|
-
const [rerenderItems, setRerenderItems] = (0, import_react.useState)({});
|
|
57
|
-
const triggerTreeRerender = (0, import_react.useCallback)(() => {
|
|
58
|
-
setRerenderItems({});
|
|
59
|
-
}, []);
|
|
60
|
-
const [treeRoot, setTreeRoot] = (0, import_react.useState)(tree.parse(treeData));
|
|
61
|
-
(0, import_react.useEffect)(() => {
|
|
62
|
-
setTreeRoot(tree.parse(treeData));
|
|
63
|
-
}, [treeData, rerenderItems, tree]);
|
|
64
|
-
const [visibleItems, setVisibleItems] = (0, import_react.useState)([]);
|
|
65
|
-
const { searchQuery, highlightOnlyQuery, onVisibleItemsChange, selection, expanded, onExpandChange } = props;
|
|
66
|
-
const updateUserExpandedState = (0, import_react.useCallback)(() => {
|
|
67
|
-
(0, import_group_expands_helpers.updateExpandedState)(treeRoot, onExpandChange);
|
|
68
|
-
}, [treeRoot, onExpandChange]);
|
|
69
|
-
(0, import_react.useEffect)(() => {
|
|
70
|
-
const parsedVisibleItems = [];
|
|
71
|
-
const newExpandedHashMap = {};
|
|
72
|
-
const shouldContinueWalking = true;
|
|
73
|
-
treeRoot.walk((node) => {
|
|
74
|
-
(0, import_tree_helpers.enrichNodeModelInPlace)(node, searchQuery, selection, expanded);
|
|
75
|
-
if (node.model.id && node.model.isGroup && node.model.isExpanded)
|
|
76
|
-
newExpandedHashMap[node.model.id] = true;
|
|
77
|
-
return shouldContinueWalking;
|
|
78
|
-
});
|
|
79
|
-
(0, import_tree_helpers.walkVisibles)(treeRoot, (node) => {
|
|
80
|
-
parsedVisibleItems.push({ ...node.model, node });
|
|
81
|
-
}, true, highlightOnlyQuery);
|
|
82
|
-
setVisibleItems(parsedVisibleItems);
|
|
83
|
-
onVisibleItemsChange(parsedVisibleItems);
|
|
84
|
-
setExpandedGroups(newExpandedHashMap);
|
|
85
|
-
}, [
|
|
86
|
-
treeRoot,
|
|
87
|
-
rerenderItems,
|
|
88
|
-
searchQuery,
|
|
89
|
-
highlightOnlyQuery,
|
|
90
|
-
selection,
|
|
91
|
-
expanded,
|
|
92
|
-
setExpandedGroups
|
|
93
|
-
]);
|
|
94
|
-
const flattenedItems = (0, import_react.useMemo)(() => (0, import_tree_helpers.flattenTreeForDnD)(data), [data]);
|
|
95
|
-
return {
|
|
96
|
-
visibleItems,
|
|
97
|
-
flattenedItems,
|
|
98
|
-
tree,
|
|
99
|
-
treeRoot,
|
|
100
|
-
rerenderItems,
|
|
101
|
-
triggerTreeRerender,
|
|
102
|
-
updateUserExpandedState
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
module.exports = __toCommonJS(useTree_exports);
|
|
106
|
-
//# sourceMappingURL=useTree.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/utils/useTree.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { useState, useCallback, useMemo, useEffect } from 'react';\nimport TreeModel from 'tree-model';\nimport { cloneDeep } from 'lodash';\n\nimport { walkVisibles, enrichNodeModelInPlace, flattenTreeForDnD } from './tree-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\nimport { updateExpandedState } from './group-expands-helpers';\n\nexport const useTree = (\n data: DSTreeviewT.SimpleItem[],\n props: DSTreeviewT.Props,\n states: {\n setExpandedGroups: DSTreeviewInternalsT.StateSetter<DSTreeviewT.ExpandedItems>;\n },\n) => {\n const { setExpandedGroups } = states;\n const unfrozenData = useMemo(() => cloneDeep(data), [data]);\n\n // convert data into a TreeModel with extra isExpanded prop\n // root element type is an exception, children model is based on what the dev passed on\n // since root is an excepcion we must typecast\n const tree = useMemo(() => new TreeModel(), []);\n const [treeData, setTreeData] = useState({\n id: '__ds_tree_root',\n name: '__root',\n isExpanded: true,\n children: unfrozenData,\n } as unknown as DSTreeviewT.Item);\n\n useEffect(() => {\n setTreeData({\n id: '__ds_tree_root',\n name: '__root',\n isExpanded: true,\n children: unfrozenData,\n } as unknown as DSTreeviewT.Item);\n }, [unfrozenData]);\n\n // expose a way to rerender the tree\n // used for expand functionality\n const [rerenderItems, setRerenderItems] = useState({});\n const triggerTreeRerender = useCallback(() => {\n setRerenderItems({});\n }, []);\n\n // when re-rendering we re-parse the list\n const [treeRoot, setTreeRoot] = useState(tree.parse(treeData));\n useEffect(() => {\n setTreeRoot(tree.parse(treeData));\n }, [treeData, rerenderItems, tree]);\n\n const [visibleItems, setVisibleItems] = useState<DSTreeviewT.Item[]>([]);\n\n const { searchQuery, highlightOnlyQuery, onVisibleItemsChange, selection, expanded, onExpandChange } = props;\n\n const updateUserExpandedState = useCallback(() => {\n updateExpandedState(treeRoot, onExpandChange);\n }, [treeRoot, onExpandChange]);\n // we add missing properties to the received Items\n // not the best of the patterns, but it works\n // this is where we convert \"SimpleItems\" to \"Items\"\n // this was done to avoid breaking changes back in v1\n useEffect(() => {\n const parsedVisibleItems: DSTreeviewT.Item[] = [];\n const newExpandedHashMap: DSTreeviewT.ExpandedItems = {};\n const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking\n treeRoot.walk((node) => {\n enrichNodeModelInPlace(node, searchQuery, selection, expanded);\n if (node.model.id && node.model.isGroup && node.model.isExpanded) newExpandedHashMap[node.model.id] = true;\n return shouldContinueWalking;\n });\n\n walkVisibles(\n treeRoot,\n (node) => {\n parsedVisibleItems.push({ ...node.model, node });\n },\n true,\n highlightOnlyQuery,\n );\n setVisibleItems(parsedVisibleItems);\n onVisibleItemsChange(parsedVisibleItems);\n\n setExpandedGroups(newExpandedHashMap);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n treeRoot,\n rerenderItems,\n searchQuery,\n highlightOnlyQuery,\n selection,\n expanded,\n setExpandedGroups,\n // onVisibleItemsChange // evaluate potential performance hit?\n ]);\n\n const flattenedItems = useMemo(() => flattenTreeForDnD(data), [data]);\n\n return {\n visibleItems,\n flattenedItems,\n tree,\n treeRoot,\n rerenderItems,\n triggerTreeRerender,\n updateUserExpandedState,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA0D;AAC1D,wBAAsB;AACtB,oBAA0B;AAE1B,0BAAwE;AAGxE,mCAAoC;AAE7B,MAAM,UAAU,CACrB,MACA,OACA,WAGG;AACH,QAAM,EAAE,sBAAsB;AAC9B,QAAM,eAAe,0BAAQ,MAAM,6BAAU,OAAO,CAAC;AAKrD,QAAM,OAAO,0BAAQ,MAAM,IAAI,6BAAa;AAC5C,QAAM,CAAC,UAAU,eAAe,2BAAS;AAAA,IACvC,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,UAAU;AAAA;AAGZ,8BAAU,MAAM;AACd,gBAAY;AAAA,MACV,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,UAAU;AAAA;AAAA,KAEX,CAAC;AAIJ,QAAM,CAAC,eAAe,oBAAoB,2BAAS;AACnD,QAAM,sBAAsB,8BAAY,MAAM;AAC5C,qBAAiB;AAAA,KAChB;AAGH,QAAM,CAAC,UAAU,eAAe,2BAAS,KAAK,MAAM;AACpD,8BAAU,MAAM;AACd,gBAAY,KAAK,MAAM;AAAA,KACtB,CAAC,UAAU,eAAe;AAE7B,QAAM,CAAC,cAAc,mBAAmB,2BAA6B;AAErE,QAAM,EAAE,aAAa,oBAAoB,sBAAsB,WAAW,UAAU,mBAAmB;AAEvG,QAAM,0BAA0B,8BAAY,MAAM;AAChD,0DAAoB,UAAU;AAAA,KAC7B,CAAC,UAAU;AAKd,8BAAU,MAAM;AACd,UAAM,qBAAyC;AAC/C,UAAM,qBAAgD;AACtD,UAAM,wBAAwB;AAC9B,aAAS,KAAK,CAAC,SAAS;AACtB,sDAAuB,MAAM,aAAa,WAAW;AACrD,UAAI,KAAK,MAAM,MAAM,KAAK,MAAM,WAAW,KAAK,MAAM;AAAY,2BAAmB,KAAK,MAAM,MAAM;AACtG,aAAO;AAAA;AAGT,0CACE,UACA,CAAC,SAAS;AACR,yBAAmB,KAAK,KAAK,KAAK,OAAO;AAAA,OAE3C,MACA;AAEF,oBAAgB;AAChB,yBAAqB;AAErB,sBAAkB;AAAA,KAEjB;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIF,QAAM,iBAAiB,0BAAQ,MAAM,2CAAkB,OAAO,CAAC;AAE/D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/TreeView.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2 from "react";
|
|
3
|
-
import { describe } from "react-desc";
|
|
4
|
-
import { TreeViewPropTypes } from "./react-desc-prop-types";
|
|
5
|
-
import TreeViewContext from "./TreeViewContext";
|
|
6
|
-
import { useTreeview } from "./config/useTreeview";
|
|
7
|
-
import { TreeList } from "./parts/TreeList";
|
|
8
|
-
function TreeView(props) {
|
|
9
|
-
const { ctx } = useTreeview(props);
|
|
10
|
-
return /* @__PURE__ */ React2.createElement(TreeViewContext.Provider, {
|
|
11
|
-
value: ctx
|
|
12
|
-
}, /* @__PURE__ */ React2.createElement(TreeList, null));
|
|
13
|
-
}
|
|
14
|
-
TreeView.propTypes = TreeViewPropTypes;
|
|
15
|
-
const TreeViewWithSchema = describe(TreeView);
|
|
16
|
-
TreeViewWithSchema.propTypes = TreeViewPropTypes;
|
|
17
|
-
export {
|
|
18
|
-
TreeView,
|
|
19
|
-
TreeViewWithSchema
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=TreeView.js.map
|
package/dist/esm/TreeView.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/TreeView.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { WeakValidationMap } from 'react';\n\nimport { describe } from 'react-desc';\nimport { TreeViewPropTypes } from './react-desc-prop-types';\nimport TreeViewContext from './TreeViewContext';\nimport { useTreeview } from './config/useTreeview';\nimport { TreeList } from './parts/TreeList';\nimport type { DSTreeviewT } from './react-desc-prop-types';\nexport function TreeView(props: DSTreeviewT.Props) {\n const { ctx } = useTreeview(props);\n\n return (\n <TreeViewContext.Provider value={ctx}>\n <TreeList />\n </TreeViewContext.Provider>\n );\n}\n\nTreeView.propTypes = TreeViewPropTypes as WeakValidationMap<unknown>;\nconst TreeViewWithSchema = describe(TreeView);\nTreeViewWithSchema.propTypes = TreeViewPropTypes;\n\nexport { TreeViewWithSchema };\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEA;AACA;AACA;AACA;AACA;AAEO,kBAAkB,OAA0B;AACjD,QAAM,EAAE,QAAQ,YAAY;AAE5B,SACE,qCAAC,gBAAgB,UAAjB;AAAA,IAA0B,OAAO;AAAA,KAC/B,qCAAC,UAAD;AAAA;AAKN,SAAS,YAAY;AACrB,MAAM,qBAAqB,SAAS;AACpC,mBAAmB,YAAY;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/TreeViewContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-unused-vars */\nimport { createContext, createRef } from 'react';\nimport type { DSTreeviewT } from './react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from './sharedTypes';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction noop<T extends unknown[]>(..._args: T): void {}\n\nexport const defaultProps = {\n plugins: [],\n selection: {},\n instanceRef: createRef(),\n isItemDisabled: () => false,\n disableIcons: false,\n fluid: false,\n isMultiSelect: false,\n isSingleSelect: false,\n getIsDropValid: () => true,\n restrictDragAndDrop: false,\n showChildrenAmount: false,\n sortable: false,\n isLoading: false,\n highlightOnlyQuery: false,\n onItemClick: noop,\n onItemFocus: noop,\n onVisibleItemsChange: noop,\n onOrderChange: noop,\n onSelectionChange: noop,\n onExpandChange: noop,\n onInstanceRefInitialized: noop,\n rowSize: 'normal',\n labelOverflow: 'wrap',\n noItemsPlaceholder: 'No items found',\n nameKey: 'name',\n width: '100%',\n height: '100%',\n groupIcon: null,\n itemIcon: null,\n searchQuery: '',\n // workaround on the typings over the fact that\n // when we instantiate the context we can't have all the props\n // we only have a part of them but the final typings will include missing props\n // this is safe to do because\n // we will \"mergeWithDefaults\" + \"validatePropTypes\" when we do instantiate the context\n} as unknown as DSTreeviewT.Props;\n\nexport const defaultRelativeMouseCoord = {\n isBefore: false,\n isAfter: false,\n isValid: true,\n item: null,\n x: null,\n y: null,\n relativeElementDOMRect: null,\n relativeElementIndex: null,\n};\n\nconst defaultContext: DSTreeviewInternalsT.CTX = {\n props: defaultProps,\n visibleItems: [],\n flattenedItems: [],\n withRadioChecks: false,\n withCheckboxChecks: false,\n withDragAndDrop: false,\n triggerTreeRerender: noop,\n tree: undefined,\n treeRoot: undefined,\n virtualListHelpers: {\n virtualItems: [],\n totalSize: 0,\n scrollToOffset: noop,\n scrollToIndex: noop,\n },\n virtualListRef: undefined,\n uniqueTreeViewUUID: '',\n selectedItem: null,\n setSelectedItem: noop,\n focusedItem: null,\n setFocusedItem: noop,\n selectedCheckboxes: {},\n setSelectedCheckboxes: noop,\n expandedGroups: {},\n setExpandedGroups: noop,\n latestToggledItem: null,\n setLatestToggledItem: noop,\n hoverItem: null,\n setHoverItem: noop,\n handleExpandGroup: noop,\n updateUserExpandedState: noop,\n};\n\n/** Context for cross component communication */\nconst TreeViewContext = createContext(defaultContext);\n\nexport default TreeViewContext;\n"],
|
|
5
|
-
"mappings": "AAAA;ACCA;AAKA,iBAAsC,OAAgB;AAAA;AAE/C,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EACtB,cAAc;AAAA,EACd,OAAO;AAAA,EACP,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,gBAAgB,MAAM;AAAA,EACtB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,0BAA0B;AAAA,EAC1B,SAAS;AAAA,EACT,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA;AAQR,MAAM,4BAA4B;AAAA,EACvC,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,wBAAwB;AAAA,EACxB,sBAAsB;AAAA;AAGxB,MAAM,iBAA2C;AAAA,EAC/C,OAAO;AAAA,EACP,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,oBAAoB;AAAA,IAClB,cAAc;AAAA,IACd,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,eAAe;AAAA;AAAA,EAEjB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,WAAW;AAAA,EACX,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,yBAAyB;AAAA;AAI3B,MAAM,kBAAkB,cAAc;AAEtC,IAAO,0BAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
const DSTreeViewPrefix = "em-ds";
|
|
3
|
-
const treeItemBlockName = "tree-item";
|
|
4
|
-
const treeListBlockName = "tree-list";
|
|
5
|
-
const treeListNoItemsBn = `${treeListBlockName}-no-items`;
|
|
6
|
-
export {
|
|
7
|
-
DSTreeViewPrefix,
|
|
8
|
-
treeItemBlockName,
|
|
9
|
-
treeListBlockName,
|
|
10
|
-
treeListNoItemsBn
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=cssClassesConstants.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/cssClassesConstants.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSTreeViewPrefix = 'em-ds';\nexport const treeItemBlockName = 'tree-item';\nexport const treeListBlockName = 'tree-list';\nexport const treeListNoItemsBn = `${treeListBlockName}-no-items`;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAO,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB,GAAG;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useState, useRef, useEffect, useMemo, useCallback } from "react";
|
|
3
|
-
import { useVirtual } from "react-virtual";
|
|
4
|
-
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
|
|
5
|
-
import { v4 as uuidv4 } from "uuid";
|
|
6
|
-
import { TreeViewPropTypes } from "../react-desc-prop-types";
|
|
7
|
-
import { defaultProps } from "../TreeViewContext";
|
|
8
|
-
import { TreeDndPlugin } from "../plugins/dnd";
|
|
9
|
-
import { useTree } from "../utils/useTree";
|
|
10
|
-
import { useNotifyExpandedChange, toggleItemExpand } from "../utils/group-expands-helpers";
|
|
11
|
-
import { useInstanceRefActions } from "../utils/useInstanceRefActions";
|
|
12
|
-
import { useGlobalToggleAllExpandShortcut } from "../utils/keyboard-helpers";
|
|
13
|
-
const useTreeview = (props) => {
|
|
14
|
-
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
15
|
-
useValidateTypescriptPropTypes(propsWithDefault, TreeViewPropTypes);
|
|
16
|
-
const defaultActions = {
|
|
17
|
-
actions: {
|
|
18
|
-
toggleExpandAll: () => {
|
|
19
|
-
},
|
|
20
|
-
scrollTo: () => {
|
|
21
|
-
},
|
|
22
|
-
setSelectedItemByVirtualIndex: () => {
|
|
23
|
-
},
|
|
24
|
-
setFocusedItemByVirtualIndex: () => {
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const treeRef = useRef(defaultActions);
|
|
29
|
-
const {
|
|
30
|
-
data,
|
|
31
|
-
plugins,
|
|
32
|
-
onOrderChange,
|
|
33
|
-
isMultiSelect,
|
|
34
|
-
isSingleSelect,
|
|
35
|
-
instanceRef,
|
|
36
|
-
selection,
|
|
37
|
-
onInstanceRefInitialized
|
|
38
|
-
} = propsWithDefault;
|
|
39
|
-
const [uniqueTreeViewUUID] = useState(uuidv4());
|
|
40
|
-
const [hoverItem, setHoverItem] = useState(null);
|
|
41
|
-
const [latestToggledItem, setLatestToggledItem] = useState(null);
|
|
42
|
-
const [selectedItem, setSelectedItem] = useState(null);
|
|
43
|
-
const [focusedItem, setFocusedItem] = useState(null);
|
|
44
|
-
const [selectedCheckboxes, setSelectedCheckboxes] = useState({
|
|
45
|
-
...selection
|
|
46
|
-
});
|
|
47
|
-
const [expandedGroups, setExpandedGroups] = useState({});
|
|
48
|
-
const { visibleItems, flattenedItems, tree, treeRoot, triggerTreeRerender, updateUserExpandedState } = useTree(data, propsWithDefault, {
|
|
49
|
-
setExpandedGroups
|
|
50
|
-
});
|
|
51
|
-
const virtualListRef = useRef();
|
|
52
|
-
const virtualListHelpers = useVirtual({
|
|
53
|
-
size: visibleItems.length,
|
|
54
|
-
parentRef: virtualListRef,
|
|
55
|
-
overscan: 15
|
|
56
|
-
});
|
|
57
|
-
const withDragAndDrop = !!(plugins?.includes(TreeDndPlugin) && onOrderChange);
|
|
58
|
-
const withRadioChecks = isSingleSelect && !isMultiSelect;
|
|
59
|
-
const withCheckboxChecks = !isSingleSelect && isMultiSelect;
|
|
60
|
-
const handleExpandGroup = useCallback(toggleItemExpand, []);
|
|
61
|
-
const ctx = useMemo(() => ({
|
|
62
|
-
props: propsWithDefault,
|
|
63
|
-
virtualListHelpers,
|
|
64
|
-
virtualListRef,
|
|
65
|
-
tree,
|
|
66
|
-
treeRoot,
|
|
67
|
-
visibleItems,
|
|
68
|
-
flattenedItems,
|
|
69
|
-
triggerTreeRerender,
|
|
70
|
-
withRadioChecks,
|
|
71
|
-
withCheckboxChecks,
|
|
72
|
-
withDragAndDrop,
|
|
73
|
-
uniqueTreeViewUUID,
|
|
74
|
-
selectedCheckboxes,
|
|
75
|
-
setSelectedCheckboxes,
|
|
76
|
-
selectedItem,
|
|
77
|
-
setSelectedItem,
|
|
78
|
-
expandedGroups,
|
|
79
|
-
setExpandedGroups,
|
|
80
|
-
latestToggledItem,
|
|
81
|
-
setLatestToggledItem,
|
|
82
|
-
focusedItem,
|
|
83
|
-
setFocusedItem,
|
|
84
|
-
hoverItem,
|
|
85
|
-
setHoverItem,
|
|
86
|
-
handleExpandGroup,
|
|
87
|
-
updateUserExpandedState
|
|
88
|
-
}), [
|
|
89
|
-
propsWithDefault,
|
|
90
|
-
virtualListHelpers,
|
|
91
|
-
tree,
|
|
92
|
-
treeRoot,
|
|
93
|
-
visibleItems,
|
|
94
|
-
flattenedItems,
|
|
95
|
-
triggerTreeRerender,
|
|
96
|
-
withRadioChecks,
|
|
97
|
-
withCheckboxChecks,
|
|
98
|
-
withDragAndDrop,
|
|
99
|
-
uniqueTreeViewUUID,
|
|
100
|
-
selectedCheckboxes,
|
|
101
|
-
selectedItem,
|
|
102
|
-
expandedGroups,
|
|
103
|
-
latestToggledItem,
|
|
104
|
-
focusedItem,
|
|
105
|
-
hoverItem,
|
|
106
|
-
handleExpandGroup,
|
|
107
|
-
updateUserExpandedState
|
|
108
|
-
]);
|
|
109
|
-
if (instanceRef)
|
|
110
|
-
instanceRef.current = treeRef.current;
|
|
111
|
-
useInstanceRefActions(treeRef.current, ctx);
|
|
112
|
-
useGlobalToggleAllExpandShortcut(treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
|
|
113
|
-
useNotifyExpandedChange(propsWithDefault, ctx);
|
|
114
|
-
useEffect(() => {
|
|
115
|
-
setTimeout(() => onInstanceRefInitialized(treeRef), 100);
|
|
116
|
-
}, []);
|
|
117
|
-
return useMemo(() => ({ ctx }), [ctx]);
|
|
118
|
-
};
|
|
119
|
-
export {
|
|
120
|
-
useTreeview
|
|
121
|
-
};
|
|
122
|
-
//# sourceMappingURL=useTreeview.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useTreeview.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-statements */\nimport { useState, useRef, useEffect, useMemo, useCallback } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { TreeViewPropTypes } from '../react-desc-prop-types';\nimport { defaultProps } from '../TreeViewContext';\nimport { TreeDndPlugin } from '../plugins/dnd';\nimport { useTree } from '../utils/useTree';\nimport { useNotifyExpandedChange, toggleItemExpand } from '../utils/group-expands-helpers';\nimport { useInstanceRefActions } from '../utils/useInstanceRefActions';\nimport { useGlobalToggleAllExpandShortcut } from '../utils/keyboard-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\n\ntype UseTreeviewT = (props: DSTreeviewT.Props) => { ctx: DSTreeviewInternalsT.CTX };\n\nexport const useTreeview: UseTreeviewT = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSTreeviewT.Props>(props, defaultProps);\n useValidateTypescriptPropTypes<DSTreeviewT.Props>(propsWithDefault, TreeViewPropTypes);\n const defaultActions = {\n actions: {\n toggleExpandAll: () => {},\n scrollTo: () => {},\n setSelectedItemByVirtualIndex: () => {},\n setFocusedItemByVirtualIndex: () => {},\n },\n } as unknown as DSTreeviewT.InstanceRef;\n const treeRef = useRef(defaultActions);\n const {\n data,\n plugins,\n onOrderChange,\n isMultiSelect,\n isSingleSelect,\n instanceRef,\n selection,\n onInstanceRefInitialized,\n } = propsWithDefault;\n const [uniqueTreeViewUUID] = useState(uuidv4());\n const [hoverItem, setHoverItem] = useState<DSTreeviewT.Item | null>(null);\n const [latestToggledItem, setLatestToggledItem] = useState<DSTreeviewT.Item | null>(null);\n const [selectedItem, setSelectedItem] = useState<DSTreeviewT.Item | null>(null);\n const [focusedItem, setFocusedItem] = useState<DSTreeviewT.Item | null>(null);\n const [selectedCheckboxes, setSelectedCheckboxes] = useState({\n ...selection,\n });\n const [expandedGroups, setExpandedGroups] = useState<DSTreeviewT.ExpandedItems>({});\n const { visibleItems, flattenedItems, tree, treeRoot, triggerTreeRerender, updateUserExpandedState } = useTree(\n data,\n propsWithDefault,\n {\n setExpandedGroups,\n },\n );\n\n const virtualListRef = useRef<HTMLUListElement>();\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n\n const virtualListHelpers = useVirtual({\n size: visibleItems.length,\n parentRef: virtualListRef,\n overscan: 15,\n });\n\n const withDragAndDrop = !!(plugins?.includes(TreeDndPlugin) && onOrderChange);\n const withRadioChecks = isSingleSelect && !isMultiSelect;\n const withCheckboxChecks = !isSingleSelect && isMultiSelect;\n\n const handleExpandGroup = useCallback(toggleItemExpand, []);\n\n const ctx: DSTreeviewInternalsT.CTX = useMemo(\n () => ({\n props: propsWithDefault,\n virtualListHelpers,\n virtualListRef,\n tree,\n treeRoot,\n visibleItems,\n flattenedItems,\n triggerTreeRerender,\n withRadioChecks,\n withCheckboxChecks,\n withDragAndDrop,\n uniqueTreeViewUUID,\n selectedCheckboxes,\n setSelectedCheckboxes,\n selectedItem,\n setSelectedItem,\n expandedGroups,\n setExpandedGroups,\n latestToggledItem,\n setLatestToggledItem,\n focusedItem,\n setFocusedItem,\n hoverItem,\n setHoverItem,\n handleExpandGroup,\n updateUserExpandedState,\n }),\n [\n propsWithDefault,\n virtualListHelpers,\n tree,\n treeRoot,\n visibleItems,\n flattenedItems,\n triggerTreeRerender,\n withRadioChecks,\n withCheckboxChecks,\n withDragAndDrop,\n uniqueTreeViewUUID,\n selectedCheckboxes,\n selectedItem,\n expandedGroups,\n latestToggledItem,\n focusedItem,\n hoverItem,\n handleExpandGroup,\n updateUserExpandedState,\n ],\n );\n // this hooks can't use the context because the context provider doesn't wrap this\n // as such we manually pass the second parameter as fit\n if (instanceRef) instanceRef.current = treeRef.current;\n useInstanceRefActions(treeRef.current, ctx);\n useGlobalToggleAllExpandShortcut(treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);\n useNotifyExpandedChange(propsWithDefault, ctx);\n\n // this is an horrible hack.\n // this is required because there is no \"on rendered\" react-way to check if every children has finished rendering\n // this should be working for now, in the future we may want to review this for a better solution\n useEffect(() => {\n setTimeout(() => onInstanceRefInitialized(treeRef), 100);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return useMemo(() => ({ ctx }), [ctx]);\n};\n"],
|
|
5
|
-
"mappings": "AAAA;ACEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAMO,MAAM,cAA4B,CAAC,UAAU;AAClD,QAAM,mBAAmB,6BAAgD,OAAO;AAChF,iCAAkD,kBAAkB;AACpE,QAAM,iBAAiB;AAAA,IACrB,SAAS;AAAA,MACP,iBAAiB,MAAM;AAAA;AAAA,MACvB,UAAU,MAAM;AAAA;AAAA,MAChB,+BAA+B,MAAM;AAAA;AAAA,MACrC,8BAA8B,MAAM;AAAA;AAAA;AAAA;AAGxC,QAAM,UAAU,OAAO;AACvB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE;AACJ,QAAM,CAAC,sBAAsB,SAAS;AACtC,QAAM,CAAC,WAAW,gBAAgB,SAAkC;AACpE,QAAM,CAAC,mBAAmB,wBAAwB,SAAkC;AACpF,QAAM,CAAC,cAAc,mBAAmB,SAAkC;AAC1E,QAAM,CAAC,aAAa,kBAAkB,SAAkC;AACxE,QAAM,CAAC,oBAAoB,yBAAyB,SAAS;AAAA,OACxD;AAAA;AAEL,QAAM,CAAC,gBAAgB,qBAAqB,SAAoC;AAChF,QAAM,EAAE,cAAc,gBAAgB,MAAM,UAAU,qBAAqB,4BAA4B,QACrG,MACA,kBACA;AAAA,IACE;AAAA;AAIJ,QAAM,iBAAiB;AAIvB,QAAM,qBAAqB,WAAW;AAAA,IACpC,MAAM,aAAa;AAAA,IACnB,WAAW;AAAA,IACX,UAAU;AAAA;AAGZ,QAAM,kBAAkB,CAAC,CAAE,UAAS,SAAS,kBAAkB;AAC/D,QAAM,kBAAkB,kBAAkB,CAAC;AAC3C,QAAM,qBAAqB,CAAC,kBAAkB;AAE9C,QAAM,oBAAoB,YAAY,kBAAkB;AAExD,QAAM,MAAgC,QACpC,MAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAKJ,MAAI;AAAa,gBAAY,UAAU,QAAQ;AAC/C,wBAAsB,QAAQ,SAAS;AACvC,mCAAiC,UAAU,qBAAqB,sBAAsB;AACtF,0BAAwB,kBAAkB;AAK1C,YAAU,MAAM;AACd,eAAW,MAAM,yBAAyB,UAAU;AAAA,KAEnD;AAEH,SAAO,QAAQ,MAAO,GAAE,QAAQ,CAAC;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { createContext } from "react";
|
|
3
|
-
import { DropIndicatorPosition } from "./SortableItemContext";
|
|
4
|
-
const DnDTreeContext = createContext({
|
|
5
|
-
depth: void 0,
|
|
6
|
-
activeIndex: void 0,
|
|
7
|
-
visibleItems: void 0,
|
|
8
|
-
dropIndicatorPosition: DropIndicatorPosition.None,
|
|
9
|
-
lastActiveId: void 0,
|
|
10
|
-
setLastActiveId: void 0,
|
|
11
|
-
isDropValid: false
|
|
12
|
-
});
|
|
13
|
-
export {
|
|
14
|
-
DnDTreeContext
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=DnDTreeContext.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hoc/DnDTreeContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext } from 'react';\nimport { DSTreeviewT } from '../react-desc-prop-types';\nimport { DropIndicatorPosition } from './SortableItemContext';\n\ntype DnDTreeContextType = {\n depth: number | undefined;\n activeIndex: number | undefined;\n visibleItems: DSTreeviewT.Item[] | undefined;\n dropIndicatorPosition: DropIndicatorPosition;\n lastActiveId: string | undefined;\n setLastActiveId: React.Dispatch<React.SetStateAction<string>> | undefined;\n isDropValid: boolean;\n};\n\nexport const DnDTreeContext = createContext<DnDTreeContextType>({\n depth: undefined,\n activeIndex: undefined,\n visibleItems: undefined,\n dropIndicatorPosition: DropIndicatorPosition.None,\n lastActiveId: undefined,\n setLastActiveId: undefined,\n isDropValid: false,\n});\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEA;AAYO,MAAM,iBAAiB,cAAkC;AAAA,EAC9D,OAAO;AAAA,EACP,aAAa;AAAA,EACb,cAAc;AAAA,EACd,uBAAuB,sBAAsB;AAAA,EAC7C,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,aAAa;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { createContext } from "react";
|
|
3
|
-
var DropIndicatorPosition = /* @__PURE__ */ ((DropIndicatorPosition2) => {
|
|
4
|
-
DropIndicatorPosition2[DropIndicatorPosition2["None"] = 0] = "None";
|
|
5
|
-
DropIndicatorPosition2[DropIndicatorPosition2["Before"] = 1] = "Before";
|
|
6
|
-
DropIndicatorPosition2[DropIndicatorPosition2["After"] = 2] = "After";
|
|
7
|
-
DropIndicatorPosition2[DropIndicatorPosition2["Inside"] = 3] = "Inside";
|
|
8
|
-
return DropIndicatorPosition2;
|
|
9
|
-
})(DropIndicatorPosition || {});
|
|
10
|
-
const SortableItemContext = createContext({
|
|
11
|
-
draggableProps: false
|
|
12
|
-
});
|
|
13
|
-
export {
|
|
14
|
-
DropIndicatorPosition,
|
|
15
|
-
SortableItemContext
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=SortableItemContext.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hoc/SortableItemContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useSortable } from '@dnd-kit/sortable';\nimport { createContext } from 'react';\n\nexport enum DropIndicatorPosition {\n None = 0,\n Before = 1,\n After = 2,\n Inside = 3,\n}\n\nexport type SortableItemContextType = {\n draggableProps:\n | false\n | (ReturnType<typeof useSortable> & {\n dropIndicatorPosition: DropIndicatorPosition;\n shouldShowDropIndicatorPosition: boolean;\n lastActiveId?: string;\n setLastActiveId?: React.Dispatch<React.SetStateAction<string>>;\n isDropValid: boolean;\n });\n};\n\n/** Context for cross component communication */\nexport const SortableItemContext = createContext<SortableItemContextType>({\n draggableProps: false,\n});\n"],
|
|
5
|
-
"mappings": "AAAA;ACCA;AAEO,IAAK,wBAAL,kBAAK,2BAAL;AACL,0DAAO,KAAP;AACA,4DAAS,KAAT;AACA,2DAAQ,KAAR;AACA,4DAAS,KAAT;AAJU;AAAA;AAoBL,MAAM,sBAAsB,cAAuC;AAAA,EACxE,gBAAgB;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2, { useCallback, useContext, useMemo } from "react";
|
|
3
|
-
import { DndContext, DragOverlay } from "@dnd-kit/core";
|
|
4
|
-
import { SortableContext } from "@dnd-kit/sortable";
|
|
5
|
-
import { useTreeDndkitConfig } from "@elliemae/ds-drag-and-drop";
|
|
6
|
-
import TreeViewContext from "../TreeViewContext";
|
|
7
|
-
import { TreeItem } from "../parts/TreeItem";
|
|
8
|
-
import { DnDTreeContext } from "./DnDTreeContext";
|
|
9
|
-
const ensure = (argument, message = "This should never happen") => {
|
|
10
|
-
if (argument === void 0 || argument === null) {
|
|
11
|
-
throw new TypeError(message);
|
|
12
|
-
}
|
|
13
|
-
return argument;
|
|
14
|
-
};
|
|
15
|
-
const withConditionalDnDRowContext = (Component) => (props) => {
|
|
16
|
-
const [lastActiveId, setLastActiveId] = React2.useState("");
|
|
17
|
-
const {
|
|
18
|
-
props: { data, onOrderChange, getIsDropValid },
|
|
19
|
-
flattenedItems,
|
|
20
|
-
visibleItems: flattenedVisibleTree,
|
|
21
|
-
withDragAndDrop
|
|
22
|
-
} = useContext(TreeViewContext);
|
|
23
|
-
const flattenedVisibleTreeForDnD = useMemo(() => flattenedVisibleTree.map((item, index) => ({
|
|
24
|
-
uid: item.id.toString(),
|
|
25
|
-
depth: (item.treeDepth ?? 1) - 1,
|
|
26
|
-
realIndex: index,
|
|
27
|
-
childrenCount: item.children?.length ?? 0,
|
|
28
|
-
parentId: item.node.parent?.model?.id?.toString() ?? null,
|
|
29
|
-
original: item
|
|
30
|
-
})), [flattenedVisibleTree]);
|
|
31
|
-
const onReorder = useCallback((tree, indexes) => {
|
|
32
|
-
const nodes = {};
|
|
33
|
-
tree.forEach((item) => {
|
|
34
|
-
const originalItem = item.original;
|
|
35
|
-
originalItem.children = [];
|
|
36
|
-
nodes[item.uid] = item.original;
|
|
37
|
-
});
|
|
38
|
-
const newUserTree = [];
|
|
39
|
-
tree.forEach((item) => {
|
|
40
|
-
if (item.parentId !== null && item.parentId !== void 0 && item.parentId !== "__ds_tree_root") {
|
|
41
|
-
const parentNode = nodes[item.parentId];
|
|
42
|
-
parentNode.children?.push(item.original);
|
|
43
|
-
} else if (item.uid !== "__ds_tree_root")
|
|
44
|
-
newUserTree.push(item.original);
|
|
45
|
-
});
|
|
46
|
-
onOrderChange(newUserTree, data, flattenedItems[indexes.fromIndex]);
|
|
47
|
-
}, [onOrderChange, data, flattenedItems]);
|
|
48
|
-
const {
|
|
49
|
-
dndContextProps,
|
|
50
|
-
sortableContextProps,
|
|
51
|
-
activeId,
|
|
52
|
-
activeIndex,
|
|
53
|
-
depth,
|
|
54
|
-
dropIndicatorPosition,
|
|
55
|
-
visibleItems,
|
|
56
|
-
isDropValid
|
|
57
|
-
} = useTreeDndkitConfig({
|
|
58
|
-
flattenedItems,
|
|
59
|
-
visibleItems: flattenedVisibleTreeForDnD,
|
|
60
|
-
isHorizontalDnD: false,
|
|
61
|
-
isExpandable: true,
|
|
62
|
-
onReorder,
|
|
63
|
-
getIsDropValid,
|
|
64
|
-
maxDragAndDropLevel: Infinity
|
|
65
|
-
});
|
|
66
|
-
if (lastActiveId !== activeId && activeId)
|
|
67
|
-
setLastActiveId(activeId);
|
|
68
|
-
if (withDragAndDrop)
|
|
69
|
-
return /* @__PURE__ */ React2.createElement(DndContext, {
|
|
70
|
-
...dndContextProps
|
|
71
|
-
}, /* @__PURE__ */ React2.createElement(SortableContext, {
|
|
72
|
-
...sortableContextProps
|
|
73
|
-
}, /* @__PURE__ */ React2.createElement(DnDTreeContext.Provider, {
|
|
74
|
-
value: {
|
|
75
|
-
activeIndex,
|
|
76
|
-
depth,
|
|
77
|
-
visibleItems: visibleItems.map((item) => item.original),
|
|
78
|
-
dropIndicatorPosition,
|
|
79
|
-
lastActiveId,
|
|
80
|
-
setLastActiveId,
|
|
81
|
-
isDropValid
|
|
82
|
-
}
|
|
83
|
-
}, /* @__PURE__ */ React2.createElement(Component, {
|
|
84
|
-
...props
|
|
85
|
-
}))), /* @__PURE__ */ React2.createElement(DragOverlay, {
|
|
86
|
-
style: { width: "auto" }
|
|
87
|
-
}, activeId ? /* @__PURE__ */ React2.createElement(TreeItem, {
|
|
88
|
-
itemIndex: activeIndex,
|
|
89
|
-
item: ensure(flattenedVisibleTree.find((item) => item.id.toString() === activeId)),
|
|
90
|
-
isDragOverlay: true
|
|
91
|
-
}) : null));
|
|
92
|
-
return /* @__PURE__ */ React2.createElement(Component, {
|
|
93
|
-
...props
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
export {
|
|
97
|
-
withConditionalDnDRowContext
|
|
98
|
-
};
|
|
99
|
-
//# sourceMappingURL=WithConditionalDnDContext.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hoc/WithConditionalDnDContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useContext, useMemo } from 'react';\nimport { DndContext, DragOverlay } from '@dnd-kit/core';\nimport { SortableContext } from '@dnd-kit/sortable';\nimport { useTreeDndkitConfig } from '@elliemae/ds-drag-and-drop';\nimport { DSTreeviewT } from '../react-desc-prop-types';\nimport TreeViewContext from '../TreeViewContext';\nimport { TreeItem } from '../parts/TreeItem';\nimport { DnDTreeContext } from './DnDTreeContext';\n\ntype FunctionalHOC = <T = unknown>(Component: React.ComponentType<T>, ...other: unknown[]) => (props: T) => JSX.Element;\n\nconst ensure = <T,>(argument: T | undefined | null, message = 'This should never happen'): T => {\n if (argument === undefined || argument === null) {\n throw new TypeError(message);\n }\n\n return argument;\n};\n\n// only wraps in \"DnDContext\" and \"DnDTreeContext\" if any Drag and Drop functionality is requested\nexport const withConditionalDnDRowContext: FunctionalHOC = (Component) => (props) => {\n const [lastActiveId, setLastActiveId] = React.useState('');\n\n const {\n props: { data, onOrderChange, getIsDropValid },\n flattenedItems,\n visibleItems: flattenedVisibleTree,\n withDragAndDrop,\n } = useContext(TreeViewContext);\n\n const flattenedVisibleTreeForDnD = useMemo(\n () =>\n flattenedVisibleTree.map((item, index) => ({\n uid: item.id.toString(),\n depth: (item.treeDepth ?? 1) - 1,\n realIndex: index,\n childrenCount: item.children?.length ?? 0,\n parentId: item.node.parent?.model?.id?.toString() ?? null,\n original: item,\n })),\n [flattenedVisibleTree],\n );\n\n const onReorder = useCallback(\n (tree: DSTreeviewT.DndItem[], indexes: { targetIndex: number; fromIndex: number }) => {\n // Pull the row's original data into an object\n const nodes: Record<DSTreeviewT.StringOrNum, DSTreeviewT.SimpleItem> = {};\n tree.forEach((item) => {\n const originalItem = item.original;\n originalItem.children = [];\n nodes[item.uid] = item.original;\n });\n\n const newUserTree: DSTreeviewT.SimpleItem[] = [];\n tree.forEach((item) => {\n // If row has parent, insert it to it's subrows\n // otherwise append it to the new user data\n if (item.parentId !== null && item.parentId !== undefined && item.parentId !== '__ds_tree_root') {\n const parentNode = nodes[item.parentId];\n parentNode.children?.push(item.original);\n } else if (item.uid !== '__ds_tree_root') newUserTree.push(item.original);\n });\n // Tell the user that the order has change, he can chose to commit it or not\n onOrderChange(newUserTree, data, flattenedItems[indexes.fromIndex]);\n },\n [onOrderChange, data, flattenedItems],\n );\n\n const {\n dndContextProps,\n sortableContextProps,\n activeId,\n activeIndex,\n depth,\n dropIndicatorPosition,\n visibleItems,\n isDropValid,\n } = useTreeDndkitConfig({\n flattenedItems,\n visibleItems: flattenedVisibleTreeForDnD,\n isHorizontalDnD: false,\n isExpandable: true,\n onReorder,\n getIsDropValid,\n maxDragAndDropLevel: Infinity,\n });\n\n if (lastActiveId !== activeId && activeId) setLastActiveId(activeId);\n\n if (withDragAndDrop)\n return (\n <DndContext {...dndContextProps}>\n <SortableContext {...sortableContextProps}>\n <DnDTreeContext.Provider\n value={{\n activeIndex,\n depth,\n visibleItems: visibleItems.map((item) => item.original) as DSTreeviewT.Item[],\n dropIndicatorPosition,\n lastActiveId,\n setLastActiveId,\n isDropValid,\n }}\n >\n <Component {...props} />\n </DnDTreeContext.Provider>\n </SortableContext>\n <DragOverlay style={{ width: 'auto' }}>\n {activeId ? (\n <TreeItem\n itemIndex={activeIndex}\n item={ensure(flattenedVisibleTree.find((item) => item.id.toString() === activeId))}\n isDragOverlay\n />\n ) : null}\n </DragOverlay>\n </DndContext>\n );\n return <Component {...props} />;\n};\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAIA,MAAM,SAAS,CAAK,UAAgC,UAAU,+BAAkC;AAC9F,MAAI,aAAa,UAAa,aAAa,MAAM;AAC/C,UAAM,IAAI,UAAU;AAAA;AAGtB,SAAO;AAAA;AAIF,MAAM,+BAA8C,CAAC,cAAc,CAAC,UAAU;AACnF,QAAM,CAAC,cAAc,mBAAmB,OAAM,SAAS;AAEvD,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM,eAAe;AAAA,IAC9B;AAAA,IACA,cAAc;AAAA,IACd;AAAA,MACE,WAAW;AAEf,QAAM,6BAA6B,QACjC,MACE,qBAAqB,IAAI,CAAC,MAAM,UAAW;AAAA,IACzC,KAAK,KAAK,GAAG;AAAA,IACb,OAAQ,MAAK,aAAa,KAAK;AAAA,IAC/B,WAAW;AAAA,IACX,eAAe,KAAK,UAAU,UAAU;AAAA,IACxC,UAAU,KAAK,KAAK,QAAQ,OAAO,IAAI,cAAc;AAAA,IACrD,UAAU;AAAA,OAEd,CAAC;AAGH,QAAM,YAAY,YAChB,CAAC,MAA6B,YAAwD;AAEpF,UAAM,QAAiE;AACvE,SAAK,QAAQ,CAAC,SAAS;AACrB,YAAM,eAAe,KAAK;AAC1B,mBAAa,WAAW;AACxB,YAAM,KAAK,OAAO,KAAK;AAAA;AAGzB,UAAM,cAAwC;AAC9C,SAAK,QAAQ,CAAC,SAAS;AAGrB,UAAI,KAAK,aAAa,QAAQ,KAAK,aAAa,UAAa,KAAK,aAAa,kBAAkB;AAC/F,cAAM,aAAa,MAAM,KAAK;AAC9B,mBAAW,UAAU,KAAK,KAAK;AAAA,iBACtB,KAAK,QAAQ;AAAkB,oBAAY,KAAK,KAAK;AAAA;AAGlE,kBAAc,aAAa,MAAM,eAAe,QAAQ;AAAA,KAE1D,CAAC,eAAe,MAAM;AAGxB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,oBAAoB;AAAA,IACtB;AAAA,IACA,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA;AAGvB,MAAI,iBAAiB,YAAY;AAAU,oBAAgB;AAE3D,MAAI;AACF,WACE,qCAAC,YAAD;AAAA,SAAgB;AAAA,OACd,qCAAC,iBAAD;AAAA,SAAqB;AAAA,OACnB,qCAAC,eAAe,UAAhB;AAAA,MACE,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,cAAc,aAAa,IAAI,CAAC,SAAS,KAAK;AAAA,QAC9C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,OAGF,qCAAC,WAAD;AAAA,SAAe;AAAA,UAGnB,qCAAC,aAAD;AAAA,MAAa,OAAO,EAAE,OAAO;AAAA,OAC1B,WACC,qCAAC,UAAD;AAAA,MACE,WAAW;AAAA,MACX,MAAM,OAAO,qBAAqB,KAAK,CAAC,SAAS,KAAK,GAAG,eAAe;AAAA,MACxE,eAAa;AAAA,SAEb;AAIZ,SAAO,qCAAC,WAAD;AAAA,OAAe;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2, { useContext, useMemo } from "react";
|
|
3
|
-
import { useSortable } from "@dnd-kit/sortable";
|
|
4
|
-
import { SortableItemContext } from "./SortableItemContext";
|
|
5
|
-
import TreeViewContext from "../TreeViewContext";
|
|
6
|
-
import { DnDTreeContext } from "./DnDTreeContext";
|
|
7
|
-
const withDnDSortableItemContext = (Component) => (props) => {
|
|
8
|
-
const { withDragAndDrop } = useContext(TreeViewContext);
|
|
9
|
-
const { dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid } = useContext(DnDTreeContext);
|
|
10
|
-
const id = props.item.id.toString();
|
|
11
|
-
const draggableOptions = useMemo(() => ({
|
|
12
|
-
id
|
|
13
|
-
}), [id]);
|
|
14
|
-
const useSortableHelpers = useSortable(draggableOptions);
|
|
15
|
-
const draggableProps = useMemo(() => {
|
|
16
|
-
if (!withDragAndDrop)
|
|
17
|
-
return false;
|
|
18
|
-
const { index, overIndex } = useSortableHelpers;
|
|
19
|
-
return {
|
|
20
|
-
...useSortableHelpers,
|
|
21
|
-
shouldShowDropIndicatorPosition: overIndex === index,
|
|
22
|
-
dropIndicatorPosition,
|
|
23
|
-
lastActiveId,
|
|
24
|
-
setLastActiveId,
|
|
25
|
-
isDropValid
|
|
26
|
-
};
|
|
27
|
-
}, [withDragAndDrop, useSortableHelpers, dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid]);
|
|
28
|
-
const ctx = useMemo(() => ({
|
|
29
|
-
draggableProps
|
|
30
|
-
}), [draggableProps]);
|
|
31
|
-
return /* @__PURE__ */ React2.createElement(SortableItemContext.Provider, {
|
|
32
|
-
value: ctx
|
|
33
|
-
}, /* @__PURE__ */ React2.createElement(Component, {
|
|
34
|
-
...props
|
|
35
|
-
}));
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
withDnDSortableItemContext
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=WithDnDSortableItemContext.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hoc/WithDnDSortableItemContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport React, { useContext, useMemo } from 'react';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { SortableItemContext, SortableItemContextType } from './SortableItemContext';\nimport TreeViewContext from '../TreeViewContext';\nimport { DnDTreeContext } from './DnDTreeContext';\nimport { DSTreeviewT } from '../react-desc-prop-types';\n\ntype FunctionalHOC = <T = unknown>(Component: React.ComponentType<T>, ...other: unknown[]) => (props: T) => JSX.Element;\n\nexport const withDnDSortableItemContext: FunctionalHOC = (Component) => (props: any) => {\n const { withDragAndDrop } = useContext(TreeViewContext);\n const { dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid } = useContext(DnDTreeContext);\n\n const id = (props as { item: DSTreeviewT.Item }).item.id.toString();\n\n // onMount generate unique options, so everyting is only ran once\n const draggableOptions = useMemo(\n () => ({\n id,\n }),\n [id],\n );\n\n const useSortableHelpers = useSortable(draggableOptions);\n\n // calculate all the \"useSortable\" values as per required\n const draggableProps = useMemo(() => {\n if (!withDragAndDrop) return false;\n\n const { index, overIndex } = useSortableHelpers;\n\n return {\n ...useSortableHelpers,\n shouldShowDropIndicatorPosition: overIndex === index,\n dropIndicatorPosition,\n lastActiveId,\n setLastActiveId,\n isDropValid,\n };\n }, [withDragAndDrop, useSortableHelpers, dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid]);\n\n // we use a context so we can easly access information wherever without bubbling down\n // this context is all Memoized so as long as component is not re-mounted,\n // the context won't trigger un-required renders per-se...\n const ctx: SortableItemContextType = useMemo(\n () => ({\n draggableProps,\n }),\n [draggableProps],\n );\n // we always add the context, if draggableProps===false we don't have the DnD enabled.\n return (\n <SortableItemContext.Provider value={ctx}>\n <Component {...props} />\n </SortableItemContext.Provider>\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA;ACGA;AACA;AACA;AACA;AACA;AAKO,MAAM,6BAA4C,CAAC,cAAc,CAAC,UAAe;AACtF,QAAM,EAAE,oBAAoB,WAAW;AACvC,QAAM,EAAE,uBAAuB,cAAc,iBAAiB,gBAAgB,WAAW;AAEzF,QAAM,KAAM,MAAqC,KAAK,GAAG;AAGzD,QAAM,mBAAmB,QACvB,MAAO;AAAA,IACL;AAAA,MAEF,CAAC;AAGH,QAAM,qBAAqB,YAAY;AAGvC,QAAM,iBAAiB,QAAQ,MAAM;AACnC,QAAI,CAAC;AAAiB,aAAO;AAE7B,UAAM,EAAE,OAAO,cAAc;AAE7B,WAAO;AAAA,SACF;AAAA,MACH,iCAAiC,cAAc;AAAA,MAC/C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,KAED,CAAC,iBAAiB,oBAAoB,uBAAuB,cAAc,iBAAiB;AAK/F,QAAM,MAA+B,QACnC,MAAO;AAAA,IACL;AAAA,MAEF,CAAC;AAGH,SACE,qCAAC,oBAAoB,UAArB;AAAA,IAA8B,OAAO;AAAA,KACnC,qCAAC,WAAD;AAAA,OAAe;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './TreeView';\nexport * from './plugins';\n\nexport { TreeViewSearchBar } from './related-components/TreeViewSearchBar';\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AAEA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|