@svar-ui/gantt-store 2.6.2 → 2.7.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,13 +1,17 @@
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, IExportConfig, TFilterHandler, TScrollMode } from "./types";
4
+ import { GroupManager } from "./pro/GroupManager";
5
+ import type { IData, IDataConfig, ITask, TMethodsConfig, IResourceColumn, ILink, IResource, IVisibleArea, IParsedTask, IExportConfig, TFilterHandler, TScrollMode, IAssignment, IGroupByConfig, TDataName, TResourceAssignment, ICalendar, TDisplayMode } from "./types";
5
6
  export default class DataStore extends Store<IData> {
6
7
  in: EventBus<TMethodsConfig, keyof TMethodsConfig>;
7
8
  private _router;
8
9
  private _modules;
10
+ private _prevScaleMinUnit?;
11
+ private _prevConfig;
9
12
  constructor(w: TWritableCreator);
10
13
  init(state: Partial<IDataConfig>): void;
14
+ private changed;
11
15
  private enableModule;
12
16
  private disableModule;
13
17
  setState(state: Partial<IData>, ctx?: TDataConfig): {
@@ -15,16 +19,26 @@ export default class DataStore extends Store<IData> {
15
19
  };
16
20
  setStateAsync(state: Partial<IData>): void;
17
21
  getTask(id: TID): IParsedTask;
22
+ getResource(id: TID): import("./types").IParsedResource;
18
23
  getHistory(): HistoryManager;
19
- serialize(): Partial<ITask>[];
24
+ getCalendar(id?: TID): ICalendar | undefined;
25
+ getTaskCalendar(task: Partial<ITask>): ICalendar | undefined;
26
+ getResourceCalendar(resource: Partial<IResource>): ICalendar | undefined;
27
+ private getLoadHours;
28
+ getGrouping(): GroupManager;
29
+ serialize(config?: {
30
+ data: TDataName;
31
+ }): any[];
32
+ getTaskResources(id: TID): Array<TResourceAssignment>;
33
+ getResourceTasks(id: TID): IParsedTask[];
20
34
  private changeScale;
35
+ private shouldExpandScale;
21
36
  private isScheduled;
22
37
  private resetSummaryDates;
23
38
  private moveSummaryKids;
24
- private calcScaleDate;
25
39
  getNextRow(id: TID): IParsedTask;
26
40
  getPrevRow(id: TID): IParsedTask;
27
- scrollToTask(id: TID, mode: TScrollMode, eventSource?: keyof IDataMethodsConfig): void;
41
+ scrollToTask(id: TID, mode: TScrollMode): void;
28
42
  }
29
43
  type CombineTypes<T, N> = {
30
44
  [P in keyof T]: T[P] & N;
@@ -60,9 +74,9 @@ export type IDataMethodsConfig = CombineTypes<{
60
74
  id: TID;
61
75
  toggle?: boolean;
62
76
  range?: boolean;
63
- column?: string | boolean;
64
77
  show?: TScrollMode;
65
78
  focus?: "grid" | "chart";
79
+ eventSource?: string;
66
80
  };
67
81
  ["drag-task"]: {
68
82
  id: TID;
@@ -99,7 +113,6 @@ export type IDataMethodsConfig = CombineTypes<{
99
113
  id?: TID;
100
114
  link: Partial<ILink>;
101
115
  eventSource?: string;
102
- skipUndo: boolean;
103
116
  };
104
117
  ["update-link"]: {
105
118
  id: TID;
@@ -112,7 +125,6 @@ export type IDataMethodsConfig = CombineTypes<{
112
125
  left?: number;
113
126
  top?: number;
114
127
  date?: Date;
115
- eventSource?: string;
116
128
  };
117
129
  ["render-data"]: IVisibleArea;
118
130
  ["request-data"]: {
@@ -123,6 +135,7 @@ export type IDataMethodsConfig = CombineTypes<{
123
135
  data: {
124
136
  tasks?: Array<ITask>;
125
137
  links?: Array<ILink>;
138
+ assignments?: Array<IAssignment>;
126
139
  };
127
140
  };
128
141
  ["zoom-scale"]: {
@@ -141,6 +154,7 @@ export type IDataMethodsConfig = CombineTypes<{
141
154
  value?: any;
142
155
  open?: boolean;
143
156
  };
157
+ ["group-tasks"]: IGroupByConfig;
144
158
  ["hotkey"]: {
145
159
  key: string;
146
160
  event: any;
@@ -154,6 +168,7 @@ export type IDataMethodsConfig = CombineTypes<{
154
168
  ["schedule-tasks"]: {
155
169
  id?: TID;
156
170
  task?: Partial<ITask>;
171
+ link?: TID;
157
172
  };
158
173
  ["undo"]: void;
159
174
  ["redo"]: void;
@@ -166,9 +181,36 @@ export type IDataMethodsConfig = CombineTypes<{
166
181
  data: string;
167
182
  format?: "mspx";
168
183
  };
184
+ ["add-assignment"]: {
185
+ id?: TID;
186
+ assignment: Partial<IAssignment>;
187
+ };
188
+ ["delete-assignment"]: {
189
+ id: TID;
190
+ };
191
+ ["update-assignment"]: {
192
+ id: TID;
193
+ assignment: Partial<IAssignment>;
194
+ };
195
+ ["resize-grid"]: {
196
+ width: number;
197
+ };
198
+ ["set-display-mode"]: {
199
+ mode: TDisplayMode;
200
+ };
201
+ ["open-resource-row"]: {
202
+ id: TID;
203
+ mode: boolean;
204
+ };
205
+ ["sort-resources"]: {
206
+ key: string;
207
+ order: "asc" | "desc";
208
+ add?: boolean;
209
+ _columns: IResourceColumn[];
210
+ };
169
211
  }, {
170
212
  skipProvider?: boolean;
171
- spipUndo?: boolean;
213
+ skipUndo?: boolean;
172
214
  [key: string]: any;
173
215
  }>;
174
216
  export {};
@@ -1,3 +1,6 @@
1
- import type { IGanttColumn } from "./types";
1
+ import type { IDataConfig, IGanttColumn, IResourceColumn } from "./types";
2
+ export declare const ADD_TASK_COLUMN_WIDTH = 37;
2
3
  export declare function normalizeColumns(columns: IGanttColumn[]): IGanttColumn[];
3
4
  export declare const defaultColumns: IGanttColumn[];
5
+ export declare function getDefaultColumns(config?: Partial<IDataConfig>): IGanttColumn[];
6
+ export declare function getResourceColumns(): IResourceColumn[];
@@ -0,0 +1,4 @@
1
+ import { IVisibleArea } from "../types";
2
+ export declare function calculateArea(scrollPos: number, viewportSize: number, cells: {
3
+ width: number;
4
+ }[], extra?: number): IVisibleArea;
@@ -1,4 +1,4 @@
1
- import type { TEditorItem, ITask, IData, IDataConfig } from "../types";
1
+ import type { TEditorItem, ITask, IData, IDataConfig, IDataHash } from "../types";
2
2
  export declare function getEditorItems(config?: IDataConfig): ({
3
3
  [x: string]: any;
4
4
  id?: import("@svar-ui/lib-state").TID;
@@ -6,7 +6,7 @@ export declare function getEditorItems(config?: IDataConfig): ({
6
6
  label?: string;
7
7
  labelTemplate?: (value: any) => string;
8
8
  config?: Record<string, any>;
9
- isHidden?: (task: Partial<ITask>) => boolean;
9
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
10
10
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
11
11
  comp: "text" | "textarea";
12
12
  } | {
@@ -16,7 +16,7 @@ export declare function getEditorItems(config?: IDataConfig): ({
16
16
  label?: string;
17
17
  labelTemplate?: (value: any) => string;
18
18
  config?: Record<string, any>;
19
- isHidden?: (task: Partial<ITask>) => boolean;
19
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
20
20
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
21
21
  comp: "counter";
22
22
  } | {
@@ -26,7 +26,7 @@ export declare function getEditorItems(config?: IDataConfig): ({
26
26
  label?: string;
27
27
  labelTemplate?: (value: any) => string;
28
28
  config?: Record<string, any>;
29
- isHidden?: (task: Partial<ITask>) => boolean;
29
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
30
30
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
31
31
  comp: "radio";
32
32
  options: {
@@ -40,7 +40,7 @@ export declare function getEditorItems(config?: IDataConfig): ({
40
40
  label?: string;
41
41
  labelTemplate?: (value: any) => string;
42
42
  config?: Record<string, any>;
43
- isHidden?: (task: Partial<ITask>) => boolean;
43
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
44
44
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
45
45
  comp: "combo" | "select" | "multiselect";
46
46
  options?: {
@@ -54,7 +54,7 @@ export declare function getEditorItems(config?: IDataConfig): ({
54
54
  label?: string;
55
55
  labelTemplate?: (value: any) => string;
56
56
  config?: Record<string, any>;
57
- isHidden?: (task: Partial<ITask>) => boolean;
57
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
58
58
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
59
59
  comp: "checkbox";
60
60
  } | {
@@ -64,7 +64,7 @@ export declare function getEditorItems(config?: IDataConfig): ({
64
64
  label?: string;
65
65
  labelTemplate?: (value: any) => string;
66
66
  config?: Record<string, any>;
67
- isHidden?: (task: Partial<ITask>) => boolean;
67
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
68
68
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
69
69
  comp: "slider";
70
70
  } | {
@@ -74,7 +74,7 @@ export declare function getEditorItems(config?: IDataConfig): ({
74
74
  label?: string;
75
75
  labelTemplate?: (value: any) => string;
76
76
  config?: Record<string, any>;
77
- isHidden?: (task: Partial<ITask>) => boolean;
77
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
78
78
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
79
79
  comp: "date";
80
80
  time?: boolean;
@@ -85,7 +85,7 @@ export declare function getEditorItems(config?: IDataConfig): ({
85
85
  label?: string;
86
86
  labelTemplate?: (value: any) => string;
87
87
  config?: Record<string, any>;
88
- isHidden?: (task: Partial<ITask>) => boolean;
88
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
89
89
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
90
90
  comp: "links";
91
91
  } | {
@@ -95,8 +95,42 @@ export declare function getEditorItems(config?: IDataConfig): ({
95
95
  label?: string;
96
96
  labelTemplate?: (value: any) => string;
97
97
  config?: Record<string, any>;
98
- isHidden?: (task: Partial<ITask>) => boolean;
98
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
99
99
  isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
100
100
  comp: "twostate";
101
+ } | {
102
+ [x: string]: any;
103
+ id?: import("@svar-ui/lib-state").TID;
104
+ key: string;
105
+ label?: string;
106
+ labelTemplate?: (value: any) => string;
107
+ config?: Record<string, any>;
108
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
109
+ isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
110
+ comp: "resources";
111
+ } | {
112
+ [x: string]: any;
113
+ id?: import("@svar-ui/lib-state").TID;
114
+ key: string;
115
+ label?: string;
116
+ labelTemplate?: (value: any) => string;
117
+ config?: Record<string, any>;
118
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
119
+ isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
120
+ comp: "tabs";
121
+ } | {
122
+ [x: string]: any;
123
+ id?: import("@svar-ui/lib-state").TID;
124
+ key: string;
125
+ label?: string;
126
+ labelTemplate?: (value: any) => string;
127
+ config?: Record<string, any>;
128
+ isHidden?: (task: Partial<ITask>, state: IData) => boolean;
129
+ isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
130
+ comp: "segments";
101
131
  })[];
102
132
  export declare const defaultEditorItems: TEditorItem[];
133
+ export declare function filterEditorButtons(items: IDataHash[], handler?: (item: IDataHash) => boolean): IDataHash[];
134
+ export declare function getEditorButtons(config?: IDataConfig & {
135
+ autoSave: boolean;
136
+ }): IDataHash[];
@@ -1,3 +1,4 @@
1
1
  import { IParsedTask, TFilterHandler, TID } from "../types";
2
2
  export declare function filterTask(task: IParsedTask, filter: TFilterHandler, ids: Set<TID>, open?: boolean): boolean;
3
3
  export declare function deleteFromFiltered(ids: Set<string | number>, id: TID, branch?: IParsedTask[]): void;
4
+ export declare function resetEmptyState(task: IParsedTask): void;
@@ -1,14 +1,27 @@
1
1
  import type { TID } from "@svar-ui/lib-state";
2
- import type { IParsedTask, IHistory, IData, IDataConfig, IDataHash } from "../types";
3
- export declare function getMenuOptions(config?: IDataConfig): IOptionConfig[];
2
+ import type { IParsedTask, IHistory, IData, IDataConfig, IDataHash, ICalendar } from "../types";
3
+ export declare function getMenuOptions(config?: IDataConfig & {
4
+ group?: boolean;
5
+ }): {
6
+ id?: TID;
7
+ separator?: boolean;
8
+ text?: string;
9
+ icon?: string;
10
+ data?: IOptionConfig[];
11
+ comp?: string;
12
+ isDisabled?: ((task: IParsedTask, state?: IData, calendar?: ICalendar, target?: TID | IDataHash) => boolean) | ((history: IHistory) => boolean);
13
+ dataFactory?: (obj: any) => IOptionConfig;
14
+ subtext?: string;
15
+ isHidden?: (task: IParsedTask, state: IData, target?: TID | IDataHash) => boolean;
16
+ }[];
4
17
  export interface IOptionConfig {
5
18
  id?: TID;
6
19
  separator?: boolean;
7
20
  text?: string;
8
21
  icon?: string;
9
22
  data?: IOptionConfig[];
10
- type?: string;
11
- isDisabled?: ((task: IParsedTask, state: IData, target?: TID | IDataHash) => boolean) | ((history: IHistory) => boolean);
23
+ comp?: string;
24
+ isDisabled?: ((task: IParsedTask, state?: IData, calendar?: ICalendar, target?: TID | IDataHash) => boolean) | ((history: IHistory) => boolean);
12
25
  dataFactory?: (obj: any) => IOptionConfig;
13
26
  subtext?: string;
14
27
  isHidden?: (task: IParsedTask, state: IData, target?: TID | IDataHash) => boolean;
@@ -1,2 +1,2 @@
1
- import type { IGanttColumn, IParsedTask, TSort } from "../types";
1
+ import { IGanttColumn, IParsedTask, TSort } from "../types";
2
2
  export declare function sort(data: IParsedTask[], conf: TSort[], columns: IGanttColumn[]): IParsedTask[];
@@ -1,6 +1,8 @@
1
1
  import type { IData, IDataHash, IParsedTask, IHistory, IDataConfig } from "../types";
2
2
  import type { TID } from "@svar-ui/lib-state";
3
- export declare function getToolbarButtons(config?: IDataConfig): IButtonConfig[];
3
+ export declare function getToolbarButtons(config?: IDataConfig & {
4
+ group?: boolean;
5
+ }): IButtonConfig[];
4
6
  export interface IButtonConfig {
5
7
  id?: string;
6
8
  comp: string;
@@ -1,15 +1,17 @@
1
1
  export { default as DataStore } from "./DataStore";
2
2
  export { grid } from "./dom/scales";
3
3
  export { placeLink, normalizeLinks } from "./links";
4
- export { getDiffer, getAdder, getUnitStart, format, registerScaleUnit, } from "./time";
4
+ export { getDiffer, getAdder, getUnitStart, format, formatDay, registerScaleUnit, } from "./time";
5
5
  export { handleAction, isHandledAction } from "./helpers/actionHandlers";
6
+ export { calculateArea } from "./helpers/area";
6
7
  export { defaultToolbarButtons, getToolbarButtons, } from "./helpers/toolbarButtons";
7
8
  export { defaultMenuOptions, getMenuOptions } from "./helpers/menuOptions";
8
- export { defaultEditorItems, getEditorItems } from "./helpers/editorItems";
9
- export { defaultColumns } from "./columns";
9
+ export { defaultEditorItems, getEditorItems, getEditorButtons, filterEditorButtons, } from "./helpers/editorItems";
10
+ export { defaultColumns, getDefaultColumns, getResourceColumns, } from "./columns";
10
11
  export { defaultTaskTypes } from "./taskTypes";
11
12
  export { prepareEditTask, parseTaskDates } from "./normalizeDates";
12
13
  export { normalizeZoom } from "./scales";
13
14
  export { isSegmentMoveAllowed, extendDragOptions } from "./tasks";
14
- export declare const Calendar: any;
15
- export type { TID, IApi, ITask, ILink, IConfig, IZoomConfig, IGanttColumn, TMethodsConfig, IGanttTask, IMarker, IScheduleConfig, ICriticalPathConfig, IScaleConfig, } from "./types";
15
+ export type { TID, IApi, ITask, ILink, IResource, IAssignment, IDataAssignment, IComputedResource, IResourceLoad, IResourceColumn, IConfig, IZoomConfig, IGanttColumn, TMethodsConfig, IGanttTask, IMarker, IScheduleConfig, ICriticalPathConfig, IScaleConfig, ICalendarRule, CalendarConfig, } from "./types";
16
+ import { CalendarConfig } from "./types";
17
+ export declare function createCalendar(config?: CalendarConfig): any;
@@ -1,6 +1,6 @@
1
- import type { ITask, IData } from "./types";
2
- export declare function parseTaskDates(tasks: ITask[], state: Partial<IData>): void;
3
- export declare function normalizeDates(task: Partial<ITask>, state: Partial<IData>): void;
4
- export declare function calcDates(task: Partial<ITask>, state: Partial<IData>, isBaseline?: boolean): void;
1
+ import type { ITask, IData, ICalendar, TCalendarGetter } from "./types";
2
+ export declare function parseTaskDates(tasks: ITask[], state: Partial<IData>, calendarGetter: TCalendarGetter): void;
3
+ export declare function normalizeDates(task: Partial<ITask>, state: Partial<IData>, calendar: ICalendar | undefined): void;
4
+ export declare function calcDates(task: Partial<ITask>, state: Partial<IData>, calendar: ICalendar | undefined, isBaseline?: boolean): void;
5
5
  export declare function getFields(isBaseline: boolean): string[];
6
- export declare function prepareEditTask(task: Partial<ITask>, state: Partial<IData>, key: string): void;
6
+ export declare function prepareEditTask(task: Partial<ITask>, state: Partial<IData>, calendar: ICalendar, key: string): void;
@@ -20,3 +20,4 @@ export declare function zoomScale(zoom: IZoomConfig, step: number, level: number
20
20
  zoom: IZoomConfig;
21
21
  };
22
22
  export declare function expandScale(minWidth: number, state: Partial<IData>): Partial<IData>;
23
+ export declare function calcScaleDate(x: number, state: Partial<IData>): Date;
@@ -0,0 +1,5 @@
1
+ export type TaskSlackInfo = any;
2
+ export type ICalendarRule = any;
3
+ export type CalendarConfig = any;
4
+ export type ICalendar = any;
5
+ export declare const Calendar: any;
@@ -1,17 +1,18 @@
1
1
  import { format, Day } from "date-fns";
2
- import type { GanttScaleUnit, Calendar } from "./types";
2
+ import type { GanttScaleUnit, ICalendar } from "./types";
3
3
  export declare function getSmallerUnitCount(unit: string, lengthUnit: string, date?: Date): number;
4
4
  export declare function isCorrectLengthUnit(minUnit: string, lengthUnit: string): boolean;
5
- export declare function getDiffer(unit: string, calendar?: Calendar, _weekStart?: Day): {
5
+ export declare function getDiffer(unit: string, calendar?: ICalendar, _weekStart?: Day): {
6
6
  (start: Date, end: Date, lengthUnit?: string, unitSize?: boolean): number;
7
7
  };
8
- export declare function getAdder(unit: string, calendar?: Calendar): {
8
+ export declare function getAdder(unit: string, calendar?: ICalendar): {
9
9
  (start: number | Date, step: number): Date;
10
10
  };
11
11
  export declare function getUnitStart(unit: string, date: Date, _weekStart?: Day): Date;
12
12
  export declare function getUnitEnd(unit: string, date: Date, _weekStart?: Day): Date;
13
13
  export declare function isSameUnit(unit: string, a: Date, b: Date, _weekStart?: Day): boolean;
14
14
  export declare function registerScaleUnit(unit: string, config: GanttScaleUnit): void;
15
- export declare function adjustToWorkingDay(start: Date, diff: number, calendar: Calendar): Date;
16
- export declare function shiftByWorkingDays(calendar: Calendar): (date: Date, diff: number) => Date;
15
+ export declare function adjustToWorkingDay(start: Date, diff: number, calendar: ICalendar): Date;
16
+ export declare function shiftByWorkingDays(calendar: ICalendar): (date: Date, diff: number) => Date;
17
+ export declare function formatDay(date: Date): string;
17
18
  export { format };