@svar-ui/gantt-store 2.5.1 → 2.6.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,7 +1,7 @@
1
1
  import { Store, EventBus } from "@svar-ui/lib-state";
2
2
  import type { TDataConfig, TWritableCreator, TID } from "@svar-ui/lib-state";
3
3
  import { HistoryManager } from "./pro/HistoryManager";
4
- import type { IData, IDataConfig, ITask, TMethodsConfig, ILink, IVisibleArea, IParsedTask, TScrollTask, IExportConfig } from "./types";
4
+ import type { IData, IDataConfig, ITask, TMethodsConfig, ILink, IVisibleArea, IParsedTask, IExportConfig, TFilterHandler, TScrollMode } from "./types";
5
5
  export default class DataStore extends Store<IData> {
6
6
  in: EventBus<TMethodsConfig, keyof TMethodsConfig>;
7
7
  private _router;
@@ -24,6 +24,7 @@ export default class DataStore extends Store<IData> {
24
24
  private calcScaleDate;
25
25
  getNextRow(id: TID): IParsedTask;
26
26
  getPrevRow(id: TID): IParsedTask;
27
+ scrollToTask(id: TID, mode: TScrollMode, eventSource?: keyof IDataMethodsConfig): void;
27
28
  }
28
29
  type CombineTypes<T, N> = {
29
30
  [P in keyof T]: T[P] & N;
@@ -34,7 +35,7 @@ export type IDataMethodsConfig = CombineTypes<{
34
35
  task: Partial<ITask>;
35
36
  target?: TID;
36
37
  mode?: "before" | "after" | "child";
37
- show?: TScrollTask["mode"];
38
+ show?: TScrollMode;
38
39
  select?: boolean;
39
40
  eventSource?: string;
40
41
  };
@@ -59,7 +60,9 @@ export type IDataMethodsConfig = CombineTypes<{
59
60
  id: TID;
60
61
  toggle?: boolean;
61
62
  range?: boolean;
62
- show?: TScrollTask["mode"];
63
+ column?: string | boolean;
64
+ show?: TScrollMode;
65
+ focus?: "grid" | "chart";
63
66
  };
64
67
  ["drag-task"]: {
65
68
  id: TID;
@@ -67,7 +70,6 @@ export type IDataMethodsConfig = CombineTypes<{
67
70
  width?: number;
68
71
  left?: number;
69
72
  top?: number;
70
- start?: boolean;
71
73
  inProgress?: boolean;
72
74
  };
73
75
  ["copy-task"]: {
@@ -109,6 +111,8 @@ export type IDataMethodsConfig = CombineTypes<{
109
111
  ["scroll-chart"]: {
110
112
  left?: number;
111
113
  top?: number;
114
+ date?: Date;
115
+ eventSource?: string;
112
116
  };
113
117
  ["render-data"]: IVisibleArea;
114
118
  ["request-data"]: {
@@ -123,12 +127,7 @@ export type IDataMethodsConfig = CombineTypes<{
123
127
  };
124
128
  ["zoom-scale"]: {
125
129
  dir: number;
126
- date: Date;
127
- offset?: number;
128
- };
129
- ["expand-scale"]: {
130
- minWidth: number;
131
- date?: Date;
130
+ ratio?: number;
132
131
  offset?: number;
133
132
  };
134
133
  ["sort-tasks"]: {
@@ -136,11 +135,22 @@ export type IDataMethodsConfig = CombineTypes<{
136
135
  order: "asc" | "desc";
137
136
  add?: boolean;
138
137
  };
138
+ ["filter-tasks"]: {
139
+ filter?: TFilterHandler;
140
+ key?: string;
141
+ value?: any;
142
+ open?: boolean;
143
+ };
139
144
  ["hotkey"]: {
140
145
  key: string;
141
146
  event: any;
142
147
  eventSource?: string;
143
148
  };
149
+ ["resize-chart"]: {
150
+ width: number;
151
+ height: number;
152
+ scrollSize: number;
153
+ };
144
154
  ["schedule-tasks"]: {
145
155
  id?: TID;
146
156
  task?: Partial<ITask>;
@@ -1,7 +1,7 @@
1
1
  import { DataTree, TID } from "@svar-ui/lib-state";
2
- import type { ITask, IParsedTask, TSort } from "./types";
2
+ import { ITask, IParsedTask, TSort, TFilterHandler, IGanttColumn } from "./types";
3
3
  export default class GanttDataTree extends DataTree<IParsedTask> {
4
- private _sort;
4
+ private _filteredIds;
5
5
  constructor(tasks?: Partial<ITask>[]);
6
6
  parse(tasks: Partial<ITask>[], parent: TID): void;
7
7
  getBranch(id: TID): IParsedTask[];
@@ -9,11 +9,16 @@ export default class GanttDataTree extends DataTree<IParsedTask> {
9
9
  getIndexById(id: TID): number;
10
10
  add(task: Partial<ITask>, index: number): IParsedTask;
11
11
  copy(taskObj: ITask, parent: TID, ind: number): TID[][];
12
+ remove(id: TID): void;
12
13
  normalizeTask(task: Partial<ITask>): ITask;
13
14
  getSummaryId(id: TID): TID | null;
14
- getSummaryId(id: TID, all: true): TID[] | null;
15
- sort(conf: TSort[]): void;
16
- sortBranch(conf: TSort[], parent?: TID): void;
15
+ getSummaryId(id: TID, all: boolean): TID[] | null;
16
+ sort(conf: TSort[], columns: IGanttColumn[]): void;
17
+ sortBranch(conf: TSort[], parent: TID, columns: IGanttColumn[]): void;
17
18
  serialize(): Partial<ITask>[];
18
19
  clear(): void;
20
+ filterTree(filter?: TFilterHandler, open?: boolean): void;
21
+ toArray(all?: boolean): IParsedTask[];
22
+ isFilteredId(id: TID): boolean;
23
+ hasChildItems(task: Partial<IParsedTask>): boolean;
19
24
  }
@@ -47,6 +47,16 @@ export declare function getEditorItems(config?: IDataConfig): ({
47
47
  id: any;
48
48
  label: string;
49
49
  }[];
50
+ } | {
51
+ [x: string]: any;
52
+ id?: import("@svar-ui/lib-state").TID;
53
+ key: string;
54
+ label?: string;
55
+ labelTemplate?: (value: any) => string;
56
+ config?: Record<string, any>;
57
+ isHidden?: (task: Partial<ITask>) => boolean;
58
+ isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
59
+ comp: "checkbox";
50
60
  } | {
51
61
  [x: string]: any;
52
62
  id?: import("@svar-ui/lib-state").TID;
@@ -0,0 +1,3 @@
1
+ import { IParsedTask, TFilterHandler, TID } from "../types";
2
+ export declare function filterTask(task: IParsedTask, filter: TFilterHandler, ids: Set<TID>, open?: boolean): boolean;
3
+ export declare function deleteFromFiltered(ids: Set<string | number>, id: TID, branch?: IParsedTask[]): void;
@@ -1,2 +1,2 @@
1
- import type { IParsedTask, TSort } from "../types";
2
- export declare function sort(data: IParsedTask[], conf: TSort[]): IParsedTask[];
1
+ import type { IGanttColumn, IParsedTask, TSort } from "../types";
2
+ export declare function sort(data: IParsedTask[], conf: TSort[], columns: IGanttColumn[]): IParsedTask[];
@@ -1,5 +1,5 @@
1
1
  import type { IGanttTask, IGanttLink, ILink } from "./types";
2
- export declare const updateLink: (link: IGanttLink, startTask: IGanttTask, endTask: IGanttTask, height: number, baselines: boolean) => IGanttLink;
2
+ export declare const updateLink: (link: IGanttLink, startTask: IGanttTask, endTask: IGanttTask, cellHeight: number) => IGanttLink;
3
3
  export declare function placeLink(box: {
4
4
  left: number;
5
5
  top: number;
@@ -1,13 +1,13 @@
1
- import type { IScaleConfig, GanttScaleData, IUnitFormats, IZoomConfig, TLengthUnit, IMarker } from "./types";
1
+ import type { IScaleConfig, GanttScaleData, IUnitFormats, IZoomConfig, TLengthUnit, IMarker, IData } from "./types";
2
2
  import type GanttDataTree from "./GanttDataTree";
3
3
  import { Day } from "date-fns";
4
4
  export declare function getMinUnit(scales: IScaleConfig[]): IScaleConfig;
5
5
  export declare const units: string[];
6
- export declare function calcScales(prevStart?: Date, prevEnd?: Date, autoScale?: boolean, minUnit?: string, tasks?: GanttDataTree, markers?: IMarker[]): {
6
+ export declare function calcScales(prevStart?: Date, prevEnd?: Date, autoScale?: boolean, minUnit?: string, tasks?: GanttDataTree, markers?: IMarker[], projectStart?: Date, projectEnd?: Date, baselines?: boolean): {
7
7
  _start: Date;
8
8
  _end: Date;
9
9
  };
10
- export declare function resetScales(start: Date, end: Date, lengthUnit: TLengthUnit, width: number, height: number, _weekStart: Day, scales: IScaleConfig[]): GanttScaleData | null;
10
+ export declare function resetScales(start: Date, end: Date, lengthUnit: TLengthUnit, width: number, height: number, _weekStart: Day, scales: IScaleConfig[], minLength: number): GanttScaleData | null;
11
11
  export declare function normalizeZoom(zoom: boolean | IZoomConfig, unitFormats: IUnitFormats, scales: IScaleConfig[], cellWidth: number): {
12
12
  zoom: IZoomConfig;
13
13
  scales: IScaleConfig[];
@@ -19,3 +19,4 @@ export declare function zoomScale(zoom: IZoomConfig, step: number, level: number
19
19
  lengthUnit: TLengthUnit;
20
20
  zoom: IZoomConfig;
21
21
  };
22
+ export declare function expandScale(minWidth: number, state: Partial<IData>): Partial<IData>;
@@ -1,7 +1,8 @@
1
- import { IGanttTask, IParsedTask, GanttDataTree, ITask, IData, IDataHash } from "./types";
2
- export declare function dragSummaryKids(task: IParsedTask, dx: number, state: Partial<IData>): void;
3
- export declare function dragSummary(tasks: GanttDataTree, task: IParsedTask, state: Partial<IData>, updateHidden?: boolean): void;
1
+ import { IGanttTask, IParsedTask, GanttDataTree, ITask, IDataHash, IData } from "./types";
2
+ export declare const heightAdjustment = 7;
3
+ export declare function dragSummaryKids(task: IParsedTask, dx: number, rollups: boolean): void;
4
+ export declare function dragSummary(tasks: GanttDataTree, task: IParsedTask): void;
4
5
  export declare function setSummaryDates(task: ITask, tasks?: Partial<ITask>[]): ITask;
5
- export declare function updateTask(t: IGanttTask, i: number, state: Partial<IData>): IGanttTask;
6
+ export declare function updateTask(t: IGanttTask, i: number | null, state: Partial<IData>): IGanttTask;
6
7
  export declare function isSegmentMoveAllowed(task: IGanttTask, moveOptions: IDataHash): boolean;
7
8
  export declare function extendDragOptions(task: ITask, options: IDataHash): void;
@@ -3,7 +3,8 @@ import type { DataArray, TID, IEventBus, IPublicWritable, IEventConfig } from "@
3
3
  import type GanttDataTree from "./GanttDataTree";
4
4
  import { Day } from "date-fns";
5
5
  import type DataStore from "./DataStore";
6
- import type { IApi as ITableApi, IColumn } from "@svar-ui/grid-store";
6
+ import type { IApi as ITableApi, IColumn, IFilterValues } from "@svar-ui/grid-store";
7
+ import { TaskSlackInfo } from "@svar-ui/lib-schedule";
7
8
  export type TMethodsConfig = IDataMethodsConfig;
8
9
  export type { GanttDataTree, TID };
9
10
  export interface IExportConfig {
@@ -66,7 +67,7 @@ export interface IGanttLink extends ILink {
66
67
  id: TID;
67
68
  $p: string;
68
69
  $pl: number;
69
- $critical?: boolean;
70
+ critical?: boolean;
70
71
  }
71
72
  export interface ITask {
72
73
  start?: Date;
@@ -77,6 +78,7 @@ export interface ITask {
77
78
  base_start?: Date;
78
79
  base_end?: Date;
79
80
  base_duration?: number;
81
+ rollup?: boolean;
80
82
  open?: boolean;
81
83
  text?: string;
82
84
  details?: string;
@@ -100,8 +102,16 @@ export interface IGanttTask extends IParsedTask {
100
102
  $w: number;
101
103
  $x_base?: number;
102
104
  $w_base?: number;
105
+ $x_rollup?: number;
106
+ $h_rollup?: number;
107
+ $y_rollup_relative?: number;
108
+ $w_rollup?: number;
103
109
  $reorder?: boolean;
104
- $critical?: boolean;
110
+ critical?: boolean;
111
+ slack?: TaskSlackInfo;
112
+ $visibleSlack?: number;
113
+ $x_slack?: number;
114
+ $w_slack?: number;
105
115
  }
106
116
  export type TDispatch = <A extends keyof TMethodsConfig>(action: A, data: TMethodsConfig[A]) => void;
107
117
  export interface IMethodsHash {
@@ -141,9 +151,7 @@ export interface IHistory {
141
151
  export interface ICriticalPathConfig {
142
152
  type: "strict" | "flexible";
143
153
  }
144
- export interface ICriticalTasks {
145
- [key: TID]: boolean;
146
- }
154
+ export type ICriticalTasks = Partial<Record<TID, boolean>>;
147
155
  type UnitFormatter = (date: Date) => string;
148
156
  export interface IUnitFormats {
149
157
  [unit: string]: UnitFormatter | string;
@@ -205,6 +213,9 @@ export interface IConfig {
205
213
  undo?: boolean;
206
214
  unscheduledTasks?: boolean;
207
215
  baselines?: boolean;
216
+ rollups?: {
217
+ type: "all" | "closest";
218
+ };
208
219
  markers?: IMarker[];
209
220
  criticalPath?: ICriticalPathConfig;
210
221
  projectStart?: Date;
@@ -212,23 +223,32 @@ export interface IConfig {
212
223
  calendar?: Calendar;
213
224
  splitTasks?: boolean;
214
225
  summary?: ISummaryConfig;
226
+ slack?: boolean;
215
227
  }
216
228
  export interface IDataConfig extends IConfig {
217
229
  scrollLeft: number;
218
230
  scrollTop: number;
219
231
  area: IVisibleArea;
220
232
  history?: IHistory;
233
+ filterValues?: IFilterValues;
234
+ focusTask?: TFocusTask;
221
235
  _cellWidth?: number;
222
236
  _sort?: TSort[];
223
- _scrollTask?: TScrollTask;
224
237
  _weekStart?: Day;
225
238
  _markers?: IMarker[];
239
+ _isFiltered?: boolean;
240
+ _chartWidth?: number;
241
+ _chartHeight?: number;
242
+ _scrollSize?: number;
226
243
  }
227
244
  export interface IData extends Omit<IDataConfig, "tasks" | "links"> {
228
245
  zoom?: IZoomConfig;
229
246
  tasks: GanttDataTree;
230
247
  links: DataArray<ILink>;
231
248
  _tasks: IParsedTask[];
249
+ _rollups: {
250
+ [key: TID]: Array<ITask>;
251
+ };
232
252
  _links: IGanttLink[];
233
253
  _selected?: ITask[];
234
254
  _activeTask?: ITask;
@@ -238,7 +258,11 @@ export interface IData extends Omit<IDataConfig, "tasks" | "links"> {
238
258
  _scaleDate?: Date;
239
259
  _zoomOffset?: number;
240
260
  _weekStart?: Day;
241
- _scrollTask?: TScrollTask;
261
+ _isFiltered?: boolean;
262
+ _headerLength?: number;
263
+ _chartWidth?: number;
264
+ _chartHeight?: number;
265
+ _scrollSize?: number;
242
266
  }
243
267
  export interface IDataHash<T = any> {
244
268
  [key: string]: T;
@@ -302,6 +326,7 @@ export type IGanttColumn = {
302
326
  cell?: any;
303
327
  editor?: IColumn["editor"];
304
328
  options?: IColumn["options"];
329
+ getter?: (obj: IDataHash) => any;
305
330
  };
306
331
  export type TCommonShape = {
307
332
  id?: TID;
@@ -333,6 +358,9 @@ export type TComboFieldShape = TCommonShape & {
333
358
  label: string;
334
359
  }[];
335
360
  };
361
+ export type TCheckboxShape = TCommonShape & {
362
+ comp: "checkbox";
363
+ };
336
364
  export type TSliderShape = TCommonShape & {
337
365
  comp: "slider";
338
366
  };
@@ -346,7 +374,7 @@ export type ILinksShape = TCommonShape & {
346
374
  export type ITwoStateShape = TCommonShape & {
347
375
  comp: "twostate";
348
376
  };
349
- export type TEditorItem = TTextFieldShape | TCounterShape | TComboFieldShape | TSliderShape | TDateFieldShape | TRadioShape | ILinksShape | ITwoStateShape;
377
+ export type TEditorItem = TTextFieldShape | TCounterShape | TComboFieldShape | TSliderShape | TDateFieldShape | TRadioShape | ILinksShape | ITwoStateShape | TCheckboxShape;
350
378
  export type ITaskType = {
351
379
  id: TID;
352
380
  label: string;
@@ -356,9 +384,11 @@ export type TSort = {
356
384
  order?: "asc" | "desc";
357
385
  };
358
386
  export type TSortValue = string | number | Date;
359
- export type TScrollTask = {
387
+ export type TFilterHandler = (task: any) => boolean;
388
+ export type TScrollMode = "x" | "y" | "xy" | boolean;
389
+ export type TFocusTask = {
360
390
  id: TID;
361
- mode?: "x" | "y" | "xy" | boolean;
391
+ column?: boolean;
362
392
  };
363
393
  export interface IApi {
364
394
  exec: <A extends keyof TMethodsConfig | (string & {})>(action: A, params?: A extends keyof TMethodsConfig ? TMethodsConfig[A] : any) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svar-ui/gantt-store",
3
- "version": "2.5.1",
3
+ "version": "2.6.0",
4
4
  "description": "Internal state management used by SVAR Gantt component",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",