@xpyjs/gantt-core 0.0.1-alpha.3 → 0.0.1-alpha.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/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.3",
4
+ "version": "0.0.1-alpha.5",
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",
@@ -29,6 +29,7 @@ export declare enum EventName {
29
29
  MOVE_GUIDELINE = "move-guideline",
30
30
  SHOW_GUIDELINE = "show-guideline",
31
31
  HIDE_GUIDELINE = "hide-guideline",
32
+ TOGGLE_COLLAPSE = "toggle-collapse",
32
33
  SCROLL = "scroll",
33
34
  CHART_OFFSET_CHANGE = "chart_offset_change",
34
35
  DATA_UPDATE = "data-update",
@@ -43,6 +44,7 @@ export declare enum EventName {
43
44
  TASK_UNSELECTED = "task_unselected",
44
45
  SELECT_LINK = "select_link",
45
46
  CHECK_TASK = "check_task",
47
+ CONTEXT_LINK = "context_link",
46
48
  ROW_CLICK = "row-click",
47
49
  ROW_DBL_CLICK = "row-dbl-click",
48
50
  ROW_CONTEXTMENU = "row-contextmenu",
@@ -50,11 +52,17 @@ export declare enum EventName {
50
52
  SLIDER_DBL_CLICK = "slider-dbl-click",
51
53
  SLIDER_CONTEXTMENU = "slider-contextmenu",
52
54
  SLIDER_MOVING = "slider-moving",
55
+ SLIDER_HOVER = "slider-hover",
56
+ SLIDER_LEAVE = "slider-leave",
53
57
  ROW_HIGHLIGHT = "row-highlight",
54
58
  ROW_UNHIGHLIGHT = "row-unhighlight",
55
59
  TASK_DRAG_START = "task-drag-start",
56
60
  TASK_DRAG_MOVE = "task-drag-move",
57
61
  TASK_DRAG_END = "task-drag-end",
62
+ BASELINE_CLICK = "baseline-click",
63
+ BASELINE_CONTEXTMENU = "baseline-contextmenu",
64
+ BASELINE_MOUSEOVER = "baseline-mouseover",
65
+ BASELINE_MOUSEOUT = "baseline-mouseout",
58
66
  ERROR = "error"
59
67
  }
60
68
  export declare enum ErrorType {
@@ -0,0 +1,37 @@
1
+ import type { Dayjs } from "dayjs";
2
+ import { Store } from "@/store";
3
+ import { type EventBus } from "../event";
4
+ import { BaselineDiff } from "../types/baseline";
5
+ /**
6
+ * 基线数据模型
7
+ */
8
+ export declare class Baseline {
9
+ private store;
10
+ private event;
11
+ /** 基线ID */
12
+ id: string;
13
+ /** 任务ID */
14
+ taskId: string;
15
+ /** 开始时间 */
16
+ startTime?: Dayjs;
17
+ /** 结束时间 */
18
+ endTime?: Dayjs;
19
+ /** 基线名称 */
20
+ name?: string;
21
+ /** 原始数据 */
22
+ data: any;
23
+ /** 是否高亮 */
24
+ highlight: boolean;
25
+ /** 是否为指示器对比基线 */
26
+ target: boolean;
27
+ constructor(store: Store, event: EventBus, data: any);
28
+ getField(field: string): any;
29
+ /**
30
+ * 验证基线的有效性
31
+ */
32
+ validate(): boolean;
33
+ /**
34
+ * 获取基线与任务的时间差异分析
35
+ */
36
+ getTimeDiff(): BaselineDiff | null;
37
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Dayjs } from "dayjs";
2
2
  import { type EventBus } from "../event";
3
+ import { TaskType } from "../types/options";
3
4
  import { EmitData } from "@/types";
4
5
  import { Store } from "@/store";
5
6
  export declare class Task {
@@ -29,6 +30,8 @@ export declare class Task {
29
30
  * 任务进度
30
31
  */
31
32
  progress?: number;
33
+ /** 任务类型 */
34
+ type: TaskType;
32
35
  /**
33
36
  * 是否展开
34
37
  * 如果没有提供,则默认为 true
@@ -52,6 +55,10 @@ export declare class Task {
52
55
  * 在扁平化列表中的索引位置,从0开始
53
56
  */
54
57
  flatIndex: number;
58
+ /**
59
+ * 时间持续间隔
60
+ */
61
+ private duration;
55
62
  /**
56
63
  * 原始数据
57
64
  */
@@ -59,9 +66,13 @@ export declare class Task {
59
66
  private fields;
60
67
  constructor(store: Store, event: EventBus, data: any, parent?: Task, _id?: string);
61
68
  getField(field: string): any;
69
+ /** 切换展示模式时,需要调整时间 */
70
+ updateMode(): void;
62
71
  updateData(data: any): void;
63
72
  updateTime(startTime: Dayjs, endTime: Dayjs): void;
64
73
  clone(): Task;
65
74
  getEmitData(): EmitData;
66
75
  getAllChildren(): Task[];
76
+ isMilestone(): boolean;
77
+ isSummary(): boolean;
67
78
  }
@@ -0,0 +1,50 @@
1
+ import Konva from "konva";
2
+ import { Task } from "../../models/Task";
3
+ import { IContext } from "@/types/render";
4
+ export declare class ChartBaseline {
5
+ private context;
6
+ private stage;
7
+ private layer;
8
+ private tasks;
9
+ private chartBaselineGroup;
10
+ private indicatorGroup;
11
+ private baselineGroup;
12
+ private width;
13
+ private height;
14
+ private offsetX;
15
+ private offsetY;
16
+ constructor(context: IContext, stage: Konva.Stage, layer: Konva.Layer);
17
+ /**
18
+ * 注册事件
19
+ */
20
+ private registerEvents;
21
+ /**
22
+ * 调整基线大小
23
+ */
24
+ resize(width: number, height: number): void;
25
+ /**
26
+ * 设置偏移量 (响应滚动)
27
+ */
28
+ setOffset(x: number, y: number): void;
29
+ /**
30
+ * 更新数据
31
+ */
32
+ update(): void;
33
+ /**
34
+ * 渲染基线
35
+ */
36
+ render(tasks: Task[]): void;
37
+ /**
38
+ * 销毁关联线
39
+ */
40
+ destroy(): void;
41
+ /**
42
+ * 计算并渲染基线
43
+ */
44
+ private calculateBaselines;
45
+ private renderBaselineBar;
46
+ private renderText;
47
+ private renderCompareHighlight;
48
+ private renderCompareIndicator;
49
+ private bindEvents;
50
+ }
@@ -50,6 +50,7 @@ export declare class LinkGroup {
50
50
  */
51
51
  private calculateLinks;
52
52
  private createId;
53
+ private getPoints;
53
54
  /** 生成 FS 连线 */
54
55
  private createFS;
55
56
  /** 生成 FF 连线 */
@@ -11,9 +11,10 @@ export declare class ChartSlider {
11
11
  private offsetY;
12
12
  sliderGroup: Konva.Group;
13
13
  private slider;
14
- private sliderBg;
15
- private leftHandler;
16
- private rightHandler;
14
+ private sliderBar;
15
+ private sliderType;
16
+ private leftHandleGroup;
17
+ private rightHandleGroup;
17
18
  private progressGroup;
18
19
  private handlerWidth;
19
20
  private autoMoveTimer;
@@ -29,7 +30,8 @@ export declare class ChartSlider {
29
30
  constructor(context: IContext, x: number, y: number, task: Task, rowWidth: number);
30
31
  update(x: number, y: number): void;
31
32
  setOffset(x: number, y: number): void;
32
- private updateSize;
33
+ /** 太多需要 function 的判断,搞一个统一的转换 */
34
+ private unpackFunc;
33
35
  private render;
34
36
  private renderText;
35
37
  private renderProgress;
@@ -51,4 +53,6 @@ export declare class ChartSlider {
51
53
  private handleMouseEnter;
52
54
  private handleMouseLeave;
53
55
  private handleResizeHighlight;
56
+ /** 鼠标移入高亮 */
57
+ private handleBarHighlight;
54
58
  }
@@ -11,6 +11,7 @@ export declare class Chart {
11
11
  private holidayGroup;
12
12
  private todayLayer;
13
13
  private linkGroup;
14
+ private baselineGroup;
14
15
  private bgLayer;
15
16
  private bodyLayer;
16
17
  private width;
@@ -5,6 +5,7 @@ export declare class MiddleResizeLine {
5
5
  private line;
6
6
  private initialX;
7
7
  private initialWidth;
8
+ private collapseButton;
8
9
  constructor(root: IContext, container: HTMLElement);
9
10
  setOffset(x: number): void;
10
11
  /**
@@ -75,6 +75,7 @@ export declare class Scrollbar {
75
75
  private applyThumbStyles;
76
76
  private bindEvents;
77
77
  private unbindEvents;
78
+ private emit;
78
79
  private handleRootMouseMove;
79
80
  private handleScrollbarMouseEnter;
80
81
  private handleScrollbarMouseLeave;
@@ -46,6 +46,10 @@ export declare class ColumnManager {
46
46
  * Map<task_id, Map<col_index, object>>
47
47
  */
48
48
  private mergeInfo;
49
+ /**
50
+ * 收起表格
51
+ */
52
+ private collapseTable;
49
53
  constructor(context: IContext);
50
54
  /**
51
55
  * 初始化列数据
@@ -72,4 +76,6 @@ export declare class ColumnManager {
72
76
  clearMergeInfo(): void;
73
77
  getHandlerColumn(): IColumn<ITableColumnStandard>;
74
78
  isMultiHeader(): boolean;
79
+ collapse(): void;
80
+ isCollapsed(): boolean;
75
81
  }
@@ -2,6 +2,7 @@ import type { Dayjs } from "dayjs";
2
2
  import { type EventBus } from "../event";
3
3
  import { Task } from "../models/Task";
4
4
  import type { Store } from ".";
5
+ import { Baseline } from "../models/Baseline";
5
6
  export declare class DataManager {
6
7
  private store;
7
8
  private event;
@@ -30,6 +31,12 @@ export declare class DataManager {
30
31
  private selectedTaskId;
31
32
  /** 选中列表 */
32
33
  private checkedList;
34
+ /** 基线数据 */
35
+ private baselines;
36
+ /** 基线映射,使用ID作为键 */
37
+ private baselineMap;
38
+ /** 任务与基线映射,使用任务ID作为键。 一个任务可以对应多条基线 */
39
+ private baselineTaskMap;
33
40
  /** 数据最大层级。 0 开始 */
34
41
  dataLevel: number;
35
42
  constructor(store: Store, event: EventBus);
@@ -116,4 +123,10 @@ export declare class DataManager {
116
123
  toggleAllChecked(checked: boolean): void;
117
124
  isTaskChecked(task: Task): boolean;
118
125
  updateTaskTime(task: Task, startTime: Dayjs, endTime: Dayjs, direction?: "left" | "right" | "both", oldTasks?: Task[]): void;
126
+ setBaselines(baselines: any[]): void;
127
+ getBaselines(): Baseline[];
128
+ /** 根据ID获取基线 */
129
+ getBaselineById(id: string): Baseline | undefined;
130
+ /** 根据任务ID获取基线 */
131
+ getBaselinesByTaskId(taskId: string): Baseline[];
119
132
  }
@@ -8,4 +8,5 @@ export declare class OptionManager {
8
8
  setOptions(options: IOptions, config?: IOptionConfig): void;
9
9
  update(newOptions: IOptions): void;
10
10
  getRowBackgroundColor(task: Task): string;
11
+ unpackFunc<T>(value: T | ((data: any) => T), task: Task): T;
11
12
  }
@@ -0,0 +1,16 @@
1
+ export type BaselineDiffStatus = 'ahead' | 'ontime' | 'delayed';
2
+
3
+ export interface BaselineDiff {
4
+ /** 开始时间差异 */
5
+ startDiff: number;
6
+ /** 开始状态 */
7
+ startStatus?: BaselineDiffStatus;
8
+ /** 结束时间差异 */
9
+ endDiff: number;
10
+ /** 结束状态 */
11
+ endStatus?: BaselineDiffStatus;
12
+ /** 差异单位 */
13
+ unit: string;
14
+ /** 进度偏差 */
15
+ progressDiff?: number;
16
+ }
@@ -11,6 +11,7 @@ export interface EventMap {
11
11
  cancel: ILink | null,
12
12
  all: ILink[]
13
13
  ) => void;
14
+ "contextmenu:link": (e: MouseEvent, link: ILink) => void;
14
15
  select: (data: any[], checked: boolean, all: any[]) => void;
15
16
  "click:row": (e: MouseEvent, data: any) => void;
16
17
  "dblclick:row": (e: MouseEvent, data: any) => void;
@@ -19,4 +20,10 @@ export interface EventMap {
19
20
  "dblclick:slider": (e: MouseEvent, data: any) => void;
20
21
  "contextmenu:slider": (e: MouseEvent, data: any) => void;
21
22
  move: (data: { row: any; old: any }[]) => void;
23
+ "hover:slider": (e: MouseEvent, data: any) => void;
24
+ "leave:slider": (e: MouseEvent, data: any) => void;
25
+ "click:baseline": (e: MouseEvent, data: any, baseline: any) => void;
26
+ "contextmenu:baseline": (e: MouseEvent, data: any, baseline: any) => void;
27
+ "hover:baseline": (e: MouseEvent, data: any, baseline: any) => void;
28
+ "leave:baseline": (e: MouseEvent, data: any, baseline: any) => void;
22
29
  }
@@ -19,3 +19,8 @@ export interface EmitData {
19
19
  /** 当前数据的层级。 1 开始 */
20
20
  level: number;
21
21
  }
22
+
23
+ export interface EmitBaseline extends EmitData {
24
+ /** 基线数据 */
25
+ baseline: any;
26
+ }