ct-gantt-core 1.0.10 → 1.0.12

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/README.md CHANGED
@@ -1,83 +1,83 @@
1
- # ct-gantt-core
2
-
3
- 框架无关的甘特图数据、布局、依赖排程和命令式引擎。该包不包含界面,可用于 Vue、React、原生 JavaScript、服务端计算或自定义渲染器。
4
-
5
- ## 安装
6
-
7
- ```bash
8
- pnpm add ct-gantt-core
9
- ```
10
-
11
- 也可以使用 `npm install ct-gantt-core` 或 `yarn add ct-gantt-core`。
12
-
13
- ## 最小示例
14
-
15
- ```ts
16
- import { GanttEngine, type GanttTask } from "ct-gantt-core"
17
-
18
- const tasks: GanttTask[] = [
19
- {
20
- id: "task-1",
21
- name: "需求分析",
22
- type: "task",
23
- plan: { start: "2026-07-01", end: "2026-07-05" },
24
- actual: { start: "2026-07-01", end: "2026-07-06", progress: 60 }
25
- }
26
- ]
27
-
28
- const engine = new GanttEngine({
29
- tasks,
30
- config: { viewMode: "day", columnWidth: 30 }
31
- })
32
-
33
- const layout = engine.getLayout()
34
- if (layout.ok) {
35
- console.log(layout.data)
36
- }
37
-
38
- engine.setTask("task-1", { progress: 80 })
39
- engine.destroy()
40
- ```
41
-
42
- ## 依赖排程
43
-
44
- ```ts
45
- import { scheduleByDependencies, type GanttLink } from "ct-gantt-core"
46
-
47
- const links: GanttLink[] = [
48
- { id: "design-to-dev", sourceId: "design", targetId: "dev", type: "FS" }
49
- ]
50
-
51
- const result = scheduleByDependencies(tasks, links)
52
- if (result.ok) {
53
- console.log(result.data)
54
- }
55
- ```
56
-
57
- 支持 `FS`、`SS`、`FF`、`SF` 四种依赖类型,以及自然日或工作日间隔。
58
-
59
- ## 主要导出
60
-
61
- | API | 用途 |
62
- | --- | --- |
63
- | `GanttEngine` | 管理任务、依赖、折叠、预览、布局和视口命令 |
64
- | `computeLayout` | 计算任务条位置和尺寸 |
65
- | `computeTimeScale` | 计算时间刻度(day/week/month/quarter/year) |
66
- | `computeHourScale` | 计算小时级时间刻度(每天 24 个小时列,顶行日期 + 底部整点小时) |
67
- | `computeResourceLayout` | 资源视图布局:资源行 + 占用色条(支持 day/hour 粒度与车道堆叠) |
68
- | `resolveUsageTimes` | 将资源占用解析为布局用起止时间(hour 粒度下纯日期占用含结束日整天) |
69
- | `scheduleByDependencies` | 按依赖关系调整任务日期 |
70
- | `computeImpact` | 分析任务变更的影响和约束冲突 |
71
- | `checkCyclicDependency` | 检查循环依赖 |
72
- | `normalizeLinks` | 统一任务内依赖与独立依赖数据 |
73
- | `flattenTasks` | 将阶段树转换为可渲染行 |
74
- | `toDate`、`toDateTime`、`addDays`、`addHours`、`diffDays`、`diffHours`、`formatDate`、`formatDateTime` | 日期工具(`toDateTime`/`diffHours` 保留时间,用于小时级计算) |
75
-
76
- ## 数据说明
77
-
78
- - `plan` 表示计划日期。
79
- - `actual` 表示实际日期和完成进度。
80
- - `summary` 表示阶段,`task` 表示普通任务,`milestone` 表示任务型里程碑。
81
- - Core 不负责绘制界面;需要现成 Vue 界面时请安装 `ct-gantt-vue`。
82
-
83
- 完整类型、配置和示例请查看[项目文档](https://github.com/moonlight-219/ganttu#readme)。
1
+ # ct-gantt-core
2
+
3
+ 框架无关的甘特图数据、布局、依赖排程和命令式引擎。该包不包含界面,可用于 Vue、React、原生 JavaScript、服务端计算或自定义渲染器。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add ct-gantt-core
9
+ ```
10
+
11
+ 也可以使用 `npm install ct-gantt-core` 或 `yarn add ct-gantt-core`。
12
+
13
+ ## 最小示例
14
+
15
+ ```ts
16
+ import { GanttEngine, type GanttTask } from "ct-gantt-core"
17
+
18
+ const tasks: GanttTask[] = [
19
+ {
20
+ id: "task-1",
21
+ name: "需求分析",
22
+ type: "task",
23
+ plan: { start: "2026-07-01", end: "2026-07-05" },
24
+ actual: { start: "2026-07-01", end: "2026-07-06", progress: 60 }
25
+ }
26
+ ]
27
+
28
+ const engine = new GanttEngine({
29
+ tasks,
30
+ config: { viewMode: "day", columnWidth: 30 }
31
+ })
32
+
33
+ const layout = engine.getLayout()
34
+ if (layout.ok) {
35
+ console.log(layout.data)
36
+ }
37
+
38
+ engine.setTask("task-1", { progress: 80 })
39
+ engine.destroy()
40
+ ```
41
+
42
+ ## 依赖排程
43
+
44
+ ```ts
45
+ import { scheduleByDependencies, type GanttLink } from "ct-gantt-core"
46
+
47
+ const links: GanttLink[] = [
48
+ { id: "design-to-dev", sourceId: "design", targetId: "dev", type: "FS" }
49
+ ]
50
+
51
+ const result = scheduleByDependencies(tasks, links)
52
+ if (result.ok) {
53
+ console.log(result.data)
54
+ }
55
+ ```
56
+
57
+ 支持 `FS`、`SS`、`FF`、`SF` 四种依赖类型,以及自然日或工作日间隔。
58
+
59
+ ## 主要导出
60
+
61
+ | API | 用途 |
62
+ | --- | --- |
63
+ | `GanttEngine` | 管理任务、依赖、折叠、预览、布局和视口命令 |
64
+ | `computeLayout` | 计算任务条位置和尺寸 |
65
+ | `computeTimeScale` | 计算时间刻度(day/week/month/quarter/year) |
66
+ | `computeHourScale` | 计算小时级时间刻度(每天 24 个小时列,顶行日期 + 底部整点小时) |
67
+ | `computeResourceLayout` | 资源视图布局:资源行 + 占用色条(支持 day/hour 粒度与车道堆叠) |
68
+ | `resolveUsageTimes` | 将资源占用解析为布局用起止时间(hour 粒度下纯日期占用含结束日整天) |
69
+ | `scheduleByDependencies` | 按依赖关系调整任务日期 |
70
+ | `computeImpact` | 分析任务变更的影响和约束冲突 |
71
+ | `checkCyclicDependency` | 检查循环依赖 |
72
+ | `normalizeLinks` | 统一任务内依赖与独立依赖数据 |
73
+ | `flattenTasks` | 将阶段树转换为可渲染行 |
74
+ | `toDate`、`toDateTime`、`addDays`、`addHours`、`diffDays`、`diffHours`、`formatDate`、`formatDateTime` | 日期工具(`toDateTime`/`diffHours` 保留时间,用于小时级计算) |
75
+
76
+ ## 数据说明
77
+
78
+ - `plan` 表示计划日期。
79
+ - `actual` 表示实际日期和完成进度。
80
+ - `summary` 表示阶段,`task` 表示普通任务,`milestone` 表示任务型里程碑。
81
+ - Core 不负责绘制界面;需要现成 Vue 界面时请安装 `ct-gantt-vue`。
82
+
83
+ 完整类型、配置和示例请查看[项目文档](https://github.com/moonlight-219/ganttu#readme)。
package/dist/index.cjs CHANGED
@@ -123,7 +123,8 @@ var defaultConfig = {
123
123
  timeUnit: "day",
124
124
  hourWidth: 12,
125
125
  autoSchedule: true,
126
- editable: true
126
+ editable: true,
127
+ enableSelection: false
127
128
  };
128
129
 
129
130
  // src/services/checkCyclicDependency.ts