@elliemae/ds-treeview 2.3.0-alpha.9 → 2.3.0-next.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/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/{dist/types → types}/TreeView.d.ts +0 -0
- package/{dist/types → types}/TreeViewContext.d.ts +0 -0
- package/{dist/types → types}/config/cssClassesConstants.d.ts +0 -0
- package/{dist/types → types}/config/useTreeview.d.ts +0 -0
- package/{dist/types → types}/hoc/DnDTreeContext.d.ts +0 -0
- package/{dist/types → types}/hoc/SortableItemContext.d.ts +0 -0
- package/{dist/types → types}/hoc/WithConditionalDnDContext.d.ts +0 -0
- package/{dist/types → types}/hoc/WithDnDSortableItemContext.d.ts +0 -0
- package/{dist/types → types}/index.d.ts +0 -0
- package/{dist/types → types}/parts/CheckboxSelectable.d.ts +0 -0
- package/{dist/types → types}/parts/ChildrenCountDisplayer.d.ts +0 -0
- package/{dist/types → types}/parts/DnDHandle.d.ts +0 -0
- package/{dist/types → types}/parts/DropIndicator.d.ts +0 -0
- package/{dist/types → types}/parts/ExpandCaret.d.ts +0 -0
- package/{dist/types → types}/parts/Icon.d.ts +0 -0
- package/{dist/types → types}/parts/NestingSpace.d.ts +0 -0
- package/{dist/types → types}/parts/RadioSelectable.d.ts +0 -0
- package/{dist/types → types}/parts/TreeItem.d.ts +0 -0
- package/{dist/types → types}/parts/TreeItemText.d.ts +0 -0
- package/{dist/types → types}/parts/TreeList.d.ts +0 -0
- package/{dist/types → types}/plugins/dnd/TreeDndPlugin.d.ts +0 -0
- package/{dist/types → types}/plugins/dnd/index.d.ts +0 -0
- package/{dist/types → types}/plugins/index.d.ts +0 -0
- package/{dist/types → types}/plugins/roving/TreeRovingPlugin.d.ts +0 -0
- package/{dist/types → types}/plugins/roving/index.d.ts +0 -0
- package/{dist/types → types}/plugins/searchable/SearchableTreePlugin.d.ts +0 -0
- package/{dist/types → types}/plugins/searchable/index.d.ts +0 -0
- package/{dist/types → types}/plugins/selectable/SelectablePluginTree.d.ts +0 -0
- package/{dist/types → types}/plugins/selectable/index.d.ts +0 -0
- package/{dist/types → types}/plugins/toolbar/TreeToolbarPlugin.d.ts +0 -0
- package/{dist/types → types}/plugins/toolbar/index.d.ts +0 -0
- package/{dist/types → types}/plugins/tree/TreeDataPlugin.d.ts +0 -0
- package/{dist/types → types}/plugins/tree/index.d.ts +0 -0
- package/{dist/types → types}/plugins/virtualization/TreeVirtualizationPlugin.d.ts +0 -0
- package/{dist/types → types}/plugins/virtualization/index.d.ts +0 -0
- package/{dist/types → types}/react-desc-prop-types.d.ts +0 -0
- package/{dist/types → types}/related-components/TreeViewSearchBar.d.ts +0 -0
- package/{dist/types → types}/sharedTypes.d.ts +0 -0
- package/{dist/types → types}/utils/array-helpers.d.ts +0 -0
- package/{dist/types → types}/utils/group-expands-helpers.d.ts +0 -0
- package/{dist/types → types}/utils/keyboard-helpers.d.ts +0 -0
- package/{dist/types → types}/utils/object-helpers.d.ts +0 -0
- package/{dist/types → types}/utils/refs-helpers.d.ts +0 -0
- package/{dist/types → types}/utils/selectable-helper.d.ts +0 -0
- package/{dist/types → types}/utils/string-helpers.d.ts +0 -0
- package/{dist/types → types}/utils/tree-helpers.d.ts +0 -0
- package/{dist/types → types}/utils/useInstanceRefActions.d.ts +0 -0
- package/{dist/types → types}/utils/useTree.d.ts +0 -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
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
|
+
import { useContext } from 'react';
|
|
11
|
+
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
12
|
+
import { DSCircularProgressIndicator } from '@elliemae/ds-circular-progress-indicator';
|
|
13
|
+
import TreeViewContext from '../TreeViewContext.js';
|
|
14
|
+
import { treeListBlockName, DSTreeViewPrefix } from '../config/cssClassesConstants.js';
|
|
15
|
+
import TreeItem from './TreeItem.js';
|
|
16
|
+
import { withConditionalDnDRowContext } from '../hoc/WithConditionalDnDContext.js';
|
|
17
|
+
import { DnDTreeContext } from '../hoc/DnDTreeContext.js';
|
|
18
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
const treeListNoItemsBn = "".concat(treeListBlockName, "-no-items");
|
|
24
|
+
const TreeListNoItems = aggregatedClasses('div', {
|
|
25
|
+
'data-testid': treeListNoItemsBn
|
|
26
|
+
})(treeListNoItemsBn); // React.ComponentProps<'ul'> uses LegacyRef typings that existed pre-hook era
|
|
27
|
+
// we omit the LegacyRef typings in favor of hook-era typings
|
|
28
|
+
|
|
29
|
+
const TreeListWrapper = aggregatedClasses('ul', {
|
|
30
|
+
'data-testid': treeListBlockName,
|
|
31
|
+
role: 'tree'
|
|
32
|
+
})(treeListBlockName, null, _ref => {
|
|
33
|
+
let {
|
|
34
|
+
rowSize
|
|
35
|
+
} = _ref;
|
|
36
|
+
return {
|
|
37
|
+
["rowsize-".concat(rowSize)]: rowSize
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
const compactRowClass = "".concat(DSTreeViewPrefix, "-tv-row-size-compact");
|
|
41
|
+
const normaRowClass = "".concat(DSTreeViewPrefix, "-tv-row-size-normal");
|
|
42
|
+
|
|
43
|
+
const TreeListComp = () => {
|
|
44
|
+
const ctx = useContext(TreeViewContext);
|
|
45
|
+
const {
|
|
46
|
+
virtualListRef,
|
|
47
|
+
virtualListHelpers,
|
|
48
|
+
visibleItems: flattenedVisibleItems,
|
|
49
|
+
props: {
|
|
50
|
+
width,
|
|
51
|
+
height,
|
|
52
|
+
rowSize,
|
|
53
|
+
noItemsPlaceholder,
|
|
54
|
+
isLoading
|
|
55
|
+
}
|
|
56
|
+
} = ctx;
|
|
57
|
+
const {
|
|
58
|
+
totalSize,
|
|
59
|
+
virtualItems
|
|
60
|
+
} = virtualListHelpers;
|
|
61
|
+
const className = "".concat(rowSize === 'compact' ? "".concat(compactRowClass) : "".concat(normaRowClass));
|
|
62
|
+
const {
|
|
63
|
+
visibleItems
|
|
64
|
+
} = useContext(DnDTreeContext);
|
|
65
|
+
return /*#__PURE__*/jsxs(TreeListWrapper, {
|
|
66
|
+
ref: virtualListRef,
|
|
67
|
+
className: className,
|
|
68
|
+
style: {
|
|
69
|
+
height: "".concat(typeof height === 'number' ? "".concat(height, "px") : height),
|
|
70
|
+
width: "".concat(typeof width === 'number' ? "".concat(width, "px") : width),
|
|
71
|
+
overflow: 'auto'
|
|
72
|
+
},
|
|
73
|
+
children: [isLoading ? /*#__PURE__*/_jsx("div", {
|
|
74
|
+
style: {
|
|
75
|
+
width: '100%',
|
|
76
|
+
height: '100%',
|
|
77
|
+
display: 'flex',
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
justifyContent: 'center'
|
|
80
|
+
}
|
|
81
|
+
}, void 0, /*#__PURE__*/_jsx(DSCircularProgressIndicator, {
|
|
82
|
+
size: "xl",
|
|
83
|
+
loading: isLoading,
|
|
84
|
+
showLabel: true,
|
|
85
|
+
waiting: false,
|
|
86
|
+
showTooltip: false
|
|
87
|
+
})) : null, !isLoading && virtualItems.length === 0 ? /*#__PURE__*/_jsx(TreeListNoItems, {}, void 0, noItemsPlaceholder) : null, !isLoading && virtualItems.length !== 0 ? /*#__PURE__*/_jsx("div", {
|
|
88
|
+
style: {
|
|
89
|
+
height: "".concat(totalSize, "px"),
|
|
90
|
+
width: '100%',
|
|
91
|
+
position: 'relative'
|
|
92
|
+
}
|
|
93
|
+
}, void 0, virtualItems.map(virtualItem => {
|
|
94
|
+
const {
|
|
95
|
+
index,
|
|
96
|
+
measureRef,
|
|
97
|
+
start
|
|
98
|
+
} = virtualItem;
|
|
99
|
+
const item = (visibleItems || flattenedVisibleItems)[index];
|
|
100
|
+
if (!item) return null;
|
|
101
|
+
item.virtualIndex = index;
|
|
102
|
+
const {
|
|
103
|
+
id
|
|
104
|
+
} = item;
|
|
105
|
+
const style = {
|
|
106
|
+
position: 'absolute',
|
|
107
|
+
top: "".concat(start, "px"),
|
|
108
|
+
left: 0,
|
|
109
|
+
width: '100%'
|
|
110
|
+
};
|
|
111
|
+
const listItemProps = {
|
|
112
|
+
key: "DS-TreeView-List-Item-".concat(id),
|
|
113
|
+
virtualItemRef: measureRef,
|
|
114
|
+
index,
|
|
115
|
+
// this is consumed by the DnD HOC
|
|
116
|
+
itemIndex: index,
|
|
117
|
+
item,
|
|
118
|
+
itemWrapperStyle: style
|
|
119
|
+
};
|
|
120
|
+
return /*#__PURE__*/jsx(TreeItem, _objectSpread({}, listItemProps));
|
|
121
|
+
})) : null]
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const TreeList = withConditionalDnDRowContext(TreeListComp);
|
|
126
|
+
|
|
127
|
+
export { TreeList, TreeListNoItems, TreeListWrapper, treeListNoItemsBn };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TreeDndPlugin } from './TreeDndPlugin.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { TreeDndPlugin } from './dnd/TreeDndPlugin.js';
|
|
2
|
+
export { TreeRovingPlugin } from './roving/TreeRovingPlugin.js';
|
|
3
|
+
export { SelectablePluginTree } from './selectable/SelectablePluginTree.js';
|
|
4
|
+
export { TreeToolbarPlugin } from './toolbar/TreeToolbarPlugin.js';
|
|
5
|
+
export { TreePluginList } from './tree/TreeDataPlugin.js';
|
|
6
|
+
export { TreeVirtualizationPlugin } from './virtualization/TreeVirtualizationPlugin.js';
|
|
7
|
+
export { SearchableTreePlugin } from './searchable/SearchableTreePlugin.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TreeRovingPlugin } from './TreeRovingPlugin.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SearchableTreePlugin } from './SearchableTreePlugin.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectablePluginTree } from './SelectablePluginTree.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TreeToolbarPlugin } from './TreeToolbarPlugin.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TreePluginList } from './TreeDataPlugin.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TreeVirtualizationPlugin } from './TreeVirtualizationPlugin.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-lines */
|
|
4
|
+
const TreeViewPropTypes = {
|
|
5
|
+
data: PropTypes.arrayOf(PropTypes.shape({
|
|
6
|
+
children: PropTypes.arrayOf(PropTypes.object),
|
|
7
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
8
|
+
isGroup: PropTypes.oneOfType([PropTypes.oneOf([undefined, null]), PropTypes.bool]),
|
|
9
|
+
name: PropTypes.string,
|
|
10
|
+
node: PropTypes.object
|
|
11
|
+
})).description('data to populate tree view').isRequired,
|
|
12
|
+
plugins: PropTypes.arrayOf(PropTypes.string).description('list of enabled plugins').defaultValue([]),
|
|
13
|
+
selection: PropTypes.object.description('pre selected items').defaultValue({}),
|
|
14
|
+
expanded: PropTypes.object.description('control what items are expanded').defaultValue(undefined),
|
|
15
|
+
instanceRef: PropTypes.shape({
|
|
16
|
+
current: PropTypes.oneOfType([PropTypes.oneOf([null, undefined]), PropTypes.shape({
|
|
17
|
+
actions: PropTypes.shape({
|
|
18
|
+
toggleExpandAll: PropTypes.func,
|
|
19
|
+
scrollTo: PropTypes.func
|
|
20
|
+
}).description('').isRequired
|
|
21
|
+
})])
|
|
22
|
+
}).description('instance ref'),
|
|
23
|
+
isItemDisabled: PropTypes.func.description('Function that receives an item, and returns whether that item should be disabled').defaultValue('() => false'),
|
|
24
|
+
disableIcons: PropTypes.bool.description('disable icons').defaultValue(false),
|
|
25
|
+
fluid: PropTypes.bool.description('whether is fluid or not').defaultValue(false),
|
|
26
|
+
isMultiSelect: PropTypes.bool.description('whether the tree view is multi select or not').defaultValue(false),
|
|
27
|
+
isSingleSelect: PropTypes.bool.description('wheter the tree view is single select or not').defaultValue(false),
|
|
28
|
+
isLoading: PropTypes.bool.description('wheter the tree should show the loading state or not').defaultValue(false),
|
|
29
|
+
getIsDropValid: PropTypes.func.description("Function that returns true if the drop is valid and false if it's not").defaultValue('() => true'),
|
|
30
|
+
restrictDragAndDrop: PropTypes.bool.description('whether to restrict DnD functionality or not').defaultValue(false),
|
|
31
|
+
showChildrenAmount: PropTypes.bool.description('whether to show the amount of children or not').defaultValue(false),
|
|
32
|
+
sortable: PropTypes.bool.description('whether the sortable functionality is active or not').defaultValue(false),
|
|
33
|
+
onItemClick: PropTypes.func.description('function executed when clicking on an item').defaultValue('() => {}'),
|
|
34
|
+
onItemFocus: PropTypes.func.description('function executed when focusing on an item').defaultValue('() => {}'),
|
|
35
|
+
onVisibleItemsChange: PropTypes.func.description('function executed when the visible items change').defaultValue('() => {}'),
|
|
36
|
+
onOrderChange: PropTypes.func.description('function executed when the items order changes').defaultValue('() => {}'),
|
|
37
|
+
onSelectionChange: PropTypes.func.description('function executed when the selection changes').defaultValue('() => {}'),
|
|
38
|
+
onExpandChange: PropTypes.func.description('function executed when expanding an item').defaultValue('() => {}'),
|
|
39
|
+
onInstanceRefInitialized: PropTypes.func.description('function executed when instanceRef has terminated instanciation').defaultValue('() => {}'),
|
|
40
|
+
rowSize: PropTypes.oneOf(['normal', 'compact']).description('size of the row').defaultValue('normal'),
|
|
41
|
+
labelOverflow: PropTypes.oneOf(['wrap', 'wrap-all', 'truncate']).description('label truncation preference').defaultValue('wrap'),
|
|
42
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('components width').defaultValue('100%'),
|
|
43
|
+
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('components height').defaultValue('100%'),
|
|
44
|
+
groupIcon: PropTypes.node.description('icon for groups'),
|
|
45
|
+
itemIcon: PropTypes.node.description('icon for items'),
|
|
46
|
+
searchQuery: PropTypes.string.description('search query value'),
|
|
47
|
+
noItemsPlaceholder: PropTypes.string.description('message to be shown when there are no items in the treeview to be displayed').defaultValue('No items found'),
|
|
48
|
+
name: PropTypes.string.description('property key to identifier for items labels').defaultValue('name'),
|
|
49
|
+
highlightOnlyQuery: PropTypes.bool.description('whether to highlight results or not').defaultValue(false)
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { TreeViewPropTypes };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { DSNavSearchBox } from '@elliemae/ds-form';
|
|
4
|
+
|
|
5
|
+
function TreeViewSearchBar(props) {
|
|
6
|
+
const {
|
|
7
|
+
handleChange,
|
|
8
|
+
onNext,
|
|
9
|
+
onPrevious,
|
|
10
|
+
onClear,
|
|
11
|
+
currentResultIndex,
|
|
12
|
+
totalResults,
|
|
13
|
+
value
|
|
14
|
+
} = props;
|
|
15
|
+
return /*#__PURE__*/_jsx(DSNavSearchBox, {
|
|
16
|
+
onChange: v => {
|
|
17
|
+
handleChange({
|
|
18
|
+
target: {
|
|
19
|
+
value: v
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
onNext: onNext,
|
|
24
|
+
onPrevious: onPrevious,
|
|
25
|
+
onClear: onClear,
|
|
26
|
+
currentResultIndex: currentResultIndex,
|
|
27
|
+
totalResults: totalResults,
|
|
28
|
+
value: value
|
|
29
|
+
});
|
|
30
|
+
} // TreeViewSearchBar.propTypes = {
|
|
31
|
+
// value: PropTypes.string.isRequired,
|
|
32
|
+
// handleChange: PropTypes.func.isRequired,
|
|
33
|
+
// onNext: PropTypes.func.isRequired,
|
|
34
|
+
// onPrevious: PropTypes.func.isRequired,
|
|
35
|
+
// onClear: PropTypes.func.isRequired,
|
|
36
|
+
// currentResultIndex: PropTypes.number.isRequired,
|
|
37
|
+
// totalResults: PropTypes.number.isRequired,
|
|
38
|
+
// };
|
|
39
|
+
|
|
40
|
+
export { TreeViewSearchBar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
|
|
3
|
+
// https://github.com/sindresorhus/array-move/blob/master/index.js
|
|
2
4
|
const arrayMoveMutate = (array, from, to) => {
|
|
3
5
|
const startIndex = from < 0 ? array.length + from : from;
|
|
6
|
+
|
|
4
7
|
if (startIndex >= 0 && startIndex < array.length) {
|
|
5
8
|
const endIndex = to < 0 ? array.length + to : to;
|
|
6
9
|
const [item] = array.splice(from, 1);
|
|
@@ -12,8 +15,5 @@ const arrayMove = (array, from, to) => {
|
|
|
12
15
|
arrayMoveMutate(newArray, from, to);
|
|
13
16
|
return newArray;
|
|
14
17
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
arrayMoveMutate
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=array-helpers.js.map
|
|
18
|
+
|
|
19
|
+
export { arrayMove, arrayMoveMutate };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-params */
|
|
4
|
+
const updateExpandedState = (treeRoot, onExpandChange) => {
|
|
5
|
+
const shouldContinueWalking = true;
|
|
6
|
+
const newExpandedHashMap = {
|
|
7
|
+
__ds_tree_root: true
|
|
8
|
+
};
|
|
9
|
+
treeRoot.walk(node => {
|
|
10
|
+
if (!node.isRoot() && node.model.isGroup && node.model.isExpanded) {
|
|
11
|
+
newExpandedHashMap[node.model.id] = true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return shouldContinueWalking;
|
|
15
|
+
});
|
|
16
|
+
if (onExpandChange) onExpandChange(newExpandedHashMap, null);
|
|
17
|
+
};
|
|
18
|
+
const toggleItemExpand = function (itemToToggle, triggerTreeRerender, updateUserExpandedState) {
|
|
19
|
+
let scrollTo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => {};
|
|
20
|
+
const {
|
|
21
|
+
node: {
|
|
22
|
+
model: {
|
|
23
|
+
isExpanded
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
virtualIndex
|
|
27
|
+
} = itemToToggle;
|
|
28
|
+
|
|
29
|
+
if (itemToToggle.node.model.isGroup) {
|
|
30
|
+
itemToToggle.node.model.isExpanded = !isExpanded;
|
|
31
|
+
triggerTreeRerender();
|
|
32
|
+
updateUserExpandedState();
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
if (typeof virtualIndex === 'number') scrollTo(virtualIndex, {
|
|
35
|
+
align: 'start'
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const expandItemModel = modelToExpand => {
|
|
41
|
+
if (modelToExpand.isGroup) modelToExpand.isExpanded = true;
|
|
42
|
+
};
|
|
43
|
+
const collapseItemModel = modelToCollapse => {
|
|
44
|
+
if (modelToCollapse.isGroup) modelToCollapse.isExpanded = false;
|
|
45
|
+
};
|
|
46
|
+
const expandAll = (treeRoot, triggerTreeRerender) => {
|
|
47
|
+
const shouldContinueWalking = true;
|
|
48
|
+
treeRoot.walk(node => {
|
|
49
|
+
if (!node.isRoot()) expandItemModel(node.model);
|
|
50
|
+
return shouldContinueWalking;
|
|
51
|
+
});
|
|
52
|
+
triggerTreeRerender();
|
|
53
|
+
};
|
|
54
|
+
const collapseAll = (treeRoot, triggerTreeRerender) => {
|
|
55
|
+
const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
|
|
56
|
+
|
|
57
|
+
treeRoot.walk(node => {
|
|
58
|
+
if (!node.isRoot()) collapseItemModel(node.model);
|
|
59
|
+
return shouldContinueWalking;
|
|
60
|
+
});
|
|
61
|
+
triggerTreeRerender();
|
|
62
|
+
};
|
|
63
|
+
const getToggleExpandShouldExpand = treeRoot => {
|
|
64
|
+
let shouldExpand = false;
|
|
65
|
+
const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
|
|
66
|
+
|
|
67
|
+
treeRoot.walk(node => {
|
|
68
|
+
if (!node.isRoot()) {
|
|
69
|
+
if (!node.model.isExpanded && node.model.isGroup) {
|
|
70
|
+
shouldExpand = true; // eslint-disable-next-line no-useless-return
|
|
71
|
+
|
|
72
|
+
return shouldContinueWalking;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return shouldContinueWalking;
|
|
77
|
+
});
|
|
78
|
+
return shouldExpand;
|
|
79
|
+
};
|
|
80
|
+
const toggleExpandAllHelper = (isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
|
|
81
|
+
if (isExpand === true) expandAll(treeRoot, triggerTreeRerender);else if (isExpand === false) collapseAll(treeRoot, triggerTreeRerender);else {
|
|
82
|
+
const shouldExpand = getToggleExpandShouldExpand(treeRoot);
|
|
83
|
+
if (shouldExpand === true) expandAll(treeRoot, triggerTreeRerender);else collapseAll(treeRoot, triggerTreeRerender);
|
|
84
|
+
}
|
|
85
|
+
setLatestToggledItem(null);
|
|
86
|
+
updateUserExpandedState();
|
|
87
|
+
};
|
|
88
|
+
const useNotifyExpandedChange = (propsWithDefaults, _ref) => {
|
|
89
|
+
let {
|
|
90
|
+
latestToggledItem,
|
|
91
|
+
expandedGroups
|
|
92
|
+
} = _ref;
|
|
93
|
+
const notifyExpandedChange = useCallback(expandedGroupHashmap => propsWithDefaults === null || propsWithDefaults === void 0 ? void 0 : propsWithDefaults.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!propsWithDefaults.expanded) notifyExpandedChange(expandedGroups);
|
|
96
|
+
}, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export { collapseAll, collapseItemModel, expandAll, expandItemModel, getToggleExpandShouldExpand, toggleExpandAllHelper, toggleItemExpand, updateExpandedState, useNotifyExpandedChange };
|
|
@@ -1,55 +1,91 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { useContext, useCallback, useEffect } from 'react';
|
|
2
|
+
import TreeViewContext from '../TreeViewContext.js';
|
|
3
|
+
import { focusItem } from './tree-helpers.js';
|
|
4
|
+
import { toggleItemExpand, toggleExpandAllHelper } from './group-expands-helpers.js';
|
|
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) *
|
|
6
18
|
const useOnItemKeyDown = (item, draggableProps) => {
|
|
7
19
|
const ctx = useContext(TreeViewContext);
|
|
8
20
|
const {
|
|
9
|
-
props: {
|
|
21
|
+
props: {
|
|
22
|
+
onItemFocus
|
|
23
|
+
},
|
|
10
24
|
triggerTreeRerender,
|
|
11
25
|
visibleItems,
|
|
12
26
|
setFocusedItem,
|
|
13
27
|
setSelectedItem,
|
|
14
28
|
setLatestToggledItem,
|
|
15
29
|
updateUserExpandedState,
|
|
16
|
-
virtualListHelpers: {
|
|
30
|
+
virtualListHelpers: {
|
|
31
|
+
scrollToIndex
|
|
32
|
+
}
|
|
17
33
|
} = ctx;
|
|
18
|
-
const {
|
|
19
|
-
|
|
34
|
+
const {
|
|
35
|
+
isGroup,
|
|
36
|
+
isExpanded
|
|
37
|
+
} = item;
|
|
38
|
+
const onItemFocusCurry = useCallback(newFocusItem => onItemFocus({
|
|
20
39
|
itemIndex: newFocusItem.virtualIndex,
|
|
21
|
-
scrollToItem: (
|
|
40
|
+
scrollToItem: function () {
|
|
41
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
42
|
+
align: 'start'
|
|
43
|
+
};
|
|
44
|
+
return scrollToIndex(newFocusItem.virtualIndex, opts);
|
|
45
|
+
},
|
|
22
46
|
item: newFocusItem
|
|
23
47
|
}), [onItemFocus, scrollToIndex]);
|
|
24
|
-
const onItemKeyDown = useCallback(
|
|
25
|
-
const {
|
|
48
|
+
const onItemKeyDown = useCallback(e => {
|
|
49
|
+
const {
|
|
50
|
+
keyCode
|
|
51
|
+
} = e;
|
|
52
|
+
|
|
26
53
|
if (!(draggableProps && draggableProps.active)) {
|
|
27
|
-
if (keyCode !== 9)
|
|
28
|
-
|
|
29
|
-
if ((keyCode === 13 || keyCode === 32) && e.target.tagName ===
|
|
54
|
+
if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab
|
|
55
|
+
|
|
56
|
+
if ((keyCode === 13 || keyCode === 32) && e.target.tagName === 'LI') {
|
|
30
57
|
setSelectedItem(item);
|
|
31
58
|
}
|
|
59
|
+
|
|
32
60
|
if (keyCode === 37) {
|
|
33
61
|
if (isGroup && isExpanded) {
|
|
34
62
|
toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
|
|
35
63
|
setLatestToggledItem(item);
|
|
36
64
|
}
|
|
37
65
|
}
|
|
66
|
+
|
|
38
67
|
if (keyCode === 39) {
|
|
39
68
|
if (isGroup && !isExpanded) {
|
|
40
69
|
toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
|
|
41
70
|
setLatestToggledItem(item);
|
|
42
71
|
}
|
|
43
72
|
}
|
|
44
|
-
|
|
45
|
-
|
|
73
|
+
|
|
74
|
+
const {
|
|
75
|
+
virtualIndex
|
|
76
|
+
} = item;
|
|
77
|
+
|
|
78
|
+
if (typeof virtualIndex === 'number') {
|
|
46
79
|
const lastItemIndex = visibleItems.length - 1;
|
|
80
|
+
|
|
47
81
|
if (keyCode === 38) {
|
|
48
82
|
const isLoopedFocus = virtualIndex === 0;
|
|
49
83
|
const newFocusIndex = isLoopedFocus ? lastItemIndex : virtualIndex - 1;
|
|
50
84
|
const newFocusItem = visibleItems[newFocusIndex];
|
|
51
85
|
scrollToIndex(newFocusIndex);
|
|
86
|
+
|
|
52
87
|
if (isLoopedFocus) {
|
|
88
|
+
// when looping the list from start to end we need to wait a bit before focusing
|
|
53
89
|
setTimeout(() => {
|
|
54
90
|
setFocusedItem(newFocusItem);
|
|
55
91
|
focusItem(newFocusItem);
|
|
@@ -61,12 +97,15 @@ const useOnItemKeyDown = (item, draggableProps) => {
|
|
|
61
97
|
focusItem(newFocusItem);
|
|
62
98
|
}
|
|
63
99
|
}
|
|
100
|
+
|
|
64
101
|
if (keyCode === 40) {
|
|
65
102
|
const isLoopedFocus = virtualIndex === lastItemIndex;
|
|
66
103
|
const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;
|
|
67
104
|
const newFocusItem = visibleItems[newFocusIndex];
|
|
68
105
|
scrollToIndex(newFocusIndex);
|
|
106
|
+
|
|
69
107
|
if (isLoopedFocus) {
|
|
108
|
+
// when looping the list from start to end we need to wait a bit before focusing
|
|
70
109
|
setTimeout(() => {
|
|
71
110
|
setFocusedItem(newFocusItem);
|
|
72
111
|
onItemFocusCurry(newFocusItem);
|
|
@@ -78,6 +117,7 @@ const useOnItemKeyDown = (item, draggableProps) => {
|
|
|
78
117
|
focusItem(newFocusItem);
|
|
79
118
|
}
|
|
80
119
|
}
|
|
120
|
+
|
|
81
121
|
if (keyCode === 35) {
|
|
82
122
|
if (virtualIndex !== lastItemIndex) {
|
|
83
123
|
const newFocusItem = visibleItems[lastItemIndex];
|
|
@@ -89,6 +129,7 @@ const useOnItemKeyDown = (item, draggableProps) => {
|
|
|
89
129
|
}, 300);
|
|
90
130
|
}
|
|
91
131
|
}
|
|
132
|
+
|
|
92
133
|
if (keyCode === 36) {
|
|
93
134
|
if (virtualIndex !== 0) {
|
|
94
135
|
const newFocusItem = visibleItems[0];
|
|
@@ -102,40 +143,27 @@ const useOnItemKeyDown = (item, draggableProps) => {
|
|
|
102
143
|
}
|
|
103
144
|
}
|
|
104
145
|
}
|
|
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
|
-
]);
|
|
146
|
+
}, [draggableProps, setSelectedItem, item, isGroup, isExpanded, triggerTreeRerender, updateUserExpandedState, scrollToIndex, setLatestToggledItem, visibleItems, setFocusedItem, onItemFocusCurry]);
|
|
119
147
|
return onItemKeyDown;
|
|
120
148
|
};
|
|
121
|
-
const useGlobalKeyboardListener =
|
|
149
|
+
const useGlobalKeyboardListener = func => {
|
|
122
150
|
useEffect(() => {
|
|
123
|
-
document.addEventListener(
|
|
124
|
-
return () => document.removeEventListener(
|
|
151
|
+
document.addEventListener('keydown', func);
|
|
152
|
+
return () => document.removeEventListener('keydown', func);
|
|
125
153
|
}, [func]);
|
|
126
154
|
};
|
|
127
155
|
const useGlobalToggleAllExpandShortcut = (treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
|
|
128
|
-
const memoizedToggleAllKeyboardShortcut = useCallback(
|
|
129
|
-
const {
|
|
156
|
+
const memoizedToggleAllKeyboardShortcut = useCallback(e => {
|
|
157
|
+
const {
|
|
158
|
+
shiftKey,
|
|
159
|
+
keyCode
|
|
160
|
+
} = e;
|
|
161
|
+
|
|
130
162
|
if (shiftKey && keyCode === 56) {
|
|
131
|
-
toggleExpandAllHelper(
|
|
163
|
+
toggleExpandAllHelper('toggle', treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
|
|
132
164
|
}
|
|
133
165
|
}, [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState]);
|
|
134
166
|
return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);
|
|
135
167
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
useGlobalToggleAllExpandShortcut,
|
|
139
|
-
useOnItemKeyDown
|
|
140
|
-
};
|
|
141
|
-
//# sourceMappingURL=keyboard-helpers.js.map
|
|
168
|
+
|
|
169
|
+
export { useGlobalKeyboardListener, useGlobalToggleAllExpandShortcut, useOnItemKeyDown };
|