@canlooks/can-ui 0.0.96 → 0.0.98
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 +5 -1
- package/dist/cjs/components/menuItem/menuItem.js +1 -1
- package/dist/cjs/components/menuItem/menuItem.style.d.ts +2 -2
- 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/popper/popper.js +26 -21
- 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/select/select.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/cjs/utils/utils.d.ts +1 -1
- 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 +5 -1
- package/dist/esm/components/menuItem/menuItem.js +1 -1
- package/dist/esm/components/menuItem/menuItem.style.d.ts +2 -2
- 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/popper/popper.js +26 -21
- 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/select/select.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/dist/esm/utils/utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,248 +1,138 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.classes = void 0;
|
|
4
|
+
exports.useStyle = useStyle;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const react_1 = require("@emotion/react");
|
|
6
7
|
const utils_1 = require("../../utils");
|
|
7
8
|
const color_1 = tslib_1.__importDefault(require("color"));
|
|
9
|
+
const treeDnd_style_1 = require("./treeDnd.style");
|
|
8
10
|
exports.classes = (0, utils_1.defineInnerClasses)('tree', [
|
|
9
|
-
'levelBlock',
|
|
10
11
|
'search',
|
|
11
|
-
'container',
|
|
12
12
|
'node',
|
|
13
13
|
'contentWrap',
|
|
14
14
|
'indent',
|
|
15
15
|
'expand',
|
|
16
16
|
'checkbox',
|
|
17
|
-
'dragHandle',
|
|
18
17
|
'icon',
|
|
19
18
|
'label',
|
|
20
19
|
'prefix',
|
|
21
|
-
'suffix'
|
|
22
|
-
'dragMask',
|
|
23
|
-
'dragMaskPrev',
|
|
24
|
-
'dragMaskNext'
|
|
20
|
+
'suffix'
|
|
25
21
|
]);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.${exports.classes.container}[data-dragging=true] {
|
|
39
|
-
&, * {
|
|
40
|
-
cursor: grabbing;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.${exports.classes.node} {
|
|
45
|
-
display: flex;
|
|
46
|
-
align-items: center;
|
|
47
|
-
padding-right: ${spacing[2]}px;
|
|
48
|
-
border-radius: ${borderRadius}px;
|
|
49
|
-
transition: background-color .25s ${easing.easeOut};
|
|
50
|
-
touch-action: none;
|
|
51
|
-
-webkit-tap-highlight-color: transparent;
|
|
52
|
-
|
|
53
|
-
&[data-disabled=true] {
|
|
54
|
-
color: ${text.disabled};
|
|
55
|
-
cursor: not-allowed;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&:not([data-read-only=true]) {
|
|
59
|
-
cursor: pointer;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&[data-selected=true] {
|
|
63
|
-
background-color: ${selectedBg};
|
|
64
|
-
|
|
65
|
-
&:hover {
|
|
66
|
-
background-color: ${selectedHover};
|
|
22
|
+
function useStyle({ indent }) {
|
|
23
|
+
return [
|
|
24
|
+
(0, utils_1.useCss)(({ spacing, mode, borderRadius, text, easing, gray, divider, colors }) => {
|
|
25
|
+
const c = (0, color_1.default)(colors.primary.main);
|
|
26
|
+
const hover = gray(mode === 'light' ? .05 : .2);
|
|
27
|
+
const active = gray(mode === 'light' ? .1 : .12);
|
|
28
|
+
const selectedBg = c.alpha(mode === 'light' ? .1 : .2).string();
|
|
29
|
+
const selectedHover = c.alpha(mode === 'light' ? .07 : .17).string();
|
|
30
|
+
const selectedActive = c.alpha(mode === 'light' ? .13 : .23).string();
|
|
31
|
+
return (0, react_1.css) `
|
|
32
|
+
.${exports.classes.search} {
|
|
33
|
+
margin-bottom: ${spacing[3]}px;
|
|
67
34
|
}
|
|
68
35
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
background-color: ${active};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.${exports.classes.indent} {
|
|
85
|
-
align-self: stretch;
|
|
86
|
-
display: flex;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.${exports.classes.expand} {
|
|
90
|
-
width: 29px;
|
|
91
|
-
align-self: stretch;
|
|
92
|
-
align-items: center;
|
|
93
|
-
justify-content: center;
|
|
94
|
-
|
|
95
|
-
.${exports.classes.icon} {
|
|
96
|
-
transition: rotate .25s ${easing.easeOut};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.${exports.classes.contentWrap} {
|
|
101
|
-
flex: 1;
|
|
102
|
-
display: flex;
|
|
103
|
-
align-items: center;
|
|
104
|
-
position: relative;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.${exports.classes.dragHandle} {
|
|
108
|
-
width: 20px;
|
|
109
|
-
margin-right: ${spacing[3]}px;
|
|
110
|
-
text-align: center;
|
|
111
|
-
color: ${gray(.12)};
|
|
112
|
-
cursor: grab;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.${exports.classes.checkbox} {
|
|
116
|
-
margin-right: ${spacing[3]}px;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.${exports.classes.label} {
|
|
120
|
-
flex: 1;
|
|
121
|
-
padding: 5px 0;
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.${exports.classes.prefix} {
|
|
126
|
-
color: ${text.secondary};
|
|
127
|
-
margin-right: ${spacing[2]}px;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.${exports.classes.suffix} {
|
|
131
|
-
color: ${text.disabled};
|
|
132
|
-
margin-left: ${spacing[2]}px;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.${exports.classes.dragMask} {
|
|
136
|
-
position: absolute;
|
|
137
|
-
inset: 0;
|
|
138
|
-
|
|
139
|
-
> div {
|
|
140
|
-
width: 100%;
|
|
141
|
-
height: 50%;
|
|
142
|
-
position: absolute;
|
|
143
|
-
left: 0;
|
|
144
|
-
|
|
145
|
-
&:before, &:after {
|
|
146
|
-
content: '';
|
|
147
|
-
display: none;
|
|
148
|
-
position: absolute;
|
|
149
|
-
pointer-events: none;
|
|
36
|
+
.${exports.classes.node} {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
padding-right: ${spacing[2]}px;
|
|
40
|
+
border-radius: ${borderRadius}px;
|
|
41
|
+
transition: background-color .25s ${easing.easeOut};
|
|
42
|
+
touch-action: none;
|
|
43
|
+
-webkit-tap-highlight-color: transparent;
|
|
44
|
+
|
|
45
|
+
&[data-disabled=true] {
|
|
46
|
+
color: ${text.disabled};
|
|
47
|
+
cursor: not-allowed;
|
|
150
48
|
}
|
|
151
49
|
|
|
152
|
-
&:
|
|
153
|
-
|
|
154
|
-
height: 8px;
|
|
155
|
-
border: 2px solid ${colors.primary.main};
|
|
156
|
-
border-radius: 50%;
|
|
157
|
-
left: 0;
|
|
50
|
+
&:not([data-read-only=true]) {
|
|
51
|
+
cursor: pointer;
|
|
158
52
|
}
|
|
159
53
|
|
|
160
|
-
|
|
161
|
-
width:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
left: 8px;
|
|
54
|
+
.${exports.classes.indent} {
|
|
55
|
+
width: ${indent}px;
|
|
56
|
+
align-self: stretch;
|
|
57
|
+
display: flex;
|
|
165
58
|
}
|
|
166
59
|
|
|
167
|
-
|
|
168
|
-
|
|
60
|
+
.${exports.classes.expand} {
|
|
61
|
+
width: 29px;
|
|
62
|
+
align-self: stretch;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
169
65
|
|
|
170
|
-
|
|
171
|
-
|
|
66
|
+
.${exports.classes.icon} {
|
|
67
|
+
transition: rotate .25s ${easing.easeOut};
|
|
172
68
|
}
|
|
69
|
+
}
|
|
173
70
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
71
|
+
.${exports.classes.contentWrap} {
|
|
72
|
+
flex: 1;
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
position: relative;
|
|
177
76
|
}
|
|
178
77
|
|
|
179
|
-
|
|
180
|
-
|
|
78
|
+
.${exports.classes.checkbox} {
|
|
79
|
+
margin-right: ${spacing[3]}px;
|
|
80
|
+
}
|
|
181
81
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
82
|
+
.${exports.classes.label} {
|
|
83
|
+
flex: 1;
|
|
84
|
+
padding: 6px 0;
|
|
185
85
|
|
|
186
|
-
&:after {
|
|
187
|
-
bottom: -1px;
|
|
188
|
-
}
|
|
189
86
|
}
|
|
190
87
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
88
|
+
.${exports.classes.prefix} {
|
|
89
|
+
color: ${text.secondary};
|
|
90
|
+
margin-right: ${spacing[2]}px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.${exports.classes.suffix} {
|
|
94
|
+
color: ${text.disabled};
|
|
95
|
+
margin-left: ${spacing[2]}px;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:not(:has([data-dragging=true])) { {
|
|
100
|
+
.${exports.classes.node} {
|
|
101
|
+
&[data-selected=true] {
|
|
102
|
+
background-color: ${selectedBg};
|
|
103
|
+
|
|
104
|
+
&:hover {
|
|
105
|
+
background-color: ${selectedHover};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&:active {
|
|
109
|
+
transition: background-color 0s;
|
|
110
|
+
background-color: ${selectedActive};
|
|
111
|
+
}
|
|
201
112
|
}
|
|
202
113
|
|
|
203
|
-
&:
|
|
204
|
-
|
|
205
|
-
left: 36px;
|
|
114
|
+
&:not([data-disabled=true]):not([data-selected=true]):hover {
|
|
115
|
+
background-color: ${hover};
|
|
206
116
|
}
|
|
207
|
-
}
|
|
208
117
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
118
|
+
&:not([data-disabled=true]):not([data-selected=true]):active {
|
|
119
|
+
transition: background-color 0s;
|
|
120
|
+
background-color: ${active};
|
|
212
121
|
}
|
|
213
122
|
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
&[data-show-line=true] {
|
|
219
|
-
.${exports.classes.indent}:after {
|
|
220
|
-
content: '';
|
|
221
|
-
width: 1px;
|
|
222
|
-
height: 100%;
|
|
223
|
-
margin-left: 14px;
|
|
224
|
-
background-color: ${divider};
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
&, .${exports.classes.levelBlock} {
|
|
229
|
-
&[data-active=true] {
|
|
230
|
-
outline: 1px dashed ${colors.primary.main};
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
&[data-sortable=true] {
|
|
235
|
-
.${exports.classes.node} {
|
|
236
|
-
&[data-dragging=true] {
|
|
237
|
-
&, &:active {
|
|
238
|
-
background-color: ${selectedBg};
|
|
239
|
-
}
|
|
240
|
-
}
|
|
123
|
+
}}
|
|
241
124
|
|
|
242
|
-
|
|
243
|
-
|
|
125
|
+
&[data-show-line=true] {
|
|
126
|
+
.${exports.classes.indent}:after {
|
|
127
|
+
content: '';
|
|
128
|
+
width: 1px;
|
|
129
|
+
height: 100%;
|
|
130
|
+
margin-left: 14px;
|
|
131
|
+
background-color: ${divider};
|
|
132
|
+
}
|
|
244
133
|
}
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
134
|
+
`;
|
|
135
|
+
}),
|
|
136
|
+
(0, treeDnd_style_1.useStyle)({ indent })
|
|
137
|
+
];
|
|
138
|
+
}
|
|
@@ -5,21 +5,17 @@ type TreeDndContextItem<T> = [T | undefined, Dispatch<SetStateAction<T | undefin
|
|
|
5
5
|
type ITreeDndContext = {
|
|
6
6
|
sortable: boolean;
|
|
7
7
|
showDragHandle: boolean;
|
|
8
|
-
containerRef: RefObject<HTMLDivElement | null>;
|
|
9
|
-
isOffsetSatisfied: [boolean, Dispatch<SetStateAction<boolean>>];
|
|
10
8
|
dragging: TreeDndContextItem<Id>;
|
|
11
|
-
overing:
|
|
12
|
-
placement:
|
|
9
|
+
overing: RefObject<Id | undefined>;
|
|
10
|
+
placement: RefObject<SortPlacement | undefined>;
|
|
13
11
|
onSort: TreeBaseProps<any>['onSort'];
|
|
14
|
-
overingTimer: RefObject<any>;
|
|
15
12
|
};
|
|
16
13
|
export declare const TreeDndContext: import("react").Context<ITreeDndContext>;
|
|
17
14
|
export declare function useTreeDndContext(): ITreeDndContext;
|
|
18
|
-
export declare const TreeDnd: import("react").MemoExoticComponent<({ sortable, showDragHandle, onSort,
|
|
15
|
+
export declare const TreeDnd: import("react").MemoExoticComponent<({ sortable, showDragHandle, onSort, children }: {
|
|
19
16
|
sortable: boolean;
|
|
20
17
|
showDragHandle: boolean;
|
|
21
18
|
onSort: TreeBaseProps<any>["onSort"];
|
|
22
|
-
containerRef: RefObject<HTMLDivElement | null>;
|
|
23
19
|
children: ReactNode;
|
|
24
20
|
}) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
25
21
|
export {};
|
|
@@ -4,29 +4,17 @@ exports.TreeDnd = exports.TreeDndContext = void 0;
|
|
|
4
4
|
exports.useTreeDndContext = useTreeDndContext;
|
|
5
5
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
const
|
|
8
|
-
const tree_style_1 = require("./tree.style");
|
|
7
|
+
const treeDnd_style_1 = require("./treeDnd.style");
|
|
9
8
|
exports.TreeDndContext = (0, react_1.createContext)({});
|
|
10
9
|
function useTreeDndContext() {
|
|
11
10
|
return (0, react_1.useContext)(exports.TreeDndContext);
|
|
12
11
|
}
|
|
13
|
-
exports.TreeDnd = (0, react_1.memo)(({ sortable, showDragHandle, onSort,
|
|
14
|
-
const isOffsetSatisfied = (0, react_1.useState)(false);
|
|
12
|
+
exports.TreeDnd = (0, react_1.memo)(({ sortable, showDragHandle, onSort, children }) => {
|
|
15
13
|
const dragging = (0, react_1.useState)(void 0);
|
|
16
|
-
const overing = (0, react_1.
|
|
17
|
-
const placement = (0,
|
|
18
|
-
(0, react_1.useEffect)(() => {
|
|
19
|
-
if (dragging[0]) {
|
|
20
|
-
document.documentElement.style.cursor = 'grabbing';
|
|
21
|
-
}
|
|
22
|
-
return () => {
|
|
23
|
-
document.documentElement.style.cursor = '';
|
|
24
|
-
};
|
|
25
|
-
}, [dragging[0]]);
|
|
26
|
-
const overingTimer = (0, react_1.useRef)(void 0);
|
|
14
|
+
const overing = (0, react_1.useRef)(void 0);
|
|
15
|
+
const placement = (0, react_1.useRef)(void 0);
|
|
27
16
|
return ((0, jsx_runtime_1.jsx)(exports.TreeDndContext, { value: {
|
|
28
|
-
sortable, showDragHandle, onSort,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { className: tree_style_1.classes.container, "data-dragging": !!dragging[0], children: children }) }));
|
|
17
|
+
sortable, showDragHandle, onSort,
|
|
18
|
+
dragging, overing, placement
|
|
19
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: treeDnd_style_1.treeDndClasses.levelBlock, children: children }) }));
|
|
32
20
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const treeDndClasses: {
|
|
2
|
+
mask: string;
|
|
3
|
+
child: string;
|
|
4
|
+
levelBlock: string;
|
|
5
|
+
dragHandle: string;
|
|
6
|
+
predecessor: string;
|
|
7
|
+
sibling: string;
|
|
8
|
+
siblingPrev: string;
|
|
9
|
+
siblingNext: string;
|
|
10
|
+
} & {
|
|
11
|
+
root: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function useStyle({ indent }: {
|
|
14
|
+
indent: number;
|
|
15
|
+
}): import("@emotion/react").SerializedStyles;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.treeDndClasses = void 0;
|
|
4
|
+
exports.useStyle = useStyle;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const react_1 = require("@emotion/react");
|
|
8
|
+
const tree_style_1 = require("./tree.style");
|
|
9
|
+
const color_1 = tslib_1.__importDefault(require("color"));
|
|
10
|
+
exports.treeDndClasses = (0, utils_1.defineInnerClasses)('tree-dnd', [
|
|
11
|
+
'levelBlock',
|
|
12
|
+
'dragHandle',
|
|
13
|
+
'mask',
|
|
14
|
+
'predecessor',
|
|
15
|
+
'sibling',
|
|
16
|
+
'siblingPrev',
|
|
17
|
+
'siblingNext',
|
|
18
|
+
'child'
|
|
19
|
+
]);
|
|
20
|
+
function useStyle({ indent }) {
|
|
21
|
+
return (0, utils_1.useCss)(({ mode, spacing, gray, colors }) => (0, react_1.css) `
|
|
22
|
+
.${tree_style_1.classes.node} {
|
|
23
|
+
position: relative;
|
|
24
|
+
|
|
25
|
+
&[data-dragging=true] {
|
|
26
|
+
background-color: ${(0, color_1.default)(colors.primary.main).alpha(mode === 'light' ? .13 : .23).string()} !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&[data-active=true] {
|
|
30
|
+
outline: 2px solid ${colors.primary.main};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.${exports.treeDndClasses.dragHandle} {
|
|
35
|
+
width: 20px;
|
|
36
|
+
margin-right: ${spacing[3]}px;
|
|
37
|
+
text-align: center;
|
|
38
|
+
color: ${gray(.12)};
|
|
39
|
+
cursor: grab;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.${exports.treeDndClasses.mask} {
|
|
43
|
+
display: flex;
|
|
44
|
+
position: absolute;
|
|
45
|
+
inset: 0;
|
|
46
|
+
z-index: 1;
|
|
47
|
+
|
|
48
|
+
.${tree_style_1.classes.indent}:after {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.${exports.treeDndClasses.predecessor} {
|
|
53
|
+
width: ${indent}px;
|
|
54
|
+
position: relative;
|
|
55
|
+
|
|
56
|
+
&:has(+ .${exports.treeDndClasses.sibling}) {
|
|
57
|
+
width: 29px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&[data-active=true] {
|
|
61
|
+
&:before, &:after {
|
|
62
|
+
content: '';
|
|
63
|
+
position: absolute;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:before {
|
|
67
|
+
width: 8px;
|
|
68
|
+
height: 8px;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
border: 2px solid ${colors.primary.main};
|
|
71
|
+
left: 0;
|
|
72
|
+
bottom: -4px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:after {
|
|
76
|
+
width: calc(100% - 8px);
|
|
77
|
+
height: 2px;
|
|
78
|
+
background: ${colors.primary.main};
|
|
79
|
+
left: 8px;
|
|
80
|
+
bottom: -1px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
& ~ * {
|
|
84
|
+
&:after {
|
|
85
|
+
content: '';
|
|
86
|
+
width: 100%;
|
|
87
|
+
height: 2px;
|
|
88
|
+
background: ${colors.primary.main};
|
|
89
|
+
position: absolute;
|
|
90
|
+
left: 0;
|
|
91
|
+
bottom: -1px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.${exports.treeDndClasses.sibling} {
|
|
98
|
+
width: ${indent * 2}px;
|
|
99
|
+
flex: 1;
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
position: relative;
|
|
103
|
+
|
|
104
|
+
.${exports.treeDndClasses.siblingPrev}, .${exports.treeDndClasses.siblingNext} {
|
|
105
|
+
flex: 1;
|
|
106
|
+
position: relative;
|
|
107
|
+
|
|
108
|
+
&[data-active=true] {
|
|
109
|
+
&:before, &:after {
|
|
110
|
+
content: '';
|
|
111
|
+
position: absolute;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&:before {
|
|
115
|
+
width: 8px;
|
|
116
|
+
height: 8px;
|
|
117
|
+
border-radius: 50%;
|
|
118
|
+
border: 2px solid ${colors.primary.main};
|
|
119
|
+
left: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:after {
|
|
123
|
+
width: calc(100% - 8px);
|
|
124
|
+
height: 2px;
|
|
125
|
+
background: ${colors.primary.main};
|
|
126
|
+
left: 8px;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.${exports.treeDndClasses.siblingPrev} {
|
|
132
|
+
&:before {
|
|
133
|
+
top: -4px
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&:after {
|
|
137
|
+
top: -1px;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.${exports.treeDndClasses.siblingNext} {
|
|
142
|
+
&:before {
|
|
143
|
+
bottom: -4px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&:after {
|
|
147
|
+
bottom: -1px;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.${exports.treeDndClasses.child} {
|
|
152
|
+
width: calc(100% - ${indent * 2}px);
|
|
153
|
+
height: 50%;
|
|
154
|
+
position: absolute;
|
|
155
|
+
right: 0;
|
|
156
|
+
bottom: 0;
|
|
157
|
+
|
|
158
|
+
&[data-active=true] {
|
|
159
|
+
&:before, &:after {
|
|
160
|
+
content: '';
|
|
161
|
+
position: absolute;
|
|
162
|
+
bottom: -1px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&:before {
|
|
166
|
+
width: 8px;
|
|
167
|
+
height: 8px;
|
|
168
|
+
border-left: 2px solid ${colors.primary.main};
|
|
169
|
+
border-bottom: 2px solid ${colors.primary.main};
|
|
170
|
+
left: 0;
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&:after {
|
|
175
|
+
width: calc(100% - 12px);
|
|
176
|
+
height: 2px;
|
|
177
|
+
background: ${colors.primary.main};
|
|
178
|
+
left: 12px;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.${exports.treeDndClasses.levelBlock} {
|
|
186
|
+
&[data-active=true] {
|
|
187
|
+
outline: 1px dashed ${colors.primary.main};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
`, [indent]);
|
|
191
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { DivProps, Id } from '../../types';
|
|
3
|
-
export interface TreeNodeProps extends Omit<DivProps, 'prefix'> {
|
|
4
|
-
|
|
3
|
+
export interface TreeNodeProps extends Omit<DivProps, 'id' | 'prefix'> {
|
|
4
|
+
id: Id;
|
|
5
5
|
label?: ReactNode;
|
|
6
6
|
prefix?: ReactNode;
|
|
7
7
|
suffix?: ReactNode;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
-
/** @private
|
|
9
|
+
/** @private 表明该节点的层级 */
|
|
10
10
|
_level?: number;
|
|
11
11
|
}
|
|
12
|
-
export declare const TreeNode: React.MemoExoticComponent<({
|
|
12
|
+
export declare const TreeNode: React.MemoExoticComponent<({ id, label, prefix, suffix, disabled, _level, ...props }: TreeNodeProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|