@svar-ui/gantt-store 2.7.2 → 2.8.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.
@@ -1,14 +1,31 @@
1
1
  import type { IDataMethodsConfig } from "./DataStore";
2
- import type { DataArray, TID, IEventBus, IPublicWritable, IEventConfig } from "@svar-ui/lib-state";
2
+ import type { DataArray, TID, IEventBus, IPublicWritable, IEventConfig, DataTree } from "@svar-ui/lib-state";
3
3
  import type GanttDataTree from "./GanttDataTree";
4
4
  import { Day } from "date-fns";
5
5
  import type DataStore from "./DataStore";
6
6
  import type { IApi as ITableApi, IColumn, IFilterValues } from "@svar-ui/grid-store";
7
- import type { TaskSlackInfo, ICalendarRule, CalendarConfig, ICalendar } from "./schedule-types";
8
- export type { TaskSlackInfo, ICalendarRule, CalendarConfig, ICalendar };
9
- import ResourceDataTree from "./pro/ResourceDataTree";
7
+ import type { TaskSlackInfo, ICalendarRule, CalendarConfig, ICalendar, Constraint, Conflict, InvalidLinkReason } from "./schedule-types";
8
+ export type { TaskSlackInfo, ICalendarRule, CalendarConfig, ICalendar, Constraint, Conflict, InvalidLinkReason, };
9
+ export type ITaskCalendar = ICalendar & {
10
+ noWorkingTime?: boolean;
11
+ };
10
12
  export type TMethodsConfig = IDataMethodsConfig;
11
13
  export type { GanttDataTree, TID };
14
+ export interface IConflict {
15
+ type: "link" | "constraint";
16
+ task: TID;
17
+ link?: TID;
18
+ required: Date;
19
+ }
20
+ export interface IConflictReportRow extends IConflict {
21
+ id: string;
22
+ typeKey: string | null;
23
+ }
24
+ export interface IConflictsIndex {
25
+ rows: IConflictReportRow[];
26
+ constraints: Set<TID>;
27
+ links: Set<TID>;
28
+ }
12
29
  export interface IExportConfig {
13
30
  url?: string;
14
31
  format?: "pdf" | "png" | "xlsx" | "mspx";
@@ -68,7 +85,9 @@ export type TSerializeData = {
68
85
  };
69
86
  export type TDataName = keyof TSerializeData;
70
87
  export type TSortFunction = (a: IDataHash, b: IDataHash) => 1 | -1 | 0;
88
+ export type TDisplayPanel = "grid" | "chart" | "subGrid";
71
89
  export type TDisplayMode = "all" | "grid" | "chart";
90
+ export type TDisplayModeConfig = TDisplayMode | TDisplayPanel[];
72
91
  export type TCellBorders = "column" | "full";
73
92
  export type TCalendarGetter = (task: Partial<ITask>) => ICalendar | undefined;
74
93
  export interface ILink {
@@ -114,12 +133,54 @@ export interface IParsedResource extends IResource {
114
133
  $level: number;
115
134
  data?: IParsedResource[];
116
135
  }
136
+ export interface IResourceDataTree extends DataTree<IParsedResource> {
137
+ sort(conf: TSort[], columns?: IResourceColumn[]): void;
138
+ }
117
139
  export interface IComputedResource extends IParsedResource {
118
140
  data?: IComputedResource[];
119
141
  $load: Record<string, IResourceLoad>;
142
+ $capacity: Record<string, number>;
143
+ $capacityTotal: number;
144
+ $fullDay: number;
120
145
  $total: number;
121
146
  $overloaded: boolean;
122
147
  $unitLoad?: Record<string, IResourceLoad>;
148
+ $unitCapacity?: Record<string, number>;
149
+ }
150
+ export interface IHistogramColumn {
151
+ id: string;
152
+ width: number;
153
+ date: Date;
154
+ end?: Date;
155
+ pxPerDayThreshold: number;
156
+ overloadHeadroom?: number;
157
+ }
158
+ export interface IResourceHistogramConfig {
159
+ overloadHeadroom?: number;
160
+ capacityLine?: boolean;
161
+ }
162
+ export interface IResourceHistogramTooltip {
163
+ resource: IComputedResource;
164
+ start: Date;
165
+ end: Date;
166
+ hours: number;
167
+ capacity: number;
168
+ days: number;
169
+ }
170
+ export interface IHistogramColumnPosition {
171
+ column: IHistogramColumn;
172
+ left: number;
173
+ }
174
+ export interface IHistogramBar {
175
+ key: string;
176
+ start: Date;
177
+ end?: Date;
178
+ hours: number;
179
+ capacity: number;
180
+ ceiling: number;
181
+ width: number;
182
+ days: number;
183
+ overloaded: boolean;
123
184
  }
124
185
  export interface IResourceColumn {
125
186
  id: string;
@@ -153,6 +214,7 @@ export interface ITask {
153
214
  base_start?: Date;
154
215
  base_end?: Date;
155
216
  base_duration?: number;
217
+ deadline?: Date;
156
218
  rollup?: boolean;
157
219
  open?: boolean;
158
220
  text?: string;
@@ -161,8 +223,12 @@ export interface ITask {
161
223
  type?: TTaskType;
162
224
  parent?: TID;
163
225
  calendar?: TID;
226
+ skipResourceCalendars?: boolean;
164
227
  unscheduled?: boolean;
228
+ manual?: boolean;
229
+ inactive?: boolean;
165
230
  segments?: Partial<ITask>[];
231
+ constraint?: Constraint | null;
166
232
  [key: string]: any;
167
233
  }
168
234
  export interface IParsedTask extends ITask {
@@ -171,6 +237,8 @@ export interface IParsedTask extends ITask {
171
237
  data?: IParsedTask[];
172
238
  $level: number;
173
239
  $wbs?: string;
240
+ $noWorkingTime?: boolean;
241
+ $placeholder?: boolean;
174
242
  }
175
243
  export interface IGanttTask extends IParsedTask {
176
244
  $x: number;
@@ -183,12 +251,15 @@ export interface IGanttTask extends IParsedTask {
183
251
  $h_rollup?: number;
184
252
  $y_rollup_relative?: number;
185
253
  $w_rollup?: number;
254
+ $x_deadline?: number;
255
+ $overdue?: boolean;
186
256
  $reorder?: boolean;
187
257
  critical?: boolean;
188
258
  slack?: TaskSlackInfo;
189
259
  $visibleSlack?: number;
190
260
  $x_slack?: number;
191
261
  $w_slack?: number;
262
+ $x_constraint?: number;
192
263
  }
193
264
  export type TDispatch = <A extends keyof TMethodsConfig>(action: A, data: TMethodsConfig[A]) => void;
194
265
  export interface IMethodsHash {
@@ -222,10 +293,69 @@ export interface IMarker {
222
293
  css?: string;
223
294
  left?: number;
224
295
  }
296
+ export interface IProgressLineData {
297
+ statusX: number;
298
+ statusDate: Date;
299
+ }
300
+ export type TSCurveType = "scheduled" | "earned" | "baseline";
301
+ export type TSCurveMetric = "duration" | "progress";
302
+ export type TSCurveLine = {
303
+ type: TSCurveType;
304
+ metric?: TSCurveMetric;
305
+ css?: string;
306
+ };
307
+ export type TSCurveConfig = boolean | TSCurveLine[];
308
+ export interface ISCurveLineInfo {
309
+ type: TSCurveType;
310
+ metric: TSCurveMetric;
311
+ }
312
+ export interface ISCurveLineConfig extends ISCurveLineInfo {
313
+ css?: string;
314
+ }
315
+ export type TSCurvePlan = "scheduled" | "baseline";
316
+ export interface ISCurveLine extends ISCurveLineInfo {
317
+ series: Float64Array;
318
+ }
319
+ export interface ISCurveData {
320
+ lines: ISCurveLine[];
321
+ start: number;
322
+ end: number;
323
+ }
324
+ export interface ISCurveViewPoint {
325
+ index: number;
326
+ x: number;
327
+ y: number;
328
+ }
329
+ export interface ISCurveLineView extends ISCurveLineConfig {
330
+ line: number;
331
+ path: string;
332
+ points: ISCurveViewPoint[];
333
+ }
334
+ export interface ISCurveTooltipLine extends ISCurveLineInfo {
335
+ line: number;
336
+ value: number;
337
+ }
338
+ export interface ISCurveTooltip {
339
+ date: Date;
340
+ hovered: ISCurveTooltipLine;
341
+ lines: ISCurveTooltipLine[];
342
+ }
225
343
  export interface IHistory {
226
344
  undo: number;
227
345
  redo: number;
228
346
  }
347
+ export interface IHistoryManager {
348
+ startBatch: () => void;
349
+ endBatch: (discard?: boolean) => void;
350
+ isBatching: () => boolean;
351
+ handleUndo: () => void;
352
+ handleRedo: () => void;
353
+ resetHistory: () => void;
354
+ }
355
+ export interface IGroupManager {
356
+ buildTree: () => GanttDataTree;
357
+ updateTaskGroup: (id: TID) => void;
358
+ }
229
359
  export interface ICriticalPathConfig {
230
360
  type: "strict" | "flexible";
231
361
  }
@@ -237,6 +367,7 @@ export interface IUnitFormats {
237
367
  export interface IScheduleConfig {
238
368
  type?: "forward";
239
369
  auto?: boolean;
370
+ resourceCalendars?: boolean;
240
371
  }
241
372
  export interface ISummaryConfig {
242
373
  autoProgress?: boolean;
@@ -266,11 +397,12 @@ export interface IConfig {
266
397
  segmentIndex: number;
267
398
  };
268
399
  scales?: IScaleConfig[];
269
- columns?: IGanttColumn[];
400
+ columns?: false | IGanttColumn[];
270
401
  start?: Date;
271
402
  end?: Date;
272
403
  lengthUnit?: TLengthUnit;
273
404
  durationUnit?: TDurationUnit;
405
+ inclusiveEnd?: boolean;
274
406
  cellWidth?: number;
275
407
  cellHeight?: number;
276
408
  scaleHeight?: number;
@@ -279,6 +411,8 @@ export interface IConfig {
279
411
  schedule?: IScheduleConfig;
280
412
  undo?: boolean;
281
413
  unscheduledTasks?: boolean;
414
+ inactiveTasks?: boolean;
415
+ placeholderRow?: boolean;
282
416
  baselines?: boolean;
283
417
  rollups?: boolean | {
284
418
  type: "all" | "closest";
@@ -295,11 +429,18 @@ export interface IConfig {
295
429
  groupBy?: string | IGroupByConfig | null;
296
430
  wbs?: boolean;
297
431
  highlightTime?: (date: Date, unit: TDurationUnit) => string;
298
- displayMode?: TDisplayMode;
432
+ displayMode?: TDisplayModeConfig;
299
433
  gridWidth?: number;
434
+ subGridWidth?: number;
300
435
  cellBorders?: TCellBorders;
436
+ deadlines?: boolean;
437
+ progressLine?: boolean | Date | null;
438
+ sCurve?: TSCurveConfig | null;
301
439
  }
302
440
  export interface IDataConfig extends IConfig {
441
+ displayMode: TDisplayPanel[];
442
+ gridWidth: number;
443
+ _displayPanels: TDisplayPanel[];
303
444
  scrollLeft: number;
304
445
  scrollTop: number;
305
446
  area: IVisibleArea;
@@ -322,24 +463,34 @@ export interface IDataConfig extends IConfig {
322
463
  _chartHeight?: number;
323
464
  _scrollSize?: number;
324
465
  _calendar?: ICalendar;
325
- _calendars?: Record<TID, ICalendar>;
466
+ _calendars?: Map<TID, ICalendar>;
467
+ _composites?: Map<string, ICalendar>;
326
468
  _compactMode: boolean;
469
+ _containerWidth: number | null;
327
470
  _columnsWidth?: number;
328
471
  _gridCollapseThreshold?: number;
472
+ _progressLine?: IProgressLineData | null;
473
+ _progressLinePoints?: string | null;
474
+ _sCurve?: ISCurveData | null;
475
+ _sCurvePoints?: ISCurveLineView[] | null;
476
+ conflicts?: IConflict[];
477
+ _conflicts?: IConflictsIndex | null;
478
+ showConflicts?: boolean;
329
479
  }
330
- export interface IData extends Omit<IDataConfig, TDataName | "rollups" | "groupBy"> {
480
+ export interface IData extends Omit<IDataConfig, TDataName> {
481
+ columns?: IGanttColumn[];
482
+ _columns?: IGanttColumn[];
331
483
  rollups?: false | {
332
484
  type: "all" | "closest";
333
485
  };
334
486
  zoom?: IZoomConfig;
335
487
  tasks: GanttDataTree;
336
488
  links: DataArray<ILink>;
337
- resources?: ResourceDataTree;
489
+ resources?: IResourceDataTree;
338
490
  assignments?: DataArray<IAssignment>;
339
491
  calendars?: GanttCalendarConfig[];
340
492
  tree: GanttDataTree;
341
493
  _tasks: IParsedTask[];
342
- _tasksPatch?: boolean | null;
343
494
  _rollups: {
344
495
  [key: TID]: Array<ITask>;
345
496
  };
@@ -352,7 +503,6 @@ export interface IData extends Omit<IDataConfig, TDataName | "rollups" | "groupB
352
503
  _start?: Date;
353
504
  _end?: Date;
354
505
  _scales?: GanttScaleData;
355
- _scaleMinUnit?: TLengthUnit;
356
506
  _scaleDate?: Date;
357
507
  _zoomOffset?: number;
358
508
  _weekStart?: Day;
@@ -364,6 +514,9 @@ export interface IData extends Omit<IDataConfig, TDataName | "rollups" | "groupB
364
514
  _columnsWidth?: number;
365
515
  groupBy?: IGroupByConfig;
366
516
  _gridCollapseThreshold?: number;
517
+ _progressLine?: IProgressLineData | null;
518
+ _progressLinePoints?: string | null;
519
+ conflicts: IConflict[];
367
520
  }
368
521
  export interface IDataHash<T = any> {
369
522
  [key: string]: T;
@@ -381,7 +534,10 @@ export type IScaleConfig = {
381
534
  export type GanttScaleCell = {
382
535
  width: number;
383
536
  value: string;
537
+ date: Date;
538
+ key: string;
384
539
  css: string;
540
+ unit: TLengthUnit;
385
541
  };
386
542
  export type GanttScaleRow = {
387
543
  cells: GanttScaleCell[];
@@ -414,11 +570,13 @@ export type GanttScaleUnit = {
414
570
  [key: TLengthUnit]: number | ((date: Date) => number);
415
571
  };
416
572
  };
573
+ export type TColumnSection = "grid" | "subGrid";
417
574
  export type IGanttColumn = {
418
575
  width?: number;
419
576
  align?: "left" | "right" | "center";
420
577
  flexgrow?: number;
421
578
  hidden?: boolean;
579
+ section?: TColumnSection;
422
580
  resize?: boolean;
423
581
  header?: IColumn["header"];
424
582
  id?: string;
@@ -429,6 +587,7 @@ export type IGanttColumn = {
429
587
  editor?: IColumn["editor"];
430
588
  options?: IColumn["options"];
431
589
  getter?: (obj: IDataHash) => any;
590
+ setter?: (obj: IDataHash, value: any) => void;
432
591
  };
433
592
  export type TCommonShape = {
434
593
  id?: TID;
@@ -448,17 +607,11 @@ export type TCounterShape = TCommonShape & {
448
607
  };
449
608
  export type TRadioShape = TCommonShape & {
450
609
  comp: "radio";
451
- options: {
452
- id: TID;
453
- label: string;
454
- }[];
610
+ options: IOption[];
455
611
  };
456
612
  export type TComboFieldShape = TCommonShape & {
457
613
  comp: "combo" | "select" | "multiselect";
458
- options?: {
459
- id: any;
460
- label: string;
461
- }[];
614
+ options?: IOption<any>[];
462
615
  };
463
616
  export type TCheckboxShape = TCommonShape & {
464
617
  comp: "checkbox";
@@ -485,11 +638,16 @@ export type ITabs = TCommonShape & {
485
638
  export type ISegments = TCommonShape & {
486
639
  comp: "segments";
487
640
  };
488
- export type TEditorItem = TTextFieldShape | TCounterShape | TComboFieldShape | TSliderShape | TDateFieldShape | TRadioShape | ILinksShape | ITwoStateShape | TCheckboxShape | IResources | ISegments | ITabs;
489
- export type ITaskType = {
490
- id: TID;
641
+ export type IConstraintShape = TCommonShape & {
642
+ comp: "constraint";
643
+ };
644
+ export type TEditorItem = TTextFieldShape | TCounterShape | TComboFieldShape | TSliderShape | TDateFieldShape | TRadioShape | ILinksShape | ITwoStateShape | TCheckboxShape | IResources | ISegments | IConstraintShape | ITabs;
645
+ export type IOption<T = TID> = {
646
+ id: T;
491
647
  label: string;
492
648
  };
649
+ export type ITaskType = IOption;
650
+ export type IConstraintType = IOption;
493
651
  export type TSort = {
494
652
  key: string;
495
653
  order?: "asc" | "desc";
@@ -499,8 +657,13 @@ export type TFilterHandler = (task: any) => boolean;
499
657
  export type TScrollMode = "x" | "y" | "xy" | boolean;
500
658
  export type TFocusTask = {
501
659
  id: TID;
502
- column?: boolean;
660
+ /** Where to move focus; omitted or "chart" focuses the chart bar. */
661
+ section?: TDisplayPanel;
662
+ };
663
+ export type TLinkDraft = Pick<ILink, "source" | "target" | "type"> & {
664
+ id?: TID;
503
665
  };
666
+ export type TLinkValidator = (link: TLinkDraft) => InvalidLinkReason | null;
504
667
  export interface IApi {
505
668
  exec: <A extends keyof TMethodsConfig | (string & {})>(action: A, params?: A extends keyof TMethodsConfig ? TMethodsConfig[A] : any) => Promise<any>;
506
669
  on: <A extends keyof TMethodsConfig | (string & {})>(action: A, callback: (config: A extends keyof TMethodsConfig ? TMethodsConfig[A] : any) => any, config?: IEventConfig) => void;
@@ -514,13 +677,17 @@ export interface IApi {
514
677
  getStores: () => {
515
678
  data: DataStore;
516
679
  };
517
- getTable: (waitRender?: boolean) => Promise<ITableApi> | ITableApi;
680
+ getTable: (waitRender?: boolean, section?: TColumnSection) => Promise<ITableApi> | ITableApi;
518
681
  getTask: (id: TID) => ITask;
519
682
  getResource: (id: TID) => IResource;
520
683
  serialize: (config?: {
521
684
  data?: keyof TSerializeData;
522
685
  }) => TSerializeData[keyof TSerializeData] | null;
523
686
  getCalendar: (id?: TID) => ICalendar | undefined;
687
+ getTaskCalendar: (task: Partial<ITask>) => ITaskCalendar | undefined;
688
+ getResourceCalendar: (resource: Partial<IResource>) => ICalendar | undefined;
689
+ getHistory: () => IHistoryManager | null | undefined;
524
690
  getTaskResources: (id: TID) => TResourceAssignment[];
525
691
  getResourceTasks: (id: TID) => ITask[];
692
+ getLinkValidator: () => TLinkValidator;
526
693
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svar-ui/gantt-store",
3
- "version": "2.7.2",
3
+ "version": "2.8.0",
4
4
  "description": "Internal state management used by SVAR Gantt component",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,6 +21,7 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "date-fns": "3.6.0",
24
- "@svar-ui/lib-state": "1.9.7"
24
+ "@svar-ui/lib-dom": "0.14.0",
25
+ "@svar-ui/lib-state": "1.10.1"
25
26
  }
26
27
  }