@xpyjs/gantt-core 0.0.1-alpha.1 → 0.0.1-alpha.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xpyjs/gantt-core",
3
3
  "private": false,
4
- "version": "0.0.1-alpha.1",
4
+ "version": "0.0.1-alpha.3",
5
5
  "description": "A powerful and flexible Gantt chart component library for modern web applications with TypeScript support",
6
6
  "type": "module",
7
7
  "main": "./dist/x-gantt.umd.cjs",
@@ -72,6 +72,6 @@
72
72
  "test": "vitest",
73
73
  "test:coverage": "vitest run --coverage",
74
74
  "clean": "rimraf dist types",
75
- "release": "pnpm publish --access public --no-git-checks"
75
+ "release": "pnpm publish --access public"
76
76
  }
77
77
  }
package/types/XGantt.d.ts CHANGED
@@ -27,7 +27,7 @@ import { EventMap } from "./types/event";
27
27
  * });
28
28
  *
29
29
  * // 更新配置
30
- * gantt.updateOptions({
30
+ * gantt.update({
31
31
  * unit: 'week',
32
32
  * primaryColor: '#007acc'
33
33
  * });
@@ -55,23 +55,23 @@ export declare class XGantt {
55
55
  *
56
56
  * @example
57
57
  * ```typescript
58
- * // 更新数据源
59
- * gantt.updateOptions({
58
+ * // 更新数据源。数据会被完全替换,除非原数据的 key 一致
59
+ * gantt.update({
60
60
  * data: newTaskData
61
61
  * });
62
62
  *
63
63
  * // 更新显示单位
64
- * gantt.updateOptions({
64
+ * gantt.update({
65
65
  * unit: 'month'
66
66
  * });
67
67
  *
68
68
  * // 更新主题色
69
- * gantt.updateOptions({
69
+ * gantt.update({
70
70
  * primaryColor: '#ff6b6b'
71
71
  * });
72
72
  *
73
73
  * // 批量更新多个配置
74
- * gantt.updateOptions({
74
+ * gantt.update({
75
75
  * unit: 'week',
76
76
  * primaryColor: '#4ecdc4',
77
77
  * dateFormat: 'YYYY-MM-DD',
@@ -79,13 +79,17 @@ export declare class XGantt {
79
79
  * height: 40
80
80
  * }
81
81
  * });
82
+ *
83
+ * // 完全替换配置(不合并)
84
+ * gantt.update(newOptions, { merge: false });
82
85
  * ```
86
+ *
83
87
  */
84
- updateOptions(options: IOptions, config?: IOptionConfig): void;
88
+ update(options: IOptions, config?: IOptionConfig): void;
85
89
  /**
86
90
  * 渲染甘特图视图
87
91
  *
88
- * @description 此方法通常不需要主动调用,初始化以及 `updateOptions` 中都会自动更新。 如果你需要强制刷新页面,可以在合适的时候调用此方法
92
+ * @description 此方法通常不需要主动调用,初始化以及 `update` 中都会自动更新。 如果你需要强制刷新页面,可以在合适的时候调用此方法
89
93
  */
90
94
  render(): void;
91
95
  /**
@@ -180,6 +184,7 @@ export declare class XGantt {
180
184
  * 同一个事件注册多个,只会执行最后一个监听器。
181
185
  *
182
186
  * 支持的事件类型包括:
187
+ * - `loaded`: 加载完成事件,组件初始化完成后触发
183
188
  * - `error`: 错误事件,当组件发生错误时触发
184
189
  * - `update:link`: 关联线更新事件
185
190
  * - `create:link`: 关联线创建事件
@@ -24,6 +24,7 @@ export declare class EventBus {
24
24
  offAll(): void;
25
25
  }
26
26
  export declare enum EventName {
27
+ LOADED = "loaded",
27
28
  COLUMN_WIDTH_CHANGE = "column-width-change",
28
29
  MOVE_GUIDELINE = "move-guideline",
29
30
  SHOW_GUIDELINE = "show-guideline",
@@ -48,6 +49,7 @@ export declare enum EventName {
48
49
  SLIDER_CLICK = "slider-click",
49
50
  SLIDER_DBL_CLICK = "slider-dbl-click",
50
51
  SLIDER_CONTEXTMENU = "slider-contextmenu",
52
+ SLIDER_MOVING = "slider-moving",
51
53
  ROW_HIGHLIGHT = "row-highlight",
52
54
  ROW_UNHIGHLIGHT = "row-unhighlight",
53
55
  TASK_DRAG_START = "task-drag-start",
@@ -57,9 +59,9 @@ export declare enum EventName {
57
59
  }
58
60
  export declare enum ErrorType {
59
61
  /** 连线不被允许 */
60
- LINK_NOT_ALLOWED = "link:not-allowed",
62
+ LINK_NOT_ALLOWED = "LINK_NOT_ALLOWED",
61
63
  /** 相同节点 */
62
- LINK_SAME = "link:same",
64
+ LINK_SAME = "LINK_SAME",
63
65
  /** 当前关联已存在 */
64
- LINK_EXIST = "link:exist"
66
+ LINK_EXIST = "LINK_EXIST"
65
67
  }
package/types/index.d.ts CHANGED
@@ -8,5 +8,6 @@ export declare const version: string;
8
8
  import type { IOptions, IOptionConfig, EmitData } from "./types";
9
9
  import type { EventMap } from "./types/event";
10
10
  import type { ILink } from "./types/link";
11
- import { ErrorType } from "./event";
12
- export type { IOptions, IOptionConfig, EmitData, EventMap, ILink, ErrorType };
11
+ import type { ErrorType } from "./event";
12
+ import type { XGanttUnit } from "./types/options";
13
+ export type { IOptions, IOptionConfig, EmitData, EventMap, ILink, ErrorType, XGanttUnit };
@@ -14,6 +14,7 @@ export declare class Renderer {
14
14
  private _id;
15
15
  private width;
16
16
  private height;
17
+ private isInitialized;
17
18
  getScrollbar(): Scrollbar;
18
19
  constructor(context: IContext, // 渲染器上下文
19
20
  container: HTMLElement);
@@ -10,6 +10,7 @@ export declare class LinkGroup {
10
10
  private linksGroup;
11
11
  private templateArrow;
12
12
  private isDragging;
13
+ private isSliderMoving;
13
14
  private selectedMap;
14
15
  private width;
15
16
  private height;
@@ -48,6 +49,7 @@ export declare class LinkGroup {
48
49
  * 计算关联线位置
49
50
  */
50
51
  private calculateLinks;
52
+ private createId;
51
53
  /** 生成 FS 连线 */
52
54
  private createFS;
53
55
  /** 生成 FF 连线 */
@@ -41,7 +41,7 @@ export declare class TableRow {
41
41
  /**
42
42
  * 更新行
43
43
  */
44
- update(): void;
44
+ update(task: Task): void;
45
45
  /**
46
46
  * 更新宽度
47
47
  */
@@ -2,6 +2,7 @@ import { ErrorType } from "../event";
2
2
  import { ILink } from "./link";
3
3
 
4
4
  export interface EventMap {
5
+ loaded: () => void;
5
6
  error: (error: ErrorType) => void;
6
7
  "update:link": (link: ILink) => void;
7
8
  "create:link": (link: ILink) => void;
@@ -1,5 +1,6 @@
1
1
  import { EmitData } from ".";
2
2
  import { IChartOptions } from "./chart";
3
+ import { ILink } from "./link";
3
4
  import { IPattern } from "./styles";
4
5
  import { ITableOptions } from "./table";
5
6
 
@@ -85,7 +86,11 @@ export interface IGanttOptions {
85
86
  * @argument {"S"} - 允许以 S,也就是左侧起始点作为终点创建连线
86
87
  * @argument {"F"} - 允许以 F,也就是右侧结束点作为终点创建连线
87
88
  */
88
- to: boolean | "S" | "F" | ((row: EmitData) => boolean | "S" | "F");
89
+ to:
90
+ | boolean
91
+ | "S"
92
+ | "F"
93
+ | ((row: EmitData, from: EmitData) => boolean | "S" | "F");
89
94
  };
90
95
  /** 默认关连线的颜色。每一条线可以单独配置后覆盖当前颜色。默认主色 */
91
96
  color?: string;
@@ -348,7 +353,7 @@ export interface IGanttOptions {
348
353
  *
349
354
  * - none: 不联动
350
355
  * - scale: 按比例缩放。按照伸缩比例进行联动
351
- * - fixed: 按固定值缩放。进针对两边超出进行缩放
356
+ * - fixed: 按固定值缩放。仅针对两边超出进行缩放
352
357
  */
353
358
  child: "none" | "scale" | "fixed";
354
359
  /**
@@ -505,11 +510,13 @@ export interface IGanttOptions {
505
510
  /**
506
511
  * 配置节假日期。可以针对不同节假日配置不同的背景颜色。默认使用统一配置颜色
507
512
  */
508
- holidays?: Array<{
509
- date: Date | number | string | Array<Date | number | string>;
510
- backgroundColor?: string;
511
- opacity?: number;
512
- }>;
513
+ holidays?: Array<
514
+ {
515
+ date: Date | number | string | Array<Date | number | string>;
516
+ backgroundColor?: string;
517
+ opacity?: number;
518
+ } & IPattern
519
+ >;
513
520
  } & IPattern;
514
521
 
515
522
  /** 滚动条配置 */
@@ -61,7 +61,7 @@ export interface ITableColumnStandard {
61
61
  */
62
62
  merge?: (
63
63
  value: any,
64
- row: any,
64
+ data: any,
65
65
  colIndex: number,
66
66
  level: number
67
67
  ) => { col: number; row: number } | undefined;