@opensumi/ide-components 2.12.1-next-079c1930
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/README.md +65 -0
- package/dist/index.css +1 -0
- package/dist/index.js +26330 -0
- package/lib/badge/index.d.ts +4 -0
- package/lib/badge/index.d.ts.map +1 -0
- package/lib/badge/index.js +13 -0
- package/lib/badge/index.js.map +1 -0
- package/lib/badge/styles.less +17 -0
- package/lib/button/index.d.ts +54 -0
- package/lib/button/index.d.ts.map +1 -0
- package/lib/button/index.js +68 -0
- package/lib/button/index.js.map +1 -0
- package/lib/button/style.less +251 -0
- package/lib/checkbox/index.d.ts +9 -0
- package/lib/checkbox/index.d.ts.map +1 -0
- package/lib/checkbox/index.js +27 -0
- package/lib/checkbox/index.js.map +1 -0
- package/lib/checkbox/style.less +80 -0
- package/lib/common.d.ts +7 -0
- package/lib/common.d.ts.map +1 -0
- package/lib/common.js +11 -0
- package/lib/common.js.map +1 -0
- package/lib/dialog/index.d.ts +26 -0
- package/lib/dialog/index.d.ts.map +1 -0
- package/lib/dialog/index.js +28 -0
- package/lib/dialog/index.js.map +1 -0
- package/lib/dialog/styles.less +85 -0
- package/lib/dropdown/dropdown.d.ts +48 -0
- package/lib/dropdown/dropdown.d.ts.map +1 -0
- package/lib/dropdown/dropdown.js +80 -0
- package/lib/dropdown/dropdown.js.map +1 -0
- package/lib/dropdown/index.d.ts +5 -0
- package/lib/dropdown/index.d.ts.map +1 -0
- package/lib/dropdown/index.js +8 -0
- package/lib/dropdown/index.js.map +1 -0
- package/lib/dropdown/style.less +254 -0
- package/lib/icon/icon.d.ts +33 -0
- package/lib/icon/icon.d.ts.map +1 -0
- package/lib/icon/icon.js +71 -0
- package/lib/icon/icon.js.map +1 -0
- package/lib/icon/iconfont/iconManager.d.ts +187 -0
- package/lib/icon/iconfont/iconManager.d.ts.map +1 -0
- package/lib/icon/iconfont/iconManager.js +67 -0
- package/lib/icon/iconfont/iconManager.js.map +1 -0
- package/lib/icon/iconfont/iconMap.d.ts +160 -0
- package/lib/icon/iconfont/iconMap.d.ts.map +1 -0
- package/lib/icon/iconfont/iconMap.js +165 -0
- package/lib/icon/iconfont/iconMap.js.map +1 -0
- package/lib/icon/iconfont/iconfont.css +646 -0
- package/lib/icon/iconfont/iconfont.eot +0 -0
- package/lib/icon/iconfont/iconfont.html +1522 -0
- package/lib/icon/iconfont/iconfont.svg +333 -0
- package/lib/icon/iconfont/iconfont.ttf +0 -0
- package/lib/icon/iconfont/iconfont.woff +0 -0
- package/lib/icon/iconfont/iconfont.woff2 +0 -0
- package/lib/icon/iconfont-cn.d.ts +15 -0
- package/lib/icon/iconfont-cn.d.ts.map +1 -0
- package/lib/icon/iconfont-cn.js +78 -0
- package/lib/icon/iconfont-cn.js.map +1 -0
- package/lib/icon/index.d.ts +4 -0
- package/lib/icon/index.d.ts.map +1 -0
- package/lib/icon/index.js +9 -0
- package/lib/icon/index.js.map +1 -0
- package/lib/icon/styles.less +105 -0
- package/lib/icon/util.d.ts +29 -0
- package/lib/icon/util.d.ts.map +1 -0
- package/lib/icon/util.js +53 -0
- package/lib/icon/util.js.map +1 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +23 -0
- package/lib/index.js.map +1 -0
- package/lib/input/HistoryInputBox.d.ts +38 -0
- package/lib/input/HistoryInputBox.d.ts.map +1 -0
- package/lib/input/HistoryInputBox.js +114 -0
- package/lib/input/HistoryInputBox.js.map +1 -0
- package/lib/input/Input.d.ts +43 -0
- package/lib/input/Input.d.ts.map +1 -0
- package/lib/input/Input.js +124 -0
- package/lib/input/Input.js.map +1 -0
- package/lib/input/ProxiedInput.d.ts +8 -0
- package/lib/input/ProxiedInput.d.ts.map +1 -0
- package/lib/input/ProxiedInput.js +67 -0
- package/lib/input/ProxiedInput.js.map +1 -0
- package/lib/input/TextArea.d.ts +6 -0
- package/lib/input/TextArea.d.ts.map +1 -0
- package/lib/input/TextArea.js +11 -0
- package/lib/input/TextArea.js.map +1 -0
- package/lib/input/ValidateInput.d.ts +20 -0
- package/lib/input/ValidateInput.d.ts.map +1 -0
- package/lib/input/ValidateInput.js +59 -0
- package/lib/input/ValidateInput.js.map +1 -0
- package/lib/input/index.d.ts +5 -0
- package/lib/input/index.d.ts.map +1 -0
- package/lib/input/index.js +8 -0
- package/lib/input/index.js.map +1 -0
- package/lib/input/input.less +83 -0
- package/lib/input/validate-input.less +88 -0
- package/lib/locale-context-provider.d.ts +16 -0
- package/lib/locale-context-provider.d.ts.map +1 -0
- package/lib/locale-context-provider.js +26 -0
- package/lib/locale-context-provider.js.map +1 -0
- package/lib/menu/MenuContext.d.ts +8 -0
- package/lib/menu/MenuContext.d.ts.map +1 -0
- package/lib/menu/MenuContext.js +8 -0
- package/lib/menu/MenuContext.js.map +1 -0
- package/lib/menu/MenuItem.d.ts +29 -0
- package/lib/menu/MenuItem.d.ts.map +1 -0
- package/lib/menu/MenuItem.js +32 -0
- package/lib/menu/MenuItem.js.map +1 -0
- package/lib/menu/SubMenu.d.ts +30 -0
- package/lib/menu/SubMenu.d.ts.map +1 -0
- package/lib/menu/SubMenu.js +28 -0
- package/lib/menu/SubMenu.js.map +1 -0
- package/lib/menu/index.d.ts +64 -0
- package/lib/menu/index.d.ts.map +1 -0
- package/lib/menu/index.js +203 -0
- package/lib/menu/index.js.map +1 -0
- package/lib/menu/style.less +513 -0
- package/lib/message/index.d.ts +10 -0
- package/lib/message/index.d.ts.map +1 -0
- package/lib/message/index.js +21 -0
- package/lib/message/index.js.map +1 -0
- package/lib/message/message.d.ts +42 -0
- package/lib/message/message.d.ts.map +1 -0
- package/lib/message/message.js +128 -0
- package/lib/message/message.js.map +1 -0
- package/lib/message/style.less +76 -0
- package/lib/modal/Modal.d.ts +127 -0
- package/lib/modal/Modal.d.ts.map +1 -0
- package/lib/modal/Modal.js +87 -0
- package/lib/modal/Modal.js.map +1 -0
- package/lib/modal/index.d.ts +5 -0
- package/lib/modal/index.d.ts.map +1 -0
- package/lib/modal/index.js +8 -0
- package/lib/modal/index.js.map +1 -0
- package/lib/modal/locale.d.ts +8 -0
- package/lib/modal/locale.d.ts.map +1 -0
- package/lib/modal/locale.js +23 -0
- package/lib/modal/locale.js.map +1 -0
- package/lib/modal/style.less +168 -0
- package/lib/notification/index.d.ts +8 -0
- package/lib/notification/index.d.ts.map +1 -0
- package/lib/notification/index.js +80 -0
- package/lib/notification/index.js.map +1 -0
- package/lib/notification/notification.d.ts +44 -0
- package/lib/notification/notification.d.ts.map +1 -0
- package/lib/notification/notification.js +156 -0
- package/lib/notification/notification.js.map +1 -0
- package/lib/notification/notification.less +231 -0
- package/lib/overlay/index.d.ts +19 -0
- package/lib/overlay/index.d.ts.map +1 -0
- package/lib/overlay/index.js +13 -0
- package/lib/overlay/index.js.map +1 -0
- package/lib/overlay/styles.less +44 -0
- package/lib/popover/index.d.ts +28 -0
- package/lib/popover/index.d.ts.map +1 -0
- package/lib/popover/index.js +127 -0
- package/lib/popover/index.js.map +1 -0
- package/lib/popover/styles.less +135 -0
- package/lib/recycle-list/RecycleList.d.ts +105 -0
- package/lib/recycle-list/RecycleList.d.ts.map +1 -0
- package/lib/recycle-list/RecycleList.js +253 -0
- package/lib/recycle-list/RecycleList.js.map +1 -0
- package/lib/recycle-list/index.d.ts +2 -0
- package/lib/recycle-list/index.d.ts.map +1 -0
- package/lib/recycle-list/index.js +5 -0
- package/lib/recycle-list/index.js.map +1 -0
- package/lib/recycle-tree/RecycleTree.d.ts +254 -0
- package/lib/recycle-tree/RecycleTree.d.ts.map +1 -0
- package/lib/recycle-tree/RecycleTree.js +635 -0
- package/lib/recycle-tree/RecycleTree.js.map +1 -0
- package/lib/recycle-tree/TreeNodeRendererWrap.d.ts +37 -0
- package/lib/recycle-tree/TreeNodeRendererWrap.d.ts.map +1 -0
- package/lib/recycle-tree/TreeNodeRendererWrap.js +18 -0
- package/lib/recycle-tree/TreeNodeRendererWrap.js.map +1 -0
- package/lib/recycle-tree/decorators/Adaptive/index.d.ts +10 -0
- package/lib/recycle-tree/decorators/Adaptive/index.d.ts.map +1 -0
- package/lib/recycle-tree/decorators/Adaptive/index.js +97 -0
- package/lib/recycle-tree/decorators/Adaptive/index.js.map +1 -0
- package/lib/recycle-tree/decorators/Filter/filter.less +11 -0
- package/lib/recycle-tree/decorators/Filter/index.d.ts +26 -0
- package/lib/recycle-tree/decorators/Filter/index.d.ts.map +1 -0
- package/lib/recycle-tree/decorators/Filter/index.js +53 -0
- package/lib/recycle-tree/decorators/Filter/index.js.map +1 -0
- package/lib/recycle-tree/decorators/index.d.ts +3 -0
- package/lib/recycle-tree/decorators/index.d.ts.map +1 -0
- package/lib/recycle-tree/decorators/index.js +6 -0
- package/lib/recycle-tree/decorators/index.js.map +1 -0
- package/lib/recycle-tree/index.d.ts +7 -0
- package/lib/recycle-tree/index.d.ts.map +1 -0
- package/lib/recycle-tree/index.js +10 -0
- package/lib/recycle-tree/index.js.map +1 -0
- package/lib/recycle-tree/prompt/NewPromptHandle.d.ts +12 -0
- package/lib/recycle-tree/prompt/NewPromptHandle.d.ts.map +1 -0
- package/lib/recycle-tree/prompt/NewPromptHandle.js +21 -0
- package/lib/recycle-tree/prompt/NewPromptHandle.js.map +1 -0
- package/lib/recycle-tree/prompt/PromptHandle.d.ts +59 -0
- package/lib/recycle-tree/prompt/PromptHandle.d.ts.map +1 -0
- package/lib/recycle-tree/prompt/PromptHandle.js +200 -0
- package/lib/recycle-tree/prompt/PromptHandle.js.map +1 -0
- package/lib/recycle-tree/prompt/RenamePromptHandle.d.ts +10 -0
- package/lib/recycle-tree/prompt/RenamePromptHandle.d.ts.map +1 -0
- package/lib/recycle-tree/prompt/RenamePromptHandle.js +21 -0
- package/lib/recycle-tree/prompt/RenamePromptHandle.js.map +1 -0
- package/lib/recycle-tree/prompt/index.d.ts +4 -0
- package/lib/recycle-tree/prompt/index.d.ts.map +1 -0
- package/lib/recycle-tree/prompt/index.js +7 -0
- package/lib/recycle-tree/prompt/index.js.map +1 -0
- package/lib/recycle-tree/tree/Tree.d.ts +20 -0
- package/lib/recycle-tree/tree/Tree.d.ts.map +1 -0
- package/lib/recycle-tree/tree/Tree.js +43 -0
- package/lib/recycle-tree/tree/Tree.js.map +1 -0
- package/lib/recycle-tree/tree/TreeNode.d.ts +222 -0
- package/lib/recycle-tree/tree/TreeNode.d.ts.map +1 -0
- package/lib/recycle-tree/tree/TreeNode.js +1099 -0
- package/lib/recycle-tree/tree/TreeNode.js.map +1 -0
- package/lib/recycle-tree/tree/decoration/CompositeDecoration.d.ts +60 -0
- package/lib/recycle-tree/tree/decoration/CompositeDecoration.d.ts.map +1 -0
- package/lib/recycle-tree/tree/decoration/CompositeDecoration.js +328 -0
- package/lib/recycle-tree/tree/decoration/CompositeDecoration.js.map +1 -0
- package/lib/recycle-tree/tree/decoration/Decoration.d.ts +79 -0
- package/lib/recycle-tree/tree/decoration/Decoration.d.ts.map +1 -0
- package/lib/recycle-tree/tree/decoration/Decoration.js +183 -0
- package/lib/recycle-tree/tree/decoration/Decoration.js.map +1 -0
- package/lib/recycle-tree/tree/decoration/DecorationManager.d.ts +34 -0
- package/lib/recycle-tree/tree/decoration/DecorationManager.d.ts.map +1 -0
- package/lib/recycle-tree/tree/decoration/DecorationManager.js +166 -0
- package/lib/recycle-tree/tree/decoration/DecorationManager.js.map +1 -0
- package/lib/recycle-tree/tree/decoration/index.d.ts +4 -0
- package/lib/recycle-tree/tree/decoration/index.d.ts.map +1 -0
- package/lib/recycle-tree/tree/decoration/index.js +7 -0
- package/lib/recycle-tree/tree/decoration/index.js.map +1 -0
- package/lib/recycle-tree/tree/index.d.ts +5 -0
- package/lib/recycle-tree/tree/index.d.ts.map +1 -0
- package/lib/recycle-tree/tree/index.js +8 -0
- package/lib/recycle-tree/tree/index.js.map +1 -0
- package/lib/recycle-tree/tree/model/TreeModel.d.ts +50 -0
- package/lib/recycle-tree/tree/model/TreeModel.d.ts.map +1 -0
- package/lib/recycle-tree/tree/model/TreeModel.js +81 -0
- package/lib/recycle-tree/tree/model/TreeModel.js.map +1 -0
- package/lib/recycle-tree/tree/model/index.d.ts +2 -0
- package/lib/recycle-tree/tree/model/index.d.ts.map +1 -0
- package/lib/recycle-tree/tree/model/index.js +5 -0
- package/lib/recycle-tree/tree/model/index.js.map +1 -0
- package/lib/recycle-tree/tree/model/treeState/TreeStateManager.d.ts +65 -0
- package/lib/recycle-tree/tree/model/treeState/TreeStateManager.d.ts.map +1 -0
- package/lib/recycle-tree/tree/model/treeState/TreeStateManager.js +191 -0
- package/lib/recycle-tree/tree/model/treeState/TreeStateManager.js.map +1 -0
- package/lib/recycle-tree/tree/model/treeState/TreeStateWatcher.d.ts +15 -0
- package/lib/recycle-tree/tree/model/treeState/TreeStateWatcher.d.ts.map +1 -0
- package/lib/recycle-tree/tree/model/treeState/TreeStateWatcher.js +104 -0
- package/lib/recycle-tree/tree/model/treeState/TreeStateWatcher.js.map +1 -0
- package/lib/recycle-tree/tree/model/treeState/index.d.ts +4 -0
- package/lib/recycle-tree/tree/model/treeState/index.d.ts.map +1 -0
- package/lib/recycle-tree/tree/model/treeState/index.js +8 -0
- package/lib/recycle-tree/tree/model/treeState/index.js.map +1 -0
- package/lib/recycle-tree/tree/model/treeState/types.d.ts +21 -0
- package/lib/recycle-tree/tree/model/treeState/types.d.ts.map +1 -0
- package/lib/recycle-tree/tree/model/treeState/types.js +18 -0
- package/lib/recycle-tree/tree/model/treeState/types.js.map +1 -0
- package/lib/recycle-tree/types/index.d.ts +4 -0
- package/lib/recycle-tree/types/index.d.ts.map +1 -0
- package/lib/recycle-tree/types/index.js +7 -0
- package/lib/recycle-tree/types/index.js.map +1 -0
- package/lib/recycle-tree/types/tree-node.d.ts +70 -0
- package/lib/recycle-tree/types/tree-node.d.ts.map +1 -0
- package/lib/recycle-tree/types/tree-node.js +11 -0
- package/lib/recycle-tree/types/tree-node.js.map +1 -0
- package/lib/recycle-tree/types/tree.d.ts +8 -0
- package/lib/recycle-tree/types/tree.d.ts.map +1 -0
- package/lib/recycle-tree/types/tree.js +3 -0
- package/lib/recycle-tree/types/tree.js.map +1 -0
- package/lib/recycle-tree/types/watcher.d.ts +114 -0
- package/lib/recycle-tree/types/watcher.d.ts.map +1 -0
- package/lib/recycle-tree/types/watcher.js +46 -0
- package/lib/recycle-tree/types/watcher.js.map +1 -0
- package/lib/scrollbars/index.d.ts +14 -0
- package/lib/scrollbars/index.d.ts.map +1 -0
- package/lib/scrollbars/index.js +52 -0
- package/lib/scrollbars/index.js.map +1 -0
- package/lib/scrollbars/styles.less +46 -0
- package/lib/select/index.d.ts +119 -0
- package/lib/select/index.d.ts.map +1 -0
- package/lib/select/index.js +327 -0
- package/lib/select/index.js.map +1 -0
- package/lib/select/style.less +224 -0
- package/lib/style/base.less +542 -0
- package/lib/style/index.less +14 -0
- package/lib/style/mixins.less +135 -0
- package/lib/style/motion/fade.less +31 -0
- package/lib/style/motion/move.less +120 -0
- package/lib/style/motion/other.less +45 -0
- package/lib/style/motion/slide.less +120 -0
- package/lib/style/motion/swing.less +34 -0
- package/lib/style/motion/zoom.less +162 -0
- package/lib/style/variable.less +204 -0
- package/lib/tabs/index.d.ts +12 -0
- package/lib/tabs/index.d.ts.map +1 -0
- package/lib/tabs/index.js +24 -0
- package/lib/tabs/index.js.map +1 -0
- package/lib/tabs/style.less +34 -0
- package/lib/tooltip/index.d.ts +7 -0
- package/lib/tooltip/index.d.ts.map +1 -0
- package/lib/tooltip/index.js +58 -0
- package/lib/tooltip/index.js.map +1 -0
- package/lib/tooltip/style.less +41 -0
- package/lib/utils/deprecated.d.ts +3 -0
- package/lib/utils/deprecated.d.ts.map +1 -0
- package/lib/utils/deprecated.js +18 -0
- package/lib/utils/deprecated.js.map +1 -0
- package/lib/utils/disposable.d.ts +37 -0
- package/lib/utils/disposable.d.ts.map +1 -0
- package/lib/utils/disposable.js +140 -0
- package/lib/utils/disposable.js.map +1 -0
- package/lib/utils/event.d.ts +189 -0
- package/lib/utils/event.d.ts.map +1 -0
- package/lib/utils/event.js +569 -0
- package/lib/utils/event.js.map +1 -0
- package/lib/utils/index.d.ts +10 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/iterator.d.ts +14 -0
- package/lib/utils/iterator.d.ts.map +1 -0
- package/lib/utils/iterator.js +9 -0
- package/lib/utils/iterator.js.map +1 -0
- package/lib/utils/linkedList.d.ts +18 -0
- package/lib/utils/linkedList.d.ts.map +1 -0
- package/lib/utils/linkedList.js +139 -0
- package/lib/utils/linkedList.js.map +1 -0
- package/lib/utils/motion.d.ts +24 -0
- package/lib/utils/motion.d.ts.map +1 -0
- package/lib/utils/motion.js +17 -0
- package/lib/utils/motion.js.map +1 -0
- package/lib/utils/os.d.ts +4 -0
- package/lib/utils/os.d.ts.map +1 -0
- package/lib/utils/os.js +22 -0
- package/lib/utils/os.js.map +1 -0
- package/lib/utils/path.d.ts +92 -0
- package/lib/utils/path.d.ts.map +1 -0
- package/lib/utils/path.js +1712 -0
- package/lib/utils/path.js.map +1 -0
- package/lib/utils/process.d.ts +6 -0
- package/lib/utils/process.d.ts.map +1 -0
- package/lib/utils/process.js +17 -0
- package/lib/utils/process.js.map +1 -0
- package/lib/utils/raf.d.ts +10 -0
- package/lib/utils/raf.d.ts.map +1 -0
- package/lib/utils/raf.js +33 -0
- package/lib/utils/raf.js.map +1 -0
- package/lib/utils/type.d.ts +4 -0
- package/lib/utils/type.d.ts.map +1 -0
- package/lib/utils/type.js +9 -0
- package/lib/utils/type.js.map +1 -0
- package/lib/utils/warning.d.ts +8 -0
- package/lib/utils/warning.d.ts.map +1 -0
- package/lib/utils/warning.js +40 -0
- package/lib/utils/warning.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecycleTree = exports.RenderErrorType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = (0, tslib_1.__importDefault)(require("react"));
|
|
6
|
+
const react_window_1 = require("react-window");
|
|
7
|
+
const tree_1 = require("./tree");
|
|
8
|
+
const prompt_1 = require("./prompt");
|
|
9
|
+
const NewPromptHandle_1 = require("./prompt/NewPromptHandle");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const TreeNodeRendererWrap_1 = require("./TreeNodeRendererWrap");
|
|
12
|
+
const types_1 = require("./types");
|
|
13
|
+
const scrollbars_1 = require("../scrollbars");
|
|
14
|
+
const fuzzy_1 = (0, tslib_1.__importDefault)(require("fuzzy"));
|
|
15
|
+
var RenderErrorType;
|
|
16
|
+
(function (RenderErrorType) {
|
|
17
|
+
RenderErrorType[RenderErrorType["RENDER_ITEM"] = 0] = "RENDER_ITEM";
|
|
18
|
+
RenderErrorType[RenderErrorType["GET_RENDED_KEY"] = 1] = "GET_RENDED_KEY";
|
|
19
|
+
RenderErrorType[RenderErrorType["RENDER_ERROR"] = 2] = "RENDER_ERROR";
|
|
20
|
+
})(RenderErrorType = exports.RenderErrorType || (exports.RenderErrorType = {}));
|
|
21
|
+
const InnerElementType = react_1.default.forwardRef((props, ref) => {
|
|
22
|
+
const _a = props, { style } = _a, rest = (0, tslib_1.__rest)(_a, ["style"]);
|
|
23
|
+
return react_1.default.createElement("div", Object.assign({ ref: ref, style: Object.assign(Object.assign({}, style), { height: `${parseFloat(style.height) + RecycleTree.PADDING_BOTTOM_SIZE}px` }) }, rest));
|
|
24
|
+
});
|
|
25
|
+
class RecycleTree extends react_1.default.Component {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.idxToRendererPropsCache = new Map();
|
|
29
|
+
this.dynamicSizeMap = new Map();
|
|
30
|
+
this.listRef = react_1.default.createRef();
|
|
31
|
+
this.disposables = new utils_1.DisposableCollection();
|
|
32
|
+
this.onErrorEmitter = new utils_1.Emitter();
|
|
33
|
+
this.onDidUpdateEmitter = new utils_1.Emitter();
|
|
34
|
+
this.onDidModelChangeEmitter = new utils_1.Emitter();
|
|
35
|
+
// 索引应该比目标折叠节点索引+1,即位于折叠节点下的首个节点
|
|
36
|
+
this.newPromptInsertionIndex = -1;
|
|
37
|
+
this.idToFilterRendererPropsCache = new Map();
|
|
38
|
+
this.filterFlattenBranchChildrenCache = new Map();
|
|
39
|
+
this.filterWatcherDisposeCollection = new utils_1.DisposableCollection();
|
|
40
|
+
this.batchUpdatePromise = null;
|
|
41
|
+
// 批量更新Tree节点
|
|
42
|
+
this.batchUpdate = (() => {
|
|
43
|
+
let timer;
|
|
44
|
+
const commitUpdate = () => {
|
|
45
|
+
const { root } = this.props.model;
|
|
46
|
+
let newFilePromptInsertionIndex = -1;
|
|
47
|
+
if (this.promptTargetID > -1 &&
|
|
48
|
+
this.promptHandle instanceof NewPromptHandle_1.NewPromptHandle &&
|
|
49
|
+
this.promptHandle.parent &&
|
|
50
|
+
this.promptHandle.parent.expanded &&
|
|
51
|
+
root.isItemVisibleAtSurface(this.promptHandle.parent) &&
|
|
52
|
+
!this.promptHandle.destroyed) {
|
|
53
|
+
const idx = root.getIndexAtTreeNodeId(this.promptTargetID);
|
|
54
|
+
if (idx > -1 || this.promptHandle.parent === root) {
|
|
55
|
+
// 如果新建节点类型为普通节点,则在可折叠节点后插入
|
|
56
|
+
if (this.promptHandle.type === types_1.TreeNodeType.TreeNode) {
|
|
57
|
+
const parent = this.promptHandle.parent;
|
|
58
|
+
if (parent) {
|
|
59
|
+
newFilePromptInsertionIndex = this.getNewPromptInsertIndex(idx, parent);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
newFilePromptInsertionIndex = idx + 1;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
newFilePromptInsertionIndex = idx + 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.promptTargetID = -1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (newFilePromptInsertionIndex === -1) {
|
|
74
|
+
// 新建节点,异常情况下的特殊处理,需要把promptHandle销毁,仅需要考虑NewPromptHandle情况
|
|
75
|
+
if (this.promptHandle && this.promptHandle.constructor === NewPromptHandle_1.NewPromptHandle && !this.promptHandle.destroyed) {
|
|
76
|
+
this.promptHandle.destroy();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
this.newPromptInsertionIndex = newFilePromptInsertionIndex;
|
|
80
|
+
// 清理cache,这里可以确保分支已更新完毕
|
|
81
|
+
this.idxToRendererPropsCache.clear();
|
|
82
|
+
// 更新React组件
|
|
83
|
+
this.forceUpdate(this.batchUpdateResolver);
|
|
84
|
+
if (this.props.filter && this.props.filterProvider && this.props.filterProvider.filterAlways) {
|
|
85
|
+
this.filterItems(this.props.filter);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return () => {
|
|
89
|
+
if (!this.batchUpdatePromise) {
|
|
90
|
+
this.batchUpdatePromise = new Promise((res) => this.batchUpdateResolver = res);
|
|
91
|
+
this.batchUpdatePromise.then(() => {
|
|
92
|
+
this.batchUpdatePromise = null;
|
|
93
|
+
this.batchUpdateResolver = null;
|
|
94
|
+
this.onDidUpdateEmitter.fire();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// 更新批量更新返回的promise对象
|
|
98
|
+
clearTimeout(timer);
|
|
99
|
+
timer = setTimeout(commitUpdate, RecycleTree.BATCHED_UPDATE_MAX_DEBOUNCE_MS);
|
|
100
|
+
return this.batchUpdatePromise;
|
|
101
|
+
};
|
|
102
|
+
})();
|
|
103
|
+
// 使用箭头函数绑定当前this
|
|
104
|
+
this.promptNewTreeNode = (pathOrTreeNode) => {
|
|
105
|
+
return this.promptNew(pathOrTreeNode);
|
|
106
|
+
};
|
|
107
|
+
this.promptNewCompositeTreeNode = (pathOrTreeNode) => {
|
|
108
|
+
return this.promptNew(pathOrTreeNode, types_1.TreeNodeType.CompositeTreeNode);
|
|
109
|
+
};
|
|
110
|
+
this.promptRename = async (pathOrTreeNode, defaultName) => {
|
|
111
|
+
var _a;
|
|
112
|
+
const { root } = this.props.model;
|
|
113
|
+
const node = (typeof pathOrTreeNode === 'string'
|
|
114
|
+
? await root.getTreeNodeByPath(pathOrTreeNode)
|
|
115
|
+
: pathOrTreeNode);
|
|
116
|
+
if (!tree_1.TreeNode.is(node) || tree_1.CompositeTreeNode.isRoot(node)) {
|
|
117
|
+
throw new TypeError(`Cannot rename object of type ${typeof node}`);
|
|
118
|
+
}
|
|
119
|
+
const promptHandle = new prompt_1.RenamePromptHandle(defaultName || node.name, node);
|
|
120
|
+
this.promptHandle = promptHandle;
|
|
121
|
+
this.promptTargetID = node.id;
|
|
122
|
+
if (!root.isItemVisibleAtSurface(node)) {
|
|
123
|
+
await node.parent.setExpanded(true);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
await this.batchUpdate();
|
|
127
|
+
}
|
|
128
|
+
(_a = this.listRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(root.getIndexAtTreeNodeId(this.promptTargetID));
|
|
129
|
+
return this.promptHandle;
|
|
130
|
+
};
|
|
131
|
+
this.expandNode = async (pathOrCompositeTreeNode) => {
|
|
132
|
+
const { root } = this.props.model;
|
|
133
|
+
const directory = typeof pathOrCompositeTreeNode === 'string'
|
|
134
|
+
? await root.getTreeNodeByPath(pathOrCompositeTreeNode)
|
|
135
|
+
: await root.getTreeNodeByPath(pathOrCompositeTreeNode.path);
|
|
136
|
+
if (directory && tree_1.CompositeTreeNode.is(directory)) {
|
|
137
|
+
return directory.setExpanded(true);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
this.collapseNode = async (pathOrCompositeTreeNode) => {
|
|
141
|
+
const { root } = this.props.model;
|
|
142
|
+
const directory = typeof pathOrCompositeTreeNode === 'string'
|
|
143
|
+
? await root.getTreeNodeByPath(pathOrCompositeTreeNode)
|
|
144
|
+
: root.getTreeNodeByPath(pathOrCompositeTreeNode.path);
|
|
145
|
+
if (directory && tree_1.CompositeTreeNode.is(directory)) {
|
|
146
|
+
return directory.setCollapsed();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
this._isEnsuring = false;
|
|
150
|
+
this.ensureVisible = async (pathOrTreeNode, align = 'smart', untilStable = false) => {
|
|
151
|
+
if (this._isEnsuring) {
|
|
152
|
+
// 同一时间段只能让一次定位节点的操作生效
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this._isEnsuring = true;
|
|
156
|
+
const { root } = this.props.model;
|
|
157
|
+
const node = typeof pathOrTreeNode === 'string'
|
|
158
|
+
? await root.forceLoadTreeNodeAtPath(pathOrTreeNode)
|
|
159
|
+
: pathOrTreeNode;
|
|
160
|
+
if (!tree_1.TreeNode.is(node) || tree_1.CompositeTreeNode.isRoot(node)) {
|
|
161
|
+
// 异常
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
let parent = node.parent;
|
|
165
|
+
while (parent) {
|
|
166
|
+
if (!parent.expanded) {
|
|
167
|
+
await parent.setExpanded(true);
|
|
168
|
+
}
|
|
169
|
+
parent = parent.parent;
|
|
170
|
+
}
|
|
171
|
+
if (untilStable) {
|
|
172
|
+
this.tryScrollIntoViewWhileStable(node, align);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.tryScrollIntoView(node, align);
|
|
176
|
+
}
|
|
177
|
+
this._isEnsuring = false;
|
|
178
|
+
return node;
|
|
179
|
+
};
|
|
180
|
+
this.getItemAtIndex = (index) => {
|
|
181
|
+
const { filter } = this.props;
|
|
182
|
+
if (!!filter && this.filterFlattenBranch.length > 0) {
|
|
183
|
+
return this.idToFilterRendererPropsCache.get(this.filterFlattenBranch[index]);
|
|
184
|
+
}
|
|
185
|
+
let cached = this.idxToRendererPropsCache.get(index);
|
|
186
|
+
if (!cached) {
|
|
187
|
+
const promptInsertionIdx = this.newPromptInsertionIndex;
|
|
188
|
+
const { root } = this.props.model;
|
|
189
|
+
// 存在新建输入框
|
|
190
|
+
if (promptInsertionIdx > -1 &&
|
|
191
|
+
this.promptHandle && this.promptHandle.constructor === NewPromptHandle_1.NewPromptHandle &&
|
|
192
|
+
!this.promptHandle.destroyed) {
|
|
193
|
+
if (index === promptInsertionIdx) {
|
|
194
|
+
cached = {
|
|
195
|
+
itemType: types_1.TreeNodeType.NewPrompt,
|
|
196
|
+
item: this.promptHandle,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const item = root.getTreeNodeAtIndex(index - (index >= promptInsertionIdx ? 1 : 0));
|
|
201
|
+
cached = {
|
|
202
|
+
itemType: tree_1.CompositeTreeNode.is(item) ? types_1.TreeNodeType.CompositeTreeNode : types_1.TreeNodeType.TreeNode,
|
|
203
|
+
item,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
const item = root.getTreeNodeAtIndex(index);
|
|
209
|
+
// 检查是否为重命名节点
|
|
210
|
+
if (item &&
|
|
211
|
+
item.id === this.promptTargetID &&
|
|
212
|
+
this.promptHandle &&
|
|
213
|
+
this.promptHandle.constructor === prompt_1.RenamePromptHandle &&
|
|
214
|
+
!this.promptHandle.destroyed) {
|
|
215
|
+
cached = {
|
|
216
|
+
itemType: types_1.TreeNodeType.RenamePrompt,
|
|
217
|
+
item: this.promptHandle,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
cached = {
|
|
222
|
+
itemType: tree_1.CompositeTreeNode.is(item) ? types_1.TreeNodeType.CompositeTreeNode : types_1.TreeNodeType.TreeNode,
|
|
223
|
+
item,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
this.idxToRendererPropsCache.set(index, cached);
|
|
228
|
+
}
|
|
229
|
+
return cached;
|
|
230
|
+
};
|
|
231
|
+
this.handleListScroll = ({ scrollOffset }) => {
|
|
232
|
+
const { model } = this.props;
|
|
233
|
+
model.state.saveScrollOffset(scrollOffset);
|
|
234
|
+
};
|
|
235
|
+
this.getItemKey = (index) => {
|
|
236
|
+
const node = this.getItemAtIndex(index);
|
|
237
|
+
const { getItemKey } = this.props;
|
|
238
|
+
const id = getItemKey ? getItemKey(node) : undefined;
|
|
239
|
+
return id !== null && id !== void 0 ? id : index;
|
|
240
|
+
};
|
|
241
|
+
// 过滤Root节点展示
|
|
242
|
+
this.filterItems = (filter) => {
|
|
243
|
+
const { model: { root }, filterProvider } = this.props;
|
|
244
|
+
this.filterWatcherDisposeCollection.dispose();
|
|
245
|
+
this.idToFilterRendererPropsCache.clear();
|
|
246
|
+
if (!filter) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const isPathFilter = /\//.test(filter);
|
|
250
|
+
const idSets = new Set();
|
|
251
|
+
const idToRenderTemplate = new Map();
|
|
252
|
+
const nodes = [];
|
|
253
|
+
for (let idx = 0; idx < root.branchSize; idx++) {
|
|
254
|
+
const node = root.getTreeNodeAtIndex(idx);
|
|
255
|
+
nodes.push(node);
|
|
256
|
+
}
|
|
257
|
+
if (isPathFilter) {
|
|
258
|
+
nodes.forEach((node) => {
|
|
259
|
+
if (node && node.path.indexOf(filter) > -1) {
|
|
260
|
+
idSets.add(node.id);
|
|
261
|
+
let parent = node.parent;
|
|
262
|
+
// 不应包含根节点
|
|
263
|
+
while (parent && !tree_1.CompositeTreeNode.isRoot(parent)) {
|
|
264
|
+
idSets.add(parent.id);
|
|
265
|
+
parent = parent.parent;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
let fuzzyLists = [];
|
|
272
|
+
if (filterProvider) {
|
|
273
|
+
fuzzyLists = fuzzy_1.default.filter(filter, nodes, filterProvider.fuzzyOptions());
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
fuzzyLists = fuzzy_1.default.filter(filter, nodes, RecycleTree.FILTER_FUZZY_OPTIONS);
|
|
277
|
+
}
|
|
278
|
+
fuzzyLists.forEach((item) => {
|
|
279
|
+
const node = item.original;
|
|
280
|
+
idSets.add(node.id);
|
|
281
|
+
let parent = node.parent;
|
|
282
|
+
idToRenderTemplate.set(node.id, () => {
|
|
283
|
+
return react_1.default.createElement("div", { style: {
|
|
284
|
+
flex: 1,
|
|
285
|
+
overflow: 'hidden',
|
|
286
|
+
textOverflow: 'ellipsis',
|
|
287
|
+
whiteSpace: 'nowrap',
|
|
288
|
+
}, dangerouslySetInnerHTML: { __html: item.string || '' } });
|
|
289
|
+
});
|
|
290
|
+
// 不应包含根节点
|
|
291
|
+
while (parent && !tree_1.CompositeTreeNode.isRoot(parent)) {
|
|
292
|
+
idSets.add(parent.id);
|
|
293
|
+
parent = parent.parent;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
this.filterFlattenBranch = new Array(idSets.size);
|
|
298
|
+
for (let flatTreeIdx = 0, idx = 0; idx < root.branchSize; idx++) {
|
|
299
|
+
const node = root.getTreeNodeAtIndex(idx);
|
|
300
|
+
if (node && idSets.has(node.id)) {
|
|
301
|
+
this.filterFlattenBranch[flatTreeIdx] = node.id;
|
|
302
|
+
if (tree_1.CompositeTreeNode.is(node)) {
|
|
303
|
+
this.idToFilterRendererPropsCache.set(node.id, {
|
|
304
|
+
item: node,
|
|
305
|
+
itemType: types_1.TreeNodeType.CompositeTreeNode,
|
|
306
|
+
template: idToRenderTemplate.has(node.id) ? idToRenderTemplate.get(node.id) : undefined,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
this.idToFilterRendererPropsCache.set(node.id, {
|
|
311
|
+
item: node,
|
|
312
|
+
itemType: types_1.TreeNodeType.TreeNode,
|
|
313
|
+
template: idToRenderTemplate.has(node.id) ? idToRenderTemplate.get(node.id) : undefined,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
flatTreeIdx++;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
// 根据折叠情况变化裁剪filterFlattenBranch
|
|
320
|
+
this.filterWatcherDisposeCollection.push(root.watcher.on(types_1.TreeNodeEvent.DidChangeExpansionState, (target, nowExpanded) => {
|
|
321
|
+
const expandItemIndex = this.filterFlattenBranch.indexOf(target.id);
|
|
322
|
+
if (!nowExpanded) {
|
|
323
|
+
const collapesArray = [];
|
|
324
|
+
for (let i = expandItemIndex + 1; i < this.filterFlattenBranch.length; i++) {
|
|
325
|
+
const node = root.getTreeNodeById(this.filterFlattenBranch[i]);
|
|
326
|
+
if (node && node.depth > target.depth) {
|
|
327
|
+
collapesArray.push(node.id);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
this.filterFlattenBranchChildrenCache.set(target.id, collapesArray);
|
|
334
|
+
this.filterFlattenBranch = (0, tree_1.spliceArray)(this.filterFlattenBranch, expandItemIndex + 1, collapesArray.length);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
const spliceUint32Array = this.filterFlattenBranchChildrenCache.get(target.id);
|
|
338
|
+
if (spliceUint32Array && spliceUint32Array.length > 0) {
|
|
339
|
+
this.filterFlattenBranch = (0, tree_1.spliceArray)(this.filterFlattenBranch, expandItemIndex + 1, 0, spliceUint32Array);
|
|
340
|
+
this.filterFlattenBranchChildrenCache.delete(target.id);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}));
|
|
344
|
+
this.filterWatcherDisposeCollection.push(utils_1.Disposable.create(() => {
|
|
345
|
+
this.filterFlattenBranchChildrenCache.clear();
|
|
346
|
+
}));
|
|
347
|
+
};
|
|
348
|
+
this.renderItem = ({ index, style }) => {
|
|
349
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
350
|
+
this.shouldComponentUpdate = react_window_1.shouldComponentUpdate.bind(this);
|
|
351
|
+
const { children, overflow = 'ellipsis', supportDynamicHeights } = this.props;
|
|
352
|
+
const node = this.getItemAtIndex(index);
|
|
353
|
+
const wrapRef = react_1.default.useRef(null);
|
|
354
|
+
if (!node) {
|
|
355
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
356
|
+
}
|
|
357
|
+
const { item, itemType: type, template } = node;
|
|
358
|
+
if (!item) {
|
|
359
|
+
return react_1.default.createElement("div", { style: style });
|
|
360
|
+
}
|
|
361
|
+
let ariaInfo;
|
|
362
|
+
// ref: https://developers.google.com/web/fundamentals/accessibility/semantics-aria/aria-labels-and-relationships
|
|
363
|
+
if (tree_1.CompositeTreeNode.is(item)) {
|
|
364
|
+
ariaInfo = {
|
|
365
|
+
'aria-label': (_a = item.accessibilityInformation) === null || _a === void 0 ? void 0 : _a.label,
|
|
366
|
+
'aria-expanded': item.expanded,
|
|
367
|
+
'aria-level': item.depth,
|
|
368
|
+
'aria-setsize': (_c = (_b = item.parent) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c.length,
|
|
369
|
+
'aria-posinset': index,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
else if (tree_1.TreeNode.is(item)) {
|
|
373
|
+
ariaInfo = {
|
|
374
|
+
'aria-label': (_d = item.accessibilityInformation) === null || _d === void 0 ? void 0 : _d.label,
|
|
375
|
+
'aria-level': item.depth,
|
|
376
|
+
'aria-setsize': (_f = (_e = item.parent) === null || _e === void 0 ? void 0 : _e.children) === null || _f === void 0 ? void 0 : _f.length,
|
|
377
|
+
'aria-posinset': index,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const calcDynamicHeight = () => {
|
|
381
|
+
if (!supportDynamicHeights) {
|
|
382
|
+
return RecycleTree.DEFAULT_ITEM_HEIGHT;
|
|
383
|
+
}
|
|
384
|
+
let size = 0;
|
|
385
|
+
if (wrapRef.current) {
|
|
386
|
+
const ref = wrapRef.current;
|
|
387
|
+
size = Array.from(ref.children).reduce((pre, cur) => pre + cur.getBoundingClientRect().height, 0);
|
|
388
|
+
}
|
|
389
|
+
if (size) {
|
|
390
|
+
this.dynamicSizeMap.set(index, size);
|
|
391
|
+
}
|
|
392
|
+
return Math.max(size, RecycleTree.DEFAULT_ITEM_HEIGHT);
|
|
393
|
+
};
|
|
394
|
+
const itemStyle = overflow === 'ellipsis' ? style : Object.assign(Object.assign({}, style), { width: 'auto', minWidth: '100%', height: `${calcDynamicHeight()}px` });
|
|
395
|
+
return react_1.default.createElement("div", Object.assign({ ref: wrapRef, style: itemStyle, role: ((_g = item.accessibilityInformation) === null || _g === void 0 ? void 0 : _g.role) || 'treeiem' }, ariaInfo),
|
|
396
|
+
react_1.default.createElement(TreeNodeRendererWrap_1.NodeRendererWrap, { item: item, depth: item.depth, itemType: type, template: template, hasPrompt: !!this.promptHandle && !this.promptHandle.destroyed, expanded: tree_1.CompositeTreeNode.is(item) ? item.expanded : void 0 }, children));
|
|
397
|
+
};
|
|
398
|
+
this.layoutItem = () => {
|
|
399
|
+
if (!this.props.supportDynamicHeights) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (this.listRef && this.listRef.current && '_getRangeToRender' in this.listRef.current) {
|
|
403
|
+
// _getRangeToRender 是 react-window 的内部方法,用于获取可视区域的下标范围
|
|
404
|
+
// @ts-ignore
|
|
405
|
+
const range = this.listRef.current._getRangeToRender();
|
|
406
|
+
if (range) {
|
|
407
|
+
const start = range[0];
|
|
408
|
+
const end = range[1];
|
|
409
|
+
Array.from({ length: end - start }).forEach((_, i) => {
|
|
410
|
+
this.listRef.current.resetAfterIndex(start + i);
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
getNewPromptInsertIndex(startIndex, parent) {
|
|
417
|
+
const { root } = this.props.model;
|
|
418
|
+
let insertIndex = startIndex + 1;
|
|
419
|
+
// 合并文件夹以及深层级子节点
|
|
420
|
+
for (; insertIndex - startIndex <= parent.branchSize; insertIndex++) {
|
|
421
|
+
const node = root.getTreeNodeAtIndex(insertIndex);
|
|
422
|
+
if (!node) {
|
|
423
|
+
return insertIndex;
|
|
424
|
+
}
|
|
425
|
+
if (tree_1.CompositeTreeNode.is(node)) {
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
else if ((node === null || node === void 0 ? void 0 : node.depth) > parent.depth + 1) {
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
return insertIndex;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return insertIndex;
|
|
436
|
+
}
|
|
437
|
+
UNSAFE_componentWillUpdate(prevProps) {
|
|
438
|
+
if (this.props.filter !== prevProps.filter) {
|
|
439
|
+
this.filterItems(prevProps.filter);
|
|
440
|
+
}
|
|
441
|
+
if (this.props.model !== prevProps.model) {
|
|
442
|
+
// model变化时,在渲染前清理缓存
|
|
443
|
+
this.idxToRendererPropsCache.clear();
|
|
444
|
+
this.idToFilterRendererPropsCache.clear();
|
|
445
|
+
this.dynamicSizeMap.clear();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
componentDidUpdate(prevProps) {
|
|
449
|
+
var _a;
|
|
450
|
+
if (this.props.model !== prevProps.model) {
|
|
451
|
+
this.disposables.dispose();
|
|
452
|
+
const { model } = this.props;
|
|
453
|
+
(_a = this.listRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(model.state.scrollOffset);
|
|
454
|
+
this.disposables.push(model.onChange(this.batchUpdate));
|
|
455
|
+
this.disposables.push(model.state.onDidLoadState(() => {
|
|
456
|
+
var _a;
|
|
457
|
+
(_a = this.listRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(model.state.scrollOffset);
|
|
458
|
+
}));
|
|
459
|
+
this.onDidModelChangeEmitter.fire({
|
|
460
|
+
preModel: prevProps.model,
|
|
461
|
+
nextModel: model,
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
async promptNew(pathOrTreeNode, type = types_1.TreeNodeType.TreeNode) {
|
|
466
|
+
var _a;
|
|
467
|
+
const { root } = this.props.model;
|
|
468
|
+
let node = typeof pathOrTreeNode === 'string'
|
|
469
|
+
? await root.getTreeNodeByPath(pathOrTreeNode)
|
|
470
|
+
: pathOrTreeNode;
|
|
471
|
+
if (type !== types_1.TreeNodeType.TreeNode && type !== types_1.TreeNodeType.CompositeTreeNode) {
|
|
472
|
+
throw new TypeError(`Invalid type supplied. Expected 'TreeNodeType.TreeNode' or 'TreeNodeType.CompositeTreeNode', got ${type}`);
|
|
473
|
+
}
|
|
474
|
+
if (!!node && !tree_1.CompositeTreeNode.is(node)) {
|
|
475
|
+
// 获取的子节点如果不是CompositeTreeNode,尝试获取父级节点
|
|
476
|
+
node = node.parent;
|
|
477
|
+
if (!tree_1.CompositeTreeNode.is(node)) {
|
|
478
|
+
throw new TypeError(`Cannot create new prompt at object of type ${typeof node}`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (!node) {
|
|
482
|
+
throw new Error(`Cannot find node at ${pathOrTreeNode}`);
|
|
483
|
+
}
|
|
484
|
+
const promptHandle = new NewPromptHandle_1.NewPromptHandle(type, node);
|
|
485
|
+
this.promptHandle = promptHandle;
|
|
486
|
+
this.promptTargetID = node.id;
|
|
487
|
+
if (node !== root && (!node.expanded || !root.isItemVisibleAtSurface(node))) {
|
|
488
|
+
// 调用setExpanded即会在之后调用batchUpdate函数
|
|
489
|
+
await node.setExpanded(true);
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
await this.batchUpdate();
|
|
493
|
+
}
|
|
494
|
+
if (this.newPromptInsertionIndex >= 0) {
|
|
495
|
+
// 说明已在输入框已在可视区域
|
|
496
|
+
(_a = this.listRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(this.newPromptInsertionIndex);
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
this.tryScrollIntoViewWhileStable(this.promptHandle);
|
|
500
|
+
}
|
|
501
|
+
return this.promptHandle;
|
|
502
|
+
}
|
|
503
|
+
tryScrollIntoView(node, align = 'auto') {
|
|
504
|
+
var _a, _b;
|
|
505
|
+
const { root } = this.props.model;
|
|
506
|
+
if (node.constructor === NewPromptHandle_1.NewPromptHandle && !node.destroyed) {
|
|
507
|
+
(_a = this.listRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(this.newPromptInsertionIndex);
|
|
508
|
+
}
|
|
509
|
+
else if (root.isItemVisibleAtSurface(node)) {
|
|
510
|
+
(_b = this.listRef.current) === null || _b === void 0 ? void 0 : _b.scrollToItem(root.getIndexAtTreeNode(node), align);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
tryScrollIntoViewWhileStable(node, align = 'auto') {
|
|
514
|
+
const { root } = this.props.model;
|
|
515
|
+
if (this.tryEnsureVisibleTimes > RecycleTree.TRY_ENSURE_VISIBLE_MAX_TIMES) {
|
|
516
|
+
this.tryEnsureVisibleTimes = 0;
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
utils_1.Event.once(this.props.model.onChange)(async () => {
|
|
520
|
+
var _a, _b;
|
|
521
|
+
await this.batchUpdatePromise;
|
|
522
|
+
if (node.constructor === NewPromptHandle_1.NewPromptHandle && !node.destroyed) {
|
|
523
|
+
(_a = this.listRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(this.newPromptInsertionIndex);
|
|
524
|
+
}
|
|
525
|
+
else if (root.isItemVisibleAtSurface(node)) {
|
|
526
|
+
(_b = this.listRef.current) === null || _b === void 0 ? void 0 : _b.scrollToItem(root.getIndexAtTreeNode(node), align);
|
|
527
|
+
this.tryEnsureVisibleTimes = 0;
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
this.tryEnsureVisibleTimes++;
|
|
531
|
+
this.tryScrollIntoViewWhileStable(node, align);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
componentDidMount() {
|
|
536
|
+
var _a;
|
|
537
|
+
const { model, onReady } = this.props;
|
|
538
|
+
(_a = this.listRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(model.state.scrollOffset);
|
|
539
|
+
this.disposables.push(model.onChange(this.batchUpdate));
|
|
540
|
+
this.disposables.push(model.state.onDidLoadState(() => {
|
|
541
|
+
var _a;
|
|
542
|
+
(_a = this.listRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(model.state.scrollOffset);
|
|
543
|
+
}));
|
|
544
|
+
if (typeof onReady === 'function') {
|
|
545
|
+
const api = {
|
|
546
|
+
promptNewTreeNode: this.promptNewTreeNode,
|
|
547
|
+
promptNewCompositeTreeNode: this.promptNewCompositeTreeNode,
|
|
548
|
+
promptRename: this.promptRename,
|
|
549
|
+
expandNode: this.expandNode,
|
|
550
|
+
collapseNode: this.collapseNode,
|
|
551
|
+
ensureVisible: this.ensureVisible,
|
|
552
|
+
getModel: () => this.props.model,
|
|
553
|
+
layoutItem: this.layoutItem,
|
|
554
|
+
getCurrentSize: () => ({
|
|
555
|
+
width: this.props.width,
|
|
556
|
+
height: this.props.height,
|
|
557
|
+
}),
|
|
558
|
+
onDidChangeModel: this.onDidModelChangeEmitter.event,
|
|
559
|
+
onDidUpdate: this.onDidUpdateEmitter.event,
|
|
560
|
+
onOnceDidUpdate: utils_1.Event.once(this.onDidUpdateEmitter.event),
|
|
561
|
+
onError: this.onErrorEmitter.event,
|
|
562
|
+
};
|
|
563
|
+
onReady(api);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
componentWillUnmount() {
|
|
567
|
+
this.disposables.dispose();
|
|
568
|
+
}
|
|
569
|
+
set promptHandle(handle) {
|
|
570
|
+
if (this._promptHandle === handle) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (this._promptHandle instanceof prompt_1.PromptHandle && !this._promptHandle.destroyed) {
|
|
574
|
+
this._promptHandle.destroy();
|
|
575
|
+
}
|
|
576
|
+
handle.onDestroy(this.batchUpdate);
|
|
577
|
+
this._promptHandle = handle;
|
|
578
|
+
}
|
|
579
|
+
get promptHandle() {
|
|
580
|
+
return this._promptHandle;
|
|
581
|
+
}
|
|
582
|
+
// 根据是否携带新建输入框计算行数
|
|
583
|
+
get adjustedRowCount() {
|
|
584
|
+
const { root } = this.props.model;
|
|
585
|
+
const { filter } = this.props;
|
|
586
|
+
if (!!filter) {
|
|
587
|
+
return this.filterFlattenBranch.length;
|
|
588
|
+
}
|
|
589
|
+
return (this.newPromptInsertionIndex > -1 &&
|
|
590
|
+
this.promptHandle && this.promptHandle.constructor === NewPromptHandle_1.NewPromptHandle &&
|
|
591
|
+
!this.promptHandle.destroyed)
|
|
592
|
+
? root.branchSize + 1
|
|
593
|
+
: root.branchSize;
|
|
594
|
+
}
|
|
595
|
+
render() {
|
|
596
|
+
const { children, itemHeight, width, height, style, className, placeholder, overScanCount, leaveBottomBlank, supportDynamicHeights, } = this.props;
|
|
597
|
+
if (placeholder && this.adjustedRowCount === 0) {
|
|
598
|
+
const Placeholder = placeholder;
|
|
599
|
+
return react_1.default.createElement(Placeholder, null);
|
|
600
|
+
}
|
|
601
|
+
const addonProps = {
|
|
602
|
+
children,
|
|
603
|
+
height,
|
|
604
|
+
width,
|
|
605
|
+
itemData: [],
|
|
606
|
+
itemCount: this.adjustedRowCount,
|
|
607
|
+
itemKey: this.getItemKey,
|
|
608
|
+
overscanCount: overScanCount || RecycleTree.DEFAULT_OVER_SCAN_COUNT,
|
|
609
|
+
onScroll: this.handleListScroll,
|
|
610
|
+
style: Object.assign({ transform: 'translate3d(0px, 0px, 0px)' }, style),
|
|
611
|
+
className,
|
|
612
|
+
outerElementType: scrollbars_1.ScrollbarsVirtualList,
|
|
613
|
+
};
|
|
614
|
+
if (leaveBottomBlank) {
|
|
615
|
+
addonProps.innerElementType = InnerElementType;
|
|
616
|
+
}
|
|
617
|
+
return (supportDynamicHeights
|
|
618
|
+
? react_1.default.createElement(react_window_1.VariableSizeList, Object.assign({ ref: this.listRef, itemSize: (index) => (this.dynamicSizeMap.get(index) || itemHeight) }, addonProps), this.renderItem)
|
|
619
|
+
: react_1.default.createElement(react_window_1.FixedSizeList, Object.assign({ ref: this.listRef, itemSize: itemHeight }, addonProps), this.renderItem));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
exports.RecycleTree = RecycleTree;
|
|
623
|
+
RecycleTree.PADDING_BOTTOM_SIZE = 22;
|
|
624
|
+
RecycleTree.DEFAULT_ITEM_HEIGHT = 22;
|
|
625
|
+
RecycleTree.BATCHED_UPDATE_MAX_DEBOUNCE_MS = 100;
|
|
626
|
+
RecycleTree.TRY_ENSURE_VISIBLE_MAX_TIMES = 5;
|
|
627
|
+
RecycleTree.FILTER_FUZZY_OPTIONS = {
|
|
628
|
+
pre: '<match>',
|
|
629
|
+
post: '</match>',
|
|
630
|
+
extract: (node) => {
|
|
631
|
+
return (node === null || node === void 0 ? void 0 : node.name) || '';
|
|
632
|
+
},
|
|
633
|
+
};
|
|
634
|
+
RecycleTree.DEFAULT_OVER_SCAN_COUNT = 50;
|
|
635
|
+
//# sourceMappingURL=RecycleTree.js.map
|