@xpyjs/gantt-core 0.0.1-rc.4 → 0.0.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/style.css +1 -1
- package/dist/x-gantt.js +969 -803
- package/dist/x-gantt.umd.cjs +23 -3
- package/package.json +1 -1
- package/types/GanttContext.d.ts +1 -0
- package/types/event/index.d.ts +3 -0
- package/types/models/Task.d.ts +1 -0
- package/types/rendering/Renderer.d.ts +2 -0
- package/types/rendering/chart/ChartBody.d.ts +4 -0
- package/types/rendering/table/DragHandler.d.ts +50 -0
- package/types/store/DataManager.d.ts +2 -0
- package/types/types/chart.d.ts +2 -0
- package/types/types/event.d.ts +6 -3
- package/types/types/options.d.ts +36 -2
- package/types/types/render.d.ts +5 -0
- package/types/types/table.d.ts +2 -2
- package/types/utils/helpers.d.ts +2 -1
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
|
|
4
|
+
"version": "0.0.1",
|
|
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",
|
package/types/GanttContext.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class XGanttContext implements IContext {
|
|
|
13
13
|
private renderer;
|
|
14
14
|
constructor(container: HTMLElement, events: Map<keyof EventMap, Function[]>, options?: IOptions);
|
|
15
15
|
getScrollbar(): import("./rendering/scrollbar").Scrollbar;
|
|
16
|
+
getRootElement(): HTMLElement;
|
|
16
17
|
getOptions(): import("./types/options").IGanttOptions;
|
|
17
18
|
private setOptions;
|
|
18
19
|
render(): void;
|
package/types/event/index.d.ts
CHANGED
|
@@ -67,6 +67,9 @@ export declare enum EventName {
|
|
|
67
67
|
BASELINE_MOUSEENTER = "baseline-mouseenter",
|
|
68
68
|
BASELINE_MOUSEMOVE = "baseline-mousemove",
|
|
69
69
|
BASELINE_MOUSEOUT = "baseline-mouseout",
|
|
70
|
+
ROW_DRAG_START = "row-drag-start",
|
|
71
|
+
ROW_DRAGGING = "row-dragging",
|
|
72
|
+
ROW_DRAG_END = "row-drag-end",
|
|
70
73
|
ERROR = "error"
|
|
71
74
|
}
|
|
72
75
|
export declare enum ErrorType {
|
package/types/models/Task.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export declare class Renderer {
|
|
|
15
15
|
private width;
|
|
16
16
|
private height;
|
|
17
17
|
private isInitialized;
|
|
18
|
+
private resizeObserver?;
|
|
18
19
|
getScrollbar(): Scrollbar;
|
|
20
|
+
getRootElement(): HTMLElement;
|
|
19
21
|
constructor(context: IContext, // 渲染器上下文
|
|
20
22
|
container: HTMLElement);
|
|
21
23
|
/**
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { IContext } from "@/types/render";
|
|
2
|
+
import type { Task } from "@/models/Task";
|
|
3
|
+
export declare class DragHandler {
|
|
4
|
+
private context;
|
|
5
|
+
private container?;
|
|
6
|
+
private task?;
|
|
7
|
+
private element;
|
|
8
|
+
private isDragging;
|
|
9
|
+
private dragStartY;
|
|
10
|
+
private dragStartIndex;
|
|
11
|
+
private currentIndex;
|
|
12
|
+
private dragType;
|
|
13
|
+
private canDrop;
|
|
14
|
+
private ghostElement;
|
|
15
|
+
private placeholderElement;
|
|
16
|
+
private animationFrameId;
|
|
17
|
+
private rowElement;
|
|
18
|
+
constructor(context: IContext, container?: HTMLDivElement | undefined, task?: Task | undefined);
|
|
19
|
+
private createElement;
|
|
20
|
+
private bindEvents;
|
|
21
|
+
private handleMouseDown;
|
|
22
|
+
private handleMouseMove;
|
|
23
|
+
private handleMouseUp;
|
|
24
|
+
/**
|
|
25
|
+
* 创建拖拽跟随影像
|
|
26
|
+
*/
|
|
27
|
+
private createGhostElement;
|
|
28
|
+
/**
|
|
29
|
+
* 更新 ghost 元素位置
|
|
30
|
+
*/
|
|
31
|
+
private updateGhostPosition;
|
|
32
|
+
/**
|
|
33
|
+
* 创建插入占位符元素
|
|
34
|
+
*/
|
|
35
|
+
private createPlaceholderElement;
|
|
36
|
+
/**
|
|
37
|
+
* 更新占位符的位置
|
|
38
|
+
*/
|
|
39
|
+
private updatePlaceholderPosition;
|
|
40
|
+
/**
|
|
41
|
+
* 清理拖拽状态
|
|
42
|
+
*/
|
|
43
|
+
private cleanup;
|
|
44
|
+
/** 获取元素 */
|
|
45
|
+
getElement(): HTMLDivElement;
|
|
46
|
+
/**
|
|
47
|
+
* 销毁组件
|
|
48
|
+
*/
|
|
49
|
+
destroy(): void;
|
|
50
|
+
}
|
|
@@ -71,6 +71,7 @@ export declare class DataManager {
|
|
|
71
71
|
/**
|
|
72
72
|
* 移动任务位置
|
|
73
73
|
*/
|
|
74
|
+
moveTask(type: "before" | "after" | "inside", task: Task | undefined, targetIndex: number): void;
|
|
74
75
|
/**
|
|
75
76
|
* 展开任务
|
|
76
77
|
*/
|
|
@@ -101,6 +102,7 @@ export declare class DataManager {
|
|
|
101
102
|
/**
|
|
102
103
|
* 更新子任务的层级
|
|
103
104
|
*/
|
|
105
|
+
private updateChildrenLevel;
|
|
104
106
|
/**
|
|
105
107
|
* 使缓存失效,标记需要重新生成扁平化任务列表
|
|
106
108
|
*/
|
package/types/types/chart.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface IChartOptions {
|
|
|
33
33
|
* @description small | normal | large 会根据当前展示单位,自动计算宽度。或者直接给对象,指定具体每一个单位下 cell 的宽度值
|
|
34
34
|
*
|
|
35
35
|
* @description 如果同时给定了起止时间,则图表则只会渲染给定的时间区间,并且指定宽度将失效。(失效是指:如果给定时间区间范围小于可视范围,则会自动撑满宽度,此时每一格 cell 的宽度则会变为自动;如果时间区间范围大于可视范围,则继续按照当前设定宽度展示,超出部分可通过滚动条移动展示)
|
|
36
|
+
*
|
|
37
|
+
* @description 对于 cell 的定义,它表示一个最小单位的宽度。当为 unit 单位为 hour 时,cell 的最小单位是 hour,当 unit 单位大于 day 时,cell 的最小单位永远为 day。例如:当前 unit 单位为 month,那么在3月份中就会有对应天数 cell 31个。
|
|
36
38
|
*/
|
|
37
39
|
cellWidth:
|
|
38
40
|
| number
|
package/types/types/event.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Dayjs } from "../utils/time";
|
|
1
2
|
import { ErrorType } from "../event";
|
|
2
3
|
import { ILink } from "./link";
|
|
3
4
|
|
|
@@ -24,11 +25,13 @@ export interface EventMap {
|
|
|
24
25
|
/** 任务被选中(checkbox)事件,支持多个选中 */
|
|
25
26
|
select: (data: any[], checked: boolean, all: any[]) => void;
|
|
26
27
|
/** 行点击事件 */
|
|
27
|
-
"click:row": (e: MouseEvent, data: any) => void;
|
|
28
|
+
"click:row": (e: MouseEvent, data: any, time?: Dayjs) => void;
|
|
28
29
|
/** 行双击事件 */
|
|
29
|
-
"dblclick:row": (e: MouseEvent, data: any) => void;
|
|
30
|
+
"dblclick:row": (e: MouseEvent, data: any, time?: Dayjs) => void;
|
|
30
31
|
/** 行右键点击事件 */
|
|
31
|
-
"contextmenu:row": (e: MouseEvent, data: any) => void;
|
|
32
|
+
"contextmenu:row": (e: MouseEvent, data: any, time?: Dayjs) => void;
|
|
33
|
+
/** 行拖拽事件。当且仅当行拖拽结束时被触发。仅当 启用 drag 配置项后生效 */
|
|
34
|
+
"drag:row": (target: any, source: any) => void;
|
|
32
35
|
/** 任务条点击事件 */
|
|
33
36
|
"click:slider": (e: MouseEvent, data: any) => void;
|
|
34
37
|
/** 任务条双击事件 */
|
package/types/types/options.d.ts
CHANGED
|
@@ -8,9 +8,15 @@ export type XGanttUnit = "hour" | "day" | "week" | "month" | "quarter";
|
|
|
8
8
|
export type TaskType = "task" | "milestone" | "summary";
|
|
9
9
|
|
|
10
10
|
export interface IGanttOptions {
|
|
11
|
-
/** 日志 level。 默认
|
|
11
|
+
/** 日志 level。 默认 warn */
|
|
12
12
|
logLevel?: "debug" | "info" | "warn" | "error" | "none";
|
|
13
13
|
|
|
14
|
+
/** 配置 resize 规则 */
|
|
15
|
+
resize?: {
|
|
16
|
+
/** 是否启用自适应 */
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
14
20
|
/** 源数据 */
|
|
15
21
|
data: any[];
|
|
16
22
|
|
|
@@ -287,7 +293,7 @@ export interface IGanttOptions {
|
|
|
287
293
|
/** 差异显示模式 */
|
|
288
294
|
mode: 'highlight' | 'indicator' | 'both';
|
|
289
295
|
/** 以何种基准展示对比。基线高亮只会以一种(起始/结束)基线进行对比。默认以结束时间为基准('end') */
|
|
290
|
-
target: 'start' | 'end'
|
|
296
|
+
target: 'start' | 'end';
|
|
291
297
|
|
|
292
298
|
/** 超期任务的高亮配置 */
|
|
293
299
|
delayed: {
|
|
@@ -487,6 +493,34 @@ export interface IGanttOptions {
|
|
|
487
493
|
includeSelf: boolean;
|
|
488
494
|
};
|
|
489
495
|
|
|
496
|
+
/** 配置任务间的拖拽 */
|
|
497
|
+
drag: {
|
|
498
|
+
/** 是否启用任务拖拽功能 */
|
|
499
|
+
enabled: boolean | ((row: EmitData) => boolean);
|
|
500
|
+
/** 图标颜色。默认 #999 */
|
|
501
|
+
color?: string;
|
|
502
|
+
/** 可放置区域的背景色。默认主色 */
|
|
503
|
+
targetBackgroundColor?: string;
|
|
504
|
+
/** 可放置区域的透明度。默认 0.2 */
|
|
505
|
+
targetOpacity?: number;
|
|
506
|
+
/** 放置的相关配置 */
|
|
507
|
+
drop?: {
|
|
508
|
+
/**
|
|
509
|
+
* 允许放置的回调函数,如果不配置,则表示可被放置的内容均允许放置。
|
|
510
|
+
*
|
|
511
|
+
* @description 该方法的优先级最低,结合其他参数配置使用
|
|
512
|
+
* @description 需要注意的是,无论如何配置,都不能将一个任务放置到其子项中的任意内容
|
|
513
|
+
*/
|
|
514
|
+
allowed?: ((target: EmitData, source: EmitData) => boolean);
|
|
515
|
+
/**
|
|
516
|
+
* 允许跨层级放置。默认情况下只允许在当前父级下进行拖拽
|
|
517
|
+
*
|
|
518
|
+
* @description 主要注意的是,同层级、不同父级的内容,也属于跨层级放置
|
|
519
|
+
*/
|
|
520
|
+
crossLevel?: boolean;
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
490
524
|
/**
|
|
491
525
|
* 时间刻度
|
|
492
526
|
*
|
package/types/types/render.d.ts
CHANGED
package/types/types/table.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface ITableColumnStandard {
|
|
|
21
21
|
/**
|
|
22
22
|
* 当前列对齐方式
|
|
23
23
|
*
|
|
24
|
-
* @default
|
|
24
|
+
* @default left
|
|
25
25
|
*/
|
|
26
26
|
align?: "left" | "center" | "right";
|
|
27
27
|
/**
|
|
@@ -102,7 +102,7 @@ export interface ITableOptions {
|
|
|
102
102
|
/**
|
|
103
103
|
* 统一设置列对齐方式。每列的对齐方式可以单独设置
|
|
104
104
|
*
|
|
105
|
-
* @default
|
|
105
|
+
* @default left
|
|
106
106
|
*/
|
|
107
107
|
align: "left" | "center" | "right";
|
|
108
108
|
|
package/types/utils/helpers.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ export declare function parseNumberWithPercent(value: number | string, target: n
|
|
|
12
12
|
* 获取距离当前值最近的基准值或其倍数
|
|
13
13
|
* @param value 当前值
|
|
14
14
|
* @param target 基准值
|
|
15
|
+
* @param type 取值方式,默认为 round,可选 floor 或 ceil
|
|
15
16
|
* @returns 最近的基准值或其倍数
|
|
16
17
|
*/
|
|
17
|
-
export declare function getStandardValue(value: number, target: number): number;
|
|
18
|
+
export declare function getStandardValue(value: number, target: number, type?: 'round' | 'floor' | 'ceil'): number;
|
|
18
19
|
/**
|
|
19
20
|
* 计算两个数的最大公约数
|
|
20
21
|
*/
|