@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
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
-
var treeHelpers = require('./tree-helpers.js');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
19
|
-
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__default["default"](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; }
|
|
20
|
-
const getGroupCheckState = node => {
|
|
21
|
-
let childAllChecked = true;
|
|
22
|
-
let anyChildChecked = false;
|
|
23
|
-
treeHelpers.walkAllNodeChildren(node, childNode => {
|
|
24
|
-
const {
|
|
25
|
-
model: {
|
|
26
|
-
isChecked
|
|
27
|
-
}
|
|
28
|
-
} = childNode;
|
|
29
|
-
if (isChecked === 'mixed' || isChecked === true) anyChildChecked = true;else childAllChecked = false;
|
|
30
|
-
});
|
|
31
|
-
if (childAllChecked) return true;
|
|
32
|
-
if (anyChildChecked) return 'mixed';
|
|
33
|
-
return false;
|
|
34
|
-
};
|
|
35
|
-
const selectCheckboxItemModelParentsTillRoot = function (modelToCheck) {
|
|
36
|
-
let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
37
|
-
const newSelections = {};
|
|
38
|
-
const {
|
|
39
|
-
nodePath
|
|
40
|
-
} = modelToCheck;
|
|
41
|
-
treeHelpers.walkParents(nodePath, parentNode => {
|
|
42
|
-
const nextState = getGroupCheckState(parentNode);
|
|
43
|
-
parentNode.model.isChecked = nextState;
|
|
44
|
-
newSelections[parentNode.model.id] = nextState;
|
|
45
|
-
});
|
|
46
|
-
if (triggerTreeRerender) triggerTreeRerender();
|
|
47
|
-
return newSelections;
|
|
48
|
-
};
|
|
49
|
-
const toggleCheckboxItem = function (itemToSelect) {
|
|
50
|
-
let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
51
|
-
const {
|
|
52
|
-
node: {
|
|
53
|
-
model: {
|
|
54
|
-
id,
|
|
55
|
-
isChecked,
|
|
56
|
-
children = []
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} = itemToSelect;
|
|
60
|
-
const newSelections = {}; // 'mixed' -> true -> false -> true [...->false -> true]
|
|
61
|
-
|
|
62
|
-
const nextState = isChecked === 'mixed' ? true : !isChecked;
|
|
63
|
-
itemToSelect.node.model.isChecked = nextState;
|
|
64
|
-
newSelections[id] = nextState;
|
|
65
|
-
|
|
66
|
-
if (children.length > 0 && (nextState === true || nextState === false)) {
|
|
67
|
-
treeHelpers.walkAllNodeChildren(itemToSelect.node, childNode => {
|
|
68
|
-
childNode.model.isChecked = nextState;
|
|
69
|
-
newSelections[childNode.model.id] = nextState;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(itemToSelect);
|
|
74
|
-
if (triggerTreeRerender) triggerTreeRerender();
|
|
75
|
-
return _objectSpread(_objectSpread({}, parentsNewSelections), newSelections);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
exports.getGroupCheckState = getGroupCheckState;
|
|
79
|
-
exports.selectCheckboxItemModelParentsTillRoot = selectCheckboxItemModelParentsTillRoot;
|
|
80
|
-
exports.toggleCheckboxItem = toggleCheckboxItem;
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
-
require('core-js/modules/esnext.async-iterator.find.js');
|
|
10
|
-
require('core-js/modules/esnext.iterator.find.js');
|
|
11
|
-
require('core-js/modules/esnext.async-iterator.every.js');
|
|
12
|
-
require('core-js/modules/esnext.iterator.every.js');
|
|
13
|
-
var React = require('react');
|
|
14
|
-
var stringHelpers = require('./string-helpers.js');
|
|
15
|
-
|
|
16
|
-
const walkVisibles = function (node, callback) {
|
|
17
|
-
let skipRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
18
|
-
let highlightOnlyQuery = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
19
|
-
const {
|
|
20
|
-
children,
|
|
21
|
-
model
|
|
22
|
-
} = node;
|
|
23
|
-
const {
|
|
24
|
-
name,
|
|
25
|
-
isExpanded,
|
|
26
|
-
childrenMatchesSearchQuery,
|
|
27
|
-
matchesSearchQuery
|
|
28
|
-
} = model;
|
|
29
|
-
const shouldSkipBecauseIsRoot = skipRoot && name === '__root';
|
|
30
|
-
const queryRestrictionsPassed = !!(highlightOnlyQuery || childrenMatchesSearchQuery || matchesSearchQuery);
|
|
31
|
-
if (!shouldSkipBecauseIsRoot && queryRestrictionsPassed) callback(node);
|
|
32
|
-
const shouldWalkChildren = !!(children.length > 0 && isExpanded && queryRestrictionsPassed);
|
|
33
|
-
|
|
34
|
-
if (shouldWalkChildren) {
|
|
35
|
-
children.forEach(childNode => {
|
|
36
|
-
walkVisibles(childNode, callback, skipRoot, highlightOnlyQuery);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const walkParents = function (nodePath, callback) {
|
|
41
|
-
let skipRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
42
|
-
const parents = [...nodePath].reverse();
|
|
43
|
-
parents.shift(); // remove current node from the parents array
|
|
44
|
-
|
|
45
|
-
if (skipRoot) parents.pop(); // remove the root from the parents if skipping root
|
|
46
|
-
|
|
47
|
-
parents.forEach(callback);
|
|
48
|
-
};
|
|
49
|
-
const walkAllNodeChildren = function (node, callback) {
|
|
50
|
-
let isFirst = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
51
|
-
const {
|
|
52
|
-
children = []
|
|
53
|
-
} = node;
|
|
54
|
-
const shouldWalkChildren = children.length;
|
|
55
|
-
if (!isFirst) callback(node);
|
|
56
|
-
|
|
57
|
-
if (shouldWalkChildren) {
|
|
58
|
-
children.forEach(childNode => {
|
|
59
|
-
walkAllNodeChildren(childNode, callback, false);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const getNodeById = (treeRoot, id) => {
|
|
64
|
-
const nodes = treeRoot.all(node => node.model.id === id);
|
|
65
|
-
return nodes[0];
|
|
66
|
-
};
|
|
67
|
-
const cloneNode = (tree, node) => tree.parse(node.model);
|
|
68
|
-
const itemsShareSameParent = function () {
|
|
69
|
-
let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
70
|
-
if (items.length === 0) throw new Error('Received empty items for comparison');
|
|
71
|
-
if (items.length === 1) return true; // when moving in first position we receive [undefined,...{items}]
|
|
72
|
-
// when moving in last position we receive [...{items}, undefined]
|
|
73
|
-
|
|
74
|
-
const firstExistingItem = items.find(item => !!item);
|
|
75
|
-
if (!firstExistingItem) throw new Error("Received no items, can't retrieve parent");
|
|
76
|
-
const firstExistingItemPath = firstExistingItem.node.getPath(); // path is like [rootParent, ...[parentsNodes], currentNode]
|
|
77
|
-
// length -1 is the current-node
|
|
78
|
-
// length -2 is the parent-node
|
|
79
|
-
// root node is not printed and is always present so minimum path length is 2 (root + currentNode)
|
|
80
|
-
|
|
81
|
-
const directParentNode = firstExistingItemPath[firstExistingItemPath.length - 2];
|
|
82
|
-
return items.every(item => {
|
|
83
|
-
// undefined nodes count as having the same parent
|
|
84
|
-
if (!item) return true;
|
|
85
|
-
const itemPath = item.node.getPath();
|
|
86
|
-
const itemDirectParent = itemPath[itemPath.length - 2];
|
|
87
|
-
return directParentNode === itemDirectParent;
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
const getItemsParentNode = function () {
|
|
91
|
-
let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
92
|
-
let skipSameParentCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
93
|
-
if (items.length === 0) throw new Error("Received empty items, can't retrieve parent"); // in case we already know the items compared shares the same parent
|
|
94
|
-
|
|
95
|
-
if (!skipSameParentCheck) if (!itemsShareSameParent(items)) // if we don't know (default, we don't) check if they share the parent
|
|
96
|
-
throw new Error("Received items don't share the same parent, can't retrieve parent"); // when moving in first position we receive [undefined,...{items}]
|
|
97
|
-
// when moving in last position we receive [...{items}, undefined]
|
|
98
|
-
|
|
99
|
-
const firstExistingItem = items.find(item => !!item);
|
|
100
|
-
if (!firstExistingItem) throw new Error("Received no items, can't retrieve parent");
|
|
101
|
-
const firstExistingItemPath = firstExistingItem.node.getPath(); // path is like [rootParent, ...[parentsNodes], currentNode]
|
|
102
|
-
// length -1 is the current-node
|
|
103
|
-
// length -2 is the parent-node
|
|
104
|
-
// root node is not printed and is always present so minimum path length is 2 (root + currentNode)
|
|
105
|
-
|
|
106
|
-
const directParentNode = firstExistingItemPath[firstExistingItemPath.length - 2];
|
|
107
|
-
return directParentNode;
|
|
108
|
-
};
|
|
109
|
-
const getNodeMatchesSearchQuery = function (node) {
|
|
110
|
-
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
111
|
-
const standardizedName = stringHelpers.standardizeSearchQueryString(node.model.name);
|
|
112
|
-
const standardizedSearchQuery = stringHelpers.standardizeSearchQueryString(searchQuery);
|
|
113
|
-
return standardizedName.includes(standardizedSearchQuery);
|
|
114
|
-
};
|
|
115
|
-
const getChildrenMatchesSearchQuery = function (parentNode) {
|
|
116
|
-
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
117
|
-
let anyChildMatch = false;
|
|
118
|
-
walkAllNodeChildren(parentNode, node => {
|
|
119
|
-
if (getNodeMatchesSearchQuery(node, searchQuery)) anyChildMatch = true;
|
|
120
|
-
});
|
|
121
|
-
return anyChildMatch;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Mutate in place a node from tree-model normalizing object properties like "isGroup" even if user didn't specify it explicitly,
|
|
125
|
-
* after execution the node will have "nodePath" "treeDepth" "nodeItemRef" "isGroup" "isExpanded"
|
|
126
|
-
* (optionally, based on the provided arguments) "matchesSearchQuery" "childrenMatchesSearchQuery" "isChecked"
|
|
127
|
-
*
|
|
128
|
-
* @param {Object} node - node (based on 'tree-model' lib) that you wish to mutate with extra props
|
|
129
|
-
* @param {string} [searchQuery=''] - optional string used to parse "matchesSearchQuery"/"childrenMatchesSearchQuery" properties
|
|
130
|
-
* @param {Object} [selection=null] - optional selection hashmap used to parse "isChecked" properties
|
|
131
|
-
* @param {Object} [expanded=null] - optional expanded hashmap used to parse "isExpanded" properties
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
const enrichNodeModelInPlace = function (node) {
|
|
135
|
-
var _node$model$children$, _node$model, _node$model$children;
|
|
136
|
-
|
|
137
|
-
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
138
|
-
let selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
139
|
-
let expanded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
140
|
-
const path = node.getPath();
|
|
141
|
-
const depth = path.length - 1;
|
|
142
|
-
node.model.nodePath = path;
|
|
143
|
-
node.model.treeDepth = depth;
|
|
144
|
-
|
|
145
|
-
if (!node.model.nodeItemRef) {
|
|
146
|
-
node.model.nodeItemRef = /*#__PURE__*/React.createRef();
|
|
147
|
-
} // if a node has children but was not marked as isGroup, force-mark as group
|
|
148
|
-
// this is useful to avoid having to always check both the flag and the children.length...
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (typeof node.model.isGroup !== 'boolean' && ((_node$model$children$ = (_node$model = node.model) === null || _node$model === void 0 ? void 0 : (_node$model$children = _node$model.children) === null || _node$model$children === void 0 ? void 0 : _node$model$children.length) !== null && _node$model$children$ !== void 0 ? _node$model$children$ : 0) > 0) {
|
|
152
|
-
node.model.isGroup = true;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (node.model.isGroup && node.model.id !== '__ds_tree_root') {
|
|
156
|
-
if (expanded) node.model.isExpanded = !!expanded[node.model.id];else if (typeof node.model.isExpanded !== 'boolean') {
|
|
157
|
-
node.model.isExpanded = false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
node.model.matchesSearchQuery = true;
|
|
162
|
-
node.model.childrenMatchesSearchQuery = false;
|
|
163
|
-
const partiallyEnrichedNode = node;
|
|
164
|
-
|
|
165
|
-
if (searchQuery) {
|
|
166
|
-
partiallyEnrichedNode.model.matchesSearchQuery = getNodeMatchesSearchQuery(partiallyEnrichedNode, searchQuery);
|
|
167
|
-
|
|
168
|
-
if (partiallyEnrichedNode.model.isGroup === true) {
|
|
169
|
-
partiallyEnrichedNode.model.childrenMatchesSearchQuery = getChildrenMatchesSearchQuery(partiallyEnrichedNode, searchQuery);
|
|
170
|
-
if (partiallyEnrichedNode.model.childrenMatchesSearchQuery) partiallyEnrichedNode.model.isExpanded = true;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (selection && selection[partiallyEnrichedNode.model.id]) {
|
|
175
|
-
partiallyEnrichedNode.model.isChecked = selection[partiallyEnrichedNode.model.id];
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
const focusItem = item => {
|
|
179
|
-
var _item$nodeItemRef, _item$nodeItemRef$cur;
|
|
180
|
-
|
|
181
|
-
item === null || item === void 0 ? void 0 : (_item$nodeItemRef = item.nodeItemRef) === null || _item$nodeItemRef === void 0 ? void 0 : (_item$nodeItemRef$cur = _item$nodeItemRef.current) === null || _item$nodeItemRef$cur === void 0 ? void 0 : _item$nodeItemRef$cur.focus();
|
|
182
|
-
};
|
|
183
|
-
const flattenTreeForDnD = function (data) {
|
|
184
|
-
let shouldDescend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => true;
|
|
185
|
-
const flattenedTree = [];
|
|
186
|
-
let index = 0;
|
|
187
|
-
|
|
188
|
-
const doit = function (node) {
|
|
189
|
-
var _node$children$length, _node$children, _node$children2;
|
|
190
|
-
|
|
191
|
-
let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
192
|
-
let parentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
193
|
-
flattenedTree.push({
|
|
194
|
-
uid: node.id.toString(),
|
|
195
|
-
depth,
|
|
196
|
-
realIndex: index,
|
|
197
|
-
childrenCount: (_node$children$length = (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.length) !== null && _node$children$length !== void 0 ? _node$children$length : 0,
|
|
198
|
-
parentId: parentId !== null ? parentId.toString() : null,
|
|
199
|
-
original: node
|
|
200
|
-
});
|
|
201
|
-
index += 1;
|
|
202
|
-
if (shouldDescend(node)) (_node$children2 = node.children) === null || _node$children2 === void 0 ? void 0 : _node$children2.forEach(child => doit(child, depth + 1, node.id.toString()));
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
data.forEach(datum => doit(datum));
|
|
206
|
-
return flattenedTree;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
exports.cloneNode = cloneNode;
|
|
210
|
-
exports.enrichNodeModelInPlace = enrichNodeModelInPlace;
|
|
211
|
-
exports.flattenTreeForDnD = flattenTreeForDnD;
|
|
212
|
-
exports.focusItem = focusItem;
|
|
213
|
-
exports.getChildrenMatchesSearchQuery = getChildrenMatchesSearchQuery;
|
|
214
|
-
exports.getItemsParentNode = getItemsParentNode;
|
|
215
|
-
exports.getNodeById = getNodeById;
|
|
216
|
-
exports.getNodeMatchesSearchQuery = getNodeMatchesSearchQuery;
|
|
217
|
-
exports.itemsShareSameParent = itemsShareSameParent;
|
|
218
|
-
exports.walkAllNodeChildren = walkAllNodeChildren;
|
|
219
|
-
exports.walkParents = walkParents;
|
|
220
|
-
exports.walkVisibles = walkVisibles;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var treeHelpers = require('./tree-helpers.js');
|
|
8
|
-
var groupExpandsHelpers = require('./group-expands-helpers.js');
|
|
9
|
-
|
|
10
|
-
const useInstanceRefActions = (_ref, ctx) => {
|
|
11
|
-
let {
|
|
12
|
-
actions
|
|
13
|
-
} = _ref;
|
|
14
|
-
const {
|
|
15
|
-
props: {
|
|
16
|
-
onItemFocus
|
|
17
|
-
},
|
|
18
|
-
virtualListHelpers,
|
|
19
|
-
treeRoot,
|
|
20
|
-
visibleItems,
|
|
21
|
-
triggerTreeRerender,
|
|
22
|
-
updateUserExpandedState,
|
|
23
|
-
setSelectedItem,
|
|
24
|
-
setFocusedItem,
|
|
25
|
-
setLatestToggledItem
|
|
26
|
-
} = ctx;
|
|
27
|
-
const {
|
|
28
|
-
current: promises
|
|
29
|
-
} = React.useRef({});
|
|
30
|
-
const {
|
|
31
|
-
scrollToIndex
|
|
32
|
-
} = React.useMemo(() => virtualListHelpers, [virtualListHelpers]);
|
|
33
|
-
const [expandPromise, setPromise] = React.useState();
|
|
34
|
-
React.useEffect(() => {
|
|
35
|
-
if (expandPromise && promises.expandResolve) {
|
|
36
|
-
promises.expandResolve(visibleItems);
|
|
37
|
-
promises.expandResolve = null;
|
|
38
|
-
setPromise(null);
|
|
39
|
-
}
|
|
40
|
-
}, [visibleItems, expandPromise, promises]);
|
|
41
|
-
actions.toggleExpandAll = React.useCallback(isExpand => {
|
|
42
|
-
const p = new Promise(resolve => {
|
|
43
|
-
promises.expandResolve = resolve;
|
|
44
|
-
if (treeRoot) groupExpandsHelpers.toggleExpandAllHelper(isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
|
|
45
|
-
});
|
|
46
|
-
setPromise(p);
|
|
47
|
-
return p;
|
|
48
|
-
}, [promises, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState]);
|
|
49
|
-
actions.scrollTo = React.useCallback(function (indx) {
|
|
50
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
51
|
-
align: 'start'
|
|
52
|
-
};
|
|
53
|
-
if (scrollToIndex) scrollToIndex(indx, opts);
|
|
54
|
-
}, [scrollToIndex]);
|
|
55
|
-
actions.setSelectedItemByVirtualIndex = React.useCallback(index => {
|
|
56
|
-
const itemByIndex = visibleItems[index];
|
|
57
|
-
setSelectedItem(itemByIndex);
|
|
58
|
-
}, [visibleItems, setSelectedItem]);
|
|
59
|
-
actions.setFocusedItemByVirtualIndex = React.useCallback(function (index) {
|
|
60
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
61
|
-
align: 'start',
|
|
62
|
-
withScroll: false
|
|
63
|
-
};
|
|
64
|
-
const itemByIndex = visibleItems[index];
|
|
65
|
-
const onItemFocusParams = {
|
|
66
|
-
itemIndex: itemByIndex.virtualIndex,
|
|
67
|
-
scrollToItem: () => scrollToIndex(index, opts),
|
|
68
|
-
item: itemByIndex
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
if (opts.withScroll && scrollToIndex) {
|
|
72
|
-
scrollToIndex(index, opts);
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
setFocusedItem(itemByIndex);
|
|
75
|
-
treeHelpers.focusItem(itemByIndex);
|
|
76
|
-
onItemFocus(onItemFocusParams);
|
|
77
|
-
}, 300);
|
|
78
|
-
} else {
|
|
79
|
-
setFocusedItem(itemByIndex);
|
|
80
|
-
treeHelpers.focusItem(itemByIndex);
|
|
81
|
-
onItemFocus(onItemFocusParams);
|
|
82
|
-
}
|
|
83
|
-
}, [visibleItems, scrollToIndex, setFocusedItem, onItemFocus]);
|
|
84
|
-
return actions;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
exports.useInstanceRefActions = useInstanceRefActions;
|
package/cjs/utils/useTree.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
-
var React = require('react');
|
|
13
|
-
var TreeModel = require('tree-model');
|
|
14
|
-
var lodash = require('lodash');
|
|
15
|
-
var treeHelpers = require('./tree-helpers.js');
|
|
16
|
-
var groupExpandsHelpers = require('./group-expands-helpers.js');
|
|
17
|
-
|
|
18
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
-
|
|
20
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
21
|
-
var TreeModel__default = /*#__PURE__*/_interopDefaultLegacy(TreeModel);
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
25
|
-
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__default["default"](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; }
|
|
26
|
-
const useTree = (data, props, states) => {
|
|
27
|
-
const {
|
|
28
|
-
setExpandedGroups
|
|
29
|
-
} = states;
|
|
30
|
-
const unfrozenData = React.useMemo(() => lodash.cloneDeep(data), [data]); // convert data into a TreeModel with extra isExpanded prop
|
|
31
|
-
// root element type is an exception, children model is based on what the dev passed on
|
|
32
|
-
// since root is an excepcion we must typecast
|
|
33
|
-
|
|
34
|
-
const tree = React.useMemo(() => new TreeModel__default["default"](), []);
|
|
35
|
-
const [treeData, setTreeData] = React.useState({
|
|
36
|
-
id: '__ds_tree_root',
|
|
37
|
-
name: '__root',
|
|
38
|
-
isExpanded: true,
|
|
39
|
-
children: unfrozenData
|
|
40
|
-
});
|
|
41
|
-
React.useEffect(() => {
|
|
42
|
-
setTreeData({
|
|
43
|
-
id: '__ds_tree_root',
|
|
44
|
-
name: '__root',
|
|
45
|
-
isExpanded: true,
|
|
46
|
-
children: unfrozenData
|
|
47
|
-
});
|
|
48
|
-
}, [unfrozenData]); // expose a way to rerender the tree
|
|
49
|
-
// used for expand functionality
|
|
50
|
-
|
|
51
|
-
const [rerenderItems, setRerenderItems] = React.useState({});
|
|
52
|
-
const triggerTreeRerender = React.useCallback(() => {
|
|
53
|
-
setRerenderItems({});
|
|
54
|
-
}, []); // when re-rendering we re-parse the list
|
|
55
|
-
|
|
56
|
-
const [treeRoot, setTreeRoot] = React.useState(tree.parse(treeData));
|
|
57
|
-
React.useEffect(() => {
|
|
58
|
-
setTreeRoot(tree.parse(treeData));
|
|
59
|
-
}, [treeData, rerenderItems, tree]);
|
|
60
|
-
const [visibleItems, setVisibleItems] = React.useState([]);
|
|
61
|
-
const {
|
|
62
|
-
searchQuery,
|
|
63
|
-
highlightOnlyQuery,
|
|
64
|
-
onVisibleItemsChange,
|
|
65
|
-
selection,
|
|
66
|
-
expanded,
|
|
67
|
-
onExpandChange
|
|
68
|
-
} = props;
|
|
69
|
-
const updateUserExpandedState = React.useCallback(() => {
|
|
70
|
-
groupExpandsHelpers.updateExpandedState(treeRoot, onExpandChange);
|
|
71
|
-
}, [treeRoot, onExpandChange]); // we add missing properties to the received Items
|
|
72
|
-
// not the best of the patterns, but it works
|
|
73
|
-
// this is where we convert "SimpleItems" to "Items"
|
|
74
|
-
// this was done to avoid breaking changes back in v1
|
|
75
|
-
|
|
76
|
-
React.useEffect(() => {
|
|
77
|
-
const parsedVisibleItems = [];
|
|
78
|
-
const newExpandedHashMap = {};
|
|
79
|
-
const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
|
|
80
|
-
|
|
81
|
-
treeRoot.walk(node => {
|
|
82
|
-
treeHelpers.enrichNodeModelInPlace(node, searchQuery, selection, expanded);
|
|
83
|
-
if (node.model.id && node.model.isGroup && node.model.isExpanded) newExpandedHashMap[node.model.id] = true;
|
|
84
|
-
return shouldContinueWalking;
|
|
85
|
-
});
|
|
86
|
-
treeHelpers.walkVisibles(treeRoot, node => {
|
|
87
|
-
parsedVisibleItems.push(_objectSpread(_objectSpread({}, node.model), {}, {
|
|
88
|
-
node
|
|
89
|
-
}));
|
|
90
|
-
}, true, highlightOnlyQuery);
|
|
91
|
-
setVisibleItems(parsedVisibleItems);
|
|
92
|
-
onVisibleItemsChange(parsedVisibleItems);
|
|
93
|
-
setExpandedGroups(newExpandedHashMap); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
-
}, [treeRoot, rerenderItems, searchQuery, highlightOnlyQuery, selection, expanded, setExpandedGroups // onVisibleItemsChange // evaluate potential performance hit?
|
|
95
|
-
]);
|
|
96
|
-
const flattenedItems = React.useMemo(() => treeHelpers.flattenTreeForDnD(data), [data]);
|
|
97
|
-
return {
|
|
98
|
-
visibleItems,
|
|
99
|
-
flattenedItems,
|
|
100
|
-
tree,
|
|
101
|
-
treeRoot,
|
|
102
|
-
rerenderItems,
|
|
103
|
-
triggerTreeRerender,
|
|
104
|
-
updateUserExpandedState
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
exports.useTree = useTree;
|
package/esm/TreeView.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import 'react';
|
|
3
|
-
import { describe } from 'react-desc';
|
|
4
|
-
import { TreeViewPropTypes } from './react-desc-prop-types.js';
|
|
5
|
-
import TreeViewContext from './TreeViewContext.js';
|
|
6
|
-
import { useTreeview } from './config/useTreeview.js';
|
|
7
|
-
import { TreeList } from './parts/TreeList.js';
|
|
8
|
-
|
|
9
|
-
var _TreeList;
|
|
10
|
-
function TreeView(props) {
|
|
11
|
-
const {
|
|
12
|
-
ctx
|
|
13
|
-
} = useTreeview(props);
|
|
14
|
-
return /*#__PURE__*/_jsx(TreeViewContext.Provider, {
|
|
15
|
-
value: ctx
|
|
16
|
-
}, void 0, _TreeList || (_TreeList = /*#__PURE__*/_jsx(TreeList, {})));
|
|
17
|
-
}
|
|
18
|
-
const TreeViewWithSchema = describe(TreeView);
|
|
19
|
-
TreeViewWithSchema.propTypes = TreeViewPropTypes;
|
|
20
|
-
|
|
21
|
-
export { TreeView, TreeViewWithSchema };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const DSTreeViewPrefix = 'em-ds';
|
|
2
|
-
const treeItemBlockName = 'tree-item';
|
|
3
|
-
const treeListBlockName = 'tree-list';
|
|
4
|
-
const treeListNoItemsBn = "".concat(treeListBlockName, "-no-items");
|
|
5
|
-
|
|
6
|
-
export { DSTreeViewPrefix, treeItemBlockName, treeListBlockName, treeListNoItemsBn };
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
-
import { useRef, useState, useCallback, useMemo, useEffect } from 'react';
|
|
9
|
-
import { useVirtual } from 'react-virtual';
|
|
10
|
-
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
|
|
11
|
-
import { v4 } from 'uuid';
|
|
12
|
-
import { TreeViewPropTypes } from '../react-desc-prop-types.js';
|
|
13
|
-
import { defaultProps } from '../TreeViewContext.js';
|
|
14
|
-
import { TreeDndPlugin } from '../plugins/dnd/TreeDndPlugin.js';
|
|
15
|
-
import { useTree } from '../utils/useTree.js';
|
|
16
|
-
import { toggleItemExpand, useNotifyExpandedChange } from '../utils/group-expands-helpers.js';
|
|
17
|
-
import { useInstanceRefActions } from '../utils/useInstanceRefActions.js';
|
|
18
|
-
import { useGlobalToggleAllExpandShortcut } from '../utils/keyboard-helpers.js';
|
|
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 useTreeview = props => {
|
|
24
|
-
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
25
|
-
useValidateTypescriptPropTypes(propsWithDefault, TreeViewPropTypes);
|
|
26
|
-
const defaultActions = {
|
|
27
|
-
actions: {
|
|
28
|
-
toggleExpandAll: () => {},
|
|
29
|
-
scrollTo: () => {},
|
|
30
|
-
setSelectedItemByVirtualIndex: () => {},
|
|
31
|
-
setFocusedItemByVirtualIndex: () => {}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const treeRef = useRef(defaultActions);
|
|
35
|
-
const {
|
|
36
|
-
data,
|
|
37
|
-
plugins,
|
|
38
|
-
onOrderChange,
|
|
39
|
-
isMultiSelect,
|
|
40
|
-
isSingleSelect,
|
|
41
|
-
instanceRef,
|
|
42
|
-
selection,
|
|
43
|
-
onInstanceRefInitialized
|
|
44
|
-
} = propsWithDefault;
|
|
45
|
-
const [uniqueTreeViewUUID] = useState(v4());
|
|
46
|
-
const [hoverItem, setHoverItem] = useState(null);
|
|
47
|
-
const [latestToggledItem, setLatestToggledItem] = useState(null);
|
|
48
|
-
const [selectedItem, setSelectedItem] = useState(null);
|
|
49
|
-
const [focusedItem, setFocusedItem] = useState(null);
|
|
50
|
-
const [selectedCheckboxes, setSelectedCheckboxes] = useState(_objectSpread({}, selection));
|
|
51
|
-
const [expandedGroups, setExpandedGroups] = useState({});
|
|
52
|
-
const {
|
|
53
|
-
visibleItems,
|
|
54
|
-
flattenedItems,
|
|
55
|
-
tree,
|
|
56
|
-
treeRoot,
|
|
57
|
-
triggerTreeRerender,
|
|
58
|
-
updateUserExpandedState
|
|
59
|
-
} = useTree(data, propsWithDefault, {
|
|
60
|
-
setExpandedGroups
|
|
61
|
-
});
|
|
62
|
-
const virtualListRef = useRef(); // estimateSize should not be really required given what was stated on
|
|
63
|
-
// https://github.com/tannerlinsley/react-virtual/issues/23
|
|
64
|
-
|
|
65
|
-
const virtualListHelpers = useVirtual({
|
|
66
|
-
size: visibleItems.length,
|
|
67
|
-
parentRef: virtualListRef,
|
|
68
|
-
overscan: 15
|
|
69
|
-
});
|
|
70
|
-
const withDragAndDrop = !!(plugins !== null && plugins !== void 0 && plugins.includes(TreeDndPlugin) && onOrderChange);
|
|
71
|
-
const withRadioChecks = isSingleSelect && !isMultiSelect;
|
|
72
|
-
const withCheckboxChecks = !isSingleSelect && isMultiSelect;
|
|
73
|
-
const handleExpandGroup = useCallback(toggleItemExpand, []);
|
|
74
|
-
const ctx = useMemo(() => ({
|
|
75
|
-
props: propsWithDefault,
|
|
76
|
-
virtualListHelpers,
|
|
77
|
-
virtualListRef,
|
|
78
|
-
tree,
|
|
79
|
-
treeRoot,
|
|
80
|
-
visibleItems,
|
|
81
|
-
flattenedItems,
|
|
82
|
-
triggerTreeRerender,
|
|
83
|
-
withRadioChecks,
|
|
84
|
-
withCheckboxChecks,
|
|
85
|
-
withDragAndDrop,
|
|
86
|
-
uniqueTreeViewUUID,
|
|
87
|
-
selectedCheckboxes,
|
|
88
|
-
setSelectedCheckboxes,
|
|
89
|
-
selectedItem,
|
|
90
|
-
setSelectedItem,
|
|
91
|
-
expandedGroups,
|
|
92
|
-
setExpandedGroups,
|
|
93
|
-
latestToggledItem,
|
|
94
|
-
setLatestToggledItem,
|
|
95
|
-
focusedItem,
|
|
96
|
-
setFocusedItem,
|
|
97
|
-
hoverItem,
|
|
98
|
-
setHoverItem,
|
|
99
|
-
handleExpandGroup,
|
|
100
|
-
updateUserExpandedState
|
|
101
|
-
}), [propsWithDefault, virtualListHelpers, tree, treeRoot, visibleItems, flattenedItems, triggerTreeRerender, withRadioChecks, withCheckboxChecks, withDragAndDrop, uniqueTreeViewUUID, selectedCheckboxes, selectedItem, expandedGroups, latestToggledItem, focusedItem, hoverItem, handleExpandGroup, updateUserExpandedState]); // this hooks can't use the context because the context provider doesn't wrap this
|
|
102
|
-
// as such we manually pass the second parameter as fit
|
|
103
|
-
|
|
104
|
-
if (instanceRef) instanceRef.current = treeRef.current;
|
|
105
|
-
useInstanceRefActions(treeRef.current, ctx);
|
|
106
|
-
useGlobalToggleAllExpandShortcut(treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
|
|
107
|
-
useNotifyExpandedChange(propsWithDefault, ctx); // this is an horrible hack.
|
|
108
|
-
// this is required because there is no "on rendered" react-way to check if every children has finished rendering
|
|
109
|
-
// this should be working for now, in the future we may want to review this for a better solution
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
setTimeout(() => onInstanceRefInitialized(treeRef), 100); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
-
}, []);
|
|
114
|
-
return useMemo(() => ({
|
|
115
|
-
ctx
|
|
116
|
-
}), [ctx]);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export { useTreeview };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
import { DropIndicatorPosition } from './SortableItemContext.js';
|
|
3
|
-
|
|
4
|
-
const DnDTreeContext = /*#__PURE__*/createContext({
|
|
5
|
-
depth: undefined,
|
|
6
|
-
activeIndex: undefined,
|
|
7
|
-
visibleItems: undefined,
|
|
8
|
-
dropIndicatorPosition: DropIndicatorPosition.None,
|
|
9
|
-
lastActiveId: undefined,
|
|
10
|
-
setLastActiveId: undefined,
|
|
11
|
-
isDropValid: false
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export { DnDTreeContext };
|