@xpyjs/gantt-react 0.0.1-rc.3 → 0.0.1-rc.5

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 CHANGED
@@ -175,13 +175,20 @@ const XGanttReact = react.forwardRef(
175
175
  ganttInstanceRef.current = null;
176
176
  }
177
177
  }, []);
178
+ const removeDataById = react.useCallback((id) => {
179
+ if (ganttInstanceRef.current) {
180
+ return ganttInstanceRef.current.removeDataById(id);
181
+ }
182
+ return false;
183
+ }, []);
178
184
  react.useImperativeHandle(ref, () => ({
179
185
  getInstance: () => ganttInstanceRef.current,
180
186
  jumpTo,
181
187
  getDataChain,
182
188
  scrollTo,
183
189
  getDataById,
184
- getDataSize
190
+ getDataSize,
191
+ removeDataById
185
192
  }), [jumpTo]);
186
193
  react.useEffect(() => {
187
194
  initGantt();
@@ -238,6 +245,10 @@ function useXGantt() {
238
245
  var _a;
239
246
  return ((_a = ganttRef.current) == null ? void 0 : _a.getDataSize()) || 0;
240
247
  }, []);
248
+ const removeDataById = react.useCallback((id) => {
249
+ var _a;
250
+ return ((_a = ganttRef.current) == null ? void 0 : _a.removeDataById(id)) || false;
251
+ }, []);
241
252
  return {
242
253
  ganttRef,
243
254
  getInstance,
@@ -245,7 +256,8 @@ function useXGantt() {
245
256
  getDataChain,
246
257
  scrollTo,
247
258
  getDataById,
248
- getDataSize
259
+ getDataSize,
260
+ removeDataById
249
261
  };
250
262
  }
251
263
  Object.defineProperty(exports, "colorjs", {
package/dist/index.d.ts CHANGED
@@ -87,6 +87,7 @@ export declare function useXGantt(): {
87
87
  scrollTo: (id?: string, highlight?: boolean) => boolean;
88
88
  getDataById: (id: string) => any;
89
89
  getDataSize: () => number;
90
+ removeDataById: (id: string) => boolean;
90
91
  };
91
92
 
92
93
  /**
@@ -406,6 +407,17 @@ export declare interface XGanttReactRef {
406
407
  * 获取当前数据集合的数量
407
408
  */
408
409
  getDataSize(): number;
410
+ /**
411
+ * 移除指定 ID 的数据。该操作会直接修改当前数据源,并且不可逆,请谨慎使用
412
+ * @param id 数据 ID
413
+ * @returns 是否成功移除
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * const success = gantt.removeDataById('task-1');
418
+ * ```
419
+ */
420
+ removeDataById(id: string): boolean;
409
421
  }
410
422
 
411
423
  export { XGanttUnit }
package/dist/index.js CHANGED
@@ -174,13 +174,20 @@ const XGanttReact = forwardRef(
174
174
  ganttInstanceRef.current = null;
175
175
  }
176
176
  }, []);
177
+ const removeDataById = useCallback((id) => {
178
+ if (ganttInstanceRef.current) {
179
+ return ganttInstanceRef.current.removeDataById(id);
180
+ }
181
+ return false;
182
+ }, []);
177
183
  useImperativeHandle(ref, () => ({
178
184
  getInstance: () => ganttInstanceRef.current,
179
185
  jumpTo,
180
186
  getDataChain,
181
187
  scrollTo,
182
188
  getDataById,
183
- getDataSize
189
+ getDataSize,
190
+ removeDataById
184
191
  }), [jumpTo]);
185
192
  useEffect(() => {
186
193
  initGantt();
@@ -237,6 +244,10 @@ function useXGantt() {
237
244
  var _a;
238
245
  return ((_a = ganttRef.current) == null ? void 0 : _a.getDataSize()) || 0;
239
246
  }, []);
247
+ const removeDataById = useCallback((id) => {
248
+ var _a;
249
+ return ((_a = ganttRef.current) == null ? void 0 : _a.removeDataById(id)) || false;
250
+ }, []);
240
251
  return {
241
252
  ganttRef,
242
253
  getInstance,
@@ -244,7 +255,8 @@ function useXGantt() {
244
255
  getDataChain,
245
256
  scrollTo,
246
257
  getDataById,
247
- getDataSize
258
+ getDataSize,
259
+ removeDataById
248
260
  };
249
261
  }
250
262
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpyjs/gantt-react",
3
- "version": "0.0.1-rc.3",
3
+ "version": "0.0.1-rc.5",
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-rc.3"
26
+ "@xpyjs/gantt-core": "0.0.1-rc.5"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "react": ">=16.8.0",