@xpyjs/gantt-react 0.0.1-beta.3 → 0.0.1-rc.1
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/index.cjs +48 -2
- package/dist/index.d.ts +32 -0
- package/dist/index.js +48 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -23,10 +23,12 @@ const XGanttReact = react.forwardRef(
|
|
|
23
23
|
onDoubleClickSlider,
|
|
24
24
|
onContextMenuSlider,
|
|
25
25
|
onMove,
|
|
26
|
+
onEnterSlider,
|
|
26
27
|
onHoverSlider,
|
|
27
28
|
onLeaveSlider,
|
|
28
29
|
onClickBaseline,
|
|
29
30
|
onContextMenuBaseline,
|
|
31
|
+
onEnterBaseline,
|
|
30
32
|
onHoverBaseline,
|
|
31
33
|
onLeaveBaseline,
|
|
32
34
|
...restProps
|
|
@@ -78,6 +80,9 @@ const XGanttReact = react.forwardRef(
|
|
|
78
80
|
if (onMove) {
|
|
79
81
|
instance.on("move", onMove);
|
|
80
82
|
}
|
|
83
|
+
if (onEnterSlider) {
|
|
84
|
+
instance.on("enter:slider", onEnterSlider);
|
|
85
|
+
}
|
|
81
86
|
if (onHoverSlider) {
|
|
82
87
|
instance.on("hover:slider", onHoverSlider);
|
|
83
88
|
}
|
|
@@ -90,6 +95,9 @@ const XGanttReact = react.forwardRef(
|
|
|
90
95
|
if (onContextMenuBaseline) {
|
|
91
96
|
instance.on("contextmenu:baseline", onContextMenuBaseline);
|
|
92
97
|
}
|
|
98
|
+
if (onEnterBaseline) {
|
|
99
|
+
instance.on("enter:baseline", onEnterBaseline);
|
|
100
|
+
}
|
|
93
101
|
if (onHoverBaseline) {
|
|
94
102
|
instance.on("hover:baseline", onHoverBaseline);
|
|
95
103
|
}
|
|
@@ -111,10 +119,12 @@ const XGanttReact = react.forwardRef(
|
|
|
111
119
|
onDoubleClickSlider,
|
|
112
120
|
onContextMenuSlider,
|
|
113
121
|
onMove,
|
|
122
|
+
onEnterSlider,
|
|
114
123
|
onHoverSlider,
|
|
115
124
|
onLeaveSlider,
|
|
116
125
|
onClickBaseline,
|
|
117
126
|
onContextMenuBaseline,
|
|
127
|
+
onEnterBaseline,
|
|
118
128
|
onHoverBaseline,
|
|
119
129
|
onLeaveBaseline
|
|
120
130
|
]);
|
|
@@ -141,6 +151,24 @@ const XGanttReact = react.forwardRef(
|
|
|
141
151
|
current: void 0
|
|
142
152
|
};
|
|
143
153
|
}, []);
|
|
154
|
+
const scrollTo = react.useCallback((id, highlight) => {
|
|
155
|
+
if (ganttInstanceRef.current) {
|
|
156
|
+
return ganttInstanceRef.current.scrollTo(id, highlight);
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}, []);
|
|
160
|
+
const getDataById = react.useCallback((id) => {
|
|
161
|
+
if (ganttInstanceRef.current) {
|
|
162
|
+
return ganttInstanceRef.current.getDataById(id);
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}, []);
|
|
166
|
+
const getDataSize = react.useCallback(() => {
|
|
167
|
+
if (ganttInstanceRef.current) {
|
|
168
|
+
return ganttInstanceRef.current.getDataSize();
|
|
169
|
+
}
|
|
170
|
+
return 0;
|
|
171
|
+
}, []);
|
|
144
172
|
const destroyGantt = react.useCallback(() => {
|
|
145
173
|
if (ganttInstanceRef.current) {
|
|
146
174
|
ganttInstanceRef.current.destroy();
|
|
@@ -150,7 +178,10 @@ const XGanttReact = react.forwardRef(
|
|
|
150
178
|
react.useImperativeHandle(ref, () => ({
|
|
151
179
|
getInstance: () => ganttInstanceRef.current,
|
|
152
180
|
jumpTo,
|
|
153
|
-
getDataChain
|
|
181
|
+
getDataChain,
|
|
182
|
+
scrollTo,
|
|
183
|
+
getDataById,
|
|
184
|
+
getDataSize
|
|
154
185
|
}), [jumpTo]);
|
|
155
186
|
react.useEffect(() => {
|
|
156
187
|
initGantt();
|
|
@@ -195,11 +226,26 @@ function useXGantt() {
|
|
|
195
226
|
var _a;
|
|
196
227
|
return ((_a = ganttRef.current) == null ? void 0 : _a.getDataChain(id)) || [];
|
|
197
228
|
}, []);
|
|
229
|
+
const scrollTo = react.useCallback((id, highlight) => {
|
|
230
|
+
var _a;
|
|
231
|
+
return ((_a = ganttRef.current) == null ? void 0 : _a.scrollTo(id, highlight)) || false;
|
|
232
|
+
}, []);
|
|
233
|
+
const getDataById = react.useCallback((id) => {
|
|
234
|
+
var _a;
|
|
235
|
+
return ((_a = ganttRef.current) == null ? void 0 : _a.getDataById(id)) || null;
|
|
236
|
+
}, []);
|
|
237
|
+
const getDataSize = react.useCallback(() => {
|
|
238
|
+
var _a;
|
|
239
|
+
return ((_a = ganttRef.current) == null ? void 0 : _a.getDataSize()) || 0;
|
|
240
|
+
}, []);
|
|
198
241
|
return {
|
|
199
242
|
ganttRef,
|
|
200
243
|
getInstance,
|
|
201
244
|
jumpTo,
|
|
202
|
-
getDataChain
|
|
245
|
+
getDataChain,
|
|
246
|
+
scrollTo,
|
|
247
|
+
getDataById,
|
|
248
|
+
getDataSize
|
|
203
249
|
};
|
|
204
250
|
}
|
|
205
251
|
Object.defineProperty(exports, "colorjs", {
|
package/dist/index.d.ts
CHANGED
|
@@ -84,6 +84,9 @@ export declare function useXGantt(): {
|
|
|
84
84
|
getInstance: () => XGantt | null;
|
|
85
85
|
jumpTo: (date?: any) => boolean;
|
|
86
86
|
getDataChain: (id: string) => DataChain | never[];
|
|
87
|
+
scrollTo: (id?: string, highlight?: boolean) => boolean;
|
|
88
|
+
getDataById: (id: string) => any;
|
|
89
|
+
getDataSize: () => number;
|
|
87
90
|
};
|
|
88
91
|
|
|
89
92
|
/**
|
|
@@ -263,6 +266,14 @@ export declare interface XGanttReactProps extends Omit<React.HTMLAttributes<HTML
|
|
|
263
266
|
* @param data 移动的任务信息数组,包含新旧位置信息
|
|
264
267
|
*/
|
|
265
268
|
onMove?: EventMap["move"];
|
|
269
|
+
/**
|
|
270
|
+
* 鼠标进入任务条的事件回调
|
|
271
|
+
*
|
|
272
|
+
* @description 当鼠标进入任务条时触发
|
|
273
|
+
* @param e 鼠标事件对象
|
|
274
|
+
* @param data 进入的任务数据
|
|
275
|
+
*/
|
|
276
|
+
onEnterSlider?: EventMap["enter:slider"];
|
|
266
277
|
/**
|
|
267
278
|
* 鼠标悬停在任务条的事件回调
|
|
268
279
|
*
|
|
@@ -295,6 +306,15 @@ export declare interface XGanttReactProps extends Omit<React.HTMLAttributes<HTML
|
|
|
295
306
|
* @param baseline 右键的基线数据
|
|
296
307
|
*/
|
|
297
308
|
onContextMenuBaseline?: EventMap["contextmenu:baseline"];
|
|
309
|
+
/**
|
|
310
|
+
* 基线进入事件回调
|
|
311
|
+
*
|
|
312
|
+
* @description 当鼠标进入基线时触发
|
|
313
|
+
* @param e 鼠标事件对象
|
|
314
|
+
* @param data 进入的任务数据
|
|
315
|
+
* @param baseline 进入的基线数据
|
|
316
|
+
*/
|
|
317
|
+
onEnterBaseline?: EventMap["enter:baseline"];
|
|
298
318
|
/**
|
|
299
319
|
* 基线悬停事件回调
|
|
300
320
|
*
|
|
@@ -370,10 +390,22 @@ export declare interface XGanttReactRef {
|
|
|
370
390
|
* ```
|
|
371
391
|
*/
|
|
372
392
|
jumpTo: (date?: any) => boolean;
|
|
393
|
+
/**
|
|
394
|
+
* 滚动到指定数据
|
|
395
|
+
*/
|
|
396
|
+
scrollTo: (id?: string, highlight?: boolean) => boolean;
|
|
373
397
|
/**
|
|
374
398
|
* 获取指定任务的所有相关联的完整路径,包含所有连接线与任务节点
|
|
375
399
|
*/
|
|
376
400
|
getDataChain(id: string): DataChain;
|
|
401
|
+
/**
|
|
402
|
+
* 获取某一条数据
|
|
403
|
+
*/
|
|
404
|
+
getDataById(id: string): any | null;
|
|
405
|
+
/**
|
|
406
|
+
* 获取当前数据集合的数量
|
|
407
|
+
*/
|
|
408
|
+
getDataSize(): number;
|
|
377
409
|
}
|
|
378
410
|
|
|
379
411
|
export { XGanttUnit }
|
package/dist/index.js
CHANGED
|
@@ -22,10 +22,12 @@ const XGanttReact = forwardRef(
|
|
|
22
22
|
onDoubleClickSlider,
|
|
23
23
|
onContextMenuSlider,
|
|
24
24
|
onMove,
|
|
25
|
+
onEnterSlider,
|
|
25
26
|
onHoverSlider,
|
|
26
27
|
onLeaveSlider,
|
|
27
28
|
onClickBaseline,
|
|
28
29
|
onContextMenuBaseline,
|
|
30
|
+
onEnterBaseline,
|
|
29
31
|
onHoverBaseline,
|
|
30
32
|
onLeaveBaseline,
|
|
31
33
|
...restProps
|
|
@@ -77,6 +79,9 @@ const XGanttReact = forwardRef(
|
|
|
77
79
|
if (onMove) {
|
|
78
80
|
instance.on("move", onMove);
|
|
79
81
|
}
|
|
82
|
+
if (onEnterSlider) {
|
|
83
|
+
instance.on("enter:slider", onEnterSlider);
|
|
84
|
+
}
|
|
80
85
|
if (onHoverSlider) {
|
|
81
86
|
instance.on("hover:slider", onHoverSlider);
|
|
82
87
|
}
|
|
@@ -89,6 +94,9 @@ const XGanttReact = forwardRef(
|
|
|
89
94
|
if (onContextMenuBaseline) {
|
|
90
95
|
instance.on("contextmenu:baseline", onContextMenuBaseline);
|
|
91
96
|
}
|
|
97
|
+
if (onEnterBaseline) {
|
|
98
|
+
instance.on("enter:baseline", onEnterBaseline);
|
|
99
|
+
}
|
|
92
100
|
if (onHoverBaseline) {
|
|
93
101
|
instance.on("hover:baseline", onHoverBaseline);
|
|
94
102
|
}
|
|
@@ -110,10 +118,12 @@ const XGanttReact = forwardRef(
|
|
|
110
118
|
onDoubleClickSlider,
|
|
111
119
|
onContextMenuSlider,
|
|
112
120
|
onMove,
|
|
121
|
+
onEnterSlider,
|
|
113
122
|
onHoverSlider,
|
|
114
123
|
onLeaveSlider,
|
|
115
124
|
onClickBaseline,
|
|
116
125
|
onContextMenuBaseline,
|
|
126
|
+
onEnterBaseline,
|
|
117
127
|
onHoverBaseline,
|
|
118
128
|
onLeaveBaseline
|
|
119
129
|
]);
|
|
@@ -140,6 +150,24 @@ const XGanttReact = forwardRef(
|
|
|
140
150
|
current: void 0
|
|
141
151
|
};
|
|
142
152
|
}, []);
|
|
153
|
+
const scrollTo = useCallback((id, highlight) => {
|
|
154
|
+
if (ganttInstanceRef.current) {
|
|
155
|
+
return ganttInstanceRef.current.scrollTo(id, highlight);
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}, []);
|
|
159
|
+
const getDataById = useCallback((id) => {
|
|
160
|
+
if (ganttInstanceRef.current) {
|
|
161
|
+
return ganttInstanceRef.current.getDataById(id);
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}, []);
|
|
165
|
+
const getDataSize = useCallback(() => {
|
|
166
|
+
if (ganttInstanceRef.current) {
|
|
167
|
+
return ganttInstanceRef.current.getDataSize();
|
|
168
|
+
}
|
|
169
|
+
return 0;
|
|
170
|
+
}, []);
|
|
143
171
|
const destroyGantt = useCallback(() => {
|
|
144
172
|
if (ganttInstanceRef.current) {
|
|
145
173
|
ganttInstanceRef.current.destroy();
|
|
@@ -149,7 +177,10 @@ const XGanttReact = forwardRef(
|
|
|
149
177
|
useImperativeHandle(ref, () => ({
|
|
150
178
|
getInstance: () => ganttInstanceRef.current,
|
|
151
179
|
jumpTo,
|
|
152
|
-
getDataChain
|
|
180
|
+
getDataChain,
|
|
181
|
+
scrollTo,
|
|
182
|
+
getDataById,
|
|
183
|
+
getDataSize
|
|
153
184
|
}), [jumpTo]);
|
|
154
185
|
useEffect(() => {
|
|
155
186
|
initGantt();
|
|
@@ -194,11 +225,26 @@ function useXGantt() {
|
|
|
194
225
|
var _a;
|
|
195
226
|
return ((_a = ganttRef.current) == null ? void 0 : _a.getDataChain(id)) || [];
|
|
196
227
|
}, []);
|
|
228
|
+
const scrollTo = useCallback((id, highlight) => {
|
|
229
|
+
var _a;
|
|
230
|
+
return ((_a = ganttRef.current) == null ? void 0 : _a.scrollTo(id, highlight)) || false;
|
|
231
|
+
}, []);
|
|
232
|
+
const getDataById = useCallback((id) => {
|
|
233
|
+
var _a;
|
|
234
|
+
return ((_a = ganttRef.current) == null ? void 0 : _a.getDataById(id)) || null;
|
|
235
|
+
}, []);
|
|
236
|
+
const getDataSize = useCallback(() => {
|
|
237
|
+
var _a;
|
|
238
|
+
return ((_a = ganttRef.current) == null ? void 0 : _a.getDataSize()) || 0;
|
|
239
|
+
}, []);
|
|
197
240
|
return {
|
|
198
241
|
ganttRef,
|
|
199
242
|
getInstance,
|
|
200
243
|
jumpTo,
|
|
201
|
-
getDataChain
|
|
244
|
+
getDataChain,
|
|
245
|
+
scrollTo,
|
|
246
|
+
getDataById,
|
|
247
|
+
getDataSize
|
|
202
248
|
};
|
|
203
249
|
}
|
|
204
250
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpyjs/gantt-react",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-rc.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React wrapper for x-gantt",
|
|
6
6
|
"author": "JeremyJone",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"README.md"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@xpyjs/gantt-core": "0.0.1-
|
|
26
|
+
"@xpyjs/gantt-core": "0.0.1-rc.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": ">=16.8.0",
|