@elliemae/ds-treeview 2.3.1 → 3.0.0-alpha.3
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/dist/cjs/TreeView.js +50 -0
- package/dist/cjs/TreeView.js.map +7 -0
- package/dist/cjs/TreeViewContext.js +116 -0
- package/dist/cjs/TreeViewContext.js.map +7 -0
- package/dist/cjs/config/cssClassesConstants.js +41 -0
- package/dist/cjs/config/cssClassesConstants.js.map +7 -0
- package/dist/cjs/config/useTreeview.js +163 -0
- package/dist/cjs/config/useTreeview.js.map +7 -0
- package/dist/cjs/hoc/DnDTreeContext.js +45 -0
- package/dist/cjs/hoc/DnDTreeContext.js.map +7 -0
- package/dist/cjs/hoc/SortableItemContext.js +46 -0
- package/dist/cjs/hoc/SortableItemContext.js.map +7 -0
- package/dist/cjs/hoc/WithConditionalDnDContext.js +134 -0
- package/dist/cjs/hoc/WithConditionalDnDContext.js.map +7 -0
- package/dist/cjs/hoc/WithDnDSortableItemContext.js +83 -0
- package/dist/cjs/hoc/WithDnDSortableItemContext.js.map +7 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/parts/CheckboxSelectable.js +111 -0
- package/dist/cjs/parts/CheckboxSelectable.js.map +7 -0
- package/dist/cjs/parts/ChildrenCountDisplayer.js +47 -0
- package/dist/cjs/parts/ChildrenCountDisplayer.js.map +7 -0
- package/dist/cjs/parts/DnDHandle.js +71 -0
- package/dist/cjs/parts/DnDHandle.js.map +7 -0
- package/dist/cjs/parts/DropIndicator.js +80 -0
- package/dist/cjs/parts/DropIndicator.js.map +7 -0
- package/dist/cjs/parts/ExpandCaret.js +96 -0
- package/dist/cjs/parts/ExpandCaret.js.map +7 -0
- package/dist/cjs/parts/Icon.js +52 -0
- package/dist/cjs/parts/Icon.js.map +7 -0
- package/dist/cjs/parts/NestingSpace.js +55 -0
- package/dist/cjs/parts/NestingSpace.js.map +7 -0
- package/dist/cjs/parts/RadioSelectable.js +74 -0
- package/dist/cjs/parts/RadioSelectable.js.map +7 -0
- package/dist/cjs/parts/TreeItem.js +180 -0
- package/dist/cjs/parts/TreeItem.js.map +7 -0
- package/dist/cjs/parts/TreeItemText.js +101 -0
- package/dist/cjs/parts/TreeItemText.js.map +7 -0
- package/dist/cjs/parts/TreeList.js +135 -0
- package/dist/cjs/parts/TreeList.js.map +7 -0
- package/dist/cjs/plugins/dnd/TreeDndPlugin.js +35 -0
- package/dist/cjs/plugins/dnd/TreeDndPlugin.js.map +7 -0
- package/dist/cjs/plugins/dnd/index.js +28 -0
- package/dist/cjs/plugins/dnd/index.js.map +7 -0
- package/dist/cjs/plugins/index.js +34 -0
- package/dist/cjs/plugins/index.js.map +7 -0
- package/dist/cjs/plugins/roving/TreeRovingPlugin.js +35 -0
- package/dist/cjs/plugins/roving/TreeRovingPlugin.js.map +7 -0
- package/dist/cjs/plugins/roving/index.js +28 -0
- package/dist/cjs/plugins/roving/index.js.map +7 -0
- package/dist/cjs/plugins/searchable/SearchableTreePlugin.js +35 -0
- package/dist/cjs/plugins/searchable/SearchableTreePlugin.js.map +7 -0
- package/dist/cjs/plugins/searchable/index.js +28 -0
- package/dist/cjs/plugins/searchable/index.js.map +7 -0
- package/dist/cjs/plugins/selectable/SelectablePluginTree.js +35 -0
- package/dist/cjs/plugins/selectable/SelectablePluginTree.js.map +7 -0
- package/dist/cjs/plugins/selectable/index.js +28 -0
- package/dist/cjs/plugins/selectable/index.js.map +7 -0
- package/dist/cjs/plugins/toolbar/TreeToolbarPlugin.js +35 -0
- package/dist/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
- package/dist/cjs/plugins/toolbar/index.js +28 -0
- package/dist/cjs/plugins/toolbar/index.js.map +7 -0
- package/dist/cjs/plugins/tree/TreeDataPlugin.js +35 -0
- package/dist/cjs/plugins/tree/TreeDataPlugin.js.map +7 -0
- package/dist/cjs/plugins/tree/index.js +28 -0
- package/dist/cjs/plugins/tree/index.js.map +7 -0
- package/dist/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +35 -0
- package/dist/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
- package/dist/cjs/plugins/virtualization/index.js +28 -0
- package/dist/cjs/plugins/virtualization/index.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +85 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/related-components/TreeViewSearchBar.js +50 -0
- package/dist/cjs/related-components/TreeViewSearchBar.js.map +7 -0
- package/dist/cjs/sharedTypes.js +27 -0
- package/dist/cjs/sharedTypes.js.map +7 -0
- package/dist/cjs/utils/array-helpers.js +48 -0
- package/dist/cjs/utils/array-helpers.js.map +7 -0
- package/dist/cjs/utils/group-expands-helpers.js +138 -0
- package/dist/cjs/utils/group-expands-helpers.js.map +7 -0
- package/dist/cjs/utils/keyboard-helpers.js +170 -0
- package/dist/cjs/utils/keyboard-helpers.js.map +7 -0
- package/dist/cjs/utils/object-helpers.js +76 -0
- package/dist/cjs/utils/object-helpers.js.map +7 -0
- package/dist/cjs/utils/refs-helpers.js +52 -0
- package/dist/cjs/utils/refs-helpers.js.map +7 -0
- package/dist/cjs/utils/selectable-helper.js +102 -0
- package/dist/cjs/utils/selectable-helper.js.map +7 -0
- package/dist/cjs/utils/string-helpers.js +35 -0
- package/dist/cjs/utils/string-helpers.js.map +7 -0
- package/dist/cjs/utils/tree-helpers.js +184 -0
- package/dist/cjs/utils/tree-helpers.js.map +7 -0
- package/dist/cjs/utils/useInstanceRefActions.js +98 -0
- package/dist/cjs/utils/useInstanceRefActions.js.map +7 -0
- package/dist/cjs/utils/useTree.js +123 -0
- package/dist/cjs/utils/useTree.js.map +7 -0
- package/dist/esm/TreeView.js +21 -0
- package/dist/esm/TreeView.js.map +7 -0
- package/{esm → dist/esm}/TreeViewContext.js +24 -29
- package/dist/esm/TreeViewContext.js.map +7 -0
- package/dist/esm/config/cssClassesConstants.js +12 -0
- package/dist/esm/config/cssClassesConstants.js.map +7 -0
- package/dist/esm/config/useTreeview.js +136 -0
- package/dist/esm/config/useTreeview.js.map +7 -0
- package/dist/esm/hoc/DnDTreeContext.js +16 -0
- package/dist/esm/hoc/DnDTreeContext.js.map +7 -0
- package/dist/esm/hoc/SortableItemContext.js +17 -0
- package/dist/esm/hoc/SortableItemContext.js.map +7 -0
- package/dist/esm/hoc/WithConditionalDnDContext.js +107 -0
- package/dist/esm/hoc/WithConditionalDnDContext.js.map +7 -0
- package/dist/esm/hoc/WithDnDSortableItemContext.js +56 -0
- package/dist/esm/hoc/WithDnDSortableItemContext.js.map +7 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parts/CheckboxSelectable.js +84 -0
- package/dist/esm/parts/CheckboxSelectable.js.map +7 -0
- package/dist/esm/parts/ChildrenCountDisplayer.js +18 -0
- package/dist/esm/parts/ChildrenCountDisplayer.js.map +7 -0
- package/dist/esm/parts/DnDHandle.js +44 -0
- package/dist/esm/parts/DnDHandle.js.map +7 -0
- package/dist/esm/parts/DropIndicator.js +51 -0
- package/dist/esm/parts/DropIndicator.js.map +7 -0
- package/dist/esm/parts/ExpandCaret.js +67 -0
- package/dist/esm/parts/ExpandCaret.js.map +7 -0
- package/dist/esm/parts/Icon.js +23 -0
- package/dist/esm/parts/Icon.js.map +7 -0
- package/dist/esm/parts/NestingSpace.js +26 -0
- package/dist/esm/parts/NestingSpace.js.map +7 -0
- package/dist/esm/parts/RadioSelectable.js +45 -0
- package/dist/esm/parts/RadioSelectable.js.map +7 -0
- package/dist/esm/parts/TreeItem.js +153 -0
- package/dist/esm/parts/TreeItem.js.map +7 -0
- package/dist/esm/parts/TreeItemText.js +72 -0
- package/dist/esm/parts/TreeItemText.js.map +7 -0
- package/dist/esm/parts/TreeList.js +108 -0
- package/dist/esm/parts/TreeList.js.map +7 -0
- package/dist/esm/plugins/dnd/TreeDndPlugin.js +6 -0
- package/dist/esm/plugins/dnd/TreeDndPlugin.js.map +7 -0
- package/dist/esm/plugins/dnd/index.js +3 -0
- package/dist/esm/plugins/dnd/index.js.map +7 -0
- package/dist/esm/plugins/index.js +9 -0
- package/dist/esm/plugins/index.js.map +7 -0
- package/dist/esm/plugins/roving/TreeRovingPlugin.js +6 -0
- package/dist/esm/plugins/roving/TreeRovingPlugin.js.map +7 -0
- package/dist/esm/plugins/roving/index.js +3 -0
- package/dist/esm/plugins/roving/index.js.map +7 -0
- package/dist/esm/plugins/searchable/SearchableTreePlugin.js +6 -0
- package/dist/esm/plugins/searchable/SearchableTreePlugin.js.map +7 -0
- package/dist/esm/plugins/searchable/index.js +3 -0
- package/dist/esm/plugins/searchable/index.js.map +7 -0
- package/dist/esm/plugins/selectable/SelectablePluginTree.js +6 -0
- package/dist/esm/plugins/selectable/SelectablePluginTree.js.map +7 -0
- package/dist/esm/plugins/selectable/index.js +3 -0
- package/dist/esm/plugins/selectable/index.js.map +7 -0
- package/dist/esm/plugins/toolbar/TreeToolbarPlugin.js +6 -0
- package/dist/esm/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
- package/dist/esm/plugins/toolbar/index.js +3 -0
- package/dist/esm/plugins/toolbar/index.js.map +7 -0
- package/dist/esm/plugins/tree/TreeDataPlugin.js +6 -0
- package/dist/esm/plugins/tree/TreeDataPlugin.js.map +7 -0
- package/dist/esm/plugins/tree/index.js +3 -0
- package/dist/esm/plugins/tree/index.js.map +7 -0
- package/dist/esm/plugins/virtualization/TreeVirtualizationPlugin.js +6 -0
- package/dist/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
- package/dist/esm/plugins/virtualization/index.js +3 -0
- package/dist/esm/plugins/virtualization/index.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +56 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/related-components/TreeViewSearchBar.js +21 -0
- package/dist/esm/related-components/TreeViewSearchBar.js.map +7 -0
- package/dist/esm/sharedTypes.js +2 -0
- package/dist/esm/sharedTypes.js.map +7 -0
- package/{esm → dist/esm}/utils/array-helpers.js +6 -6
- package/dist/esm/utils/array-helpers.js.map +7 -0
- package/dist/esm/utils/group-expands-helpers.js +109 -0
- package/dist/esm/utils/group-expands-helpers.js.map +7 -0
- package/{esm → dist/esm}/utils/keyboard-helpers.js +43 -71
- package/dist/esm/utils/keyboard-helpers.js.map +7 -0
- package/dist/esm/utils/object-helpers.js +47 -0
- package/dist/esm/utils/object-helpers.js.map +7 -0
- package/dist/esm/utils/refs-helpers.js +23 -0
- package/dist/esm/utils/refs-helpers.js.map +7 -0
- package/dist/esm/utils/selectable-helper.js +75 -0
- package/dist/esm/utils/selectable-helper.js.map +7 -0
- package/dist/esm/utils/string-helpers.js +6 -0
- package/dist/esm/utils/string-helpers.js.map +7 -0
- package/dist/esm/utils/tree-helpers.js +155 -0
- package/dist/esm/utils/tree-helpers.js.map +7 -0
- package/{esm → dist/esm}/utils/useInstanceRefActions.js +21 -35
- package/dist/esm/utils/useInstanceRefActions.js.map +7 -0
- package/dist/esm/utils/useTree.js +96 -0
- package/dist/esm/utils/useTree.js.map +7 -0
- package/package.json +133 -123
- package/cjs/TreeView.js +0 -30
- package/cjs/TreeViewContext.js +0 -98
- package/cjs/config/cssClassesConstants.js +0 -13
- package/cjs/config/useTreeview.js +0 -127
- package/cjs/hoc/DnDTreeContext.js +0 -18
- package/cjs/hoc/SortableItemContext.js +0 -21
- package/cjs/hoc/WithConditionalDnDContext.js +0 -138
- package/cjs/hoc/WithDnDSortableItemContext.js +0 -70
- package/cjs/index.js +0 -26
- package/cjs/parts/CheckboxSelectable.js +0 -86
- package/cjs/parts/ChildrenCountDisplayer.js +0 -30
- package/cjs/parts/DnDHandle.js +0 -46
- package/cjs/parts/DropIndicator.js +0 -75
- package/cjs/parts/ExpandCaret.js +0 -94
- package/cjs/parts/Icon.js +0 -37
- package/cjs/parts/NestingSpace.js +0 -47
- package/cjs/parts/RadioSelectable.js +0 -59
- package/cjs/parts/TreeItem.js +0 -185
- package/cjs/parts/TreeItemText.js +0 -108
- package/cjs/parts/TreeList.js +0 -139
- package/cjs/plugins/dnd/TreeDndPlugin.js +0 -7
- package/cjs/plugins/dnd/index.js +0 -9
- package/cjs/plugins/index.js +0 -21
- package/cjs/plugins/roving/TreeRovingPlugin.js +0 -7
- package/cjs/plugins/roving/index.js +0 -9
- package/cjs/plugins/searchable/SearchableTreePlugin.js +0 -7
- package/cjs/plugins/searchable/index.js +0 -9
- package/cjs/plugins/selectable/SelectablePluginTree.js +0 -7
- package/cjs/plugins/selectable/index.js +0 -9
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js +0 -7
- package/cjs/plugins/toolbar/index.js +0 -9
- package/cjs/plugins/tree/TreeDataPlugin.js +0 -7
- package/cjs/plugins/tree/index.js +0 -9
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +0 -7
- package/cjs/plugins/virtualization/index.js +0 -9
- package/cjs/react-desc-prop-types.js +0 -56
- package/cjs/related-components/TreeViewSearchBar.js +0 -48
- package/cjs/sharedTypes.js +0 -2
- package/cjs/utils/array-helpers.js +0 -24
- package/cjs/utils/group-expands-helpers.js +0 -111
- package/cjs/utils/keyboard-helpers.js +0 -175
- package/cjs/utils/object-helpers.js +0 -69
- package/cjs/utils/refs-helpers.js +0 -31
- package/cjs/utils/selectable-helper.js +0 -80
- package/cjs/utils/string-helpers.js +0 -7
- package/cjs/utils/tree-helpers.js +0 -220
- package/cjs/utils/useInstanceRefActions.js +0 -87
- package/cjs/utils/useTree.js +0 -108
- package/esm/TreeView.js +0 -21
- package/esm/config/cssClassesConstants.js +0 -6
- package/esm/config/useTreeview.js +0 -119
- package/esm/hoc/DnDTreeContext.js +0 -14
- package/esm/hoc/SortableItemContext.js +0 -17
- package/esm/hoc/WithConditionalDnDContext.js +0 -128
- package/esm/hoc/WithDnDSortableItemContext.js +0 -61
- package/esm/index.js +0 -9
- package/esm/parts/CheckboxSelectable.js +0 -78
- package/esm/parts/ChildrenCountDisplayer.js +0 -22
- package/esm/parts/DnDHandle.js +0 -38
- package/esm/parts/DropIndicator.js +0 -68
- package/esm/parts/ExpandCaret.js +0 -85
- package/esm/parts/Icon.js +0 -29
- package/esm/parts/NestingSpace.js +0 -39
- package/esm/parts/RadioSelectable.js +0 -53
- package/esm/parts/TreeItem.js +0 -173
- package/esm/parts/TreeItemText.js +0 -99
- package/esm/parts/TreeList.js +0 -127
- package/esm/plugins/dnd/TreeDndPlugin.js +0 -3
- package/esm/plugins/dnd/index.js +0 -1
- package/esm/plugins/index.js +0 -7
- package/esm/plugins/roving/TreeRovingPlugin.js +0 -3
- package/esm/plugins/roving/index.js +0 -1
- package/esm/plugins/searchable/SearchableTreePlugin.js +0 -3
- package/esm/plugins/searchable/index.js +0 -1
- package/esm/plugins/selectable/SelectablePluginTree.js +0 -3
- package/esm/plugins/selectable/index.js +0 -1
- package/esm/plugins/toolbar/TreeToolbarPlugin.js +0 -3
- package/esm/plugins/toolbar/index.js +0 -1
- package/esm/plugins/tree/TreeDataPlugin.js +0 -3
- package/esm/plugins/tree/index.js +0 -1
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +0 -3
- package/esm/plugins/virtualization/index.js +0 -1
- package/esm/react-desc-prop-types.js +0 -52
- package/esm/related-components/TreeViewSearchBar.js +0 -40
- package/esm/sharedTypes.js +0 -1
- package/esm/utils/group-expands-helpers.js +0 -99
- package/esm/utils/object-helpers.js +0 -64
- package/esm/utils/refs-helpers.js +0 -27
- package/esm/utils/selectable-helper.js +0 -70
- package/esm/utils/string-helpers.js +0 -3
- package/esm/utils/tree-helpers.js +0 -205
- package/esm/utils/useTree.js +0 -99
- package/types/TreeView.d.ts +0 -13
- package/types/TreeViewContext.d.ts +0 -17
- package/types/config/cssClassesConstants.d.ts +0 -4
- package/types/config/useTreeview.d.ts +0 -7
- package/types/hoc/DnDTreeContext.d.ts +0 -14
- package/types/hoc/SortableItemContext.d.ts +0 -19
- package/types/hoc/WithConditionalDnDContext.d.ts +0 -4
- package/types/hoc/WithDnDSortableItemContext.d.ts +0 -4
- package/types/index.d.ts +0 -3
- package/types/parts/CheckboxSelectable.d.ts +0 -8
- package/types/parts/ChildrenCountDisplayer.d.ts +0 -7
- package/types/parts/DnDHandle.d.ts +0 -6
- package/types/parts/DropIndicator.d.ts +0 -10
- package/types/parts/ExpandCaret.d.ts +0 -7
- package/types/parts/Icon.d.ts +0 -7
- package/types/parts/NestingSpace.d.ts +0 -8
- package/types/parts/RadioSelectable.d.ts +0 -8
- package/types/parts/TreeItem.d.ts +0 -17
- package/types/parts/TreeItemText.d.ts +0 -7
- package/types/parts/TreeList.d.ts +0 -20
- package/types/plugins/dnd/TreeDndPlugin.d.ts +0 -1
- package/types/plugins/dnd/index.d.ts +0 -1
- package/types/plugins/index.d.ts +0 -7
- package/types/plugins/roving/TreeRovingPlugin.d.ts +0 -1
- package/types/plugins/roving/index.d.ts +0 -1
- package/types/plugins/searchable/SearchableTreePlugin.d.ts +0 -1
- package/types/plugins/searchable/index.d.ts +0 -1
- package/types/plugins/selectable/SelectablePluginTree.d.ts +0 -1
- package/types/plugins/selectable/index.d.ts +0 -1
- package/types/plugins/toolbar/TreeToolbarPlugin.d.ts +0 -1
- package/types/plugins/toolbar/index.d.ts +0 -1
- package/types/plugins/tree/TreeDataPlugin.d.ts +0 -1
- package/types/plugins/tree/index.d.ts +0 -1
- package/types/plugins/virtualization/TreeVirtualizationPlugin.d.ts +0 -1
- package/types/plugins/virtualization/index.d.ts +0 -1
- package/types/react-desc-prop-types.d.ts +0 -210
- package/types/related-components/TreeViewSearchBar.d.ts +0 -16
- package/types/sharedTypes.d.ts +0 -47
- package/types/utils/array-helpers.d.ts +0 -2
- package/types/utils/group-expands-helpers.d.ts +0 -14
- package/types/utils/keyboard-helpers.d.ts +0 -6
- package/types/utils/object-helpers.d.ts +0 -6
- package/types/utils/refs-helpers.d.ts +0 -4
- package/types/utils/selectable-helper.d.ts +0 -7
- package/types/utils/string-helpers.d.ts +0 -1
- package/types/utils/tree-helpers.d.ts +0 -28
- package/types/utils/useInstanceRefActions.d.ts +0 -3
- package/types/utils/useTree.d.ts +0 -14
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
const updateExpandedState = (treeRoot, onExpandChange) => {
|
|
4
|
+
const shouldContinueWalking = true;
|
|
5
|
+
const newExpandedHashMap = { __ds_tree_root: true };
|
|
6
|
+
treeRoot.walk((node) => {
|
|
7
|
+
if (!node.isRoot() && node.model.isGroup && node.model.isExpanded) {
|
|
8
|
+
newExpandedHashMap[node.model.id] = true;
|
|
9
|
+
}
|
|
10
|
+
return shouldContinueWalking;
|
|
11
|
+
});
|
|
12
|
+
if (onExpandChange)
|
|
13
|
+
onExpandChange(newExpandedHashMap, null);
|
|
14
|
+
};
|
|
15
|
+
const toggleItemExpand = (itemToToggle, triggerTreeRerender, updateUserExpandedState, scrollTo = () => {
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
node: {
|
|
19
|
+
model: { isExpanded }
|
|
20
|
+
},
|
|
21
|
+
virtualIndex
|
|
22
|
+
} = itemToToggle;
|
|
23
|
+
if (itemToToggle.node.model.isGroup) {
|
|
24
|
+
itemToToggle.node.model.isExpanded = !isExpanded;
|
|
25
|
+
triggerTreeRerender();
|
|
26
|
+
updateUserExpandedState();
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
if (typeof virtualIndex === "number")
|
|
29
|
+
scrollTo(virtualIndex, { align: "start" });
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const expandItemModel = (modelToExpand) => {
|
|
34
|
+
if (modelToExpand.isGroup)
|
|
35
|
+
modelToExpand.isExpanded = true;
|
|
36
|
+
};
|
|
37
|
+
const collapseItemModel = (modelToCollapse) => {
|
|
38
|
+
if (modelToCollapse.isGroup)
|
|
39
|
+
modelToCollapse.isExpanded = false;
|
|
40
|
+
};
|
|
41
|
+
const expandAll = (treeRoot, triggerTreeRerender) => {
|
|
42
|
+
const shouldContinueWalking = true;
|
|
43
|
+
treeRoot.walk((node) => {
|
|
44
|
+
if (!node.isRoot())
|
|
45
|
+
expandItemModel(node.model);
|
|
46
|
+
return shouldContinueWalking;
|
|
47
|
+
});
|
|
48
|
+
triggerTreeRerender();
|
|
49
|
+
};
|
|
50
|
+
const collapseAll = (treeRoot, triggerTreeRerender) => {
|
|
51
|
+
const shouldContinueWalking = true;
|
|
52
|
+
treeRoot.walk((node) => {
|
|
53
|
+
if (!node.isRoot())
|
|
54
|
+
collapseItemModel(node.model);
|
|
55
|
+
return shouldContinueWalking;
|
|
56
|
+
});
|
|
57
|
+
triggerTreeRerender();
|
|
58
|
+
};
|
|
59
|
+
const getToggleExpandShouldExpand = (treeRoot) => {
|
|
60
|
+
let shouldExpand = false;
|
|
61
|
+
const shouldContinueWalking = true;
|
|
62
|
+
treeRoot.walk((node) => {
|
|
63
|
+
if (!node.isRoot()) {
|
|
64
|
+
if (!node.model.isExpanded && node.model.isGroup) {
|
|
65
|
+
shouldExpand = true;
|
|
66
|
+
return shouldContinueWalking;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return shouldContinueWalking;
|
|
70
|
+
});
|
|
71
|
+
return shouldExpand;
|
|
72
|
+
};
|
|
73
|
+
const toggleExpandAllHelper = (isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
|
|
74
|
+
if (isExpand === true)
|
|
75
|
+
expandAll(treeRoot, triggerTreeRerender);
|
|
76
|
+
else if (isExpand === false)
|
|
77
|
+
collapseAll(treeRoot, triggerTreeRerender);
|
|
78
|
+
else {
|
|
79
|
+
const shouldExpand = getToggleExpandShouldExpand(treeRoot);
|
|
80
|
+
if (shouldExpand === true)
|
|
81
|
+
expandAll(treeRoot, triggerTreeRerender);
|
|
82
|
+
else
|
|
83
|
+
collapseAll(treeRoot, triggerTreeRerender);
|
|
84
|
+
}
|
|
85
|
+
setLatestToggledItem(null);
|
|
86
|
+
updateUserExpandedState();
|
|
87
|
+
};
|
|
88
|
+
const useNotifyExpandedChange = (propsWithDefaults, {
|
|
89
|
+
latestToggledItem,
|
|
90
|
+
expandedGroups
|
|
91
|
+
}) => {
|
|
92
|
+
const notifyExpandedChange = useCallback((expandedGroupHashmap) => propsWithDefaults?.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!propsWithDefaults.expanded)
|
|
95
|
+
notifyExpandedChange(expandedGroups);
|
|
96
|
+
}, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
collapseAll,
|
|
100
|
+
collapseItemModel,
|
|
101
|
+
expandAll,
|
|
102
|
+
expandItemModel,
|
|
103
|
+
getToggleExpandShouldExpand,
|
|
104
|
+
toggleExpandAllHelper,
|
|
105
|
+
toggleItemExpand,
|
|
106
|
+
updateExpandedState,
|
|
107
|
+
useNotifyExpandedChange
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=group-expands-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/group-expands-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport { useCallback, useEffect } from 'react';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\n\nexport const updateExpandedState = (\n treeRoot: DSTreeviewT.Item['node'],\n onExpandChange: DSTreeviewT.Props['onExpandChange'] | null | undefined,\n) => {\n const shouldContinueWalking = true;\n const newExpandedHashMap: DSTreeviewT.ExpandedItems = { __ds_tree_root: true };\n treeRoot.walk((node) => {\n if (!node.isRoot() && node.model.isGroup && node.model.isExpanded) {\n newExpandedHashMap[node.model.id] = true;\n }\n return shouldContinueWalking;\n });\n if (onExpandChange) onExpandChange(newExpandedHashMap, null);\n};\n\nexport const toggleItemExpand = (\n itemToToggle: DSTreeviewT.Item,\n triggerTreeRerender: () => void,\n updateUserExpandedState: DSTreeviewInternalsT.CTX['updateUserExpandedState'],\n scrollTo: DSTreeviewT.ScrollToFunc = () => {},\n) => {\n const {\n node: {\n model: { isExpanded },\n },\n virtualIndex,\n } = itemToToggle;\n if (itemToToggle.node.model.isGroup) {\n itemToToggle.node.model.isExpanded = !isExpanded;\n triggerTreeRerender();\n updateUserExpandedState();\n setTimeout(() => {\n if (typeof virtualIndex === 'number') scrollTo(virtualIndex, { align: 'start' });\n });\n }\n};\n\nexport const expandItemModel = (modelToExpand: DSTreeviewT.Item['model']) => {\n if (modelToExpand.isGroup) modelToExpand.isExpanded = true;\n};\n\nexport const collapseItemModel = (modelToCollapse: DSTreeviewT.Item['model']) => {\n if (modelToCollapse.isGroup) modelToCollapse.isExpanded = false;\n};\n\nexport const expandAll = (treeRoot: DSTreeviewT.Item['node'], triggerTreeRerender: () => void) => {\n const shouldContinueWalking = true;\n treeRoot.walk((node) => {\n if (!node.isRoot()) expandItemModel(node.model);\n return shouldContinueWalking;\n });\n triggerTreeRerender();\n};\n\nexport const collapseAll = (treeRoot: DSTreeviewT.Item['node'], triggerTreeRerender: () => void) => {\n const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking\n treeRoot.walk((node) => {\n if (!node.isRoot()) collapseItemModel(node.model);\n return shouldContinueWalking;\n });\n triggerTreeRerender();\n};\n\nexport const getToggleExpandShouldExpand = (treeRoot: DSTreeviewT.Item['node']) => {\n let shouldExpand = false;\n const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking\n treeRoot.walk((node) => {\n if (!node.isRoot()) {\n if (!node.model.isExpanded && node.model.isGroup) {\n shouldExpand = true;\n // eslint-disable-next-line no-useless-return\n return shouldContinueWalking;\n }\n }\n return shouldContinueWalking;\n });\n return shouldExpand;\n};\n\nexport const toggleExpandAllHelper = (\n isExpand: boolean | 'toggle',\n treeRoot: DSTreeviewT.Item['node'],\n triggerTreeRerender: () => void,\n setLatestToggledItem: DSTreeviewInternalsT.CTX['setLatestToggledItem'],\n updateUserExpandedState: DSTreeviewInternalsT.CTX['updateUserExpandedState'],\n) => {\n if (isExpand === true) expandAll(treeRoot, triggerTreeRerender);\n else if (isExpand === false) collapseAll(treeRoot, triggerTreeRerender);\n else {\n const shouldExpand = getToggleExpandShouldExpand(treeRoot);\n if (shouldExpand === true) expandAll(treeRoot, triggerTreeRerender);\n else collapseAll(treeRoot, triggerTreeRerender);\n }\n setLatestToggledItem(null);\n updateUserExpandedState();\n};\n\nexport const useNotifyExpandedChange = (\n propsWithDefaults: DSTreeviewT.Props,\n {\n latestToggledItem,\n expandedGroups,\n }: {\n latestToggledItem?: DSTreeviewInternalsT.CTX['latestToggledItem'];\n expandedGroups?: DSTreeviewInternalsT.CTX['expandedGroups'];\n },\n) => {\n const notifyExpandedChange = useCallback(\n (expandedGroupHashmap?: DSTreeviewInternalsT.CTX['expandedGroups']) =>\n propsWithDefaults?.onExpandChange(expandedGroupHashmap || {}, latestToggledItem),\n [propsWithDefaults, latestToggledItem],\n );\n\n useEffect(() => {\n if (!propsWithDefaults.expanded) notifyExpandedChange(expandedGroups);\n }, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAIO,MAAM,sBAAsB,CACjC,UACA,mBACG;AACH,QAAM,wBAAwB;AAC9B,QAAM,qBAAgD,EAAE,gBAAgB;AACxE,WAAS,KAAK,CAAC,SAAS;AACtB,QAAI,CAAC,KAAK,YAAY,KAAK,MAAM,WAAW,KAAK,MAAM,YAAY;AACjE,yBAAmB,KAAK,MAAM,MAAM;AAAA;AAEtC,WAAO;AAAA;AAET,MAAI;AAAgB,mBAAe,oBAAoB;AAAA;AAGlD,MAAM,mBAAmB,CAC9B,cACA,qBACA,yBACA,WAAqC,MAAM;AAAA,MACxC;AACH,QAAM;AAAA,IACJ,MAAM;AAAA,MACJ,OAAO,EAAE;AAAA;AAAA,IAEX;AAAA,MACE;AACJ,MAAI,aAAa,KAAK,MAAM,SAAS;AACnC,iBAAa,KAAK,MAAM,aAAa,CAAC;AACtC;AACA;AACA,eAAW,MAAM;AACf,UAAI,OAAO,iBAAiB;AAAU,iBAAS,cAAc,EAAE,OAAO;AAAA;AAAA;AAAA;AAKrE,MAAM,kBAAkB,CAAC,kBAA6C;AAC3E,MAAI,cAAc;AAAS,kBAAc,aAAa;AAAA;AAGjD,MAAM,oBAAoB,CAAC,oBAA+C;AAC/E,MAAI,gBAAgB;AAAS,oBAAgB,aAAa;AAAA;AAGrD,MAAM,YAAY,CAAC,UAAoC,wBAAoC;AAChG,QAAM,wBAAwB;AAC9B,WAAS,KAAK,CAAC,SAAS;AACtB,QAAI,CAAC,KAAK;AAAU,sBAAgB,KAAK;AACzC,WAAO;AAAA;AAET;AAAA;AAGK,MAAM,cAAc,CAAC,UAAoC,wBAAoC;AAClG,QAAM,wBAAwB;AAC9B,WAAS,KAAK,CAAC,SAAS;AACtB,QAAI,CAAC,KAAK;AAAU,wBAAkB,KAAK;AAC3C,WAAO;AAAA;AAET;AAAA;AAGK,MAAM,8BAA8B,CAAC,aAAuC;AACjF,MAAI,eAAe;AACnB,QAAM,wBAAwB;AAC9B,WAAS,KAAK,CAAC,SAAS;AACtB,QAAI,CAAC,KAAK,UAAU;AAClB,UAAI,CAAC,KAAK,MAAM,cAAc,KAAK,MAAM,SAAS;AAChD,uBAAe;AAEf,eAAO;AAAA;AAAA;AAGX,WAAO;AAAA;AAET,SAAO;AAAA;AAGF,MAAM,wBAAwB,CACnC,UACA,UACA,qBACA,sBACA,4BACG;AACH,MAAI,aAAa;AAAM,cAAU,UAAU;AAAA,WAClC,aAAa;AAAO,gBAAY,UAAU;AAAA,OAC9C;AACH,UAAM,eAAe,4BAA4B;AACjD,QAAI,iBAAiB;AAAM,gBAAU,UAAU;AAAA;AAC1C,kBAAY,UAAU;AAAA;AAE7B,uBAAqB;AACrB;AAAA;AAGK,MAAM,0BAA0B,CACrC,mBACA;AAAA,EACE;AAAA,EACA;AAAA,MAKC;AACH,QAAM,uBAAuB,YAC3B,CAAC,yBACC,mBAAmB,eAAe,wBAAwB,IAAI,oBAChE,CAAC,mBAAmB;AAGtB,YAAU,MAAM;AACd,QAAI,CAAC,kBAAkB;AAAU,2BAAqB;AAAA,KACrD,CAAC,gBAAgB,sBAAsB,kBAAkB;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,91 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/* eslint-disable max-params */
|
|
7
|
-
// 9 tab
|
|
8
|
-
// 13 enter
|
|
9
|
-
// 32 space
|
|
10
|
-
// 37 left arrow
|
|
11
|
-
// 38 up arrow
|
|
12
|
-
// 39 right arrow
|
|
13
|
-
// 40 down arrow
|
|
14
|
-
// 35 end
|
|
15
|
-
// 36 home
|
|
16
|
-
// 56 number 8
|
|
17
|
-
// 106 (NumPad) *
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useContext, useEffect } from "react";
|
|
3
|
+
import TreeViewContext from "../TreeViewContext";
|
|
4
|
+
import { focusItem } from "./tree-helpers";
|
|
5
|
+
import { toggleExpandAllHelper, toggleItemExpand } from "./group-expands-helpers";
|
|
18
6
|
const useOnItemKeyDown = (item, draggableProps) => {
|
|
19
7
|
const ctx = useContext(TreeViewContext);
|
|
20
8
|
const {
|
|
21
|
-
props: {
|
|
22
|
-
onItemFocus
|
|
23
|
-
},
|
|
9
|
+
props: { onItemFocus },
|
|
24
10
|
triggerTreeRerender,
|
|
25
11
|
visibleItems,
|
|
26
12
|
setFocusedItem,
|
|
27
13
|
setSelectedItem,
|
|
28
14
|
setLatestToggledItem,
|
|
29
15
|
updateUserExpandedState,
|
|
30
|
-
virtualListHelpers: {
|
|
31
|
-
scrollToIndex
|
|
32
|
-
}
|
|
16
|
+
virtualListHelpers: { scrollToIndex }
|
|
33
17
|
} = ctx;
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
isExpanded
|
|
37
|
-
} = item;
|
|
38
|
-
const onItemFocusCurry = useCallback(newFocusItem => onItemFocus({
|
|
18
|
+
const { isGroup, isExpanded } = item;
|
|
19
|
+
const onItemFocusCurry = useCallback((newFocusItem) => onItemFocus({
|
|
39
20
|
itemIndex: newFocusItem.virtualIndex,
|
|
40
|
-
scrollToItem:
|
|
41
|
-
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
42
|
-
align: 'start'
|
|
43
|
-
};
|
|
44
|
-
return scrollToIndex(newFocusItem.virtualIndex, opts);
|
|
45
|
-
},
|
|
21
|
+
scrollToItem: (opts = { align: "start" }) => scrollToIndex(newFocusItem.virtualIndex, opts),
|
|
46
22
|
item: newFocusItem
|
|
47
23
|
}), [onItemFocus, scrollToIndex]);
|
|
48
|
-
const onItemKeyDown = useCallback(e => {
|
|
49
|
-
const {
|
|
50
|
-
keyCode
|
|
51
|
-
} = e;
|
|
52
|
-
|
|
24
|
+
const onItemKeyDown = useCallback((e) => {
|
|
25
|
+
const { keyCode } = e;
|
|
53
26
|
if (!(draggableProps && draggableProps.active)) {
|
|
54
|
-
if (keyCode !== 9)
|
|
55
|
-
|
|
56
|
-
if ((keyCode === 13 || keyCode === 32) && e.target.tagName ===
|
|
27
|
+
if (keyCode !== 9)
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
if ((keyCode === 13 || keyCode === 32) && e.target.tagName === "LI") {
|
|
57
30
|
setSelectedItem(item);
|
|
58
31
|
}
|
|
59
|
-
|
|
60
32
|
if (keyCode === 37) {
|
|
61
33
|
if (isGroup && isExpanded) {
|
|
62
34
|
toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
|
|
63
35
|
setLatestToggledItem(item);
|
|
64
36
|
}
|
|
65
37
|
}
|
|
66
|
-
|
|
67
38
|
if (keyCode === 39) {
|
|
68
39
|
if (isGroup && !isExpanded) {
|
|
69
40
|
toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
|
|
70
41
|
setLatestToggledItem(item);
|
|
71
42
|
}
|
|
72
43
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
virtualIndex
|
|
76
|
-
} = item;
|
|
77
|
-
|
|
78
|
-
if (typeof virtualIndex === 'number') {
|
|
44
|
+
const { virtualIndex } = item;
|
|
45
|
+
if (typeof virtualIndex === "number") {
|
|
79
46
|
const lastItemIndex = visibleItems.length - 1;
|
|
80
|
-
|
|
81
47
|
if (keyCode === 38) {
|
|
82
48
|
const isLoopedFocus = virtualIndex === 0;
|
|
83
49
|
const newFocusIndex = isLoopedFocus ? lastItemIndex : virtualIndex - 1;
|
|
84
50
|
const newFocusItem = visibleItems[newFocusIndex];
|
|
85
51
|
scrollToIndex(newFocusIndex);
|
|
86
|
-
|
|
87
52
|
if (isLoopedFocus) {
|
|
88
|
-
// when looping the list from start to end we need to wait a bit before focusing
|
|
89
53
|
setTimeout(() => {
|
|
90
54
|
setFocusedItem(newFocusItem);
|
|
91
55
|
focusItem(newFocusItem);
|
|
@@ -97,15 +61,12 @@ const useOnItemKeyDown = (item, draggableProps) => {
|
|
|
97
61
|
focusItem(newFocusItem);
|
|
98
62
|
}
|
|
99
63
|
}
|
|
100
|
-
|
|
101
64
|
if (keyCode === 40) {
|
|
102
65
|
const isLoopedFocus = virtualIndex === lastItemIndex;
|
|
103
66
|
const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;
|
|
104
67
|
const newFocusItem = visibleItems[newFocusIndex];
|
|
105
68
|
scrollToIndex(newFocusIndex);
|
|
106
|
-
|
|
107
69
|
if (isLoopedFocus) {
|
|
108
|
-
// when looping the list from start to end we need to wait a bit before focusing
|
|
109
70
|
setTimeout(() => {
|
|
110
71
|
setFocusedItem(newFocusItem);
|
|
111
72
|
onItemFocusCurry(newFocusItem);
|
|
@@ -117,7 +78,6 @@ const useOnItemKeyDown = (item, draggableProps) => {
|
|
|
117
78
|
focusItem(newFocusItem);
|
|
118
79
|
}
|
|
119
80
|
}
|
|
120
|
-
|
|
121
81
|
if (keyCode === 35) {
|
|
122
82
|
if (virtualIndex !== lastItemIndex) {
|
|
123
83
|
const newFocusItem = visibleItems[lastItemIndex];
|
|
@@ -129,7 +89,6 @@ const useOnItemKeyDown = (item, draggableProps) => {
|
|
|
129
89
|
}, 300);
|
|
130
90
|
}
|
|
131
91
|
}
|
|
132
|
-
|
|
133
92
|
if (keyCode === 36) {
|
|
134
93
|
if (virtualIndex !== 0) {
|
|
135
94
|
const newFocusItem = visibleItems[0];
|
|
@@ -143,27 +102,40 @@ const useOnItemKeyDown = (item, draggableProps) => {
|
|
|
143
102
|
}
|
|
144
103
|
}
|
|
145
104
|
}
|
|
146
|
-
}, [
|
|
105
|
+
}, [
|
|
106
|
+
draggableProps,
|
|
107
|
+
setSelectedItem,
|
|
108
|
+
item,
|
|
109
|
+
isGroup,
|
|
110
|
+
isExpanded,
|
|
111
|
+
triggerTreeRerender,
|
|
112
|
+
updateUserExpandedState,
|
|
113
|
+
scrollToIndex,
|
|
114
|
+
setLatestToggledItem,
|
|
115
|
+
visibleItems,
|
|
116
|
+
setFocusedItem,
|
|
117
|
+
onItemFocusCurry
|
|
118
|
+
]);
|
|
147
119
|
return onItemKeyDown;
|
|
148
120
|
};
|
|
149
|
-
const useGlobalKeyboardListener = func => {
|
|
121
|
+
const useGlobalKeyboardListener = (func) => {
|
|
150
122
|
useEffect(() => {
|
|
151
|
-
document.addEventListener(
|
|
152
|
-
return () => document.removeEventListener(
|
|
123
|
+
document.addEventListener("keydown", func);
|
|
124
|
+
return () => document.removeEventListener("keydown", func);
|
|
153
125
|
}, [func]);
|
|
154
126
|
};
|
|
155
127
|
const useGlobalToggleAllExpandShortcut = (treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
|
|
156
|
-
const memoizedToggleAllKeyboardShortcut = useCallback(e => {
|
|
157
|
-
const {
|
|
158
|
-
shiftKey,
|
|
159
|
-
keyCode
|
|
160
|
-
} = e;
|
|
161
|
-
|
|
128
|
+
const memoizedToggleAllKeyboardShortcut = useCallback((e) => {
|
|
129
|
+
const { shiftKey, keyCode } = e;
|
|
162
130
|
if (shiftKey && keyCode === 56) {
|
|
163
|
-
toggleExpandAllHelper(
|
|
131
|
+
toggleExpandAllHelper("toggle", treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
|
|
164
132
|
}
|
|
165
133
|
}, [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState]);
|
|
166
134
|
return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);
|
|
167
135
|
};
|
|
168
|
-
|
|
169
|
-
|
|
136
|
+
export {
|
|
137
|
+
useGlobalKeyboardListener,
|
|
138
|
+
useGlobalToggleAllExpandShortcut,
|
|
139
|
+
useOnItemKeyDown
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=keyboard-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/keyboard-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\n/* eslint-disable max-lines */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext, useEffect } from 'react';\nimport TreeViewContext from '../TreeViewContext';\nimport { focusItem } from './tree-helpers';\nimport { toggleExpandAllHelper, toggleItemExpand } from './group-expands-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\nimport { SortableItemContextType } from '../hoc/SortableItemContext';\n\n// 9 tab\n// 13 enter\n// 32 space\n// 37 left arrow\n// 38 up arrow\n// 39 right arrow\n// 40 down arrow\n// 35 end\n// 36 home\n\n// 56 number 8\n// 106 (NumPad) *\n\nexport const useOnItemKeyDown = (item: DSTreeviewT.Item, draggableProps: SortableItemContextType['draggableProps']) => {\n const ctx = useContext(TreeViewContext);\n const {\n props: { onItemFocus },\n triggerTreeRerender,\n visibleItems,\n setFocusedItem,\n setSelectedItem,\n setLatestToggledItem,\n updateUserExpandedState,\n virtualListHelpers: { scrollToIndex },\n } = ctx;\n const { isGroup, isExpanded } = item;\n const onItemFocusCurry = useCallback(\n (newFocusItem: DSTreeviewT.Item) =>\n onItemFocus({\n itemIndex: newFocusItem.virtualIndex as number,\n scrollToItem: (opts = { align: 'start' }) => scrollToIndex(newFocusItem.virtualIndex as number, opts),\n item: newFocusItem,\n }),\n [onItemFocus, scrollToIndex],\n );\n\n const onItemKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLLIElement>) => {\n const { keyCode } = e;\n if (!(draggableProps && draggableProps.active)) {\n if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab\n if ((keyCode === 13 || keyCode === 32) && (e.target as HTMLElement).tagName === 'LI') {\n setSelectedItem(item);\n }\n\n if (keyCode === 37) {\n if (isGroup && isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n if (keyCode === 39) {\n if (isGroup && !isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n\n const { virtualIndex } = item;\n if (typeof virtualIndex === 'number') {\n const lastItemIndex = visibleItems.length - 1;\n if (keyCode === 38) {\n const isLoopedFocus = virtualIndex === 0;\n const newFocusIndex = isLoopedFocus ? lastItemIndex : virtualIndex - 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n focusItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 40) {\n const isLoopedFocus = virtualIndex === lastItemIndex;\n const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 35) {\n if (virtualIndex !== lastItemIndex) {\n const newFocusItem = visibleItems[lastItemIndex];\n scrollToIndex(lastItemIndex);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n if (keyCode === 36) {\n if (virtualIndex !== 0) {\n const newFocusItem = visibleItems[0];\n scrollToIndex(0);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n }\n }\n },\n [\n draggableProps,\n setSelectedItem,\n item,\n isGroup,\n isExpanded,\n triggerTreeRerender,\n updateUserExpandedState,\n scrollToIndex,\n setLatestToggledItem,\n visibleItems,\n setFocusedItem,\n onItemFocusCurry,\n ],\n );\n\n return onItemKeyDown;\n};\n\nexport const useGlobalKeyboardListener = (func: (e: KeyboardEvent) => void) => {\n useEffect(() => {\n document.addEventListener('keydown', func);\n return () => document.removeEventListener('keydown', func);\n }, [func]);\n};\n\nexport const useGlobalToggleAllExpandShortcut = (\n treeRoot: DSTreeviewT.Item['node'],\n triggerTreeRerender: () => void,\n setLatestToggledItem: DSTreeviewInternalsT.CTX['setLatestToggledItem'],\n updateUserExpandedState: DSTreeviewInternalsT.CTX['updateUserExpandedState'],\n) => {\n const memoizedToggleAllKeyboardShortcut = useCallback(\n (e: KeyboardEvent) => {\n const { shiftKey, keyCode } = e;\n if (shiftKey && keyCode === 56) {\n toggleExpandAllHelper('toggle', treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);\n }\n },\n [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState],\n );\n\n return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACIA;AACA;AACA;AACA;AAkBO,MAAM,mBAAmB,CAAC,MAAwB,mBAA8D;AACrH,QAAM,MAAM,WAAW;AACvB,QAAM;AAAA,IACJ,OAAO,EAAE;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB,EAAE;AAAA,MACpB;AACJ,QAAM,EAAE,SAAS,eAAe;AAChC,QAAM,mBAAmB,YACvB,CAAC,iBACC,YAAY;AAAA,IACV,WAAW,aAAa;AAAA,IACxB,cAAc,CAAC,OAAO,EAAE,OAAO,cAAc,cAAc,aAAa,cAAwB;AAAA,IAChG,MAAM;AAAA,MAEV,CAAC,aAAa;AAGhB,QAAM,gBAAgB,YACpB,CAAC,MAA0C;AACzC,UAAM,EAAE,YAAY;AACpB,QAAI,CAAE,mBAAkB,eAAe,SAAS;AAC9C,UAAI,YAAY;AAAG,UAAE;AACrB,UAAK,aAAY,MAAM,YAAY,OAAQ,EAAE,OAAuB,YAAY,MAAM;AACpF,wBAAgB;AAAA;AAGlB,UAAI,YAAY,IAAI;AAClB,YAAI,WAAW,YAAY;AACzB,2BAAiB,MAAM,qBAAqB,yBAAyB;AACrE,+BAAqB;AAAA;AAAA;AAGzB,UAAI,YAAY,IAAI;AAClB,YAAI,WAAW,CAAC,YAAY;AAC1B,2BAAiB,MAAM,qBAAqB,yBAAyB;AACrE,+BAAqB;AAAA;AAAA;AAIzB,YAAM,EAAE,iBAAiB;AACzB,UAAI,OAAO,iBAAiB,UAAU;AACpC,cAAM,gBAAgB,aAAa,SAAS;AAC5C,YAAI,YAAY,IAAI;AAClB,gBAAM,gBAAgB,iBAAiB;AACvC,gBAAM,gBAAgB,gBAAgB,gBAAgB,eAAe;AACrE,gBAAM,eAAe,aAAa;AAClC,wBAAc;AACd,cAAI,eAAe;AAEjB,uBAAW,MAAM;AACf,6BAAe;AACf,wBAAU;AACV,+BAAiB;AAAA,eAChB;AAAA,iBACE;AACL,2BAAe;AACf,6BAAiB;AACjB,sBAAU;AAAA;AAAA;AAGd,YAAI,YAAY,IAAI;AAClB,gBAAM,gBAAgB,iBAAiB;AACvC,gBAAM,gBAAgB,gBAAgB,IAAI,eAAe;AACzD,gBAAM,eAAe,aAAa;AAClC,wBAAc;AACd,cAAI,eAAe;AAEjB,uBAAW,MAAM;AACf,6BAAe;AACf,+BAAiB;AACjB,wBAAU;AAAA,eACT;AAAA,iBACE;AACL,2BAAe;AACf,6BAAiB;AACjB,sBAAU;AAAA;AAAA;AAGd,YAAI,YAAY,IAAI;AAClB,cAAI,iBAAiB,eAAe;AAClC,kBAAM,eAAe,aAAa;AAClC,0BAAc;AACd,uBAAW,MAAM;AACf,6BAAe;AACf,+BAAiB;AACjB,wBAAU;AAAA,eACT;AAAA;AAAA;AAGP,YAAI,YAAY,IAAI;AAClB,cAAI,iBAAiB,GAAG;AACtB,kBAAM,eAAe,aAAa;AAClC,0BAAc;AACd,uBAAW,MAAM;AACf,6BAAe;AACf,+BAAiB;AACjB,wBAAU;AAAA,eACT;AAAA;AAAA;AAAA;AAAA;AAAA,KAMb;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;AAIJ,SAAO;AAAA;AAGF,MAAM,4BAA4B,CAAC,SAAqC;AAC7E,YAAU,MAAM;AACd,aAAS,iBAAiB,WAAW;AACrC,WAAO,MAAM,SAAS,oBAAoB,WAAW;AAAA,KACpD,CAAC;AAAA;AAGC,MAAM,mCAAmC,CAC9C,UACA,qBACA,sBACA,4BACG;AACH,QAAM,oCAAoC,YACxC,CAAC,MAAqB;AACpB,UAAM,EAAE,UAAU,YAAY;AAC9B,QAAI,YAAY,YAAY,IAAI;AAC9B,4BAAsB,UAAU,UAAU,qBAAqB,sBAAsB;AAAA;AAAA,KAGzF,CAAC,sBAAsB,UAAU,qBAAqB;AAGxD,SAAO,0BAA0B;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function isObjectADate(o) {
|
|
3
|
+
return o?.constructor?.name === "Date";
|
|
4
|
+
}
|
|
5
|
+
function isObjectAnArray(o) {
|
|
6
|
+
return Array.isArray(o);
|
|
7
|
+
}
|
|
8
|
+
function isObjectAString(o) {
|
|
9
|
+
return typeof o === "object";
|
|
10
|
+
}
|
|
11
|
+
const unfreeze = (o) => {
|
|
12
|
+
let oo;
|
|
13
|
+
if (o === null) {
|
|
14
|
+
oo = null;
|
|
15
|
+
} else if (o === void 0) {
|
|
16
|
+
oo = void 0;
|
|
17
|
+
} else if (isObjectADate(o)) {
|
|
18
|
+
oo = new Date(o);
|
|
19
|
+
} else if (isObjectAnArray(o)) {
|
|
20
|
+
oo = [];
|
|
21
|
+
o.forEach((v) => {
|
|
22
|
+
oo.push(v);
|
|
23
|
+
});
|
|
24
|
+
} else if (isObjectAString(o)) {
|
|
25
|
+
oo = String(o);
|
|
26
|
+
} else if (isObjectAString(o)) {
|
|
27
|
+
oo = {};
|
|
28
|
+
for (const property in o) {
|
|
29
|
+
oo[property] = o[property];
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
oo = o;
|
|
33
|
+
}
|
|
34
|
+
return oo;
|
|
35
|
+
};
|
|
36
|
+
function filterObject(obj, predicate) {
|
|
37
|
+
return Object.keys(obj).reduce((res, key) => {
|
|
38
|
+
if (predicate(obj[key]))
|
|
39
|
+
res[key] = obj[key];
|
|
40
|
+
return res;
|
|
41
|
+
}, {});
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
filterObject,
|
|
45
|
+
unfreeze
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=object-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/object-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-sequences */\n/* eslint-disable no-return-assign */\n/* eslint-disable no-restricted-syntax */\n/* eslint-disable guard-for-in */\n\nfunction isObjectADate(o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>): o is Date {\n return o?.constructor?.name === 'Date';\n}\nfunction isObjectAnArray(\n o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>,\n): o is unknown[] {\n return Array.isArray(o);\n}\nfunction isObjectAString(\n o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>,\n): o is Record<string, unknown> {\n return typeof o === 'object';\n}\n\nexport const unfreeze = (o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>) => {\n let oo: string | number | unknown[] | Date | null | undefined | Record<string, unknown>;\n if (o === null) {\n oo = null;\n } else if (o === undefined) {\n oo = undefined;\n } else if (isObjectADate(o)) {\n oo = new Date(o);\n } else if (isObjectAnArray(o)) {\n oo = [];\n o.forEach((v) => {\n (oo as unknown[]).push(v);\n });\n } else if (isObjectAString(o)) {\n oo = String(o);\n } else if (isObjectAString(o)) {\n oo = {};\n for (const property in o) {\n oo[property] = o[property];\n }\n } else {\n oo = o;\n }\n return oo;\n};\n\ntype GenericItemT<T = unknown> = { [key: string]: T };\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function filterObject<T = unknown>(obj: GenericItemT<T>, predicate: (val: T) => boolean) {\n return Object.keys(obj).reduce<GenericItemT<T>>((res, key) => {\n if (predicate(obj[key])) res[key] = obj[key];\n return res;\n }, {} as GenericItemT<T>);\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACKA,uBAAuB,GAA+F;AACpH,SAAO,GAAG,aAAa,SAAS;AAAA;AAElC,yBACE,GACgB;AAChB,SAAO,MAAM,QAAQ;AAAA;AAEvB,yBACE,GAC8B;AAC9B,SAAO,OAAO,MAAM;AAAA;AAGf,MAAM,WAAW,CAAC,MAAuF;AAC9G,MAAI;AACJ,MAAI,MAAM,MAAM;AACd,SAAK;AAAA,aACI,MAAM,QAAW;AAC1B,SAAK;AAAA,aACI,cAAc,IAAI;AAC3B,SAAK,IAAI,KAAK;AAAA,aACL,gBAAgB,IAAI;AAC7B,SAAK;AACL,MAAE,QAAQ,CAAC,MAAM;AACf,MAAC,GAAiB,KAAK;AAAA;AAAA,aAEhB,gBAAgB,IAAI;AAC7B,SAAK,OAAO;AAAA,aACH,gBAAgB,IAAI;AAC7B,SAAK;AACL,eAAW,YAAY,GAAG;AACxB,SAAG,YAAY,EAAE;AAAA;AAAA,SAEd;AACL,SAAK;AAAA;AAEP,SAAO;AAAA;AAKF,sBAAmC,KAAsB,WAAgC;AAC9F,SAAO,OAAO,KAAK,KAAK,OAAwB,CAAC,KAAK,QAAQ;AAC5D,QAAI,UAAU,IAAI;AAAO,UAAI,OAAO,IAAI;AACxC,WAAO;AAAA,KACN;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const setMultipleRefs = (...refs) => {
|
|
3
|
+
const filteredRefs = refs.filter(Boolean);
|
|
4
|
+
if (!filteredRefs.length)
|
|
5
|
+
return () => {
|
|
6
|
+
};
|
|
7
|
+
if (filteredRefs.length === 0)
|
|
8
|
+
return () => {
|
|
9
|
+
};
|
|
10
|
+
return (newRef) => {
|
|
11
|
+
filteredRefs.forEach((refToBeUpdated) => {
|
|
12
|
+
if (typeof refToBeUpdated === "function") {
|
|
13
|
+
refToBeUpdated(newRef);
|
|
14
|
+
} else if (refToBeUpdated) {
|
|
15
|
+
refToBeUpdated.current = newRef;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
setMultipleRefs
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=refs-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/refs-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// allow multiple refs to be set to point to the same DOM element\ntype GenericMergeableRef = null | undefined | React.MutableRefObject<unknown> | ((ref: HTMLElement) => void) | false;\nexport const setMultipleRefs = (...refs: GenericMergeableRef[]): ((ref: HTMLElement) => void) => {\n const filteredRefs = refs.filter(Boolean);\n if (!filteredRefs.length) return () => {};\n if (filteredRefs.length === 0) return () => {};\n\n return (newRef) => {\n filteredRefs.forEach((refToBeUpdated) => {\n if (typeof refToBeUpdated === 'function') {\n refToBeUpdated(newRef);\n } else if (refToBeUpdated) {\n refToBeUpdated.current = newRef;\n }\n });\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACEO,MAAM,kBAAkB,IAAI,SAA8D;AAC/F,QAAM,eAAe,KAAK,OAAO;AACjC,MAAI,CAAC,aAAa;AAAQ,WAAO,MAAM;AAAA;AACvC,MAAI,aAAa,WAAW;AAAG,WAAO,MAAM;AAAA;AAE5C,SAAO,CAAC,WAAW;AACjB,iBAAa,QAAQ,CAAC,mBAAmB;AACvC,UAAI,OAAO,mBAAmB,YAAY;AACxC,uBAAe;AAAA,iBACN,gBAAgB;AACzB,uBAAe,UAAU;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { walkParents, walkAllNodeChildren } from "./tree-helpers";
|
|
19
|
+
const getGroupCheckState = (node) => {
|
|
20
|
+
let childAllChecked = true;
|
|
21
|
+
let anyChildChecked = false;
|
|
22
|
+
walkAllNodeChildren(node, (childNode) => {
|
|
23
|
+
const {
|
|
24
|
+
model: { isChecked }
|
|
25
|
+
} = childNode;
|
|
26
|
+
if (isChecked === "mixed" || isChecked === true)
|
|
27
|
+
anyChildChecked = true;
|
|
28
|
+
else
|
|
29
|
+
childAllChecked = false;
|
|
30
|
+
});
|
|
31
|
+
if (childAllChecked)
|
|
32
|
+
return true;
|
|
33
|
+
if (anyChildChecked)
|
|
34
|
+
return "mixed";
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
const selectCheckboxItemModelParentsTillRoot = (modelToCheck, triggerTreeRerender = null) => {
|
|
38
|
+
const newSelections = {};
|
|
39
|
+
const { nodePath } = modelToCheck;
|
|
40
|
+
walkParents(nodePath, (parentNode) => {
|
|
41
|
+
const nextState = getGroupCheckState(parentNode);
|
|
42
|
+
parentNode.model.isChecked = nextState;
|
|
43
|
+
newSelections[parentNode.model.id] = nextState;
|
|
44
|
+
});
|
|
45
|
+
if (triggerTreeRerender)
|
|
46
|
+
triggerTreeRerender();
|
|
47
|
+
return newSelections;
|
|
48
|
+
};
|
|
49
|
+
const toggleCheckboxItem = (itemToSelect, triggerTreeRerender = null) => {
|
|
50
|
+
const {
|
|
51
|
+
node: {
|
|
52
|
+
model: { id, isChecked, children = [] }
|
|
53
|
+
}
|
|
54
|
+
} = itemToSelect;
|
|
55
|
+
const newSelections = {};
|
|
56
|
+
const nextState = isChecked === "mixed" ? true : !isChecked;
|
|
57
|
+
itemToSelect.node.model.isChecked = nextState;
|
|
58
|
+
newSelections[id] = nextState;
|
|
59
|
+
if (children.length > 0 && (nextState === true || nextState === false)) {
|
|
60
|
+
walkAllNodeChildren(itemToSelect.node, (childNode) => {
|
|
61
|
+
childNode.model.isChecked = nextState;
|
|
62
|
+
newSelections[childNode.model.id] = nextState;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(itemToSelect);
|
|
66
|
+
if (triggerTreeRerender)
|
|
67
|
+
triggerTreeRerender();
|
|
68
|
+
return __spreadValues(__spreadValues({}, parentsNewSelections), newSelections);
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
getGroupCheckState,
|
|
72
|
+
selectCheckboxItemModelParentsTillRoot,
|
|
73
|
+
toggleCheckboxItem
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=selectable-helper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/selectable-helper.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport { walkParents, walkAllNodeChildren } from './tree-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\nexport const getGroupCheckState = (node: DSTreeviewT.Item['node']) => {\n let childAllChecked = true;\n let anyChildChecked = false;\n walkAllNodeChildren(node, (childNode) => {\n const {\n model: { isChecked },\n } = childNode;\n if (isChecked === 'mixed' || isChecked === true) anyChildChecked = true;\n else childAllChecked = false;\n });\n\n if (childAllChecked) return true;\n if (anyChildChecked) return 'mixed';\n return false;\n};\n\nexport const selectCheckboxItemModelParentsTillRoot = (\n modelToCheck: DSTreeviewT.Item,\n triggerTreeRerender: (() => void) | null = null,\n) => {\n const newSelections: DSTreeviewT.SelectionItems = {};\n const { nodePath } = modelToCheck;\n walkParents(nodePath, (parentNode) => {\n const nextState = getGroupCheckState(parentNode);\n parentNode.model.isChecked = nextState;\n newSelections[parentNode.model.id] = nextState;\n });\n if (triggerTreeRerender) triggerTreeRerender();\n return newSelections;\n};\n\nexport const toggleCheckboxItem = (itemToSelect: DSTreeviewT.Item, triggerTreeRerender: (() => void) | null = null) => {\n const {\n node: {\n model: { id, isChecked, children = [] },\n },\n } = itemToSelect;\n\n const newSelections: DSTreeviewT.SelectionItems = {};\n // 'mixed' -> true -> false -> true [...->false -> true]\n const nextState = isChecked === 'mixed' ? true : !isChecked;\n itemToSelect.node.model.isChecked = nextState;\n newSelections[id] = nextState;\n\n if (children.length > 0 && (nextState === true || nextState === false)) {\n walkAllNodeChildren(itemToSelect.node, (childNode) => {\n childNode.model.isChecked = nextState;\n newSelections[childNode.model.id] = nextState;\n });\n }\n\n const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(itemToSelect);\n\n if (triggerTreeRerender) triggerTreeRerender();\n return { ...parentsNewSelections, ...newSelections };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACCA;AAGO,MAAM,qBAAqB,CAAC,SAAmC;AACpE,MAAI,kBAAkB;AACtB,MAAI,kBAAkB;AACtB,sBAAoB,MAAM,CAAC,cAAc;AACvC,UAAM;AAAA,MACJ,OAAO,EAAE;AAAA,QACP;AACJ,QAAI,cAAc,WAAW,cAAc;AAAM,wBAAkB;AAAA;AAC9D,wBAAkB;AAAA;AAGzB,MAAI;AAAiB,WAAO;AAC5B,MAAI;AAAiB,WAAO;AAC5B,SAAO;AAAA;AAGF,MAAM,yCAAyC,CACpD,cACA,sBAA2C,SACxC;AACH,QAAM,gBAA4C;AAClD,QAAM,EAAE,aAAa;AACrB,cAAY,UAAU,CAAC,eAAe;AACpC,UAAM,YAAY,mBAAmB;AACrC,eAAW,MAAM,YAAY;AAC7B,kBAAc,WAAW,MAAM,MAAM;AAAA;AAEvC,MAAI;AAAqB;AACzB,SAAO;AAAA;AAGF,MAAM,qBAAqB,CAAC,cAAgC,sBAA2C,SAAS;AACrH,QAAM;AAAA,IACJ,MAAM;AAAA,MACJ,OAAO,EAAE,IAAI,WAAW,WAAW;AAAA;AAAA,MAEnC;AAEJ,QAAM,gBAA4C;AAElD,QAAM,YAAY,cAAc,UAAU,OAAO,CAAC;AAClD,eAAa,KAAK,MAAM,YAAY;AACpC,gBAAc,MAAM;AAEpB,MAAI,SAAS,SAAS,KAAM,eAAc,QAAQ,cAAc,QAAQ;AACtE,wBAAoB,aAAa,MAAM,CAAC,cAAc;AACpD,gBAAU,MAAM,YAAY;AAC5B,oBAAc,UAAU,MAAM,MAAM;AAAA;AAAA;AAIxC,QAAM,uBAAuB,uCAAuC;AAEpE,MAAI;AAAqB;AACzB,SAAO,kCAAK,uBAAyB;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/string-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const standardizeSearchQueryString = (input: string) => input.trim().toLowerCase();\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,+BAA+B,CAAC,UAAkB,MAAM,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|