@qsxy/element-plus-react 1.0.1 → 1.0.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/Alert/Alert.d.ts +7 -0
- package/dist/Alert/Alert.js +98 -0
- package/dist/Alert/index.d.ts +2 -0
- package/dist/Alert/index.js +1 -0
- package/dist/Alert/typings.d.ts +45 -0
- package/dist/Alert/typings.js +1 -0
- package/dist/Calendar/Calendar.js +12 -3
- package/dist/Calendar/Footer.js +4 -2
- package/dist/Calendar/QuarterPanel.d.ts +4 -0
- package/dist/Calendar/QuarterPanel.js +109 -0
- package/dist/Calendar/WeekPanel.js +1 -1
- package/dist/Calendar/typings.d.ts +1 -1
- package/dist/Card/Card.js +13 -6
- package/dist/Card/typings.d.ts +1 -1
- package/dist/Cascader/Cascader.js +1 -1
- package/dist/Cascader/useCascader.d.ts +0 -14
- package/dist/Cascader/useCascader.js +33 -32
- package/dist/Checkbox/Checkbox.js +3 -2
- package/dist/ConfigProvider/ConfigProvider.js +2 -24
- package/dist/ConfigProvider/ConfigProviderContext.js +1 -1
- package/dist/ConfigProvider/typings.d.ts +1 -1
- package/dist/Container/Main.d.ts +1 -1
- package/dist/Container/typings.d.ts +1 -1
- package/dist/DatePicker/DatePicker.js +38 -12
- package/dist/DatePicker/DateRangePicker.js +27 -9
- package/dist/DatePicker/main.js +1 -1
- package/dist/DatePicker/typings.d.ts +1 -1
- package/dist/DateTimePicker/DateTimePicker.js +2 -2
- package/dist/Dialog/Dialog.js +5 -12
- package/dist/Input/Input.js +190 -149
- package/dist/Input/InputRange.js +1 -1
- package/dist/Input/TextArea.js +87 -12
- package/dist/Input/typings.d.ts +56 -5
- package/dist/Input/useComposition.d.ts +23 -0
- package/dist/Input/useComposition.js +63 -0
- package/dist/Input/utils.d.ts +7 -0
- package/dist/Input/utils.js +95 -0
- package/dist/InputNumber/InputNumber.js +351 -141
- package/dist/InputNumber/typings.d.ts +16 -2
- package/dist/Loading/Loading.js +5 -2
- package/dist/Menu/Menu.js +25 -1
- package/dist/Menu/MenuItem.js +4 -2
- package/dist/Menu/SubMenu.js +2 -2
- package/dist/Menu/SubMenuCollapseTransition.js +14 -9
- package/dist/Menu/typings.d.ts +2 -1
- package/dist/Message/Message.js +51 -23
- package/dist/Message/index.js +8 -10
- package/dist/Message/typings.d.ts +8 -5
- package/dist/MessageBox/MessageBox.js +52 -30
- package/dist/MessageBox/index.d.ts +2 -1
- package/dist/MessageBox/index.js +4 -2
- package/dist/MessageBox/typings.d.ts +3 -0
- package/dist/Notification/Notification.js +26 -19
- package/dist/Select/Option.js +30 -14
- package/dist/Select/SelectContext.d.ts +5 -5
- package/dist/Select/SelectContext.js +2 -1
- package/dist/Select/SelectCore.d.ts +2 -2
- package/dist/Select/SelectCore.js +172 -449
- package/dist/Select/SelectDropdown.js +85 -155
- package/dist/Select/index.d.ts +1 -1
- package/dist/Select/typings.d.ts +52 -22
- package/dist/Select/useSelect.d.ts +128 -0
- package/dist/Select/useSelect.js +524 -0
- package/dist/Space/Space.d.ts +4 -0
- package/dist/Space/Space.js +128 -0
- package/dist/Space/SpaceItem.d.ts +7 -0
- package/dist/Space/SpaceItem.js +14 -0
- package/dist/Space/index.d.ts +3 -0
- package/dist/Space/index.js +2 -0
- package/dist/Space/typings.d.ts +26 -0
- package/dist/Space/typings.js +1 -0
- package/dist/Space/useSpace.d.ts +7 -0
- package/dist/Space/useSpace.js +104 -0
- package/dist/Statistic/Statistic.d.ts +4 -0
- package/dist/Statistic/Statistic.js +92 -0
- package/dist/Statistic/index.d.ts +2 -0
- package/dist/Statistic/index.js +1 -0
- package/dist/Statistic/typings.d.ts +28 -0
- package/dist/Statistic/typings.js +1 -0
- package/dist/Switch/Switch.js +2 -2
- package/dist/Table/Table.js +3 -0
- package/dist/Table/typings.d.ts +2 -0
- package/dist/Table/util.js +6 -5
- package/dist/Tag/Tag.js +22 -17
- package/dist/Tag/typings.d.ts +1 -1
- package/dist/Text/Text.d.ts +4 -0
- package/dist/Text/Text.js +84 -0
- package/dist/Text/index.d.ts +2 -0
- package/dist/Text/index.js +1 -0
- package/dist/Text/typings.d.ts +15 -0
- package/dist/Text/typings.js +1 -0
- package/dist/TimePicker/TimePicker.js +2 -2
- package/dist/Tree/CollapseTransition.d.ts +7 -0
- package/dist/Tree/CollapseTransition.js +60 -0
- package/dist/Tree/Tree.d.ts +3 -140
- package/dist/Tree/Tree.js +350 -77
- package/dist/Tree/TreeContext.d.ts +9 -0
- package/dist/Tree/TreeContext.js +14 -0
- package/dist/Tree/TreeNode.d.ts +5 -3
- package/dist/Tree/TreeNode.js +321 -331
- package/dist/Tree/TreeNodeContent.d.ts +9 -0
- package/dist/Tree/TreeNodeContent.js +22 -0
- package/dist/Tree/index.d.ts +3 -8
- package/dist/Tree/index.js +1 -4
- package/dist/Tree/model/node.d.ts +62 -0
- package/dist/Tree/model/node.js +601 -0
- package/dist/Tree/model/tree-store.d.ts +52 -0
- package/dist/Tree/model/tree-store.js +510 -0
- package/dist/Tree/model/useDragNode.d.ts +30 -0
- package/dist/Tree/model/useDragNode.js +293 -0
- package/dist/Tree/model/useKeydown.d.ts +0 -0
- package/dist/Tree/model/useKeydown.js +104 -0
- package/dist/Tree/model/useNodeExpandEventBroadcast.d.ts +15 -0
- package/dist/Tree/model/useNodeExpandEventBroadcast.js +54 -0
- package/dist/Tree/model/util.d.ts +7 -0
- package/dist/Tree/model/util.js +24 -0
- package/dist/Tree/typings.d.ts +225 -114
- package/dist/TreeSelect/TreeSelect.d.ts +2 -10
- package/dist/TreeSelect/TreeSelect.js +90 -566
- package/dist/TreeSelect/TreeSelectOption.d.ts +6 -0
- package/dist/TreeSelect/TreeSelectOption.js +62 -0
- package/dist/TreeSelect/cacheOptions.d.ts +9 -0
- package/dist/TreeSelect/cacheOptions.js +22 -0
- package/dist/TreeSelect/index.d.ts +0 -1
- package/dist/TreeSelect/typings.d.ts +11 -63
- package/dist/TreeSelect/useSelect.d.ts +125 -0
- package/dist/TreeSelect/useSelect.js +104 -0
- package/dist/TreeSelect/useTree.d.ts +130 -0
- package/dist/TreeSelect/useTree.js +285 -0
- package/dist/TreeSelect/utils.d.ts +10 -0
- package/dist/TreeSelect/utils.js +38 -0
- package/dist/Upload/UploadContent.js +2 -0
- package/dist/Upload/ajax.js +3 -0
- package/dist/Upload/typings.d.ts +4 -0
- package/dist/Util/aria.d.ts +25 -0
- package/dist/Util/aria.js +118 -0
- package/dist/Util/base.d.ts +5 -0
- package/dist/Util/base.js +140 -1
- package/dist/config/Constants.d.ts +3 -0
- package/dist/config/Constants.js +8 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/popperPropsUtils.js +1 -1
- package/dist/hooks/treePropsUtils.d.ts +3 -3
- package/dist/hooks/treePropsUtils.js +2 -2
- package/dist/hooks/useCalcInputWidth.d.ts +8 -0
- package/dist/{Tree/useUnmount.js → hooks/useCalcInputWidth.js} +23 -27
- package/dist/hooks/useComposition.d.ts +16 -0
- package/dist/hooks/useComposition.js +39 -0
- package/dist/hooks/useConfigProvider.d.ts +27 -0
- package/dist/hooks/useConfigProvider.js +78 -0
- package/dist/hooks/useCursor.d.ts +2 -0
- package/dist/hooks/useCursor.js +52 -0
- package/dist/hooks/useFocusController.d.ts +27 -0
- package/dist/hooks/useFocusController.js +72 -0
- package/dist/hooks/useResizeObserver.js +6 -6
- package/dist/index.css +1 -1
- package/dist/index.d.ts +18 -11
- package/dist/index.js +11 -5
- package/dist/locale/en.d.ts +15 -0
- package/dist/locale/en.js +15 -0
- package/dist/locale/zhCn.d.ts +15 -0
- package/dist/locale/zhCn.js +15 -0
- package/package.json +1 -1
- package/theme-chalk/alert.scss +115 -0
- package/theme-chalk/aside.scss +8 -8
- package/theme-chalk/button-group.scss +80 -80
- package/theme-chalk/button.scss +304 -304
- package/theme-chalk/calendar/date-table.scss +164 -164
- package/theme-chalk/calendar/index.scss +1 -0
- package/theme-chalk/calendar/quarter-table.scss +78 -0
- package/theme-chalk/checkbox.scss +34 -0
- package/theme-chalk/color/index.scss +20 -20
- package/theme-chalk/common/transition.scss +142 -142
- package/theme-chalk/common/var.scss +1 -1
- package/theme-chalk/container.scss +14 -14
- package/theme-chalk/dark/css-vars.scss +39 -39
- package/theme-chalk/dark/var.scss +225 -225
- package/theme-chalk/date-picker.scss +12 -12
- package/theme-chalk/drawer.scss +1 -0
- package/theme-chalk/footer.scss +12 -12
- package/theme-chalk/header.scss +12 -12
- package/theme-chalk/index.scss +4 -0
- package/theme-chalk/input/input-range.scss +2 -1
- package/theme-chalk/input/input.scss +298 -437
- package/theme-chalk/input/input.scss--bak +578 -0
- package/theme-chalk/input-number.bak +172 -0
- package/theme-chalk/input-number.scss +192 -172
- package/theme-chalk/link.scss +87 -87
- package/theme-chalk/main.scss +14 -14
- package/theme-chalk/menu.scss +353 -353
- package/theme-chalk/message.scss +104 -178
- package/theme-chalk/mixins/_button.scss +224 -224
- package/theme-chalk/mixins/_col.scss +33 -33
- package/theme-chalk/mixins/_var.scss +67 -67
- package/theme-chalk/mixins/config.scss +5 -5
- package/theme-chalk/mixins/function.scss +99 -99
- package/theme-chalk/mixins/mixins.scss +240 -240
- package/theme-chalk/mixins/utils.scss +39 -39
- package/theme-chalk/notification.bak +156 -0
- package/theme-chalk/notification.scss +109 -156
- package/theme-chalk/popper.scss +104 -104
- package/theme-chalk/radio-button.scss +169 -169
- package/theme-chalk/select/index.scss +222 -191
- package/theme-chalk/select/index.scss--bak +247 -0
- package/theme-chalk/select/option-group.scss +2 -2
- package/theme-chalk/select/option.scss +2 -2
- package/theme-chalk/select/select-dropdown.scss +2 -2
- package/theme-chalk/space.scss +20 -0
- package/theme-chalk/statistic.scss +35 -0
- package/theme-chalk/switch.scss +300 -300
- package/theme-chalk/tag.scss +150 -172
- package/theme-chalk/tag.scss--bak +203 -0
- package/theme-chalk/text.scss +48 -0
- package/theme-chalk/transition.scss +34 -4
- package/theme-chalk/tree-select.scss +41 -25
- package/theme-chalk/tree.scss +136 -0
- package/theme-chalk/var.scss +83 -83
- package/dist/Tree/DirectoryTree.d.ts +0 -15
- package/dist/Tree/DirectoryTree.js +0 -183
- package/dist/Tree/DropIndicator.d.ts +0 -8
- package/dist/Tree/DropIndicator.js +0 -34
- package/dist/Tree/Indent.d.ts +0 -9
- package/dist/Tree/Indent.js +0 -25
- package/dist/Tree/MotionTreeNode.d.ts +0 -14
- package/dist/Tree/MotionTreeNode.js +0 -125
- package/dist/Tree/NodeList.d.ts +0 -50
- package/dist/Tree/NodeList.js +0 -301
- package/dist/Tree/RCTree.d.ts +0 -248
- package/dist/Tree/RCTree.js +0 -1216
- package/dist/Tree/contextTypes.d.ts +0 -69
- package/dist/Tree/contextTypes.js +0 -9
- package/dist/Tree/typings.tsx--bak +0 -245
- package/dist/Tree/useUnmount.d.ts +0 -5
- package/dist/Tree/util.d.ts +0 -51
- package/dist/Tree/util.js +0 -303
- package/dist/Tree/utils/conductUtil.d.ts +0 -17
- package/dist/Tree/utils/conductUtil.js +0 -209
- package/dist/Tree/utils/dictUtil.d.ts +0 -13
- package/dist/Tree/utils/dictUtil.js +0 -75
- package/dist/Tree/utils/diffUtil.d.ts +0 -7
- package/dist/Tree/utils/diffUtil.js +0 -48
- package/dist/Tree/utils/dropIndicator.d.ts +0 -11
- package/dist/Tree/utils/dropIndicator.js +0 -36
- package/dist/Tree/utils/iconUtil.d.ts +0 -5
- package/dist/Tree/utils/iconUtil.js +0 -62
- package/dist/Tree/utils/keyUtil.d.ts +0 -2
- package/dist/Tree/utils/keyUtil.js +0 -3
- package/dist/Tree/utils/motion.d.ts +0 -10
- package/dist/Tree/utils/motion.js +0 -54
- package/dist/Tree/utils/pickAttrs.d.ts +0 -11
- package/dist/Tree/utils/pickAttrs.js +0 -51
- package/dist/Tree/utils/treeUtil.d.ts +0 -86
- package/dist/Tree/utils/treeUtil.js +0 -364
- package/dist/TreeSelect/Utils.d.ts +0 -3
- package/dist/TreeSelect/Utils.js +0 -20
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webpack has bug for import loop, which is not the same behavior as ES module.
|
|
3
|
-
* When util.js imports the TreeNode for tree generate will cause treeContextTypes be empty.
|
|
4
|
-
*/
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import type { DraggableConfig, SemanticName } from './RCTree';
|
|
7
|
-
import type { BasicDataNode, DataNode, Direction, EventDataNode, IconType, Key, KeyEntities, TreeNodeProps } from './typings';
|
|
8
|
-
export type NodeMouseEventParams<TreeDataType extends BasicDataNode = DataNode, T = HTMLSpanElement> = {
|
|
9
|
-
event: React.MouseEvent<T>;
|
|
10
|
-
node: EventDataNode<TreeDataType>;
|
|
11
|
-
};
|
|
12
|
-
export type NodeDragEventParams<TreeDataType extends BasicDataNode = DataNode, T = HTMLDivElement> = {
|
|
13
|
-
event: React.DragEvent<T>;
|
|
14
|
-
node: EventDataNode<TreeDataType>;
|
|
15
|
-
};
|
|
16
|
-
export type NodeMouseEventHandler<TreeDataType extends BasicDataNode = DataNode, T = HTMLSpanElement> = (e: React.MouseEvent<T>, node: EventDataNode<TreeDataType>) => void;
|
|
17
|
-
export type NodeDragEventHandler<TreeDataType extends BasicDataNode = DataNode, T = HTMLDivElement> = (e: React.DragEvent<T>, nodeProps: TreeNodeProps<TreeDataType>, outsideTree?: boolean) => void;
|
|
18
|
-
export interface TreeContextProps<TreeDataType extends BasicDataNode = DataNode> {
|
|
19
|
-
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
20
|
-
classNames?: Partial<Record<SemanticName, string>>;
|
|
21
|
-
prefixCls: string;
|
|
22
|
-
selectable: boolean;
|
|
23
|
-
showIcon: boolean;
|
|
24
|
-
icon: IconType;
|
|
25
|
-
switcherIcon: IconType;
|
|
26
|
-
draggable?: DraggableConfig;
|
|
27
|
-
draggingNodeKey?: Key;
|
|
28
|
-
checkable: boolean | React.ReactNode;
|
|
29
|
-
checkStrictly: boolean;
|
|
30
|
-
disabled: boolean;
|
|
31
|
-
keyEntities: KeyEntities;
|
|
32
|
-
dropLevelOffset?: number;
|
|
33
|
-
dropContainerKey: Key | null;
|
|
34
|
-
dropTargetKey: Key | null;
|
|
35
|
-
dropPosition: -1 | 0 | 1 | null;
|
|
36
|
-
indent: number | null;
|
|
37
|
-
dropIndicatorRender: (props: {
|
|
38
|
-
dropPosition: -1 | 0 | 1;
|
|
39
|
-
dropLevelOffset: number;
|
|
40
|
-
indent: number;
|
|
41
|
-
prefixCls: string;
|
|
42
|
-
direction: Direction;
|
|
43
|
-
}) => React.ReactNode;
|
|
44
|
-
dragOverNodeKey: Key | null;
|
|
45
|
-
direction: Direction;
|
|
46
|
-
loadData: (treeNode: EventDataNode<TreeDataType>) => Promise<void>;
|
|
47
|
-
filterTreeNode: (treeNode: EventDataNode<TreeDataType>) => boolean;
|
|
48
|
-
titleRender?: (node: any) => React.ReactNode;
|
|
49
|
-
onNodeClick: NodeMouseEventHandler<TreeDataType>;
|
|
50
|
-
onNodeDoubleClick: NodeMouseEventHandler<TreeDataType>;
|
|
51
|
-
onNodeExpand: NodeMouseEventHandler<TreeDataType>;
|
|
52
|
-
onNodeSelect: NodeMouseEventHandler<TreeDataType>;
|
|
53
|
-
onNodeCheck: (e: React.MouseEvent<HTMLSpanElement>, treeNode: EventDataNode<TreeDataType>, checked: boolean) => void;
|
|
54
|
-
onNodeLoad: (treeNode: EventDataNode<TreeDataType>) => void;
|
|
55
|
-
onNodeMouseEnter: NodeMouseEventHandler<TreeDataType>;
|
|
56
|
-
onNodeMouseLeave: NodeMouseEventHandler<TreeDataType>;
|
|
57
|
-
onNodeContextMenu: NodeMouseEventHandler<TreeDataType>;
|
|
58
|
-
onNodeDragStart: NodeDragEventHandler<any, any>;
|
|
59
|
-
onNodeDragEnter: NodeDragEventHandler<any, any>;
|
|
60
|
-
onNodeDragOver: NodeDragEventHandler<any, any>;
|
|
61
|
-
onNodeDragLeave: NodeDragEventHandler<any, any>;
|
|
62
|
-
onNodeDragEnd: NodeDragEventHandler<any, any>;
|
|
63
|
-
onNodeDrop: NodeDragEventHandler<any, any>;
|
|
64
|
-
}
|
|
65
|
-
export declare const TreeContext: React.Context<TreeContextProps<any>>;
|
|
66
|
-
/** Internal usage, safe to remove. Do not use in prod */
|
|
67
|
-
export declare const UnstableContext: React.Context<{
|
|
68
|
-
nodeDisabled?: (n: DataNode) => boolean;
|
|
69
|
-
}>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webpack has bug for import loop, which is not the same behavior as ES module.
|
|
3
|
-
* When util.js imports the TreeNode for tree generate will cause treeContextTypes be empty.
|
|
4
|
-
*/
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
export var TreeContext = /*#__PURE__*/React.createContext(null);
|
|
7
|
-
|
|
8
|
-
/** Internal usage, safe to remove. Do not use in prod */
|
|
9
|
-
export var UnstableContext = /*#__PURE__*/React.createContext({});
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import { IconName } from '../Icon';
|
|
3
|
-
import { TreeProps as RcTreeProps } from './RCTree';
|
|
4
|
-
import { TreeNodeProps } from './TreeNode';
|
|
5
|
-
|
|
6
|
-
export interface AntdTreeNodeAttribute {
|
|
7
|
-
eventKey: string;
|
|
8
|
-
prefixCls: string;
|
|
9
|
-
className: string;
|
|
10
|
-
expanded: boolean;
|
|
11
|
-
selected: boolean;
|
|
12
|
-
checked: boolean;
|
|
13
|
-
halfChecked: boolean;
|
|
14
|
-
children: React.ReactElement;
|
|
15
|
-
title: React.ReactElement;
|
|
16
|
-
pos: string;
|
|
17
|
-
dragOver: boolean;
|
|
18
|
-
dragOverGapTop: boolean;
|
|
19
|
-
dragOverGapBottom: boolean;
|
|
20
|
-
isLeaf: boolean;
|
|
21
|
-
selectable: boolean;
|
|
22
|
-
disabled: boolean;
|
|
23
|
-
disableCheckbox: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface AntTreeNodeProps {
|
|
27
|
-
className?: string;
|
|
28
|
-
checkable?: boolean;
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
disableCheckbox?: boolean;
|
|
31
|
-
title?: string | React.ReactElement;
|
|
32
|
-
key?: Key;
|
|
33
|
-
eventKey?: string;
|
|
34
|
-
isLeaf?: boolean;
|
|
35
|
-
checked?: boolean;
|
|
36
|
-
expanded?: boolean;
|
|
37
|
-
loading?: boolean;
|
|
38
|
-
selected?: boolean;
|
|
39
|
-
selectable?: boolean;
|
|
40
|
-
icon?: ((treeNode: AntdTreeNodeAttribute) => React.ReactElement) | React.ReactElement;
|
|
41
|
-
children?: React.ReactElement;
|
|
42
|
-
[customProp: string]: any;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type AntTreeNode = Component<AntTreeNodeProps, {}>;
|
|
46
|
-
|
|
47
|
-
export interface AntTreeNodeBaseEvent {
|
|
48
|
-
node: AntTreeNode;
|
|
49
|
-
nativeEvent: MouseEvent;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface AntTreeNodeCheckedEvent extends AntTreeNodeBaseEvent {
|
|
53
|
-
event: 'check';
|
|
54
|
-
checked?: boolean;
|
|
55
|
-
checkedNodes?: AntTreeNode[];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface AntTreeNodeSelectedEvent extends AntTreeNodeBaseEvent {
|
|
59
|
-
event: 'select';
|
|
60
|
-
selected?: boolean;
|
|
61
|
-
selectedNodes?: DataNode[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface AntTreeNodeExpandedEvent extends AntTreeNodeBaseEvent {
|
|
65
|
-
expanded?: boolean;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface AntTreeNodeMouseEvent {
|
|
69
|
-
node: AntTreeNode;
|
|
70
|
-
event: any;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface AntTreeNodeDragEnterEvent extends AntTreeNodeMouseEvent {
|
|
74
|
-
expandedKeys: Key[];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface AntTreeNodeDropEvent {
|
|
78
|
-
node: AntTreeNode;
|
|
79
|
-
dragNode: AntTreeNode;
|
|
80
|
-
dragNodesKeys: Key[];
|
|
81
|
-
dropPosition: number;
|
|
82
|
-
dropToGap?: boolean;
|
|
83
|
-
event: React.MouseEventHandler<HTMLElement>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// [Legacy] Compatible for v3
|
|
87
|
-
export type TreeNodeNormal = DataNode;
|
|
88
|
-
|
|
89
|
-
type DraggableFn = (node: AntTreeNode) => boolean;
|
|
90
|
-
interface DraggableConfig {
|
|
91
|
-
icon?: React.ReactElement | false;
|
|
92
|
-
nodeDraggable?: DraggableFn;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface TreeProps<T> extends Omit<RcTreeProps<T>, 'prefixCls' | 'showLine' | 'direction' | 'draggable'> {
|
|
96
|
-
showLine?: boolean | { showLeafIcon: boolean };
|
|
97
|
-
className?: string;
|
|
98
|
-
|
|
99
|
-
/** 是否支持多选 */
|
|
100
|
-
multiple?: boolean;
|
|
101
|
-
|
|
102
|
-
/** 是否自动展开父节点 */
|
|
103
|
-
autoExpandParent?: boolean;
|
|
104
|
-
|
|
105
|
-
/** Checkable状态下节点选择完全受控(父子节点选中状态不再关联) */
|
|
106
|
-
checkStrictly?: boolean;
|
|
107
|
-
|
|
108
|
-
/** 是否支持选中 */
|
|
109
|
-
checkable?: boolean;
|
|
110
|
-
|
|
111
|
-
/** 是否禁用树 */
|
|
112
|
-
disabled?: boolean;
|
|
113
|
-
|
|
114
|
-
/** 默认展开所有树节点 */
|
|
115
|
-
defaultExpandAll?: boolean;
|
|
116
|
-
|
|
117
|
-
/** 默认展开对应树节点 */
|
|
118
|
-
defaultExpandParent?: boolean;
|
|
119
|
-
|
|
120
|
-
/** 默认展开指定的树节点 */
|
|
121
|
-
defaultExpandedKeys?: Key[];
|
|
122
|
-
|
|
123
|
-
/** (受控)展开指定的树节点 */
|
|
124
|
-
expandedKeys?: Key[];
|
|
125
|
-
|
|
126
|
-
/** (受控)选中复选框的树节点 */
|
|
127
|
-
checkedKeys?: Key[] | { checked: Key[]; halfChecked: Key[] };
|
|
128
|
-
|
|
129
|
-
/** 默认选中复选框的树节点 */
|
|
130
|
-
defaultCheckedKeys?: Key[];
|
|
131
|
-
|
|
132
|
-
/** (受控)设置选中的树节点 */
|
|
133
|
-
selectedKeys?: Key[];
|
|
134
|
-
|
|
135
|
-
/** 默认选中的树节点 */
|
|
136
|
-
defaultSelectedKeys?: Key[];
|
|
137
|
-
selectable?: boolean;
|
|
138
|
-
|
|
139
|
-
/** 点击树节点触发 */
|
|
140
|
-
filterAntTreeNode?: (node: AntTreeNode) => boolean;
|
|
141
|
-
loadedKeys?: Key[];
|
|
142
|
-
|
|
143
|
-
/** 设置节点可拖拽(IE>8) */
|
|
144
|
-
draggable?: DraggableFn | boolean | DraggableConfig;
|
|
145
|
-
style?: React.CSSProperties;
|
|
146
|
-
showIcon?: boolean;
|
|
147
|
-
icon?: ((nodeProps: AntdTreeNodeAttribute) => React.ReactElement) | React.ReactElement;
|
|
148
|
-
switcherIcon?: React.ReactElement<any>;
|
|
149
|
-
prefixCls?: string;
|
|
150
|
-
children?: React.ReactElement;
|
|
151
|
-
blockNode?: boolean;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/** For fieldNames, we provides a abstract interface */
|
|
155
|
-
export interface BasicDataNode {
|
|
156
|
-
checkable?: boolean;
|
|
157
|
-
disabled?: boolean;
|
|
158
|
-
disableCheckbox?: boolean;
|
|
159
|
-
icon?: IconType;
|
|
160
|
-
isLeaf?: boolean;
|
|
161
|
-
selectable?: boolean;
|
|
162
|
-
switcherIcon?: IconType;
|
|
163
|
-
|
|
164
|
-
/** Set style of TreeNode. This is not recommend if you don't have any force requirement */
|
|
165
|
-
className?: string;
|
|
166
|
-
style?: React.CSSProperties;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface DataNode<T = any> extends BasicDataNode {
|
|
170
|
-
children?: T[];
|
|
171
|
-
key?: string | number;
|
|
172
|
-
title?: string | React.ReactElement;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export interface EventDataNode extends DataNode {
|
|
176
|
-
expanded: boolean;
|
|
177
|
-
selected: boolean;
|
|
178
|
-
checked: boolean;
|
|
179
|
-
loaded: boolean;
|
|
180
|
-
loading: boolean;
|
|
181
|
-
halfChecked: boolean;
|
|
182
|
-
dragOver: boolean;
|
|
183
|
-
dragOverGapTop: boolean;
|
|
184
|
-
dragOverGapBottom: boolean;
|
|
185
|
-
pos: string;
|
|
186
|
-
active: boolean;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export type IconType = React.ReactElement | ((props: TreeNodeProps) => React.ReactElement) | IconName;
|
|
190
|
-
|
|
191
|
-
export type Key = React.Key;
|
|
192
|
-
|
|
193
|
-
export type NodeElement = React.ReactElement<TreeNodeProps> & {
|
|
194
|
-
selectHandle?: HTMLSpanElement;
|
|
195
|
-
type: {
|
|
196
|
-
isTreeNode: boolean;
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export type NodeInstance<TreeDataType extends BasicDataNode = DataNode> = Component<TreeNodeProps<TreeDataType>> & {
|
|
201
|
-
selectHandle?: HTMLSpanElement;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export interface Entity {
|
|
205
|
-
node: NodeElement;
|
|
206
|
-
index: number;
|
|
207
|
-
key: Key;
|
|
208
|
-
pos: string;
|
|
209
|
-
parent?: Entity;
|
|
210
|
-
children?: Entity[];
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export interface DataEntity<TreeDataType extends BasicDataNode = DataNode> extends Omit<Entity, 'node' | 'parent' | 'children'> {
|
|
214
|
-
node: TreeDataType;
|
|
215
|
-
nodes: TreeDataType[];
|
|
216
|
-
parent?: DataEntity<TreeDataType>;
|
|
217
|
-
children?: DataEntity<TreeDataType>[];
|
|
218
|
-
level: number;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export interface FlattenNode {
|
|
222
|
-
parent: FlattenNode | null;
|
|
223
|
-
children: FlattenNode[];
|
|
224
|
-
pos: string;
|
|
225
|
-
data: DataNode;
|
|
226
|
-
title: React.ReactElement;
|
|
227
|
-
key: Key;
|
|
228
|
-
isStart: boolean[];
|
|
229
|
-
isEnd: boolean[];
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export type GetKey<RecordType> = (record: RecordType, index?: number) => Key;
|
|
233
|
-
|
|
234
|
-
export type GetCheckDisabled<RecordType> = (record: RecordType) => boolean;
|
|
235
|
-
|
|
236
|
-
export type Direction = 'ltr' | 'rtl' | undefined;
|
|
237
|
-
|
|
238
|
-
export interface FieldNames {
|
|
239
|
-
title?: string;
|
|
240
|
-
|
|
241
|
-
/** @private Internal usage for `rc-tree-select`, safe to remove if no need */
|
|
242
|
-
_title?: string[];
|
|
243
|
-
key?: string;
|
|
244
|
-
children?: string;
|
|
245
|
-
}
|
package/dist/Tree/util.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Legacy code. Should avoid to use if you are new to import these code.
|
|
3
|
-
*/
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import type { AllowDrop, TreeProps } from './RCTree';
|
|
6
|
-
import type { BasicDataNode, DataEntity, DataNode, Direction, FlattenNode, Key, KeyEntities, NodeElement, TreeNodeProps } from './typings';
|
|
7
|
-
export { getPosition, isTreeNode } from './utils/treeUtil';
|
|
8
|
-
export declare function arrDel(list: Key[], value: Key): React.Key[];
|
|
9
|
-
export declare function arrAdd(list: Key[], value: Key): React.Key[];
|
|
10
|
-
export declare function posToArr(pos: string): string[];
|
|
11
|
-
export declare function getDragChildrenKeys<TreeDataType extends BasicDataNode = DataNode>(dragNodeKey: Key, keyEntities: KeyEntities<TreeDataType>): Key[];
|
|
12
|
-
export declare function isLastChild<TreeDataType extends BasicDataNode = DataNode>(treeNodeEntity: DataEntity<TreeDataType>): boolean;
|
|
13
|
-
export declare function isFirstChild<TreeDataType extends BasicDataNode = DataNode>(treeNodeEntity: DataEntity<TreeDataType>): boolean;
|
|
14
|
-
export declare function calcDropPosition<TreeDataType extends BasicDataNode = DataNode>(event: React.MouseEvent, dragNodeProps: TreeNodeProps<TreeDataType>, targetNodeProps: TreeNodeProps<TreeDataType>, indent: number, startMousePosition: {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
}, allowDrop: AllowDrop<TreeDataType>, flattenedNodes: FlattenNode<TreeDataType>[], keyEntities: KeyEntities<TreeDataType>, expandKeys: Key[], direction: Direction): {
|
|
18
|
-
dropPosition: -1 | 0 | 1;
|
|
19
|
-
dropLevelOffset: number;
|
|
20
|
-
dropTargetKey: Key;
|
|
21
|
-
dropTargetPos: string;
|
|
22
|
-
dropContainerKey: Key;
|
|
23
|
-
dragOverNodeKey: Key;
|
|
24
|
-
dropAllowed: boolean;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Return selectedKeys according with multiple prop
|
|
28
|
-
* @param selectedKeys
|
|
29
|
-
* @param props
|
|
30
|
-
* @returns [string]
|
|
31
|
-
*/
|
|
32
|
-
export declare function calcSelectedKeys(selectedKeys: Key[], props: TreeProps): React.Key[];
|
|
33
|
-
export declare function convertDataToTree(treeData: DataNode[], processor?: {
|
|
34
|
-
processProps: (prop: DataNode) => any;
|
|
35
|
-
}): NodeElement[];
|
|
36
|
-
/**
|
|
37
|
-
* Parse `checkedKeys` to { checkedKeys, halfCheckedKeys } style
|
|
38
|
-
*/
|
|
39
|
-
export declare function parseCheckedKeys(keys: Key[] | {
|
|
40
|
-
checked: Key[];
|
|
41
|
-
halfChecked: Key[];
|
|
42
|
-
}): {
|
|
43
|
-
checkedKeys?: Key[];
|
|
44
|
-
halfCheckedKeys?: Key[];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* If user use `autoExpandParent` we should get the list of parent node
|
|
48
|
-
* @param keyList
|
|
49
|
-
* @param keyEntities
|
|
50
|
-
*/
|
|
51
|
-
export declare function conductExpandParent(keyList: Key[], keyEntities: KeyEntities): Key[];
|
package/dist/Tree/util.js
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
var _excluded = ["children"];
|
|
2
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
10
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
11
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
-
/* eslint-disable no-lonely-if */
|
|
13
|
-
/**
|
|
14
|
-
* Legacy code. Should avoid to use if you are new to import these code.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import warning from 'rc-util/lib/warning';
|
|
18
|
-
import React from 'react';
|
|
19
|
-
import TreeNode from "./TreeNode";
|
|
20
|
-
import getEntity from "./utils/keyUtil";
|
|
21
|
-
export { getPosition, isTreeNode } from "./utils/treeUtil";
|
|
22
|
-
export function arrDel(list, value) {
|
|
23
|
-
if (!list) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
var clone = list.slice();
|
|
27
|
-
var index = clone.indexOf(value);
|
|
28
|
-
if (index >= 0) {
|
|
29
|
-
clone.splice(index, 1);
|
|
30
|
-
}
|
|
31
|
-
return clone;
|
|
32
|
-
}
|
|
33
|
-
export function arrAdd(list, value) {
|
|
34
|
-
var clone = (list || []).slice();
|
|
35
|
-
if (clone.indexOf(value) === -1) {
|
|
36
|
-
clone.push(value);
|
|
37
|
-
}
|
|
38
|
-
return clone;
|
|
39
|
-
}
|
|
40
|
-
export function posToArr(pos) {
|
|
41
|
-
return pos.split('-');
|
|
42
|
-
}
|
|
43
|
-
export function getDragChildrenKeys(dragNodeKey, keyEntities) {
|
|
44
|
-
// not contains self
|
|
45
|
-
// self for left or right drag
|
|
46
|
-
var dragChildrenKeys = [];
|
|
47
|
-
var entity = getEntity(keyEntities, dragNodeKey);
|
|
48
|
-
function dig() {
|
|
49
|
-
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
50
|
-
list.forEach(function (_ref) {
|
|
51
|
-
var key = _ref.key,
|
|
52
|
-
children = _ref.children;
|
|
53
|
-
dragChildrenKeys.push(key);
|
|
54
|
-
dig(children);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
dig(entity.children);
|
|
58
|
-
return dragChildrenKeys;
|
|
59
|
-
}
|
|
60
|
-
export function isLastChild(treeNodeEntity) {
|
|
61
|
-
if (treeNodeEntity.parent) {
|
|
62
|
-
var posArr = posToArr(treeNodeEntity.pos);
|
|
63
|
-
return Number(posArr[posArr.length - 1]) === treeNodeEntity.parent.children.length - 1;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
export function isFirstChild(treeNodeEntity) {
|
|
68
|
-
var posArr = posToArr(treeNodeEntity.pos);
|
|
69
|
-
return Number(posArr[posArr.length - 1]) === 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Only used when drag, not affect SSR.
|
|
73
|
-
export function calcDropPosition(event, dragNodeProps, targetNodeProps, indent, startMousePosition, allowDrop, flattenedNodes, keyEntities, expandKeys, direction) {
|
|
74
|
-
var _abstractDropNodeEnti;
|
|
75
|
-
var clientX = event.clientX,
|
|
76
|
-
clientY = event.clientY;
|
|
77
|
-
var _getBoundingClientRec = event.target.getBoundingClientRect(),
|
|
78
|
-
top = _getBoundingClientRec.top,
|
|
79
|
-
height = _getBoundingClientRec.height;
|
|
80
|
-
// optional chain for testing
|
|
81
|
-
var horizontalMouseOffset = (direction === 'rtl' ? -1 : 1) * (((startMousePosition === null || startMousePosition === void 0 ? void 0 : startMousePosition.x) || 0) - clientX);
|
|
82
|
-
var rawDropLevelOffset = (horizontalMouseOffset - 12) / indent;
|
|
83
|
-
|
|
84
|
-
// Filter the expanded keys to exclude the node that not has children currently (like async nodes).
|
|
85
|
-
var filteredExpandKeys = expandKeys.filter(function (key) {
|
|
86
|
-
var _keyEntities$key;
|
|
87
|
-
return (_keyEntities$key = keyEntities[key]) === null || _keyEntities$key === void 0 || (_keyEntities$key = _keyEntities$key.children) === null || _keyEntities$key === void 0 ? void 0 : _keyEntities$key.length;
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// find abstract drop node by horizontal offset
|
|
91
|
-
var abstractDropNodeEntity = getEntity(keyEntities, targetNodeProps.eventKey);
|
|
92
|
-
if (clientY < top + height / 2) {
|
|
93
|
-
// first half, set abstract drop node to previous node
|
|
94
|
-
var nodeIndex = flattenedNodes.findIndex(function (flattenedNode) {
|
|
95
|
-
return flattenedNode.key === abstractDropNodeEntity.key;
|
|
96
|
-
});
|
|
97
|
-
var prevNodeIndex = nodeIndex <= 0 ? 0 : nodeIndex - 1;
|
|
98
|
-
var prevNodeKey = flattenedNodes[prevNodeIndex].key;
|
|
99
|
-
abstractDropNodeEntity = getEntity(keyEntities, prevNodeKey);
|
|
100
|
-
}
|
|
101
|
-
var initialAbstractDropNodeKey = abstractDropNodeEntity.key;
|
|
102
|
-
var abstractDragOverEntity = abstractDropNodeEntity;
|
|
103
|
-
var dragOverNodeKey = abstractDropNodeEntity.key;
|
|
104
|
-
var dropPosition = 0;
|
|
105
|
-
var dropLevelOffset = 0;
|
|
106
|
-
|
|
107
|
-
// Only allow cross level drop when dragging on a non-expanded node
|
|
108
|
-
if (!filteredExpandKeys.includes(initialAbstractDropNodeKey)) {
|
|
109
|
-
for (var i = 0; i < rawDropLevelOffset; i += 1) {
|
|
110
|
-
if (isLastChild(abstractDropNodeEntity)) {
|
|
111
|
-
abstractDropNodeEntity = abstractDropNodeEntity.parent;
|
|
112
|
-
dropLevelOffset += 1;
|
|
113
|
-
} else {
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
var abstractDragDataNode = dragNodeProps.data;
|
|
119
|
-
var abstractDropDataNode = abstractDropNodeEntity.node;
|
|
120
|
-
var dropAllowed = true;
|
|
121
|
-
if (isFirstChild(abstractDropNodeEntity) && abstractDropNodeEntity.level === 0 && clientY < top + height / 2 && allowDrop({
|
|
122
|
-
dragNode: abstractDragDataNode,
|
|
123
|
-
dropNode: abstractDropDataNode,
|
|
124
|
-
dropPosition: -1
|
|
125
|
-
}) && abstractDropNodeEntity.key === targetNodeProps.eventKey) {
|
|
126
|
-
// first half of first node in first level
|
|
127
|
-
dropPosition = -1;
|
|
128
|
-
} else if ((abstractDragOverEntity.children || []).length && filteredExpandKeys.includes(dragOverNodeKey)) {
|
|
129
|
-
// drop on expanded node
|
|
130
|
-
// only allow drop inside
|
|
131
|
-
if (allowDrop({
|
|
132
|
-
dragNode: abstractDragDataNode,
|
|
133
|
-
dropNode: abstractDropDataNode,
|
|
134
|
-
dropPosition: 0
|
|
135
|
-
})) {
|
|
136
|
-
dropPosition = 0;
|
|
137
|
-
} else {
|
|
138
|
-
dropAllowed = false;
|
|
139
|
-
}
|
|
140
|
-
} else if (dropLevelOffset === 0) {
|
|
141
|
-
if (rawDropLevelOffset > -1.5) {
|
|
142
|
-
// | Node | <- abstractDropNode
|
|
143
|
-
// | -^-===== | <- mousePosition
|
|
144
|
-
// 1. try drop after
|
|
145
|
-
// 2. do not allow drop
|
|
146
|
-
if (allowDrop({
|
|
147
|
-
dragNode: abstractDragDataNode,
|
|
148
|
-
dropNode: abstractDropDataNode,
|
|
149
|
-
dropPosition: 1
|
|
150
|
-
})) {
|
|
151
|
-
dropPosition = 1;
|
|
152
|
-
} else {
|
|
153
|
-
dropAllowed = false;
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
// | Node | <- abstractDropNode
|
|
157
|
-
// | ---==^== | <- mousePosition
|
|
158
|
-
// whether it has children or doesn't has children
|
|
159
|
-
// always
|
|
160
|
-
// 1. try drop inside
|
|
161
|
-
// 2. try drop after
|
|
162
|
-
// 3. do not allow drop
|
|
163
|
-
if (allowDrop({
|
|
164
|
-
dragNode: abstractDragDataNode,
|
|
165
|
-
dropNode: abstractDropDataNode,
|
|
166
|
-
dropPosition: 0
|
|
167
|
-
})) {
|
|
168
|
-
dropPosition = 0;
|
|
169
|
-
} else if (allowDrop({
|
|
170
|
-
dragNode: abstractDragDataNode,
|
|
171
|
-
dropNode: abstractDropDataNode,
|
|
172
|
-
dropPosition: 1
|
|
173
|
-
})) {
|
|
174
|
-
dropPosition = 1;
|
|
175
|
-
} else {
|
|
176
|
-
dropAllowed = false;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
// | Node1 | <- abstractDropNode
|
|
181
|
-
// | Node2 |
|
|
182
|
-
// --^--|----=====| <- mousePosition
|
|
183
|
-
// 1. try insert after Node1
|
|
184
|
-
// 2. do not allow drop
|
|
185
|
-
if (allowDrop({
|
|
186
|
-
dragNode: abstractDragDataNode,
|
|
187
|
-
dropNode: abstractDropDataNode,
|
|
188
|
-
dropPosition: 1
|
|
189
|
-
})) {
|
|
190
|
-
dropPosition = 1;
|
|
191
|
-
} else {
|
|
192
|
-
dropAllowed = false;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
dropPosition: dropPosition,
|
|
197
|
-
dropLevelOffset: dropLevelOffset,
|
|
198
|
-
dropTargetKey: abstractDropNodeEntity.key,
|
|
199
|
-
dropTargetPos: abstractDropNodeEntity.pos,
|
|
200
|
-
dragOverNodeKey: dragOverNodeKey,
|
|
201
|
-
dropContainerKey: dropPosition === 0 ? null : ((_abstractDropNodeEnti = abstractDropNodeEntity.parent) === null || _abstractDropNodeEnti === void 0 ? void 0 : _abstractDropNodeEnti.key) || null,
|
|
202
|
-
dropAllowed: dropAllowed
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Return selectedKeys according with multiple prop
|
|
208
|
-
* @param selectedKeys
|
|
209
|
-
* @param props
|
|
210
|
-
* @returns [string]
|
|
211
|
-
*/
|
|
212
|
-
export function calcSelectedKeys(selectedKeys, props) {
|
|
213
|
-
if (!selectedKeys) {
|
|
214
|
-
return undefined;
|
|
215
|
-
}
|
|
216
|
-
var multiple = props.multiple;
|
|
217
|
-
if (multiple) {
|
|
218
|
-
return selectedKeys.slice();
|
|
219
|
-
}
|
|
220
|
-
if (selectedKeys.length) {
|
|
221
|
-
return [selectedKeys[0]];
|
|
222
|
-
}
|
|
223
|
-
return selectedKeys;
|
|
224
|
-
}
|
|
225
|
-
var internalProcessProps = function internalProcessProps(props) {
|
|
226
|
-
return props;
|
|
227
|
-
};
|
|
228
|
-
export function convertDataToTree(treeData, processor) {
|
|
229
|
-
if (!treeData) {
|
|
230
|
-
return [];
|
|
231
|
-
}
|
|
232
|
-
var _ref2 = processor || {},
|
|
233
|
-
_ref2$processProps = _ref2.processProps,
|
|
234
|
-
processProps = _ref2$processProps === void 0 ? internalProcessProps : _ref2$processProps;
|
|
235
|
-
var list = Array.isArray(treeData) ? treeData : [treeData];
|
|
236
|
-
return list.map(function (_ref3) {
|
|
237
|
-
var children = _ref3.children,
|
|
238
|
-
props = _objectWithoutProperties(_ref3, _excluded);
|
|
239
|
-
var childrenNodes = convertDataToTree(children, processor);
|
|
240
|
-
return /*#__PURE__*/React.createElement(TreeNode, _extends({
|
|
241
|
-
key: props.key
|
|
242
|
-
}, processProps(props)), childrenNodes);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Parse `checkedKeys` to { checkedKeys, halfCheckedKeys } style
|
|
248
|
-
*/
|
|
249
|
-
export function parseCheckedKeys(keys) {
|
|
250
|
-
if (!keys) {
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Convert keys to object format
|
|
255
|
-
var keyProps;
|
|
256
|
-
if (Array.isArray(keys)) {
|
|
257
|
-
// [Legacy] Follow the api doc
|
|
258
|
-
keyProps = {
|
|
259
|
-
checkedKeys: keys,
|
|
260
|
-
halfCheckedKeys: undefined
|
|
261
|
-
};
|
|
262
|
-
} else if (_typeof(keys) === 'object') {
|
|
263
|
-
keyProps = {
|
|
264
|
-
checkedKeys: keys.checked || undefined,
|
|
265
|
-
halfCheckedKeys: keys.halfChecked || undefined
|
|
266
|
-
};
|
|
267
|
-
} else {
|
|
268
|
-
warning(false, '`checkedKeys` is not an array or an object');
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
return keyProps;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* If user use `autoExpandParent` we should get the list of parent node
|
|
276
|
-
* @param keyList
|
|
277
|
-
* @param keyEntities
|
|
278
|
-
*/
|
|
279
|
-
export function conductExpandParent(keyList, keyEntities) {
|
|
280
|
-
var expandedKeys = new Set();
|
|
281
|
-
function conductUp(key) {
|
|
282
|
-
if (expandedKeys.has(key)) {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
var entity = getEntity(keyEntities, key);
|
|
286
|
-
if (!entity) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
expandedKeys.add(key);
|
|
290
|
-
var parent = entity.parent,
|
|
291
|
-
node = entity.node;
|
|
292
|
-
if (node.disabled) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
if (parent) {
|
|
296
|
-
conductUp(parent.key);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
(keyList || []).forEach(function (key) {
|
|
300
|
-
conductUp(key);
|
|
301
|
-
});
|
|
302
|
-
return _toConsumableArray(expandedKeys);
|
|
303
|
-
}
|