gantt-renderer 0.1.2 → 0.3.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/CHANGELOG.md +41 -0
- package/README.md +4 -3
- package/dist/index.d.mts +350 -95
- package/dist/index.mjs +1557 -599
- package/dist/index.mjs.map +1 -1
- package/dist/styles/gantt.css +27 -2
- package/package.json +90 -91
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/lib/validation/schemas.d.ts
|
|
4
4
|
declare const LinkTypeSchema: z.ZodEnum<{
|
|
5
5
|
FS: "FS";
|
|
6
6
|
SS: "SS";
|
|
7
7
|
FF: "FF";
|
|
8
8
|
SF: "SF";
|
|
9
9
|
}>;
|
|
10
|
-
declare const
|
|
10
|
+
declare const TaskKindSchema: z.ZodEnum<{
|
|
11
11
|
task: "task";
|
|
12
12
|
project: "project";
|
|
13
13
|
milestone: "milestone";
|
|
@@ -25,21 +25,36 @@ declare const SpecialDaySchema: z.ZodObject<{
|
|
|
25
25
|
label: z.ZodOptional<z.ZodString>;
|
|
26
26
|
className: z.ZodOptional<z.ZodString>;
|
|
27
27
|
}, z.core.$strip>;
|
|
28
|
-
declare const TaskSchema: z.ZodObject<{
|
|
28
|
+
declare const TaskSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
29
|
+
kind: z.ZodLiteral<"task">;
|
|
30
|
+
durationHours: z.ZodNumber;
|
|
31
|
+
percentComplete: z.ZodDefault<z.ZodNumber>;
|
|
29
32
|
id: z.ZodNumber;
|
|
30
33
|
text: z.ZodString;
|
|
31
|
-
|
|
32
|
-
duration: z.ZodNumber;
|
|
34
|
+
startDate: z.ZodString;
|
|
33
35
|
parent: z.ZodOptional<z.ZodNumber>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
color: z.ZodOptional<z.ZodString>;
|
|
37
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
kind: z.ZodLiteral<"project">;
|
|
40
|
+
durationHours: z.ZodNumber;
|
|
41
|
+
percentComplete: z.ZodDefault<z.ZodNumber>;
|
|
40
42
|
open: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
+
id: z.ZodNumber;
|
|
44
|
+
text: z.ZodString;
|
|
45
|
+
startDate: z.ZodString;
|
|
46
|
+
parent: z.ZodOptional<z.ZodNumber>;
|
|
41
47
|
color: z.ZodOptional<z.ZodString>;
|
|
42
|
-
|
|
48
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
49
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<"milestone">;
|
|
51
|
+
id: z.ZodNumber;
|
|
52
|
+
text: z.ZodString;
|
|
53
|
+
startDate: z.ZodString;
|
|
54
|
+
parent: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
color: z.ZodOptional<z.ZodString>;
|
|
56
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
57
|
+
}, z.core.$strip>], "kind">;
|
|
43
58
|
declare const LinkSchema: z.ZodObject<{
|
|
44
59
|
id: z.ZodNumber;
|
|
45
60
|
source: z.ZodNumber;
|
|
@@ -50,23 +65,39 @@ declare const LinkSchema: z.ZodObject<{
|
|
|
50
65
|
FF: "FF";
|
|
51
66
|
SF: "SF";
|
|
52
67
|
}>>;
|
|
68
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
53
69
|
}, z.core.$strip>;
|
|
54
70
|
declare const GanttInputSchema: z.ZodObject<{
|
|
55
|
-
tasks: z.ZodArray<z.ZodObject<{
|
|
71
|
+
tasks: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
72
|
+
kind: z.ZodLiteral<"task">;
|
|
73
|
+
durationHours: z.ZodNumber;
|
|
74
|
+
percentComplete: z.ZodDefault<z.ZodNumber>;
|
|
56
75
|
id: z.ZodNumber;
|
|
57
76
|
text: z.ZodString;
|
|
58
|
-
|
|
59
|
-
duration: z.ZodNumber;
|
|
77
|
+
startDate: z.ZodString;
|
|
60
78
|
parent: z.ZodOptional<z.ZodNumber>;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
color: z.ZodOptional<z.ZodString>;
|
|
80
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
81
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
82
|
+
kind: z.ZodLiteral<"project">;
|
|
83
|
+
durationHours: z.ZodNumber;
|
|
84
|
+
percentComplete: z.ZodDefault<z.ZodNumber>;
|
|
67
85
|
open: z.ZodDefault<z.ZodBoolean>;
|
|
86
|
+
id: z.ZodNumber;
|
|
87
|
+
text: z.ZodString;
|
|
88
|
+
startDate: z.ZodString;
|
|
89
|
+
parent: z.ZodOptional<z.ZodNumber>;
|
|
68
90
|
color: z.ZodOptional<z.ZodString>;
|
|
69
|
-
|
|
91
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
92
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
93
|
+
kind: z.ZodLiteral<"milestone">;
|
|
94
|
+
id: z.ZodNumber;
|
|
95
|
+
text: z.ZodString;
|
|
96
|
+
startDate: z.ZodString;
|
|
97
|
+
parent: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
color: z.ZodOptional<z.ZodString>;
|
|
99
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
100
|
+
}, z.core.$strip>], "kind">>;
|
|
70
101
|
links: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
71
102
|
id: z.ZodNumber;
|
|
72
103
|
source: z.ZodNumber;
|
|
@@ -77,21 +108,48 @@ declare const GanttInputSchema: z.ZodObject<{
|
|
|
77
108
|
FF: "FF";
|
|
78
109
|
SF: "SF";
|
|
79
110
|
}>>;
|
|
111
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
80
112
|
}, z.core.$strip>>>;
|
|
81
113
|
}, z.core.$strip>;
|
|
114
|
+
/** The raw, unvalidated input shape that consumers pass to {@link parseGanttInput}. */
|
|
115
|
+
type GanttInputRaw = z.input<typeof GanttInputSchema>;
|
|
116
|
+
/** Allowed dependency link type values: `'FS'`, `'SS'`, `'FF'`, or `'SF'`. */
|
|
82
117
|
type LinkType = z.infer<typeof LinkTypeSchema>;
|
|
83
|
-
|
|
118
|
+
/** Allowed task kind values: `'task'`, `'project'`, or `'milestone'`. */
|
|
119
|
+
type TaskKind = z.infer<typeof TaskKindSchema>;
|
|
84
120
|
type SpecialDayKind = z.infer<typeof SpecialDayKindSchema>;
|
|
85
121
|
type SpecialDay = z.infer<typeof SpecialDaySchema>;
|
|
122
|
+
/**
|
|
123
|
+
* A task in the Gantt chart — discriminated by `kind` into leaf tasks,
|
|
124
|
+
* summary projects, and milestones.
|
|
125
|
+
*
|
|
126
|
+
* - **`kind: 'task'`** — A regular task with a colored bar and duration.
|
|
127
|
+
* - **`kind: 'project'`** — A summary/group row with a colored bar and optional tree state.
|
|
128
|
+
* - **`kind: 'milestone'`** — A zero-duration marker rendered as a diamond.
|
|
129
|
+
*/
|
|
86
130
|
type Task = z.infer<typeof TaskSchema>;
|
|
131
|
+
/**
|
|
132
|
+
* A dependency link between two tasks. The `type` determines the scheduling constraint
|
|
133
|
+
* (e.g., finish-to-start, start-to-start).
|
|
134
|
+
*/
|
|
87
135
|
type Link = z.infer<typeof LinkSchema>;
|
|
136
|
+
/**
|
|
137
|
+
* The complete input data for the chart.
|
|
138
|
+
*
|
|
139
|
+
* Pass a raw plain object (typed as {@link GanttInputRaw}) to
|
|
140
|
+
* {@link parseGanttInput} to validate and get back a typed {@link GanttInput}.
|
|
141
|
+
*/
|
|
88
142
|
type GanttInput = z.infer<typeof GanttInputSchema>;
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Parses raw external data.
|
|
145
|
+
*
|
|
146
|
+
* @param raw - The unvalidated input from the consumer.
|
|
147
|
+
* @returns The parsed and validated {@link GanttInput}.
|
|
148
|
+
* @throws {import('zod').ZodError} On schema validation failure.
|
|
149
|
+
*/
|
|
150
|
+
declare function parseGanttInput(raw: GanttInputRaw): GanttInput;
|
|
93
151
|
//#endregion
|
|
94
|
-
//#region src/
|
|
152
|
+
//#region src/lib/timeline/scale.d.ts
|
|
95
153
|
type TimeScale = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
96
154
|
type ScaleConfig = {
|
|
97
155
|
/** Pixel width of one column unit */columnWidth: number; /** Milliseconds per column unit */
|
|
@@ -100,30 +158,51 @@ type ScaleConfig = {
|
|
|
100
158
|
};
|
|
101
159
|
declare const SCALE_CONFIGS: Record<TimeScale, ScaleConfig>;
|
|
102
160
|
//#endregion
|
|
103
|
-
//#region src/
|
|
161
|
+
//#region src/lib/domain/tree.d.ts
|
|
162
|
+
/**
|
|
163
|
+
* A task node in the render tree, combining the flat {@link Task} input data
|
|
164
|
+
* with computed hierarchy structure.
|
|
165
|
+
*
|
|
166
|
+
* Produced by {@link buildTaskTree}; consumed by virtualized row rendering
|
|
167
|
+
* and the timeline layout engine.
|
|
168
|
+
*/
|
|
104
169
|
type TaskNode = Task & {
|
|
105
|
-
children: TaskNode[]; /** 0 = root */
|
|
170
|
+
/** Array of child task nodes in the tree hierarchy. */children: TaskNode[]; /** 0 = root */
|
|
106
171
|
depth: number;
|
|
107
172
|
};
|
|
108
173
|
/**
|
|
109
174
|
* Builds a typed tree from a flat task array.
|
|
110
175
|
* Order of tasks[] is irrelevant — parents need not precede children.
|
|
111
|
-
*
|
|
176
|
+
*
|
|
177
|
+
* @param tasks - The flat array of tasks to convert into a tree.
|
|
178
|
+
* @returns Root-level {@link TaskNode} instances with populated `children`.
|
|
179
|
+
* @throws {GanttError} When a task references a `parent` id that does not exist,
|
|
180
|
+
* when a parent cycle is detected, or when a `parent` points to a
|
|
181
|
+
* milestone or leaf task.
|
|
112
182
|
*/
|
|
113
183
|
declare function buildTaskTree(tasks: Task[]): TaskNode[];
|
|
114
184
|
/**
|
|
115
185
|
* Flattens a tree into a visible row list.
|
|
116
|
-
* A node's children are included only when its id is in expandedIds
|
|
186
|
+
* A node's children are included only when its id is in `expandedIds`.
|
|
187
|
+
*
|
|
188
|
+
* @param roots - The root-level {@link TaskNode} instances of the tree.
|
|
189
|
+
* @param expandedIds - Set of task IDs whose children should be rendered.
|
|
190
|
+
* @returns A depth-first flattened array of visible {@link TaskNode} items.
|
|
117
191
|
*/
|
|
118
192
|
declare function flattenTree(roots: TaskNode[], expandedIds: ReadonlySet<number>): TaskNode[];
|
|
119
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* Returns `true` when a node has children in the tree.
|
|
195
|
+
*
|
|
196
|
+
* @param node - The {@link TaskNode} to inspect.
|
|
197
|
+
* @returns `true` if `node.children.length > 0`.
|
|
198
|
+
*/
|
|
120
199
|
declare function isParent(node: TaskNode): boolean;
|
|
121
200
|
//#endregion
|
|
122
|
-
//#region src/
|
|
201
|
+
//#region src/lib/timeline/pixelMapper.d.ts
|
|
123
202
|
type PixelMapper = {
|
|
124
203
|
/** Date → x pixel offset from viewport start */toX: (date: Date) => number; /** x pixel offset → Date */
|
|
125
|
-
toDate: (x: number) => Date; /**
|
|
126
|
-
durationToWidth: (
|
|
204
|
+
toDate: (x: number) => Date; /** Hours → pixel width */
|
|
205
|
+
durationToWidth: (hours: number) => number; /** Pixel width → hours (float) */
|
|
127
206
|
widthToDuration: (px: number) => number; /** The origin timestamp used for this mapper */
|
|
128
207
|
originMs: number; /** Pixel width of one column unit */
|
|
129
208
|
columnWidth: number;
|
|
@@ -131,10 +210,14 @@ type PixelMapper = {
|
|
|
131
210
|
/**
|
|
132
211
|
* Creates a stateless pixel mapper for the given scale and viewport start.
|
|
133
212
|
* All conversions are O(1) arithmetic — safe to call in tight loops.
|
|
213
|
+
*
|
|
214
|
+
* @param scale - The active {@link TimeScale}.
|
|
215
|
+
* @param viewportStart - The leftmost date visible in the viewport.
|
|
216
|
+
* @returns A {@link PixelMapper} configured for the given viewport.
|
|
134
217
|
*/
|
|
135
218
|
declare function createPixelMapper(scale: TimeScale, viewportStart: Date): PixelMapper;
|
|
136
219
|
//#endregion
|
|
137
|
-
//#region src/
|
|
220
|
+
//#region src/lib/timeline/layoutEngine.d.ts
|
|
138
221
|
declare const DENSITY: {
|
|
139
222
|
readonly rowHeight: 44;
|
|
140
223
|
readonly barHeight: 28;
|
|
@@ -153,7 +236,7 @@ type BarLayout = {
|
|
|
153
236
|
width: number;
|
|
154
237
|
height: number;
|
|
155
238
|
progressWidth: number;
|
|
156
|
-
|
|
239
|
+
kind: 'task' | 'project' | 'milestone';
|
|
157
240
|
rowIndex: number; /** Center x; identical to x + width/2 or x for milestones */
|
|
158
241
|
centerX: number;
|
|
159
242
|
centerY: number;
|
|
@@ -161,16 +244,23 @@ type BarLayout = {
|
|
|
161
244
|
/**
|
|
162
245
|
* Computes pixel-space layout for all visible task rows.
|
|
163
246
|
* Returns a map keyed by task id for O(1) lookup during link routing.
|
|
247
|
+
*
|
|
248
|
+
* @param rows - The flattened, visible {@link TaskNode} rows.
|
|
249
|
+
* @param mapper - The {@link PixelMapper} for coordinate conversion.
|
|
250
|
+
* @returns A `Map` from task ID to its computed {@link BarLayout}.
|
|
164
251
|
*/
|
|
165
252
|
declare function computeLayout(rows: TaskNode[], mapper: PixelMapper): Map<number, BarLayout>;
|
|
166
253
|
/**
|
|
167
254
|
* Derives viewport bounds from task data with padding.
|
|
168
|
-
*
|
|
255
|
+
*
|
|
256
|
+
* @param tasks - The task nodes to derive bounds from.
|
|
257
|
+
* @param paddingHours - Extra hours added before the earliest start and after the latest end. Defaults to `48`.
|
|
258
|
+
* @returns A tuple `[start, end]` of UTC midnight `Date` instances.
|
|
169
259
|
*/
|
|
170
|
-
declare function deriveViewport(tasks: TaskNode[],
|
|
260
|
+
declare function deriveViewport(tasks: TaskNode[], paddingHours?: number): [Date, Date];
|
|
171
261
|
//#endregion
|
|
172
|
-
//#region src/
|
|
173
|
-
type LocaleLabelKey = '
|
|
262
|
+
//#region src/lib/locale.d.ts
|
|
263
|
+
type LocaleLabelKey = 'ariaTask' | 'ariaMilestone' | 'addSubtaskTitle' | 'columnTaskName' | 'columnStartDate' | 'columnDuration' | 'columnQuarter';
|
|
174
264
|
type ChartLocale = {
|
|
175
265
|
code: string;
|
|
176
266
|
labels?: Partial<Record<LocaleLabelKey, string>>;
|
|
@@ -180,62 +270,124 @@ type ChartLocale = {
|
|
|
180
270
|
};
|
|
181
271
|
declare const EN_US_LABELS: Record<LocaleLabelKey, string>;
|
|
182
272
|
declare const CHART_LOCALE_EN_US: ChartLocale;
|
|
183
|
-
/**
|
|
184
|
-
* Resolves a ChartLocale from either a full ChartLocale object or a BCP 47 string.
|
|
185
|
-
* When given a string, derives weekStartsOn, weekNumbering, and weekendDays from CLDR conventions.
|
|
186
|
-
*/
|
|
187
|
-
declare function resolveChartLocale(raw: ChartLocale | string | undefined): ChartLocale;
|
|
188
273
|
/**
|
|
189
274
|
* Derives the first day of week (0=Sun, 1=Mon, 6=Sat) from a BCP 47 code.
|
|
190
|
-
* Uses Intl.Locale.getWeekInfo() where available (Chromium, Safari 15.4+),
|
|
275
|
+
* Uses `Intl.Locale.getWeekInfo()` where available (Chromium, Safari 15.4+),
|
|
191
276
|
* with a CLDR-based fallback table for Firefox and older runtimes.
|
|
277
|
+
*
|
|
278
|
+
* @param code - A BCP 47 language tag (e.g. `'en-US'`, `'de-DE'`).
|
|
279
|
+
* @returns The first day of the week: `0` (Sunday), `1` (Monday), or `6` (Saturday).
|
|
192
280
|
*/
|
|
193
281
|
declare function deriveWeekStartsOn(code: string): 0 | 1 | 6;
|
|
194
282
|
/**
|
|
195
283
|
* Derives the week numbering scheme from a BCP 47 code.
|
|
196
|
-
* Europe and ISO-aligned regions default to 'iso'
|
|
284
|
+
* Europe and ISO-aligned regions default to `'iso'`; Americas and others to `'us'`.
|
|
285
|
+
*
|
|
286
|
+
* @param code - A BCP 47 language tag (e.g. `'en-US'`, `'de-DE'`).
|
|
287
|
+
* @returns The week numbering scheme: `'iso'`, `'us'`, or `'simple'`.
|
|
197
288
|
*/
|
|
198
289
|
declare function deriveWeekNumbering(code: string): 'iso' | 'us' | 'simple';
|
|
199
290
|
/**
|
|
200
291
|
* Derives weekend days (0=Sun … 6=Sat) from a BCP 47 code.
|
|
201
|
-
* Uses Intl.Locale.getWeekInfo() where available, with a CLDR-based fallback table.
|
|
292
|
+
* Uses `Intl.Locale.getWeekInfo()` where available, with a CLDR-based fallback table.
|
|
293
|
+
*
|
|
294
|
+
* @param code - A BCP 47 language tag (e.g. `'en-US'`, `'de-DE'`).
|
|
295
|
+
* @returns An array of weekend day indices (sorted ascending).
|
|
202
296
|
*/
|
|
203
297
|
declare function deriveWeekendDays(code: string): number[];
|
|
298
|
+
/**
|
|
299
|
+
* Resolves a {@link ChartLocale} from either a full `ChartLocale` object or a BCP 47 string.
|
|
300
|
+
* When given a string, derives `weekStartsOn`, `weekNumbering`, and `weekendDays` from CLDR conventions.
|
|
301
|
+
*
|
|
302
|
+
* @param raw - A {@link ChartLocale} object, a BCP 47 language tag string, or `undefined`.
|
|
303
|
+
* @returns A fully resolved {@link ChartLocale} with defaults applied.
|
|
304
|
+
*/
|
|
305
|
+
declare function resolveChartLocale(raw: ChartLocale | string | undefined): ChartLocale;
|
|
204
306
|
/**
|
|
205
307
|
* Formats a week number according to the specified scheme.
|
|
206
308
|
*
|
|
207
309
|
* - `'iso'`: ISO 8601 (week 1 contains the first Thursday; Monday start).
|
|
208
310
|
* - `'us'`: Week 1 contains January 1; Sunday start.
|
|
209
311
|
* - `'simple'`: `Math.ceil(dayOfYear / 7)`.
|
|
312
|
+
*
|
|
313
|
+
* @param date - The date to compute the week number for.
|
|
314
|
+
* @param scheme - The week numbering scheme: `'iso'`, `'us'`, or `'simple'`.
|
|
315
|
+
* @returns The week number as a positive integer.
|
|
210
316
|
*/
|
|
211
317
|
declare function formatWeekNumber(date: Date, scheme: 'iso' | 'us' | 'simple'): number;
|
|
212
318
|
/**
|
|
213
319
|
* Formats a label template by replacing `{0}` with the given argument.
|
|
320
|
+
*
|
|
321
|
+
* @param template - The template string containing `{0}` as placeholder.
|
|
322
|
+
* @param arg - The value to substitute for `{0}`.
|
|
323
|
+
* @returns The formatted string with the placeholder replaced.
|
|
214
324
|
*/
|
|
215
325
|
declare function formatLabel(template: string, arg: string): string;
|
|
216
326
|
//#endregion
|
|
217
|
-
//#region src/
|
|
327
|
+
//#region src/lib/domain/dependencies.d.ts
|
|
218
328
|
/**
|
|
219
329
|
* Detects circular dependencies in the link graph using DFS tri-colour marking.
|
|
220
|
-
*
|
|
221
|
-
*
|
|
330
|
+
*
|
|
331
|
+
* @param tasks - The task list (used to build the vertex set).
|
|
332
|
+
* @param links - The dependency links defining the directed edges.
|
|
333
|
+
* @throws {GanttError} When a cycle is detected, with a human-readable cycle path.
|
|
222
334
|
*/
|
|
223
335
|
declare function detectCycles(tasks: Task[], links: Link[]): void;
|
|
224
336
|
/**
|
|
225
|
-
*
|
|
226
|
-
*
|
|
337
|
+
* Validates that every link references existing task IDs and that no
|
|
338
|
+
* duplicate (source, target) pairs exist.
|
|
339
|
+
*
|
|
340
|
+
* @param tasks - The task list (used as the reference set of valid IDs).
|
|
341
|
+
* @param links - The dependency links to validate.
|
|
342
|
+
* @throws {GanttError} When any link references a non-existent source or target task,
|
|
343
|
+
* when a non-FS link connects to/from a milestone, or when duplicate
|
|
344
|
+
* (source, target) pairs exist.
|
|
227
345
|
*/
|
|
228
346
|
declare function validateLinkRefs(tasks: Task[], links: Link[]): void;
|
|
229
347
|
//#endregion
|
|
230
|
-
//#region src/
|
|
231
|
-
/**
|
|
348
|
+
//#region src/lib/domain/dateMath.d.ts
|
|
349
|
+
/**
|
|
350
|
+
* Parses `YYYY-MM-DD` → UTC midnight `Date`.
|
|
351
|
+
*
|
|
352
|
+
* @param dateStr - An ISO-8601 date string in `YYYY-MM-DD` format.
|
|
353
|
+
* @returns A `Date` representing UTC midnight of the given date.
|
|
354
|
+
* @throws {Error} When `dateStr` does not represent a valid date.
|
|
355
|
+
*/
|
|
232
356
|
declare function parseDate(dateStr: string): Date;
|
|
233
|
-
/**
|
|
357
|
+
/**
|
|
358
|
+
* Returns `date + n` days using exact millisecond arithmetic.
|
|
359
|
+
*
|
|
360
|
+
* @param date - The base date.
|
|
361
|
+
* @param days - Number of days to add (may be negative).
|
|
362
|
+
* @returns A new `Date` offset by the given number of days.
|
|
363
|
+
*/
|
|
234
364
|
declare function addDays(date: Date, days: number): Date;
|
|
235
|
-
/**
|
|
365
|
+
/**
|
|
366
|
+
* Returns `date + n` hours using exact millisecond arithmetic.
|
|
367
|
+
*
|
|
368
|
+
* @param date - The base date.
|
|
369
|
+
* @param hours - Number of hours to add (may be negative).
|
|
370
|
+
* @returns A new `Date` offset by the given number of hours.
|
|
371
|
+
*/
|
|
372
|
+
declare function addHours(date: Date, hours: number): Date;
|
|
373
|
+
/**
|
|
374
|
+
* Difference in days (float). Positive when `b > a`.
|
|
375
|
+
*
|
|
376
|
+
* @param a - The earlier date.
|
|
377
|
+
* @param b - The later date.
|
|
378
|
+
* @returns The fractional number of days between the two dates.
|
|
379
|
+
*/
|
|
236
380
|
declare function diffDays(a: Date, b: Date): number;
|
|
381
|
+
/**
|
|
382
|
+
* Difference in hours (float). Positive when `b > a`.
|
|
383
|
+
*
|
|
384
|
+
* @param a - The earlier date.
|
|
385
|
+
* @param b - The later date.
|
|
386
|
+
* @returns The fractional number of hours between the two dates.
|
|
387
|
+
*/
|
|
388
|
+
declare function diffHours(a: Date, b: Date): number;
|
|
237
389
|
//#endregion
|
|
238
|
-
//#region src/
|
|
390
|
+
//#region src/lib/rendering/linkRouter.d.ts
|
|
239
391
|
type Point = {
|
|
240
392
|
x: number;
|
|
241
393
|
y: number;
|
|
@@ -243,73 +395,113 @@ type Point = {
|
|
|
243
395
|
type RoutedLink = {
|
|
244
396
|
linkId: number;
|
|
245
397
|
sourceTaskId: number;
|
|
246
|
-
targetTaskId: number;
|
|
398
|
+
targetTaskId: number;
|
|
399
|
+
type: LinkType; /** Ordered vertices of the orthogonal polyline (source → target). */
|
|
247
400
|
points: Point[];
|
|
248
401
|
};
|
|
249
402
|
/**
|
|
250
403
|
* Computes orthogonal routing for all dependency links.
|
|
251
404
|
* Links whose source or target is not in the layout map are skipped silently
|
|
252
405
|
* (e.g. when the row is collapsed).
|
|
406
|
+
*
|
|
407
|
+
* @param links - The dependency links to route.
|
|
408
|
+
* @param layouts - A map from task ID to its computed {@link BarLayout}.
|
|
409
|
+
* @returns An array of {@link RoutedLink} objects with computed vertex paths.
|
|
253
410
|
*/
|
|
254
411
|
declare function routeLinks(links: Link[], layouts: Map<number, BarLayout>): RoutedLink[];
|
|
255
412
|
//#endregion
|
|
256
|
-
//#region src/
|
|
413
|
+
//#region src/lib/vanilla/dom/gridColumns.d.ts
|
|
414
|
+
/**
|
|
415
|
+
* Union of all field names that can appear on any {@link Task} variant.
|
|
416
|
+
* Use when referencing task fields in grid column schemas that apply
|
|
417
|
+
* across a heterogeneous set of task kinds.
|
|
418
|
+
*/
|
|
419
|
+
type TaskDataField = keyof Task | 'durationHours' | 'percentComplete' | 'open';
|
|
257
420
|
type GridColumn = {
|
|
258
421
|
id: string;
|
|
259
422
|
header: string;
|
|
260
423
|
width: string;
|
|
261
424
|
align?: 'left' | 'center' | 'right';
|
|
262
425
|
visible?: boolean;
|
|
263
|
-
field?:
|
|
426
|
+
field?: TaskDataField;
|
|
264
427
|
format?: (value: unknown, task: Task, row: TaskNode, locale: ChartLocale) => string;
|
|
265
428
|
};
|
|
266
429
|
declare const DEFAULT_GRID_COLUMNS: GridColumn[];
|
|
267
430
|
/**
|
|
268
431
|
* Returns a localized default grid column schema.
|
|
269
|
-
* Column headers use locale label overrides with EN_US_LABELS fallback.
|
|
432
|
+
* Column headers use locale label overrides with `EN_US_LABELS` fallback.
|
|
433
|
+
*
|
|
434
|
+
* @param locale - The {@link ChartLocale} to derive column header labels from.
|
|
435
|
+
* @returns An array of {@link GridColumn} objects.
|
|
270
436
|
*/
|
|
271
437
|
declare function gridColumnDefaults(locale: ChartLocale): GridColumn[];
|
|
438
|
+
/**
|
|
439
|
+
* Builds a CSS `grid-template-columns` value from a column schema.
|
|
440
|
+
*
|
|
441
|
+
* @param columns - The full column schema array (only visible columns are included).
|
|
442
|
+
* @returns A space-separated CSS track list.
|
|
443
|
+
*/
|
|
272
444
|
declare function gridTemplateColumns(columns: GridColumn[]): string;
|
|
445
|
+
/**
|
|
446
|
+
* Filters a column schema to only visible columns.
|
|
447
|
+
*
|
|
448
|
+
* @param columns - The full column schema array.
|
|
449
|
+
* @returns A new array containing only columns where `visible` is not `false`.
|
|
450
|
+
*/
|
|
273
451
|
declare function visibleColumns(columns: GridColumn[]): GridColumn[];
|
|
274
452
|
declare const GRID_COLUMN_FR_MIN_WIDTH = 120;
|
|
453
|
+
/**
|
|
454
|
+
* Computes the minimum natural pixel width of a grid column schema.
|
|
455
|
+
*
|
|
456
|
+
* @param columns - The full column schema array.
|
|
457
|
+
* @returns The sum of minimum widths: `px` columns sum directly, `fr` units contribute
|
|
458
|
+
* `GRID_COLUMN_FR_MIN_WIDTH` px each.
|
|
459
|
+
*/
|
|
275
460
|
declare function gridNaturalWidth(columns: GridColumn[]): number;
|
|
276
461
|
//#endregion
|
|
277
|
-
//#region src/
|
|
278
|
-
type OnTaskSelect = (
|
|
279
|
-
|
|
280
|
-
id: number;
|
|
281
|
-
startDate: Date;
|
|
462
|
+
//#region src/lib/vanilla/gantt-chart.d.ts
|
|
463
|
+
type OnTaskSelect = (payload: {
|
|
464
|
+
task: Task;
|
|
282
465
|
}) => void;
|
|
466
|
+
type OnTaskMove = (payload: {
|
|
467
|
+
task: Task;
|
|
468
|
+
newStartDate: Date;
|
|
469
|
+
}) => boolean;
|
|
283
470
|
type OnTaskResize = (payload: {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}) =>
|
|
471
|
+
task: Task;
|
|
472
|
+
newDurationHours: number;
|
|
473
|
+
}) => boolean;
|
|
287
474
|
type OnTaskAdd = (payload: {
|
|
288
|
-
|
|
289
|
-
}) =>
|
|
475
|
+
parentTask: Task;
|
|
476
|
+
}) => boolean;
|
|
290
477
|
type OnTaskDoubleClick = (payload: {
|
|
291
|
-
id: number;
|
|
292
|
-
source: 'grid' | 'bar' | 'milestone';
|
|
293
|
-
}) => void;
|
|
294
|
-
type OnTaskEditIntent = (payload: {
|
|
295
|
-
id: number;
|
|
296
|
-
source: 'grid' | 'bar' | 'milestone';
|
|
297
|
-
trigger: 'double_click';
|
|
298
478
|
task: Task;
|
|
299
479
|
}) => void;
|
|
300
480
|
type OnLinkCreate = (payload: {
|
|
301
|
-
sourceTaskId: number;
|
|
302
|
-
targetTaskId: number;
|
|
303
481
|
type: 'FS';
|
|
482
|
+
sourceTask: Task;
|
|
483
|
+
targetTask: Task;
|
|
484
|
+
}) => boolean;
|
|
485
|
+
type OnLinkClick = (payload: {
|
|
486
|
+
link: Link;
|
|
487
|
+
}) => void;
|
|
488
|
+
type OnLinkDblClick = (payload: {
|
|
489
|
+
link: Link;
|
|
304
490
|
}) => void;
|
|
491
|
+
type OnProgressChange = (payload: {
|
|
492
|
+
task: Task;
|
|
493
|
+
newPercentComplete: number;
|
|
494
|
+
}) => boolean;
|
|
305
495
|
type GanttCallbacks = {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
496
|
+
onTaskSelect?: OnTaskSelect;
|
|
497
|
+
onTaskMove?: OnTaskMove;
|
|
498
|
+
onTaskResize?: OnTaskResize;
|
|
499
|
+
onTaskAdd?: OnTaskAdd;
|
|
310
500
|
onTaskDoubleClick?: OnTaskDoubleClick;
|
|
311
|
-
onTaskEditIntent?: OnTaskEditIntent;
|
|
312
501
|
onLinkCreate?: OnLinkCreate;
|
|
502
|
+
onLinkClick?: OnLinkClick;
|
|
503
|
+
onLinkDblClick?: OnLinkDblClick;
|
|
504
|
+
onProgressChange?: OnProgressChange;
|
|
313
505
|
onLeftPaneWidthChange?: (width: number) => void;
|
|
314
506
|
onGridColumnsChange?: (columns: GridColumn[]) => void;
|
|
315
507
|
};
|
|
@@ -318,6 +510,7 @@ type GanttOptions = {
|
|
|
318
510
|
scale?: TimeScale;
|
|
319
511
|
highlightLinkedDependenciesOnSelect?: boolean;
|
|
320
512
|
linkCreationEnabled?: boolean;
|
|
513
|
+
progressDragEnabled?: boolean;
|
|
321
514
|
leftPaneWidth?: number;
|
|
322
515
|
responsiveSplitPane?: boolean;
|
|
323
516
|
mobileBreakpoint?: number;
|
|
@@ -333,32 +526,94 @@ type GanttOptions = {
|
|
|
333
526
|
specialDays?: SpecialDay[];
|
|
334
527
|
gridColumns?: GridColumn[];
|
|
335
528
|
theme?: ThemeMode;
|
|
336
|
-
}
|
|
529
|
+
};
|
|
337
530
|
type GanttInstance = {
|
|
338
531
|
update: (input: GanttInput) => void;
|
|
339
|
-
|
|
532
|
+
setOptions: (opts: Partial<GanttOptions>) => void;
|
|
340
533
|
select: (id: number | null) => void;
|
|
341
534
|
collapseAll: () => void;
|
|
342
535
|
expandAll: () => void;
|
|
343
536
|
destroy: () => void;
|
|
344
537
|
};
|
|
538
|
+
/**
|
|
539
|
+
* Progressive-enhancement Gantt chart component.
|
|
540
|
+
* Validates input, builds a DOM tree, and renders a full interactive chart
|
|
541
|
+
* inside the given container element.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```ts
|
|
545
|
+
* const chart = new GanttChart(document.getElementById('chart')!, input, {
|
|
546
|
+
* locale: 'de-DE',
|
|
547
|
+
* theme: 'dark',
|
|
548
|
+
* });
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
345
551
|
declare class GanttChart implements GanttInstance {
|
|
346
552
|
#private;
|
|
347
|
-
|
|
553
|
+
/**
|
|
554
|
+
* Constructs a new chart, builds the DOM, and wires internal event handling.
|
|
555
|
+
* Data must be loaded via {@link update} before the chart renders.
|
|
556
|
+
*
|
|
557
|
+
* @param container - The host `HTMLElement` the chart will be appended to.
|
|
558
|
+
* @param opts - Configuration and callback options.
|
|
559
|
+
*/
|
|
560
|
+
constructor(container: HTMLElement, opts?: GanttOptions, cbs?: GanttCallbacks);
|
|
561
|
+
/**
|
|
562
|
+
* Replaces the full dataset and re-renders.
|
|
563
|
+
*
|
|
564
|
+
* @param newInput - The new {@link GanttInput} to apply.
|
|
565
|
+
* @throws {GanttError} When the instance has been destroyed.
|
|
566
|
+
*/
|
|
348
567
|
update(newInput: GanttInput): void;
|
|
349
|
-
|
|
568
|
+
/**
|
|
569
|
+
* Merges the supplied options into the current configuration and re-renders
|
|
570
|
+
* only the panes affected by the changed options.
|
|
571
|
+
*
|
|
572
|
+
* @param opts - A partial {@link GanttOptions} object. Only the keys present
|
|
573
|
+
* in this parameter are updated; missing keys keep their
|
|
574
|
+
* previous values.
|
|
575
|
+
* @throws {GanttError} When the instance has been destroyed.
|
|
576
|
+
*/
|
|
577
|
+
setOptions(opts: Partial<GanttOptions>): void;
|
|
578
|
+
/**
|
|
579
|
+
* Programmatically selects or deselects a task.
|
|
580
|
+
*
|
|
581
|
+
* @param id - The task ID to select, or `null` to clear the selection.
|
|
582
|
+
* @throws {GanttError} When the instance has been destroyed.
|
|
583
|
+
*/
|
|
350
584
|
select(id: number | null): void;
|
|
585
|
+
/**
|
|
586
|
+
* Collapses all expandable groups in the task tree.
|
|
587
|
+
*
|
|
588
|
+
* @throws {GanttError} When the instance has been destroyed.
|
|
589
|
+
*/
|
|
351
590
|
collapseAll(): void;
|
|
591
|
+
/**
|
|
592
|
+
* Expands all expandable groups in the task tree.
|
|
593
|
+
*
|
|
594
|
+
* @throws {GanttError} When the instance has been destroyed.
|
|
595
|
+
*/
|
|
352
596
|
expandAll(): void;
|
|
597
|
+
/**
|
|
598
|
+
* Removes the chart DOM and internal listeners, rendering the instance
|
|
599
|
+
* unusable. Subsequent calls to any public method will throw.
|
|
600
|
+
*/
|
|
353
601
|
destroy(): void;
|
|
354
602
|
}
|
|
355
603
|
//#endregion
|
|
356
|
-
//#region src/
|
|
357
|
-
type GanttErrorCode = 'PARENT_REFERENCE' | 'LINK_REFERENCE' | 'DEPENDENCY_CYCLE' | 'INSTANCE_DESTROYED';
|
|
604
|
+
//#region src/lib/errors.d.ts
|
|
605
|
+
type GanttErrorCode = 'PARENT_REFERENCE' | 'PARENT_CYCLE' | 'LINK_REFERENCE' | 'DEPENDENCY_CYCLE' | 'MILESTONE_LINK_TYPE' | 'DUPLICATE_LINK_PAIR' | 'INSTANCE_DESTROYED';
|
|
606
|
+
/**
|
|
607
|
+
* Domain-specific error with a machine-readable {@link GanttErrorCode}.
|
|
608
|
+
*/
|
|
358
609
|
declare class GanttError extends Error {
|
|
359
610
|
readonly code: GanttErrorCode;
|
|
611
|
+
/**
|
|
612
|
+
* @param code - A machine-readable {@link GanttErrorCode} categorising the error.
|
|
613
|
+
* @param message - A human-readable description.
|
|
614
|
+
*/
|
|
360
615
|
constructor(code: GanttErrorCode, message: string);
|
|
361
616
|
}
|
|
362
617
|
//#endregion
|
|
363
|
-
export { BAR_HEIGHT, BAR_Y_OFFSET, type BarLayout, CHART_LOCALE_EN_US, type ChartLocale, DEFAULT_GRID_COLUMNS, DENSITY, EN_US_LABELS, GRID_COLUMN_FR_MIN_WIDTH, type GanttCallbacks, GanttChart, GanttError, type GanttErrorCode, type GanttInput, GanttInputSchema, type GanttInstance, type GanttOptions, type GridColumn, type Link, LinkSchema, type LinkType, LinkTypeSchema, type LocaleLabelKey, MILESTONE_HALF, MILESTONE_SIZE, type OnLinkCreate, type
|
|
618
|
+
export { BAR_HEIGHT, BAR_Y_OFFSET, type BarLayout, CHART_LOCALE_EN_US, type ChartLocale, DEFAULT_GRID_COLUMNS, DENSITY, EN_US_LABELS, GRID_COLUMN_FR_MIN_WIDTH, type GanttCallbacks, GanttChart, GanttError, type GanttErrorCode, type GanttInput, type GanttInputRaw, GanttInputSchema, type GanttInstance, type GanttOptions, type GridColumn, type Link, LinkSchema, type LinkType, LinkTypeSchema, type LocaleLabelKey, MILESTONE_HALF, MILESTONE_SIZE, type OnLinkClick, type OnLinkCreate, type OnLinkDblClick, type OnProgressChange, type OnTaskAdd, type OnTaskDoubleClick, type OnTaskMove, type OnTaskResize, type OnTaskSelect, type PixelMapper, type Point, ROW_HEIGHT, type RoutedLink, SCALE_CONFIGS, type ScaleConfig, type SpecialDay, type SpecialDayKind, SpecialDayKindSchema, SpecialDaySchema, type Task, type TaskDataField, type TaskKind, TaskKindSchema, type TaskNode, TaskSchema, type ThemeMode, type TimeScale, addDays, addHours, buildTaskTree, computeLayout, createPixelMapper, deriveViewport, deriveWeekNumbering, deriveWeekStartsOn, deriveWeekendDays, detectCycles, diffDays, diffHours, flattenTree, formatLabel, formatWeekNumber, gridColumnDefaults, gridNaturalWidth, gridTemplateColumns, isParent, parseDate, parseGanttInput, resolveChartLocale, routeLinks, validateLinkRefs, visibleColumns };
|
|
364
619
|
//# sourceMappingURL=index.d.mts.map
|