@canlooks/can-ui 0.0.96 → 0.0.97
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/components/accordion/accordion.style.d.ts +1 -1
- package/dist/cjs/components/alert/alert.style.d.ts +3 -3
- package/dist/cjs/components/button/button.style.d.ts +1 -1
- package/dist/cjs/components/checkboxBase/checkboxBase.style.d.ts +2 -2
- package/dist/cjs/components/clickAway/clickAway.d.ts +27 -27
- package/dist/cjs/components/dataGrid/dataGrid.style.d.ts +1 -1
- package/dist/cjs/components/descriptions/descriptions.style.d.ts +1 -1
- package/dist/cjs/components/dialog/dialog.style.d.ts +3 -3
- package/dist/cjs/components/inputBase/inputBase.style.d.ts +2 -2
- package/dist/cjs/components/menuItem/menuItem.d.ts +4 -0
- package/dist/cjs/components/menuItem/menuItem.style.d.ts +2 -2
- package/dist/cjs/components/optionsBase/optionsBase.js +2 -1
- package/dist/cjs/components/palette/palette.style.d.ts +1 -1
- package/dist/cjs/components/pickerDialog/pickerDialog.style.d.ts +1 -1
- package/dist/cjs/components/progress/progress.js +2 -1
- package/dist/cjs/components/progress/progress.style.d.ts +1 -1
- package/dist/cjs/components/resizable/resizable.style.d.ts +1 -1
- package/dist/cjs/components/segmented/segmented.style.d.ts +1 -1
- package/dist/cjs/components/selectionContext/selectionContext.d.ts +2 -0
- package/dist/cjs/components/selectionContext/selectionHook.js +2 -1
- package/dist/cjs/components/snackbarBase/snackbarBase.style.d.ts +1 -1
- package/dist/cjs/components/status/status.style.d.ts +1 -1
- package/dist/cjs/components/tabs/tabs.style.d.ts +4 -4
- package/dist/cjs/components/tag/tag.style.d.ts +2 -2
- package/dist/cjs/components/transfer/transfer.style.d.ts +2 -2
- package/dist/cjs/components/tree/tree.d.ts +2 -2
- package/dist/cjs/components/tree/tree.js +15 -13
- package/dist/cjs/components/tree/tree.style.d.ts +5 -9
- package/dist/cjs/components/tree/tree.style.js +96 -206
- package/dist/cjs/components/tree/treeDnd.d.ts +3 -7
- package/dist/cjs/components/tree/treeDnd.js +7 -19
- package/dist/cjs/components/tree/treeDnd.style.d.ts +15 -0
- package/dist/cjs/components/tree/treeDnd.style.js +191 -0
- package/dist/cjs/components/tree/treeNode.d.ts +4 -4
- package/dist/cjs/components/tree/treeNode.js +82 -69
- package/dist/cjs/components/upload/upload.style.d.ts +1 -1
- package/dist/cjs/utils/dnd.d.ts +11 -3
- package/dist/cjs/utils/dnd.js +45 -2
- package/dist/esm/components/accordion/accordion.style.d.ts +1 -1
- package/dist/esm/components/alert/alert.style.d.ts +3 -3
- package/dist/esm/components/button/button.style.d.ts +1 -1
- package/dist/esm/components/checkboxBase/checkboxBase.style.d.ts +2 -2
- package/dist/esm/components/clickAway/clickAway.d.ts +27 -27
- package/dist/esm/components/dataGrid/dataGrid.style.d.ts +1 -1
- package/dist/esm/components/descriptions/descriptions.style.d.ts +1 -1
- package/dist/esm/components/dialog/dialog.style.d.ts +3 -3
- package/dist/esm/components/inputBase/inputBase.style.d.ts +2 -2
- package/dist/esm/components/menuItem/menuItem.d.ts +4 -0
- package/dist/esm/components/menuItem/menuItem.style.d.ts +2 -2
- package/dist/esm/components/optionsBase/optionsBase.js +2 -1
- package/dist/esm/components/palette/palette.style.d.ts +1 -1
- package/dist/esm/components/pickerDialog/pickerDialog.style.d.ts +1 -1
- package/dist/esm/components/progress/progress.js +2 -1
- package/dist/esm/components/progress/progress.style.d.ts +1 -1
- package/dist/esm/components/resizable/resizable.style.d.ts +1 -1
- package/dist/esm/components/segmented/segmented.style.d.ts +1 -1
- package/dist/esm/components/selectionContext/selectionContext.d.ts +2 -0
- package/dist/esm/components/selectionContext/selectionHook.js +2 -1
- package/dist/esm/components/snackbarBase/snackbarBase.style.d.ts +1 -1
- package/dist/esm/components/status/status.style.d.ts +1 -1
- package/dist/esm/components/tabs/tabs.style.d.ts +4 -4
- package/dist/esm/components/tag/tag.style.d.ts +2 -2
- package/dist/esm/components/transfer/transfer.style.d.ts +2 -2
- package/dist/esm/components/tree/tree.d.ts +2 -2
- package/dist/esm/components/tree/tree.js +18 -16
- package/dist/esm/components/tree/tree.style.d.ts +5 -9
- package/dist/esm/components/tree/tree.style.js +95 -206
- package/dist/esm/components/tree/treeDnd.d.ts +3 -7
- package/dist/esm/components/tree/treeDnd.js +8 -20
- package/dist/esm/components/tree/treeDnd.style.d.ts +15 -0
- package/dist/esm/components/tree/treeDnd.style.js +186 -0
- package/dist/esm/components/tree/treeNode.d.ts +4 -4
- package/dist/esm/components/tree/treeNode.js +82 -69
- package/dist/esm/components/upload/upload.style.d.ts +1 -1
- package/dist/esm/utils/dnd.d.ts +11 -3
- package/dist/esm/utils/dnd.js +44 -2
- package/package.json +1 -1
|
@@ -14,114 +14,127 @@ const icon_1 = require("../icon");
|
|
|
14
14
|
const faChevronRight_1 = require("@fortawesome/free-solid-svg-icons/faChevronRight");
|
|
15
15
|
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
16
16
|
const treeDnd_1 = require("./treeDnd");
|
|
17
|
-
|
|
17
|
+
const treeDnd_style_1 = require("./treeDnd.style");
|
|
18
|
+
exports.TreeNode = (0, react_1.memo)(({ id, label, prefix, suffix, disabled, _level = 0, ...props }) => {
|
|
18
19
|
const { expandedSet, toggleExpanded, indent, renderExpandIcon, showCheckbox, readOnly, clickLabelToExpand, ...context } = (0, tree_1.useTreeContext)();
|
|
19
20
|
disabled ??= context.disabled;
|
|
20
|
-
const { selectionStatus, toggleSelected } = (0, selectionContext_1.useSelectionContext)();
|
|
21
|
-
const currentExpanded = expandedSet.has(
|
|
22
|
-
const status = selectionStatus.get(
|
|
21
|
+
const { optionsMap: nodesMap, selectionStatus, toggleSelected } = (0, selectionContext_1.useSelectionContext)();
|
|
22
|
+
const currentExpanded = expandedSet.has(id);
|
|
23
|
+
const status = selectionStatus.get(id);
|
|
23
24
|
const clickHandler = () => {
|
|
24
|
-
!readOnly && !disabled && toggleSelected(
|
|
25
|
-
clickLabelToExpand && toggleExpanded(
|
|
25
|
+
!readOnly && !disabled && toggleSelected(id);
|
|
26
|
+
clickLabelToExpand && toggleExpanded(id);
|
|
26
27
|
};
|
|
27
28
|
const hasChildren = !!props.children && (!Array.isArray(props.children) || props.children.length > 0);
|
|
28
29
|
/**
|
|
29
30
|
* ---------------------------------------------------------------------
|
|
30
31
|
* 拖拽部分
|
|
31
32
|
*/
|
|
32
|
-
const { sortable, showDragHandle, onSort,
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
!showCheckbox && clickHandler();
|
|
36
|
-
};
|
|
33
|
+
const { sortable, showDragHandle, onSort, dragging: [dragging, setDragging], overing, placement } = (0, treeDnd_1.useTreeDndContext)();
|
|
34
|
+
const isDraggingNode = dragging === id;
|
|
35
|
+
const nodeRef = (0, react_1.useRef)(null);
|
|
37
36
|
const dragHandleProps = (0, utils_1.useDraggable)({
|
|
38
37
|
disabled: !sortable,
|
|
39
|
-
onDragStart(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
currentExpanded && toggleExpanded(
|
|
43
|
-
},
|
|
44
|
-
onDrag({ diff: [diffX] }) {
|
|
45
|
-
setIsOffsetSatisfied(diffX > indent * 2);
|
|
38
|
+
onDragStart() {
|
|
39
|
+
overing.current = void 0;
|
|
40
|
+
setDragging(id);
|
|
41
|
+
currentExpanded && toggleExpanded(id);
|
|
46
42
|
},
|
|
47
43
|
onDragEnd() {
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
overing.current && placement.current && onSort?.({
|
|
45
|
+
source: dragging,
|
|
46
|
+
destination: overing.current,
|
|
47
|
+
placement: placement.current
|
|
48
|
+
});
|
|
50
49
|
setDragging(void 0);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
source: dragging,
|
|
54
|
-
destination: overing,
|
|
55
|
-
placement: isOffsetSatisfied ? 'child' : placement.current
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
onClick
|
|
50
|
+
inactiveBlock();
|
|
51
|
+
}
|
|
60
52
|
});
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
const pointerEnterMaskArea = (e, _placement) => {
|
|
54
|
+
if (!isDraggingNode) {
|
|
55
|
+
activeBlock(e.currentTarget, _placement);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const pointerLeaveMaskArea = (e) => {
|
|
59
|
+
!isDraggingNode && inactiveBlock(e.currentTarget);
|
|
60
|
+
};
|
|
61
|
+
const pointerEnterPredecessor = (e, upLevel) => {
|
|
62
|
+
activeBlock(e.currentTarget, 'parent', upLevel);
|
|
63
|
+
};
|
|
64
|
+
const pointerLeavePredecessor = (e) => {
|
|
65
|
+
inactiveBlock(e.currentTarget);
|
|
66
|
+
};
|
|
67
|
+
const activeBlock = (el, _placement, upLevel = 0) => {
|
|
68
|
+
if (_placement === 'parent') {
|
|
69
|
+
let i = upLevel;
|
|
70
|
+
let parentId = id;
|
|
71
|
+
do {
|
|
72
|
+
const currentNode = nodesMap.get(parentId);
|
|
73
|
+
if (!currentNode._isLast) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
parentId = currentNode._parentId;
|
|
77
|
+
} while (--i && parentId);
|
|
78
|
+
overing.current = parentId;
|
|
79
|
+
placement.current = 'after';
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
overing.current = id;
|
|
83
|
+
placement.current = _placement;
|
|
84
|
+
}
|
|
85
|
+
el.dataset.active = 'true';
|
|
86
|
+
_placement !== 'child' && (0, utils_1.findPredecessor)(el, parent => {
|
|
87
|
+
if (parent.classList.contains(treeDnd_style_1.treeDndClasses.levelBlock) && !upLevel--) {
|
|
66
88
|
parent.dataset.active = 'true';
|
|
89
|
+
const parentNode = parent.previousElementSibling;
|
|
90
|
+
if (parentNode && parentNode.classList.contains(tree_style_1.classes.node)) {
|
|
91
|
+
parentNode.dataset.active = 'true';
|
|
92
|
+
}
|
|
67
93
|
return true;
|
|
68
94
|
}
|
|
69
95
|
});
|
|
70
96
|
};
|
|
71
|
-
const
|
|
72
|
-
|
|
97
|
+
const inactiveBlock = (el) => {
|
|
98
|
+
if (el) {
|
|
73
99
|
el.dataset.active = 'false';
|
|
74
|
-
};
|
|
75
|
-
fn(containerRef.current);
|
|
76
|
-
containerRef.current.querySelectorAll('.' + tree_style_1.classes.levelBlock).forEach(fn);
|
|
77
|
-
};
|
|
78
|
-
const overingMask = (e) => {
|
|
79
|
-
if (hasChildren && !expandedSet.has(value)) {
|
|
80
|
-
overingTimer.current ||= setTimeout(() => {
|
|
81
|
-
toggleExpanded(value);
|
|
82
|
-
placement.current === 'after' && inactiveParentBlock();
|
|
83
|
-
}, 800);
|
|
84
100
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
setPlacement(placement);
|
|
93
|
-
activeParentBlock(e.currentTarget);
|
|
94
|
-
};
|
|
95
|
-
const onPointerLeave = () => {
|
|
96
|
-
setOvering(void 0);
|
|
97
|
-
inactiveParentBlock();
|
|
101
|
+
document.querySelectorAll('.' + treeDnd_style_1.treeDndClasses.levelBlock).forEach(el => {
|
|
102
|
+
el.dataset.active = 'false';
|
|
103
|
+
});
|
|
104
|
+
document.querySelectorAll('.' + tree_style_1.classes.node).forEach(el => {
|
|
105
|
+
el.dataset.active = 'false';
|
|
106
|
+
});
|
|
107
|
+
overing.current = void 0;
|
|
98
108
|
};
|
|
99
109
|
/**
|
|
100
110
|
* ---------------------------------------------------------------------
|
|
101
111
|
* 渲染部分
|
|
102
112
|
*/
|
|
103
113
|
const renderedIndents = (0, react_1.useMemo)(() => {
|
|
104
|
-
return Array(_level).fill(void 0).map((_, i) => (0, jsx_runtime_1.jsx)("div", { className: tree_style_1.classes.indent
|
|
105
|
-
}, [_level
|
|
106
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { ...props, ref: (0, utils_1.cloneRef)(nodeRef, props.ref), className: (0, utils_1.clsx)(tree_style_1.classes.node, props.className), "data-selected": status === 2, "data-read-only": readOnly, "data-disabled": disabled, "data-dragging":
|
|
114
|
+
return Array(_level).fill(void 0).map((_, i) => (0, jsx_runtime_1.jsx)("div", { className: tree_style_1.classes.indent }, i));
|
|
115
|
+
}, [_level]);
|
|
116
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { ...props, ref: (0, utils_1.cloneRef)(nodeRef, props.ref), className: (0, utils_1.clsx)(tree_style_1.classes.node, props.className), "data-selected": status === 2, "data-read-only": readOnly, "data-disabled": disabled, "data-dragging": isDraggingNode, onClick: clickHandler, ...!showDragHandle && dragHandleProps, children: [renderedIndents, (0, jsx_runtime_1.jsx)(button_1.Button, { className: tree_style_1.classes.expand, variant: "plain", color: "text.secondary", onClick: e => {
|
|
107
117
|
e.stopPropagation();
|
|
108
|
-
toggleExpanded(
|
|
118
|
+
toggleExpanded(id);
|
|
109
119
|
}, onPointerDown: e => e.stopPropagation(), children: renderExpandIcon
|
|
110
|
-
? renderExpandIcon(
|
|
120
|
+
? renderExpandIcon(id, currentExpanded, [...expandedSet])
|
|
111
121
|
: hasChildren &&
|
|
112
122
|
(0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faChevronRight_1.faChevronRight, className: tree_style_1.classes.icon, style: {
|
|
113
123
|
rotate: currentExpanded ? '90deg' : '0deg'
|
|
114
124
|
} }) }), (0, jsx_runtime_1.jsxs)("div", { className: tree_style_1.classes.contentWrap, children: [sortable && showDragHandle &&
|
|
115
|
-
(0, jsx_runtime_1.jsx)("div", { className:
|
|
125
|
+
(0, jsx_runtime_1.jsx)("div", { className: treeDnd_style_1.treeDndClasses.dragHandle, ...dragHandleProps, onClick: e => e.stopPropagation(), children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: free_solid_svg_icons_1.faGripVertical }) }), showCheckbox &&
|
|
116
126
|
(0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { className: tree_style_1.classes.checkbox, checked: status === 2, indeterminate: status === 1, onClick: e => {
|
|
117
127
|
e.stopPropagation();
|
|
118
128
|
clickHandler();
|
|
119
129
|
} }), !!prefix &&
|
|
120
130
|
(0, jsx_runtime_1.jsx)("div", { className: tree_style_1.classes.prefix, children: prefix }), (0, jsx_runtime_1.jsx)("div", { className: tree_style_1.classes.label, children: label }), !!suffix &&
|
|
121
|
-
(0, jsx_runtime_1.jsx)("div", { className: tree_style_1.classes.suffix, children: suffix }), typeof dragging !== 'undefined' &&
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
(0, jsx_runtime_1.jsx)("div", { className: tree_style_1.classes.suffix, children: suffix })] }), typeof dragging !== 'undefined' &&
|
|
132
|
+
(0, jsx_runtime_1.jsxs)("div", { className: treeDnd_style_1.treeDndClasses.mask, children: [Array(_level + 1).fill(void 0).map((_, i) => (0, jsx_runtime_1.jsx)("div", { className: treeDnd_style_1.treeDndClasses.predecessor, ...i && {
|
|
133
|
+
onPointerEnter: e => pointerEnterPredecessor(e, _level + 1 - i),
|
|
134
|
+
onPointerLeave: pointerLeavePredecessor
|
|
135
|
+
} }, i)), (0, jsx_runtime_1.jsxs)("div", { className: treeDnd_style_1.treeDndClasses.sibling, children: [(0, jsx_runtime_1.jsx)("div", { className: treeDnd_style_1.treeDndClasses.siblingPrev, onPointerEnter: e => pointerEnterMaskArea(e, 'before'), onPointerLeave: pointerLeaveMaskArea }), (0, jsx_runtime_1.jsx)("div", { className: treeDnd_style_1.treeDndClasses.siblingNext, onPointerEnter: e => pointerEnterMaskArea(e, 'after'), onPointerLeave: pointerLeaveMaskArea }), !hasChildren &&
|
|
136
|
+
(0, jsx_runtime_1.jsx)("div", { className: treeDnd_style_1.treeDndClasses.child, onPointerEnter: e => pointerEnterMaskArea(e, 'child'), onPointerLeave: pointerLeaveMaskArea })] })] })] }), hasChildren &&
|
|
137
|
+
(0, jsx_runtime_1.jsx)(transitionBase_1.Collapse, { className: treeDnd_style_1.treeDndClasses.levelBlock, in: currentExpanded, children: react_1.Children.map(props.children, child => {
|
|
125
138
|
return (0, react_1.isValidElement)(child)
|
|
126
139
|
? (0, react_1.cloneElement)(child, { _level: _level + 1 })
|
|
127
140
|
: child;
|
package/dist/cjs/utils/dnd.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { DragEndEvent } from '@dnd-kit/core';
|
|
2
|
-
import { Obj } from '../types';
|
|
2
|
+
import { Id, Obj } from '../types';
|
|
3
|
+
import { NodeType, SortInfo } from '../components/tree';
|
|
3
4
|
/**
|
|
4
5
|
* 默认提供给@dnd-kit的sensors属性
|
|
5
6
|
*/
|
|
6
7
|
export declare function useDndSensors(): import("@dnd-kit/core").SensorDescriptor<import("@dnd-kit/core").SensorOptions>[];
|
|
7
8
|
/**
|
|
8
9
|
* <DndContext>组件通用的onDragEnd方法
|
|
9
|
-
* @param e
|
|
10
|
+
* @param e 事件
|
|
10
11
|
* @param prevState 传入需要排序的数组
|
|
11
|
-
* @param primaryKey
|
|
12
|
+
* @param primaryKey 索引用的主键,默认为`id`
|
|
12
13
|
*/
|
|
13
14
|
export declare function onDndDragEnd<S extends Obj>(e: DragEndEvent, prevState: S[], primaryKey?: string): S[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* <Tree>组件通用的onSort方法,注意:该方法会原地修改{@link treeNodes}
|
|
17
|
+
* @param info 信息
|
|
18
|
+
* @param treeNodes 树节点
|
|
19
|
+
* @param primaryKey 索引用的主键,默认为`id`
|
|
20
|
+
*/
|
|
21
|
+
export declare function onTreeNodeSort<N extends NodeType<V>, V extends Id = Id>(info: SortInfo<V>, treeNodes: N[], primaryKey?: string): N[];
|
package/dist/cjs/utils/dnd.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDndSensors = useDndSensors;
|
|
4
4
|
exports.onDndDragEnd = onDndDragEnd;
|
|
5
|
+
exports.onTreeNodeSort = onTreeNodeSort;
|
|
5
6
|
const core_1 = require("@dnd-kit/core");
|
|
6
7
|
const sortable_1 = require("@dnd-kit/sortable");
|
|
7
8
|
/**
|
|
@@ -16,9 +17,9 @@ function useDndSensors() {
|
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* <DndContext>组件通用的onDragEnd方法
|
|
19
|
-
* @param e
|
|
20
|
+
* @param e 事件
|
|
20
21
|
* @param prevState 传入需要排序的数组
|
|
21
|
-
* @param primaryKey
|
|
22
|
+
* @param primaryKey 索引用的主键,默认为`id`
|
|
22
23
|
*/
|
|
23
24
|
function onDndDragEnd(e, prevState, primaryKey = 'id') {
|
|
24
25
|
const { active, over } = e;
|
|
@@ -30,3 +31,45 @@ function onDndDragEnd(e, prevState, primaryKey = 'id') {
|
|
|
30
31
|
const newIndex = prevState.findIndex(v => v[primaryKey] === over.id);
|
|
31
32
|
return (0, sortable_1.arrayMove)(prevState, oldIndex, newIndex);
|
|
32
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* <Tree>组件通用的onSort方法,注意:该方法会原地修改{@link treeNodes}
|
|
36
|
+
* @param info 信息
|
|
37
|
+
* @param treeNodes 树节点
|
|
38
|
+
* @param primaryKey 索引用的主键,默认为`id`
|
|
39
|
+
*/
|
|
40
|
+
function onTreeNodeSort(info, treeNodes, primaryKey = 'id') {
|
|
41
|
+
const find = (arr, id) => {
|
|
42
|
+
let target = null;
|
|
43
|
+
let targetIndex = -1;
|
|
44
|
+
let siblings = null;
|
|
45
|
+
const recurse = (arr) => {
|
|
46
|
+
return !!arr?.some((v, i, _siblings) => {
|
|
47
|
+
if (v[primaryKey] === id) {
|
|
48
|
+
target = v;
|
|
49
|
+
targetIndex = i;
|
|
50
|
+
siblings = _siblings;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return v.children?.length && recurse(v.children);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
recurse(arr);
|
|
57
|
+
return target ? { target, targetIndex, siblings: siblings } : null;
|
|
58
|
+
};
|
|
59
|
+
const source = find(treeNodes, info.source);
|
|
60
|
+
source.siblings.splice(source.targetIndex, 1);
|
|
61
|
+
const destination = find(treeNodes, info.destination);
|
|
62
|
+
switch (info.placement) {
|
|
63
|
+
case 'before':
|
|
64
|
+
destination.siblings.splice(destination.targetIndex, 0, source.target);
|
|
65
|
+
break;
|
|
66
|
+
case 'after':
|
|
67
|
+
destination.siblings.splice(destination.targetIndex + 1, 0, source.target);
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
// children
|
|
71
|
+
destination.target.children ||= [];
|
|
72
|
+
destination.target.children.push(source.target);
|
|
73
|
+
}
|
|
74
|
+
return treeNodes;
|
|
75
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ColorPropsValue } from '../../types';
|
|
2
2
|
export declare const classes: {
|
|
3
3
|
title: string;
|
|
4
|
-
content: string;
|
|
5
|
-
close: string;
|
|
6
4
|
prefix: string;
|
|
7
|
-
|
|
5
|
+
content: string;
|
|
8
6
|
suffix: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
close: string;
|
|
9
9
|
description: string;
|
|
10
10
|
} & {
|
|
11
11
|
root: string;
|
|
@@ -2,9 +2,9 @@ import { CheckboxBaseProps } from './checkboxBase';
|
|
|
2
2
|
export declare const classes: {
|
|
3
3
|
input: string;
|
|
4
4
|
label: string;
|
|
5
|
-
icon: string;
|
|
6
|
-
radio: string;
|
|
7
5
|
checkbox: string;
|
|
6
|
+
radio: string;
|
|
7
|
+
icon: string;
|
|
8
8
|
radioChecked: string;
|
|
9
9
|
indeterminate: string;
|
|
10
10
|
} & {
|
|
@@ -18,26 +18,26 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
|
|
|
18
18
|
suppressContentEditableWarning: boolean;
|
|
19
19
|
suppressHydrationWarning: boolean;
|
|
20
20
|
accessKey: string;
|
|
21
|
-
autoCapitalize:
|
|
21
|
+
autoCapitalize: (string & {}) | "none" | "off" | "on" | "sentences" | "words" | "characters";
|
|
22
22
|
autoFocus: boolean;
|
|
23
23
|
className: string;
|
|
24
|
-
contentEditable: boolean | "
|
|
24
|
+
contentEditable: boolean | "inherit" | "false" | "true" | "plaintext-only";
|
|
25
25
|
contextMenu: string;
|
|
26
26
|
dir: string;
|
|
27
|
-
draggable: boolean | "
|
|
28
|
-
enterKeyHint: "search" | "done" | "
|
|
27
|
+
draggable: boolean | "false" | "true";
|
|
28
|
+
enterKeyHint: "search" | "done" | "next" | "enter" | "go" | "previous" | "send";
|
|
29
29
|
hidden: boolean;
|
|
30
30
|
id: string;
|
|
31
31
|
lang: string;
|
|
32
32
|
nonce: string;
|
|
33
33
|
slot: string;
|
|
34
|
-
spellCheck: boolean | "
|
|
34
|
+
spellCheck: boolean | "false" | "true";
|
|
35
35
|
style: import("react").CSSProperties;
|
|
36
36
|
tabIndex: number;
|
|
37
37
|
title: string;
|
|
38
|
-
translate: "
|
|
38
|
+
translate: "yes" | "no";
|
|
39
39
|
radioGroup: string;
|
|
40
|
-
role: "article" | "button" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "menu" | "menuitem" | "option" | "search" | "table" | "switch" | "
|
|
40
|
+
role: "article" | "button" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "menu" | "menuitem" | "option" | "search" | "table" | "switch" | "status" | (string & {}) | "none" | "checkbox" | "listbox" | "radio" | "region" | "cell" | "grid" | "row" | "listitem" | "menubar" | "progressbar" | "separator" | "tab" | "tabpanel" | "toolbar" | "tooltip" | "treeitem" | "scrollbar" | "alert" | "alertdialog" | "application" | "banner" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "directory" | "document" | "feed" | "gridcell" | "group" | "heading" | "list" | "log" | "marquee" | "math" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "note" | "presentation" | "radiogroup" | "rowgroup" | "rowheader" | "searchbox" | "slider" | "spinbutton" | "tablist" | "term" | "textbox" | "timer" | "tree" | "treegrid";
|
|
41
41
|
about: string;
|
|
42
42
|
content: string;
|
|
43
43
|
datatype: string;
|
|
@@ -61,7 +61,7 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
|
|
|
61
61
|
security: string;
|
|
62
62
|
unselectable: "off" | "on";
|
|
63
63
|
popover: "" | "auto" | "manual";
|
|
64
|
-
popoverTargetAction: "
|
|
64
|
+
popoverTargetAction: "hide" | "show" | "toggle";
|
|
65
65
|
popoverTarget: string;
|
|
66
66
|
inert: boolean;
|
|
67
67
|
inputMode: "text" | "search" | "none" | "tel" | "url" | "email" | "numeric" | "decimal";
|
|
@@ -69,52 +69,52 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
|
|
|
69
69
|
exportparts: string;
|
|
70
70
|
part: string;
|
|
71
71
|
"aria-activedescendant": string;
|
|
72
|
-
"aria-atomic": boolean | "
|
|
73
|
-
"aria-autocomplete": "
|
|
72
|
+
"aria-atomic": boolean | "false" | "true";
|
|
73
|
+
"aria-autocomplete": "both" | "none" | "inline" | "list";
|
|
74
74
|
"aria-braillelabel": string;
|
|
75
75
|
"aria-brailleroledescription": string;
|
|
76
|
-
"aria-busy": boolean | "
|
|
77
|
-
"aria-checked": boolean | "
|
|
76
|
+
"aria-busy": boolean | "false" | "true";
|
|
77
|
+
"aria-checked": boolean | "mixed" | "false" | "true";
|
|
78
78
|
"aria-colcount": number;
|
|
79
79
|
"aria-colindex": number;
|
|
80
80
|
"aria-colindextext": string;
|
|
81
81
|
"aria-colspan": number;
|
|
82
82
|
"aria-controls": string;
|
|
83
|
-
"aria-current": boolean | "time" | "
|
|
83
|
+
"aria-current": boolean | "time" | "step" | "page" | "false" | "true" | "location" | "date";
|
|
84
84
|
"aria-describedby": string;
|
|
85
85
|
"aria-description": string;
|
|
86
86
|
"aria-details": string;
|
|
87
|
-
"aria-disabled": boolean | "
|
|
88
|
-
"aria-dropeffect": "link" | "
|
|
87
|
+
"aria-disabled": boolean | "false" | "true";
|
|
88
|
+
"aria-dropeffect": "link" | "none" | "copy" | "move" | "execute" | "popup";
|
|
89
89
|
"aria-errormessage": string;
|
|
90
|
-
"aria-expanded": boolean | "
|
|
90
|
+
"aria-expanded": boolean | "false" | "true";
|
|
91
91
|
"aria-flowto": string;
|
|
92
|
-
"aria-grabbed": boolean | "
|
|
93
|
-
"aria-haspopup": boolean | "dialog" | "menu" | "
|
|
94
|
-
"aria-hidden": boolean | "
|
|
95
|
-
"aria-invalid": boolean | "
|
|
92
|
+
"aria-grabbed": boolean | "false" | "true";
|
|
93
|
+
"aria-haspopup": boolean | "dialog" | "menu" | "listbox" | "grid" | "false" | "true" | "tree";
|
|
94
|
+
"aria-hidden": boolean | "false" | "true";
|
|
95
|
+
"aria-invalid": boolean | "false" | "true" | "grammar" | "spelling";
|
|
96
96
|
"aria-keyshortcuts": string;
|
|
97
97
|
"aria-label": string;
|
|
98
98
|
"aria-labelledby": string;
|
|
99
99
|
"aria-level": number;
|
|
100
100
|
"aria-live": "off" | "assertive" | "polite";
|
|
101
|
-
"aria-modal": boolean | "
|
|
102
|
-
"aria-multiline": boolean | "
|
|
103
|
-
"aria-multiselectable": boolean | "
|
|
101
|
+
"aria-modal": boolean | "false" | "true";
|
|
102
|
+
"aria-multiline": boolean | "false" | "true";
|
|
103
|
+
"aria-multiselectable": boolean | "false" | "true";
|
|
104
104
|
"aria-orientation": "horizontal" | "vertical";
|
|
105
105
|
"aria-owns": string;
|
|
106
106
|
"aria-placeholder": string;
|
|
107
107
|
"aria-posinset": number;
|
|
108
|
-
"aria-pressed": boolean | "
|
|
109
|
-
"aria-readonly": boolean | "
|
|
108
|
+
"aria-pressed": boolean | "mixed" | "false" | "true";
|
|
109
|
+
"aria-readonly": boolean | "false" | "true";
|
|
110
110
|
"aria-relevant": "text" | "all" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
|
|
111
|
-
"aria-required": boolean | "
|
|
111
|
+
"aria-required": boolean | "false" | "true";
|
|
112
112
|
"aria-roledescription": string;
|
|
113
113
|
"aria-rowcount": number;
|
|
114
114
|
"aria-rowindex": number;
|
|
115
115
|
"aria-rowindextext": string;
|
|
116
116
|
"aria-rowspan": number;
|
|
117
|
-
"aria-selected": boolean | "
|
|
117
|
+
"aria-selected": boolean | "false" | "true";
|
|
118
118
|
"aria-setsize": number;
|
|
119
119
|
"aria-sort": "none" | "ascending" | "descending" | "other";
|
|
120
120
|
"aria-valuemax": number;
|
|
@@ -3,11 +3,11 @@ export declare const classes: {
|
|
|
3
3
|
title: string;
|
|
4
4
|
children: string;
|
|
5
5
|
container: string;
|
|
6
|
+
expandable: string;
|
|
6
7
|
filterForm: string;
|
|
7
8
|
functionalCell: string;
|
|
8
9
|
sortIcon: string;
|
|
9
10
|
filterButton: string;
|
|
10
|
-
expandable: string;
|
|
11
11
|
expandableWrap: string;
|
|
12
12
|
selectable: string;
|
|
13
13
|
subTd: string;
|
|
@@ -2,12 +2,12 @@ export declare const classes: {
|
|
|
2
2
|
body: string;
|
|
3
3
|
footer: string;
|
|
4
4
|
title: string;
|
|
5
|
-
content: string;
|
|
6
|
-
close: string;
|
|
7
5
|
prefix: string;
|
|
6
|
+
content: string;
|
|
7
|
+
suffix: string;
|
|
8
8
|
icon: string;
|
|
9
9
|
container: string;
|
|
10
|
-
|
|
10
|
+
close: string;
|
|
11
11
|
card: string;
|
|
12
12
|
titleRow: string;
|
|
13
13
|
bodyWrap: string;
|
|
@@ -21,6 +21,10 @@ export interface MenuItemProps extends Omit<DivProps, 'prefix'> {
|
|
|
21
21
|
suffix?: ReactNode;
|
|
22
22
|
/** 当label不为string时,该字段会取代label用来搜索 */
|
|
23
23
|
searchToken?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 若指定为`true`,则弹框打开时会自动滚动到该选项,默认为`false`
|
|
26
|
+
*/
|
|
27
|
+
scrollHere?: boolean;
|
|
24
28
|
/** @private 内部使用,缩进的层级 */
|
|
25
29
|
_level?: number;
|
|
26
30
|
indent?: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MenuItemProps } from './menuItem';
|
|
2
2
|
export declare const classes: {
|
|
3
3
|
children: string;
|
|
4
|
-
content: string;
|
|
5
4
|
prefix: string;
|
|
6
|
-
|
|
5
|
+
content: string;
|
|
7
6
|
suffix: string;
|
|
7
|
+
checkbox: string;
|
|
8
8
|
arrow: string;
|
|
9
9
|
childrenWrap: string;
|
|
10
10
|
} & {
|
|
@@ -88,7 +88,8 @@ searchValue, selectedValue, onToggleSelected, ...props }) => {
|
|
|
88
88
|
params.opt?.onPointerEnter?.(e);
|
|
89
89
|
setVerticalIndex(-1);
|
|
90
90
|
},
|
|
91
|
-
children: null
|
|
91
|
+
children: null,
|
|
92
|
+
scrollHere: void 0
|
|
92
93
|
});
|
|
93
94
|
if (options) {
|
|
94
95
|
return filteredOptions.map((opt, index) => {
|
|
@@ -11,6 +11,7 @@ export const Progress = memo(({ showInfo = true, renderInfo, color, status = 'de
|
|
|
11
11
|
const isColorSpecified = !!color;
|
|
12
12
|
color ??= 'primary';
|
|
13
13
|
const { colors: { success, error } } = useTheme();
|
|
14
|
+
value = Math.max(0, Math.min(value, 100));
|
|
14
15
|
const isSucceed = status === 'success' || (status !== 'error' && value === 100 && variant !== 'gauge');
|
|
15
16
|
const renderInfoFn = () => {
|
|
16
17
|
if (renderInfo) {
|
|
@@ -68,6 +69,6 @@ export const Progress = memo(({ showInfo = true, renderInfo, color, status = 'de
|
|
|
68
69
|
: void 0
|
|
69
70
|
}, children: [_jsx("circle", { ...commonCircleProps, className: classes.track, strokeDasharray: variant === 'gauge' ? strokeDasharray : void 0, strokeDashoffset: variant === 'gauge' ? strokeDasharray * gapDegree / 360 : void 0 }), _jsx("circle", { ...commonCircleProps, ref: barRef, css: cssAnimation, className: classes.bar, strokeDasharray: strokeDasharray, strokeDashoffset: variant === 'circular'
|
|
70
71
|
? strokeDasharray * (1 - value / 100)
|
|
71
|
-
: strokeDasharray * (1 -
|
|
72
|
+
: strokeDasharray * (1 - value / 100 * (1 - gapDegree / 360)) })] }), showInfo && !indeterminate &&
|
|
72
73
|
_jsx("div", { className: classes.info, children: renderInfoFn() })] }) }));
|
|
73
74
|
});
|