@xpyjs/gantt-core 0.0.2 → 0.1.0
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/x-gantt.js +2746 -2290
- package/dist/x-gantt.umd.cjs +6 -6
- package/package.json +1 -1
- package/types/event/index.d.ts +8 -1
- package/types/index.d.ts +2 -2
- package/types/rendering/Renderer.d.ts +1 -0
- package/types/rendering/chart/ChartBody.d.ts +9 -0
- package/types/rendering/chart/ChartGrid.d.ts +4 -0
- package/types/rendering/chart/ChartHeader.d.ts +14 -4
- package/types/rendering/chart/ChartHoliday.d.ts +2 -0
- package/types/rendering/chart/ChartSlider.d.ts +4 -0
- package/types/rendering/chart/ChartWeekend.d.ts +2 -0
- package/types/rendering/other/GuideLine.d.ts +12 -0
- package/types/rendering/other/MiddleResizeLine.d.ts +8 -0
- package/types/rendering/scrollbar/index.d.ts +1 -0
- package/types/rendering/table/DragHandler.d.ts +3 -0
- package/types/rendering/table/TableRow.d.ts +9 -0
- package/types/rendering/table/index.d.ts +3 -0
- package/types/store/ColumnManager.d.ts +2 -0
- package/types/store/DataManager.d.ts +9 -0
- package/types/store/TimeAxis.d.ts +109 -28
- package/types/types/chart.d.ts +9 -0
- package/types/types/options.d.ts +123 -1
- package/types/types/table.d.ts +0 -5
- package/types/utils/color.d.ts +2 -0
- package/types/utils/sanitize.d.ts +12 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpyjs/gantt-core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.1.0",
|
|
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/event/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare enum EventName {
|
|
|
34
34
|
CHART_OFFSET_CHANGE = "chart_offset_change",
|
|
35
35
|
DATA_UPDATE = "data-update",
|
|
36
36
|
VIEW_UPDATE = "view-update",
|
|
37
|
+
OPTIONS_UPDATE = "options-update",
|
|
37
38
|
UPDATE_TABLE_HEADER = "update_table_header",
|
|
38
39
|
UPDATE_TABLE_BODY = "update_table_body",
|
|
39
40
|
UPDATE_CHART_HEADER = "update_chart_header",
|
|
@@ -86,5 +87,11 @@ export declare enum ErrorType {
|
|
|
86
87
|
/** 无效参数 */
|
|
87
88
|
LINK_INVALID_ARG = "LINK_INVALID_ARG",
|
|
88
89
|
/** 检测到环 */
|
|
89
|
-
LINK_CYCLE = "LINK_CYCLE"
|
|
90
|
+
LINK_CYCLE = "LINK_CYCLE",
|
|
91
|
+
/** 移动目标无效 */
|
|
92
|
+
MOVE_INVALID_TARGET = "MOVE_INVALID_TARGET",
|
|
93
|
+
/** 移动产生循环依赖 */
|
|
94
|
+
MOVE_CIRCULAR_DEPENDENCY = "MOVE_CIRCULAR_DEPENDENCY",
|
|
95
|
+
/** 移动层级无效 */
|
|
96
|
+
MOVE_INVALID_HIERARCHY = "MOVE_INVALID_HIERARCHY"
|
|
90
97
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ import type { IOptions, IOptionConfig, EmitData } from "./types";
|
|
|
9
9
|
import type { EventMap } from "./types/event";
|
|
10
10
|
import type { ILink, DataChain, LinkType } from "./types/link";
|
|
11
11
|
import type { ErrorType } from "./event";
|
|
12
|
-
import type { XGanttUnit } from "./types/options";
|
|
13
|
-
export type { IOptions, IOptionConfig, EmitData, EventMap, ILink, ErrorType, XGanttUnit, DataChain, LinkType };
|
|
12
|
+
import type { XGanttUnit, DurationUnit, IScaleConfig, IScaleConfigBase, IScaleConfigBottom, ScaleUnit } from "./types/options";
|
|
13
|
+
export type { IOptions, IOptionConfig, EmitData, EventMap, ILink, ErrorType, XGanttUnit, DurationUnit, IScaleConfig, IScaleConfigBase, IScaleConfigBottom, ScaleUnit, DataChain, LinkType };
|
|
@@ -18,6 +18,15 @@ export declare class BodyGroup {
|
|
|
18
18
|
private highlightRect;
|
|
19
19
|
private selectedRowId;
|
|
20
20
|
private selectedRect;
|
|
21
|
+
private boundHandleMouseMove;
|
|
22
|
+
private boundHandleMouseLeave;
|
|
23
|
+
private boundHandleClick;
|
|
24
|
+
private boundHandleDblClick;
|
|
25
|
+
private boundHandleContextMenu;
|
|
26
|
+
private onRowHighlight;
|
|
27
|
+
private onRowUnhighlight;
|
|
28
|
+
private onTaskSelected;
|
|
29
|
+
private onTaskUnselected;
|
|
21
30
|
constructor(context: IContext, stage: Konva.Stage, layer: Konva.Layer, bgLayer: Konva.Layer);
|
|
22
31
|
/**
|
|
23
32
|
* 调整大小
|
|
@@ -9,6 +9,10 @@ export declare class GridGroup {
|
|
|
9
9
|
private height;
|
|
10
10
|
private offsetX;
|
|
11
11
|
private offsetY;
|
|
12
|
+
private renderedColStart;
|
|
13
|
+
private renderedColEnd;
|
|
14
|
+
private renderedRowStart;
|
|
15
|
+
private renderedRowEnd;
|
|
12
16
|
constructor(context: IContext, layer: Konva.Layer);
|
|
13
17
|
/**
|
|
14
18
|
* 调整网格大小
|
|
@@ -4,9 +4,13 @@ export declare class HeaderLayer {
|
|
|
4
4
|
private context;
|
|
5
5
|
private layer;
|
|
6
6
|
private background;
|
|
7
|
-
private
|
|
8
|
-
private
|
|
7
|
+
private headerGroups;
|
|
8
|
+
private separatorLines;
|
|
9
9
|
private cellCache;
|
|
10
|
+
private renderedStartX;
|
|
11
|
+
private renderedEndX;
|
|
12
|
+
/** 缓冲区比例:视口宽度的30%,左右各多渲染这么宽 */
|
|
13
|
+
private static readonly BUFFER_FACTOR;
|
|
10
14
|
private width;
|
|
11
15
|
private height;
|
|
12
16
|
private offsetX;
|
|
@@ -29,9 +33,15 @@ export declare class HeaderLayer {
|
|
|
29
33
|
*/
|
|
30
34
|
render(): void;
|
|
31
35
|
/**
|
|
32
|
-
*
|
|
36
|
+
* 构建表头结构(headerGroups + 分隔线)
|
|
37
|
+
* 仅在 resize 或数据变化时调用
|
|
33
38
|
*/
|
|
34
|
-
private
|
|
39
|
+
private buildStructure;
|
|
40
|
+
/**
|
|
41
|
+
* 渲染表头 cell 内容(带缓冲区的可视范围裁剪)
|
|
42
|
+
* 滚动超出缓冲区时调用,重建 cells 但保留 group 结构
|
|
43
|
+
*/
|
|
44
|
+
private renderCells;
|
|
35
45
|
private createCell;
|
|
36
46
|
/**
|
|
37
47
|
* 清除表头内容
|
|
@@ -8,6 +8,10 @@ export declare class GuideLine {
|
|
|
8
8
|
private element;
|
|
9
9
|
private container;
|
|
10
10
|
private visible;
|
|
11
|
+
private onShowGuideline;
|
|
12
|
+
private onHideGuideline;
|
|
13
|
+
private onMoveGuideline;
|
|
14
|
+
private onOptionsUpdate;
|
|
11
15
|
/**
|
|
12
16
|
* @param container 指示线的容器元素
|
|
13
17
|
*/
|
|
@@ -47,4 +51,12 @@ export declare class GuideLine {
|
|
|
47
51
|
* 获取当前位置
|
|
48
52
|
*/
|
|
49
53
|
getLeft(): number;
|
|
54
|
+
/**
|
|
55
|
+
* 更新参数
|
|
56
|
+
*/
|
|
57
|
+
updateOptions(): void;
|
|
58
|
+
/**
|
|
59
|
+
* 销毁指示线,清理事件监听
|
|
60
|
+
*/
|
|
61
|
+
destroy(): void;
|
|
50
62
|
}
|
|
@@ -7,9 +7,17 @@ export declare class MiddleResizeLine {
|
|
|
7
7
|
private initialWidth;
|
|
8
8
|
private collapseButton;
|
|
9
9
|
constructor(root: IContext, container: HTMLElement);
|
|
10
|
+
/**
|
|
11
|
+
* 初始化事件
|
|
12
|
+
*/
|
|
13
|
+
private initEvents;
|
|
10
14
|
setOffset(x: number): void;
|
|
11
15
|
/**
|
|
12
16
|
* 添加拖拽事件
|
|
13
17
|
*/
|
|
14
18
|
private addDragEvents;
|
|
19
|
+
/**
|
|
20
|
+
* 更新配置
|
|
21
|
+
*/
|
|
22
|
+
private updateOptions;
|
|
15
23
|
}
|
|
@@ -67,6 +67,7 @@ export declare class Scrollbar {
|
|
|
67
67
|
private throttledHandleMouseMove;
|
|
68
68
|
private throttledHandleWheel;
|
|
69
69
|
constructor(root: IContext, rootElement: HTMLElement, options?: Partial<ScrollbarOptions>);
|
|
70
|
+
updateOptions(options?: Partial<ScrollbarOptions>): void;
|
|
70
71
|
private createElements;
|
|
71
72
|
private createScrollbarElement;
|
|
72
73
|
private createScrollThumbElement;
|
|
@@ -17,10 +17,13 @@ export declare class DragHandler {
|
|
|
17
17
|
private rowElement;
|
|
18
18
|
constructor(context: IContext, container?: HTMLDivElement | undefined, task?: Task | undefined);
|
|
19
19
|
private createElement;
|
|
20
|
+
private handleSelectStart;
|
|
20
21
|
private bindEvents;
|
|
21
22
|
private handleMouseDown;
|
|
22
23
|
private handleMouseMove;
|
|
23
24
|
private handleMouseUp;
|
|
25
|
+
/** ESC 取消拖拽的 keydown */
|
|
26
|
+
private handleKeyDown;
|
|
24
27
|
/**
|
|
25
28
|
* 创建拖拽跟随影像
|
|
26
29
|
*/
|
|
@@ -7,6 +7,15 @@ export declare class TableRow {
|
|
|
7
7
|
private top;
|
|
8
8
|
element: HTMLDivElement;
|
|
9
9
|
private cells;
|
|
10
|
+
private handleMouseEnter;
|
|
11
|
+
private handleMouseLeave;
|
|
12
|
+
private handleClick;
|
|
13
|
+
private handleDblClick;
|
|
14
|
+
private handleContextMenu;
|
|
15
|
+
private onRowHighlight;
|
|
16
|
+
private onRowUnhighlight;
|
|
17
|
+
private onTaskSelected;
|
|
18
|
+
private onTaskUnselected;
|
|
10
19
|
/**
|
|
11
20
|
* 创建表格行
|
|
12
21
|
* @param context 上下文
|
|
@@ -50,6 +50,11 @@ export declare class DataManager {
|
|
|
50
50
|
private initTasks;
|
|
51
51
|
private createTask;
|
|
52
52
|
private updateTask;
|
|
53
|
+
/**
|
|
54
|
+
* 递归清理任务(从全局 Map、选中状态等中移除)
|
|
55
|
+
* 这是一个内部辅助方法,不触发视图更新事件,仅清理数据引用
|
|
56
|
+
*/
|
|
57
|
+
private removeTasksRecursive;
|
|
53
58
|
/**
|
|
54
59
|
* 获取源数据
|
|
55
60
|
*/
|
|
@@ -103,6 +108,10 @@ export declare class DataManager {
|
|
|
103
108
|
* 更新子任务的层级
|
|
104
109
|
*/
|
|
105
110
|
private updateChildrenLevel;
|
|
111
|
+
/**
|
|
112
|
+
* 重新计算所有任务的最大层级
|
|
113
|
+
*/
|
|
114
|
+
private recalculateDataLevel;
|
|
106
115
|
/**
|
|
107
116
|
* 使缓存失效,标记需要重新生成扁平化任务列表
|
|
108
117
|
*/
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import dayjs, { type Dayjs } from "../utils/time";
|
|
2
|
-
import { IGanttOptions } from "@/types/options";
|
|
3
|
-
/**
|
|
2
|
+
import { DurationUnit, IGanttOptions } from "@/types/options";
|
|
3
|
+
/** 内部标准化后的 scale 配置 */
|
|
4
|
+
export interface ParsedScale {
|
|
5
|
+
unit: DurationUnit;
|
|
6
|
+
step: number;
|
|
7
|
+
format?: string | ((date: Date, unit: DurationUnit, step: number) => string);
|
|
8
|
+
cellWidth?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
}
|
|
11
|
+
/** 时间线单元格项 */
|
|
12
|
+
export interface TimelineCellItem {
|
|
13
|
+
/** 时间对象 */
|
|
14
|
+
date: Dayjs;
|
|
15
|
+
/** 展示的文本 */
|
|
16
|
+
label: string;
|
|
17
|
+
/** 跨越多少个最小渲染单位 */
|
|
18
|
+
span: number;
|
|
19
|
+
/** 是否隐藏 */
|
|
20
|
+
hide?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** 时间线层 */
|
|
23
|
+
export interface TimelineLayer {
|
|
24
|
+
scale: ParsedScale;
|
|
25
|
+
items: TimelineCellItem[];
|
|
26
|
+
}
|
|
27
|
+
/** 表头项(旧接口,保持兼容) */
|
|
4
28
|
export interface TimelineItem {
|
|
5
29
|
/** 时间对象 */
|
|
6
30
|
date: Dayjs;
|
|
@@ -22,25 +46,52 @@ export declare class TimeAxis {
|
|
|
22
46
|
private strictEnd;
|
|
23
47
|
/** 是否自适应宽度 */
|
|
24
48
|
private isAuto;
|
|
25
|
-
/**
|
|
26
|
-
private
|
|
27
|
-
private headerGroupFormat?;
|
|
28
|
-
private headerCellFormat?;
|
|
49
|
+
/** N 层时间线缓存 */
|
|
50
|
+
private timelineLayers;
|
|
29
51
|
private isDirty;
|
|
30
52
|
/** 是否第一次赋值,如果第一次赋值,允许全部赋值 */
|
|
31
53
|
private isFirstTime;
|
|
32
54
|
/** 总宽度 */
|
|
33
55
|
private allWidth;
|
|
34
|
-
/**
|
|
35
|
-
private
|
|
36
|
-
/**
|
|
56
|
+
/** 内部标准化后的 scales */
|
|
57
|
+
private scales;
|
|
58
|
+
/** 是否旧模式(未使用 scaleUnit) */
|
|
59
|
+
private isLegacyMode;
|
|
60
|
+
/** 旧模式下的 cellWidth 映射 */
|
|
61
|
+
private legacyCellWidthMap;
|
|
62
|
+
/** 新模式下的 cellWidth(px/最小渲染单位) */
|
|
63
|
+
private _resolvedCellWidth;
|
|
64
|
+
/** 各层解析后的行高(px) */
|
|
65
|
+
private _resolvedLayerHeights;
|
|
66
|
+
/** 解析后的实际 header 高度(可能因 scaleUnit.height 溢出而扩展) */
|
|
67
|
+
private _resolvedHeaderHeight;
|
|
68
|
+
/** 旧模式记录的 unit */
|
|
37
69
|
private unit;
|
|
70
|
+
/** 旧模式的 headerGroupFormat / headerCellFormat */
|
|
71
|
+
private headerGroupFormat?;
|
|
72
|
+
private headerCellFormat?;
|
|
38
73
|
constructor();
|
|
39
74
|
getStartTime(): dayjs.Dayjs;
|
|
40
75
|
getEndTime(): dayjs.Dayjs;
|
|
76
|
+
/** 获取每个最小渲染单位的像素宽度(语义不变) */
|
|
41
77
|
getCellWidth(): number;
|
|
78
|
+
/** 获取底层 timeline 的总 cell 数 */
|
|
42
79
|
getCellCount(): number;
|
|
43
|
-
|
|
80
|
+
/** 获取最小渲染单位 */
|
|
81
|
+
getCellUnit(): "hour" | "day";
|
|
82
|
+
/** 获取内部标准化后的 scales */
|
|
83
|
+
getScales(): ParsedScale[];
|
|
84
|
+
/** 获取底层 scale */
|
|
85
|
+
getBottomScale(): ParsedScale;
|
|
86
|
+
/** 获取各层解析后的行高(px) */
|
|
87
|
+
getLayerHeights(): number[];
|
|
88
|
+
/** 获取解析后的实际 header 高度 */
|
|
89
|
+
getResolvedHeaderHeight(): number;
|
|
90
|
+
/**
|
|
91
|
+
* 获取底层一格的像素宽度
|
|
92
|
+
* 用于 ChartHeader/Grid 绘制底层 cell 的宽度
|
|
93
|
+
*/
|
|
94
|
+
getBottomCellWidth(date?: Dayjs): number;
|
|
44
95
|
setAllWidth(width: number): void;
|
|
45
96
|
getTimeLeft(time: Dayjs): number;
|
|
46
97
|
/**
|
|
@@ -52,25 +103,9 @@ export declare class TimeAxis {
|
|
|
52
103
|
init(options: IGanttOptions, isFirstTime?: boolean): void;
|
|
53
104
|
update(options: IGanttOptions): void;
|
|
54
105
|
setDate(start?: Dayjs, end?: Dayjs): void;
|
|
55
|
-
/**
|
|
56
|
-
getTimeline():
|
|
106
|
+
/** 获取 N 层时间线数据 */
|
|
107
|
+
getTimeline(): TimelineLayer[];
|
|
57
108
|
clear(): void;
|
|
58
|
-
/**
|
|
59
|
-
* 缓存失效标记
|
|
60
|
-
*/
|
|
61
|
-
private invalidateCache;
|
|
62
|
-
/** 获取细粒度单位 */
|
|
63
|
-
private getFinelyUnit;
|
|
64
|
-
/** 获取下层单位 */
|
|
65
|
-
private getChildUnit;
|
|
66
|
-
/** 获取上层单位 */
|
|
67
|
-
private getGroupUnit;
|
|
68
|
-
/** 格式化上层文本 */
|
|
69
|
-
private formatterGroupLabel;
|
|
70
|
-
/**
|
|
71
|
-
* 格式化下层文本
|
|
72
|
-
*/
|
|
73
|
-
private formatterCellLabel;
|
|
74
109
|
/**
|
|
75
110
|
* 获取时间轴的总宽度
|
|
76
111
|
* @returns 时间轴总宽度(像素)
|
|
@@ -83,4 +118,50 @@ export declare class TimeAxis {
|
|
|
83
118
|
* @returns 是否在时间轴上
|
|
84
119
|
*/
|
|
85
120
|
isInTimeAxis(time: Dayjs): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* 计算一个 scale cell 包含多少个最小渲染单位
|
|
123
|
+
* @param scale scale 配置
|
|
124
|
+
* @param date 日期(用于月/季度等变长单位)
|
|
125
|
+
*/
|
|
126
|
+
getUnitsPerCell(scale: ParsedScale, date?: Dayjs): number;
|
|
127
|
+
/** 缓存失效标记 */
|
|
128
|
+
private invalidateCache;
|
|
129
|
+
/** 获取最小渲染单位:scales 中含 hour/minute → 'hour',否则 → 'day' */
|
|
130
|
+
private getMinimumUnit;
|
|
131
|
+
/** 旧 unit → 内部 scales 自动转换 */
|
|
132
|
+
private legacyUnitToScales;
|
|
133
|
+
/** 每层最小行高 */
|
|
134
|
+
private static readonly MIN_SCALE_ROW_HEIGHT;
|
|
135
|
+
/**
|
|
136
|
+
* 解析各层行高。
|
|
137
|
+
*
|
|
138
|
+
* 规则:
|
|
139
|
+
* - 未指定 height 的层平分剩余空间
|
|
140
|
+
* - 指定的 height < MIN_SCALE_ROW_HEIGHT 时钳位
|
|
141
|
+
* - 所有指定层的 height 之和超过 headerHeight 时,自动扩展 headerHeight
|
|
142
|
+
* - 所有层均指定 height 且总和 < headerHeight 时,上对齐,底部留空白
|
|
143
|
+
*/
|
|
144
|
+
private resolveLayerHeights;
|
|
145
|
+
/** 从 chart.cellWidth 解析新模式下的 cellWidth 值 */
|
|
146
|
+
private resolveCellWidthFromChart;
|
|
147
|
+
/**
|
|
148
|
+
* 将 cursor 对齐到 scale 的自然步进边界。
|
|
149
|
+
*
|
|
150
|
+
* step=1 时,直接 startOf(unit)。
|
|
151
|
+
* step>1 时,以"父周期"为锚点,向前找到最近的 step 整数倍边界。
|
|
152
|
+
* 例如 { unit:"hour", step:8 } → 一天内的自然边界为 0:00 / 8:00 / 16:00,
|
|
153
|
+
* cursor=15:00 时对齐到 8:00,首格 8:00→16:00 会被 calculateSpan 裁剪为
|
|
154
|
+
* startTime→16:00 的不完整格,后续格保持不变。
|
|
155
|
+
*/
|
|
156
|
+
private alignToScaleStart;
|
|
157
|
+
/** 推进 cursor 到下一个 cell */
|
|
158
|
+
private advanceCursor;
|
|
159
|
+
/** 计算 cursor 到 cellEnd 之间跨越了多少个最小渲染单位 */
|
|
160
|
+
private calculateSpan;
|
|
161
|
+
/** 格式化标签 */
|
|
162
|
+
private formatLabel;
|
|
163
|
+
/** 获取默认格式化 */
|
|
164
|
+
private getDefaultFormat;
|
|
165
|
+
/** 获取一个季度的天数 */
|
|
166
|
+
private getQuarterDays;
|
|
86
167
|
}
|
package/types/types/chart.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { XGanttUnit } from "./options";
|
|
2
2
|
|
|
3
3
|
export interface IChartOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 是否显示垂直网格线
|
|
6
|
+
*
|
|
7
|
+
* @default false
|
|
8
|
+
*
|
|
9
|
+
* @description 仅对 scaleUnit 参数生效。其余仍然为默认情况。
|
|
10
|
+
*/
|
|
11
|
+
showVerticalLine?: boolean;
|
|
12
|
+
|
|
4
13
|
/**
|
|
5
14
|
* 开始时间。强制设置开始时间,覆盖数据中的开始时间。
|
|
6
15
|
*
|
package/types/types/options.d.ts
CHANGED
|
@@ -7,6 +7,81 @@ import { ITableOptions } from "./table";
|
|
|
7
7
|
export type XGanttUnit = "hour" | "day" | "week" | "month" | "quarter";
|
|
8
8
|
export type TaskType = "task" | "milestone" | "summary";
|
|
9
9
|
|
|
10
|
+
/** 所有支持的时间刻度单位 */
|
|
11
|
+
export type DurationUnit = 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 时间轴刻度的基础配置
|
|
15
|
+
*
|
|
16
|
+
* @description 用于自定义时间轴的刻度显示。每个配置项定义一个表头层级。
|
|
17
|
+
* 数组从上(粗粒度)到下(细粒度)排列,最后一项为底层刻度。
|
|
18
|
+
*/
|
|
19
|
+
export interface IScaleConfigBase {
|
|
20
|
+
/** 时间单位 */
|
|
21
|
+
unit: DurationUnit;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 步长:每格合并几个 unit。
|
|
25
|
+
*
|
|
26
|
+
* @default 1
|
|
27
|
+
*
|
|
28
|
+
* @example step: 8, unit: 'hour' → 每格8小时
|
|
29
|
+
* @example step: 2, unit: 'week' → 每格2周
|
|
30
|
+
* @example step: 15, unit: 'day' → 每格15天
|
|
31
|
+
*/
|
|
32
|
+
step?: number;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 标签格式化
|
|
36
|
+
*
|
|
37
|
+
* @description 字符串:使用 dayjs format 字符串
|
|
38
|
+
* @description 函数:(date: Date, unit: DurationUnit, step: number) => string
|
|
39
|
+
* @description 未指定时使用默认格式
|
|
40
|
+
*/
|
|
41
|
+
format?: string | ((date: Date, unit: DurationUnit, step: number) => string);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 该层表头行高(px)。
|
|
45
|
+
*
|
|
46
|
+
* @description 取值最小为 20px,低于该值会被钳位。
|
|
47
|
+
* @description 未指定时,由 `header.height` 减去已指定层的高度后在未指定层中平分。
|
|
48
|
+
* @description 应当确保所有层高总和不小于 `header.height`。
|
|
49
|
+
* @description 如果所有层指定的高度之和超过 `header.height`,则 `header.height` 会自动扩展。
|
|
50
|
+
*/
|
|
51
|
+
height?: number;
|
|
52
|
+
|
|
53
|
+
/** 非底层 scale 不允许设置 cellWidth */
|
|
54
|
+
cellWidth?: never;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 最下层时间轴刻度配置(scaleUnit 数组的最后一项)
|
|
59
|
+
*
|
|
60
|
+
* @description 底层 scale 允许设置 cellWidth,用于指定每格的像素宽度。
|
|
61
|
+
*/
|
|
62
|
+
export interface IScaleConfigBottom extends Omit<IScaleConfigBase, 'cellWidth'> {
|
|
63
|
+
/**
|
|
64
|
+
* 该层每格的宽度(px)。仅对底层 scale(scaleUnit 数组最后一项)生效。
|
|
65
|
+
*
|
|
66
|
+
* 非底层 scale 的宽度由其包含的底层 cell 数决定。
|
|
67
|
+
*
|
|
68
|
+
* 优先级:`scaleUnit[].cellWidth` > `chart.cellWidth`。
|
|
69
|
+
* 当底层 scale 指定了 cellWidth 时,将忽略 `chart.cellWidth` 配置;
|
|
70
|
+
* 未指定时,回退到 `chart.cellWidth` 按最小渲染单位推导。
|
|
71
|
+
*/
|
|
72
|
+
cellWidth?: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 单层时间轴刻度配置
|
|
77
|
+
*/
|
|
78
|
+
export type IScaleConfig = IScaleConfigBase | IScaleConfigBottom;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 自定义时间轴刻度配置
|
|
82
|
+
*/
|
|
83
|
+
export type ScaleUnit = [...IScaleConfigBase[], IScaleConfigBottom];
|
|
84
|
+
|
|
10
85
|
export interface IGanttOptions {
|
|
11
86
|
/** 日志 level。 默认 warn */
|
|
12
87
|
logLevel?: "debug" | "info" | "warn" | "error" | "none";
|
|
@@ -525,9 +600,46 @@ export interface IGanttOptions {
|
|
|
525
600
|
* 时间刻度
|
|
526
601
|
*
|
|
527
602
|
* @default 'day'
|
|
603
|
+
*
|
|
604
|
+
* // TODO: [future-major] unit 字段将被 scaleUnit 替代
|
|
528
605
|
*/
|
|
529
606
|
unit: XGanttUnit;
|
|
530
607
|
|
|
608
|
+
/**
|
|
609
|
+
* 自定义时间轴刻度配置。定义 N 层表头,从上(粗粒度)到下(细粒度)排列。
|
|
610
|
+
*
|
|
611
|
+
* 提供后将忽略 `unit`、`chart.headerGroupFormat`、`chart.headerCellFormat`。
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* // 8小时一格
|
|
615
|
+
* scaleUnit: [
|
|
616
|
+
* { unit: 'day', step: 1, format: 'MM-DD ddd' },
|
|
617
|
+
* { unit: 'hour', step: 8, format: 'HH:mm' }
|
|
618
|
+
* ]
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* // 单层表头
|
|
622
|
+
* scaleUnit: [
|
|
623
|
+
* { unit: 'month', step: 1, format: 'YYYY-MM' }
|
|
624
|
+
* ]
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* // 三层表头
|
|
628
|
+
* scaleUnit: [
|
|
629
|
+
* { unit: 'year', step: 1 },
|
|
630
|
+
* { unit: 'month', step: 1 },
|
|
631
|
+
* { unit: 'day', step: 1 }
|
|
632
|
+
* ]
|
|
633
|
+
*
|
|
634
|
+
* @example
|
|
635
|
+
* // 指定底层 cellWidth(仅最后一项允许设置)
|
|
636
|
+
* scaleUnit: [
|
|
637
|
+
* { unit: 'week', step: 1, format: 'YYYY 第ww周' },
|
|
638
|
+
* { unit: 'day', step: 1, format: 'DD', cellWidth: 50 }
|
|
639
|
+
* ]
|
|
640
|
+
*/
|
|
641
|
+
scaleUnit?: ScaleUnit;
|
|
642
|
+
|
|
531
643
|
/**
|
|
532
644
|
* 显示语言。配置参考 {@link https://day.js.org/docs/en/i18n/i18n|dayjs i18n}
|
|
533
645
|
*
|
|
@@ -556,6 +668,16 @@ export interface IGanttOptions {
|
|
|
556
668
|
color: string;
|
|
557
669
|
};
|
|
558
670
|
|
|
671
|
+
/** 表格收起按钮配置 */
|
|
672
|
+
collapse: {
|
|
673
|
+
/** 是否显示收起按钮。默认 true */
|
|
674
|
+
show: boolean;
|
|
675
|
+
/** 按钮背景颜色。默认 #fff */
|
|
676
|
+
backgroundColor: string;
|
|
677
|
+
/** 按钮圆角。针对右上角与右下角。默认 6 */
|
|
678
|
+
radius: number;
|
|
679
|
+
};
|
|
680
|
+
|
|
559
681
|
/** 头部配置 */
|
|
560
682
|
header: {
|
|
561
683
|
/**
|
|
@@ -566,7 +688,7 @@ export interface IGanttOptions {
|
|
|
566
688
|
height: number;
|
|
567
689
|
/** 背景颜色。默认使用主色调 */
|
|
568
690
|
backgroundColor?: string;
|
|
569
|
-
/**
|
|
691
|
+
/** 文字颜色。支持 auto 特殊关键字,当为 auto 时,可根据背景色自动调整为 黑/白 */
|
|
570
692
|
color: string;
|
|
571
693
|
/**
|
|
572
694
|
* 文字大小
|
package/types/types/table.d.ts
CHANGED
package/types/utils/color.d.ts
CHANGED
|
@@ -145,4 +145,6 @@ export declare class Colorjs {
|
|
|
145
145
|
* @throws {Error} 如果颜色值无法解析 (除非内部构造函数处理了默认值)。
|
|
146
146
|
*/
|
|
147
147
|
export declare const colorjs: (value: any) => Colorjs;
|
|
148
|
+
/** 判断颜色是否需要自动调整 */
|
|
149
|
+
export declare const autoColor: (color: string, target: string) => string;
|
|
148
150
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 清理 HTML 字符串,移除潜在的 XSS 攻击载荷。
|
|
3
|
+
*
|
|
4
|
+
* 清理规则:
|
|
5
|
+
* - 移除危险标签(script, iframe, object 等)
|
|
6
|
+
* - 移除所有 on* 事件处理器属性
|
|
7
|
+
* - 移除 javascript: 协议的 URL
|
|
8
|
+
*
|
|
9
|
+
* @param html 待清理的 HTML 字符串
|
|
10
|
+
* @returns 清理后的安全 HTML 字符串
|
|
11
|
+
*/
|
|
12
|
+
export declare function sanitizeHtml(html: string): string;
|