@xpyjs/gantt-core 0.0.3 → 0.1.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/x-gantt.js +2532 -1921
- package/dist/x-gantt.umd.cjs +4 -4
- package/package.json +1 -1
- package/types/event/index.d.ts +7 -1
- package/types/index.d.ts +2 -2
- package/types/models/Task.d.ts +34 -6
- 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 +6 -0
- package/types/rendering/chart/ChartWeekend.d.ts +2 -5
- package/types/rendering/other/GuideLine.d.ts +8 -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/DataManager.d.ts +8 -0
- package/types/store/TimeAxis.d.ts +109 -28
- package/types/store/index.d.ts +3 -0
- package/types/store/workCalendar.d.ts +68 -0
- package/types/types/calendar.d.ts +97 -0
- package/types/types/chart.d.ts +9 -0
- package/types/types/options.d.ts +138 -32
- package/types/utils/sanitize.d.ts +12 -0
package/types/types/options.d.ts
CHANGED
|
@@ -3,10 +3,86 @@ import { IChartOptions } from "./chart";
|
|
|
3
3
|
import { ILink } from "./link";
|
|
4
4
|
import { IPattern } from "./styles";
|
|
5
5
|
import { ITableOptions } from "./table";
|
|
6
|
+
import { IHolidayOpts, IWeekendOpts, IWorkTimeOpts } from "./calendar";
|
|
6
7
|
|
|
7
8
|
export type XGanttUnit = "hour" | "day" | "week" | "month" | "quarter";
|
|
8
9
|
export type TaskType = "task" | "milestone" | "summary";
|
|
9
10
|
|
|
11
|
+
/** 所有支持的时间刻度单位 */
|
|
12
|
+
export type DurationUnit = 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 时间轴刻度的基础配置
|
|
16
|
+
*
|
|
17
|
+
* @description 用于自定义时间轴的刻度显示。每个配置项定义一个表头层级。
|
|
18
|
+
* 数组从上(粗粒度)到下(细粒度)排列,最后一项为底层刻度。
|
|
19
|
+
*/
|
|
20
|
+
export interface IScaleConfigBase {
|
|
21
|
+
/** 时间单位 */
|
|
22
|
+
unit: DurationUnit;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 步长:每格合并几个 unit。
|
|
26
|
+
*
|
|
27
|
+
* @default 1
|
|
28
|
+
*
|
|
29
|
+
* @example step: 8, unit: 'hour' → 每格8小时
|
|
30
|
+
* @example step: 2, unit: 'week' → 每格2周
|
|
31
|
+
* @example step: 15, unit: 'day' → 每格15天
|
|
32
|
+
*/
|
|
33
|
+
step?: number;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 标签格式化
|
|
37
|
+
*
|
|
38
|
+
* @description 字符串:使用 dayjs format 字符串
|
|
39
|
+
* @description 函数:(date: Date, unit: DurationUnit, step: number) => string
|
|
40
|
+
* @description 未指定时使用默认格式
|
|
41
|
+
*/
|
|
42
|
+
format?: string | ((date: Date, unit: DurationUnit, step: number) => string);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 该层表头行高(px)。
|
|
46
|
+
*
|
|
47
|
+
* @description 取值最小为 20px,低于该值会被钳位。
|
|
48
|
+
* @description 未指定时,由 `header.height` 减去已指定层的高度后在未指定层中平分。
|
|
49
|
+
* @description 应当确保所有层高总和不小于 `header.height`。
|
|
50
|
+
* @description 如果所有层指定的高度之和超过 `header.height`,则 `header.height` 会自动扩展。
|
|
51
|
+
*/
|
|
52
|
+
height?: number;
|
|
53
|
+
|
|
54
|
+
/** 非底层 scale 不允许设置 cellWidth */
|
|
55
|
+
cellWidth?: never;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 最下层时间轴刻度配置(scaleUnit 数组的最后一项)
|
|
60
|
+
*
|
|
61
|
+
* @description 底层 scale 允许设置 cellWidth,用于指定每格的像素宽度。
|
|
62
|
+
*/
|
|
63
|
+
export interface IScaleConfigBottom extends Omit<IScaleConfigBase, 'cellWidth'> {
|
|
64
|
+
/**
|
|
65
|
+
* 该层每格的宽度(px)。仅对底层 scale(scaleUnit 数组最后一项)生效。
|
|
66
|
+
*
|
|
67
|
+
* 非底层 scale 的宽度由其包含的底层 cell 数决定。
|
|
68
|
+
*
|
|
69
|
+
* 优先级:`scaleUnit[].cellWidth` > `chart.cellWidth`。
|
|
70
|
+
* 当底层 scale 指定了 cellWidth 时,将忽略 `chart.cellWidth` 配置;
|
|
71
|
+
* 未指定时,回退到 `chart.cellWidth` 按最小渲染单位推导。
|
|
72
|
+
*/
|
|
73
|
+
cellWidth?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 单层时间轴刻度配置
|
|
78
|
+
*/
|
|
79
|
+
export type IScaleConfig = IScaleConfigBase | IScaleConfigBottom;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 自定义时间轴刻度配置
|
|
83
|
+
*/
|
|
84
|
+
export type ScaleUnit = [...IScaleConfigBase[], IScaleConfigBottom];
|
|
85
|
+
|
|
10
86
|
export interface IGanttOptions {
|
|
11
87
|
/** 日志 level。 默认 warn */
|
|
12
88
|
logLevel?: "debug" | "info" | "warn" | "error" | "none";
|
|
@@ -31,6 +107,21 @@ export interface IGanttOptions {
|
|
|
31
107
|
/** 结束时间字段 */
|
|
32
108
|
endTime: string;
|
|
33
109
|
|
|
110
|
+
/**
|
|
111
|
+
* 持续时间字段。
|
|
112
|
+
*
|
|
113
|
+
* @description 该字段不适用于 `day(不含)` 以下单位,仅针对单位为 `day` 及以上的情况有效
|
|
114
|
+
* @description 与 endTime 字段互斥,endTime 优先级更高
|
|
115
|
+
* @description 当 workTime.enabled = false 时,duration 按日历日解释
|
|
116
|
+
* @description 当 workTime.enabled = true 时,duration 按工作日解释
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* // 只有 duration 没有 endTime
|
|
120
|
+
* { id: 1, start: '2024-01-05', duration: 5 }
|
|
121
|
+
* // endTime 自动计算为 2024-01-10(5个日历日)
|
|
122
|
+
*/
|
|
123
|
+
duration?: string;
|
|
124
|
+
|
|
34
125
|
/** 名称字段 */
|
|
35
126
|
name: string;
|
|
36
127
|
|
|
@@ -525,9 +616,46 @@ export interface IGanttOptions {
|
|
|
525
616
|
* 时间刻度
|
|
526
617
|
*
|
|
527
618
|
* @default 'day'
|
|
619
|
+
*
|
|
620
|
+
* // TODO: [future-major] unit 字段将被 scaleUnit 替代
|
|
528
621
|
*/
|
|
529
622
|
unit: XGanttUnit;
|
|
530
623
|
|
|
624
|
+
/**
|
|
625
|
+
* 自定义时间轴刻度配置。定义 N 层表头,从上(粗粒度)到下(细粒度)排列。
|
|
626
|
+
*
|
|
627
|
+
* 提供后将忽略 `unit`、`chart.headerGroupFormat`、`chart.headerCellFormat`。
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* // 8小时一格
|
|
631
|
+
* scaleUnit: [
|
|
632
|
+
* { unit: 'day', step: 1, format: 'MM-DD ddd' },
|
|
633
|
+
* { unit: 'hour', step: 8, format: 'HH:mm' }
|
|
634
|
+
* ]
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* // 单层表头
|
|
638
|
+
* scaleUnit: [
|
|
639
|
+
* { unit: 'month', step: 1, format: 'YYYY-MM' }
|
|
640
|
+
* ]
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* // 三层表头
|
|
644
|
+
* scaleUnit: [
|
|
645
|
+
* { unit: 'year', step: 1 },
|
|
646
|
+
* { unit: 'month', step: 1 },
|
|
647
|
+
* { unit: 'day', step: 1 }
|
|
648
|
+
* ]
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* // 指定底层 cellWidth(仅最后一项允许设置)
|
|
652
|
+
* scaleUnit: [
|
|
653
|
+
* { unit: 'week', step: 1, format: 'YYYY 第ww周' },
|
|
654
|
+
* { unit: 'day', step: 1, format: 'DD', cellWidth: 50 }
|
|
655
|
+
* ]
|
|
656
|
+
*/
|
|
657
|
+
scaleUnit?: ScaleUnit;
|
|
658
|
+
|
|
531
659
|
/**
|
|
532
660
|
* 显示语言。配置参考 {@link https://day.js.org/docs/en/i18n/i18n|dayjs i18n}
|
|
533
661
|
*
|
|
@@ -868,7 +996,7 @@ export interface IGanttOptions {
|
|
|
868
996
|
* @default 0.1
|
|
869
997
|
*/
|
|
870
998
|
opacity: number;
|
|
871
|
-
} & IPattern;
|
|
999
|
+
} & IPattern & IWeekendOpts;
|
|
872
1000
|
|
|
873
1001
|
/** 节假日期配置 */
|
|
874
1002
|
holiday: {
|
|
@@ -880,42 +1008,20 @@ export interface IGanttOptions {
|
|
|
880
1008
|
* 背景颜色。默认使用主色
|
|
881
1009
|
*/
|
|
882
1010
|
backgroundColor?: string;
|
|
1011
|
+
|
|
883
1012
|
/**
|
|
884
1013
|
* 透明度
|
|
885
1014
|
*
|
|
886
1015
|
* @default 0.1
|
|
887
1016
|
*/
|
|
888
1017
|
opacity: number;
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
opacity?: number;
|
|
897
|
-
/**
|
|
898
|
-
* 自定义节假日期的文本
|
|
899
|
-
*/
|
|
900
|
-
text?: {
|
|
901
|
-
/** 是否显示文本 */
|
|
902
|
-
show?: boolean;
|
|
903
|
-
/** 文本内容 */
|
|
904
|
-
content?: string;
|
|
905
|
-
/** 文本颜色 */
|
|
906
|
-
color?: string;
|
|
907
|
-
/** 背景颜色 */
|
|
908
|
-
backgroundColor?: string;
|
|
909
|
-
/** 透明度 */
|
|
910
|
-
opacity?: number;
|
|
911
|
-
/** 文本字体大小 */
|
|
912
|
-
fontSize?: number;
|
|
913
|
-
/** 文本字体 */
|
|
914
|
-
fontFamily?: string;
|
|
915
|
-
}
|
|
916
|
-
} & IPattern
|
|
917
|
-
>;
|
|
918
|
-
} & IPattern;
|
|
1018
|
+
|
|
1019
|
+
} & IPattern & IHolidayOpts;
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* 配置工作日模式。启用后可以将任务范围控制在工作日内
|
|
1023
|
+
*/
|
|
1024
|
+
workTime?: IWorkTimeOpts;
|
|
919
1025
|
|
|
920
1026
|
/** 标志配置。它用于配置一个或多个标志性日期 */
|
|
921
1027
|
flag?: {
|
|
@@ -1017,4 +1123,4 @@ export interface IGanttOptions {
|
|
|
1017
1123
|
*/
|
|
1018
1124
|
animationDuration?: number;
|
|
1019
1125
|
};
|
|
1020
|
-
}
|
|
1126
|
+
};
|
|
@@ -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;
|