@svar-ui/gantt-store 2.3.0 → 2.4.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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/DataStore.d.ts +25 -1
- package/dist/types/GanttDataTree.d.ts +2 -1
- package/dist/types/helpers/actionHandlers.d.ts +4 -1
- package/dist/types/helpers/editorItems.d.ts +3 -0
- package/dist/types/helpers/getCircularLinks.d.ts +3 -0
- package/dist/types/helpers/menuOptions.d.ts +4 -2
- package/dist/types/helpers/toolbarButtons.d.ts +5 -1
- package/dist/types/index.d.ts +10 -6
- package/dist/types/links.d.ts +8 -1
- package/dist/types/modules/AutoScheduler.pro.d.ts +15 -0
- package/dist/types/modules/ChangeTracker.pro.d.ts +10 -0
- package/dist/types/modules/CriticalPath.pro.d.ts +11 -0
- package/dist/types/modules/EventTracker.pro.d.ts +20 -0
- package/dist/types/modules/HistoryManager.pro.d.ts +48 -0
- package/dist/types/normalizeDates.d.ts +5 -3
- package/dist/types/scales.d.ts +5 -4
- package/dist/types/splitTasks.pro.d.ts +11 -0
- package/dist/types/tasks.d.ts +6 -4
- package/dist/types/time.d.ts +9 -7
- package/dist/types/types.d.ts +72 -8
- package/license.txt +4 -16
- package/package.json +24 -22
- package/readme.md +5 -0
- package/dist/types/editorItems.d.ts +0 -2
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { Store, EventBus } from "@wx/lib-state";
|
|
2
2
|
import type { TDataConfig, TWritableCreator, TID } from "@wx/lib-state";
|
|
3
|
+
import { HistoryManager } from "./modules/HistoryManager.pro";
|
|
3
4
|
import type { IData, IDataConfig, ITask, TMethodsConfig, ILink, IVisibleArea, IParsedTask, TScrollTask } from "./types";
|
|
4
5
|
export default class DataStore extends Store<IData> {
|
|
5
6
|
in: EventBus<TMethodsConfig, keyof TMethodsConfig>;
|
|
6
7
|
private _router;
|
|
8
|
+
private _modules;
|
|
7
9
|
constructor(w: TWritableCreator);
|
|
8
10
|
init(state: Partial<IDataConfig>): void;
|
|
11
|
+
private enableModule;
|
|
12
|
+
private disableModule;
|
|
9
13
|
setState(state: Partial<IData>, ctx?: TDataConfig): {
|
|
10
14
|
[key: string]: () => void;
|
|
11
15
|
};
|
|
12
16
|
setStateAsync(state: Partial<IData>): void;
|
|
13
17
|
getTask(id: TID): IParsedTask;
|
|
18
|
+
getHistory(): HistoryManager;
|
|
14
19
|
serialize(): Partial<ITask>[];
|
|
15
20
|
private changeScale;
|
|
16
21
|
private isScheduled;
|
|
@@ -30,13 +35,17 @@ export type IDataMethodsConfig = CombineTypes<{
|
|
|
30
35
|
target?: TID;
|
|
31
36
|
mode?: "before" | "after" | "child";
|
|
32
37
|
show?: TScrollTask["mode"];
|
|
38
|
+
select?: boolean;
|
|
39
|
+
eventSource?: string;
|
|
33
40
|
};
|
|
34
41
|
["update-task"]: {
|
|
35
42
|
id: TID;
|
|
43
|
+
segmentIndex?: number;
|
|
36
44
|
task: Partial<ITask>;
|
|
37
45
|
diff?: number;
|
|
38
46
|
inProgress?: boolean;
|
|
39
47
|
eventSource?: string;
|
|
48
|
+
skipUndo?: boolean;
|
|
40
49
|
};
|
|
41
50
|
["delete-task"]: {
|
|
42
51
|
id: TID;
|
|
@@ -54,6 +63,7 @@ export type IDataMethodsConfig = CombineTypes<{
|
|
|
54
63
|
};
|
|
55
64
|
["drag-task"]: {
|
|
56
65
|
id: TID;
|
|
66
|
+
segmentIndex?: number;
|
|
57
67
|
width?: number;
|
|
58
68
|
left?: number;
|
|
59
69
|
top?: number;
|
|
@@ -66,11 +76,12 @@ export type IDataMethodsConfig = CombineTypes<{
|
|
|
66
76
|
source?: TID;
|
|
67
77
|
lazy?: boolean;
|
|
68
78
|
eventSource?: string;
|
|
79
|
+
skipUndo?: boolean;
|
|
69
80
|
};
|
|
70
81
|
["move-task"]: {
|
|
71
82
|
id: TID;
|
|
72
83
|
target?: TID;
|
|
73
|
-
mode
|
|
84
|
+
mode: "before" | "after" | "up" | "down" | "child";
|
|
74
85
|
inProgress?: boolean;
|
|
75
86
|
source?: TID;
|
|
76
87
|
};
|
|
@@ -84,6 +95,8 @@ export type IDataMethodsConfig = CombineTypes<{
|
|
|
84
95
|
["add-link"]: {
|
|
85
96
|
id?: TID;
|
|
86
97
|
link: Partial<ILink>;
|
|
98
|
+
eventSource?: string;
|
|
99
|
+
skipUndo: boolean;
|
|
87
100
|
};
|
|
88
101
|
["update-link"]: {
|
|
89
102
|
id: TID;
|
|
@@ -127,8 +140,19 @@ export type IDataMethodsConfig = CombineTypes<{
|
|
|
127
140
|
event: any;
|
|
128
141
|
eventSource?: string;
|
|
129
142
|
};
|
|
143
|
+
["schedule-tasks"]: {
|
|
144
|
+
id?: TID;
|
|
145
|
+
task?: Partial<ITask>;
|
|
146
|
+
};
|
|
147
|
+
["undo"]: void;
|
|
148
|
+
["redo"]: void;
|
|
149
|
+
["split-task"]: {
|
|
150
|
+
id: TID;
|
|
151
|
+
segmentIndex?: number;
|
|
152
|
+
};
|
|
130
153
|
}, {
|
|
131
154
|
skipProvider?: boolean;
|
|
155
|
+
spipUndo?: boolean;
|
|
132
156
|
[key: string]: any;
|
|
133
157
|
}>;
|
|
134
158
|
export {};
|
|
@@ -9,8 +9,9 @@ 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
|
-
normalizeTask(task: Partial<ITask
|
|
12
|
+
normalizeTask(task: Partial<ITask>): ITask;
|
|
13
13
|
getSummaryId(id: TID): TID | null;
|
|
14
|
+
getSummaryId(id: TID, all: true): TID[] | null;
|
|
14
15
|
sort(conf: TSort[]): void;
|
|
15
16
|
sortBranch(conf: TSort[], parent?: TID): void;
|
|
16
17
|
serialize(): Partial<ITask>[];
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { TID } from "@wx/lib-state";
|
|
2
|
+
import type { IDataHash } from "../types";
|
|
2
3
|
import { IOptionConfig } from "./menuOptions";
|
|
3
4
|
import { IButtonConfig } from "./toolbarButtons";
|
|
4
|
-
|
|
5
|
+
type TTarget = TID | IDataHash | null;
|
|
6
|
+
export declare function handleAction(api: any, action: string, target: TTarget, _: any): void;
|
|
5
7
|
export declare function isHandledAction(options: IOptionConfig[] | IButtonConfig[], id: TID): boolean;
|
|
8
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TID } from "@wx/lib-state";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IParsedTask, IHistory, IData, IDataConfig, IDataHash } from "../types";
|
|
3
|
+
export declare function getMenuOptions(config: IDataConfig): IOptionConfig[];
|
|
3
4
|
export interface IOptionConfig {
|
|
4
5
|
id?: TID;
|
|
5
6
|
separator?: boolean;
|
|
@@ -7,9 +8,10 @@ export interface IOptionConfig {
|
|
|
7
8
|
icon?: string;
|
|
8
9
|
data?: IOptionConfig[];
|
|
9
10
|
type?: string;
|
|
10
|
-
|
|
11
|
+
isDisabled?: ((task: IParsedTask, state: IData, target?: TID | IDataHash) => boolean) | ((history: IHistory) => boolean);
|
|
11
12
|
dataFactory?: (obj: any) => IOptionConfig;
|
|
12
13
|
subtext?: string;
|
|
14
|
+
isHidden?: (task: IParsedTask, state: IData, target?: TID | IDataHash) => boolean;
|
|
13
15
|
}
|
|
14
16
|
export declare function assignChecks<T extends IOptionConfig>(items: T[]): T[];
|
|
15
17
|
export declare const defaultMenuOptions: IOptionConfig[];
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { IData, IDataHash, IParsedTask, IHistory, IDataConfig } from "../types";
|
|
2
|
+
import type { TID } from "@wx/lib-state";
|
|
3
|
+
export declare function getToolbarButtons(config: IDataConfig): IButtonConfig[];
|
|
1
4
|
export interface IButtonConfig {
|
|
2
5
|
id?: string;
|
|
3
6
|
comp: string;
|
|
@@ -5,6 +8,7 @@ export interface IButtonConfig {
|
|
|
5
8
|
icon?: string;
|
|
6
9
|
type?: string;
|
|
7
10
|
menuText?: string;
|
|
8
|
-
|
|
11
|
+
isDisabled?: ((task: IParsedTask, state: IData, target?: TID | IDataHash) => boolean) | ((history: IHistory) => boolean);
|
|
12
|
+
isHidden?: (task: IParsedTask, state: IData, target?: TID | IDataHash) => boolean;
|
|
9
13
|
}
|
|
10
14
|
export declare const defaultToolbarButtons: IButtonConfig[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
export { default as DataStore } from "./DataStore";
|
|
2
2
|
export { grid } from "./dom/scales";
|
|
3
|
-
export { placeLink } from "./links";
|
|
3
|
+
export { placeLink, normalizeLinks } from "./links";
|
|
4
4
|
export { getDiffer, getAdder, getUnitStart, format, registerScaleUnit, } from "./time";
|
|
5
5
|
export { handleAction, isHandledAction } from "./helpers/actionHandlers";
|
|
6
|
-
export { defaultToolbarButtons } from "./helpers/toolbarButtons";
|
|
7
|
-
export { defaultMenuOptions } from "./helpers/menuOptions";
|
|
8
|
-
export { defaultEditorItems } from "./editorItems";
|
|
6
|
+
export { defaultToolbarButtons, getToolbarButtons, } from "./helpers/toolbarButtons";
|
|
7
|
+
export { defaultMenuOptions, getMenuOptions } from "./helpers/menuOptions";
|
|
8
|
+
export { defaultEditorItems, getEditorItems } from "./helpers/editorItems";
|
|
9
9
|
export { defaultColumns } from "./columns";
|
|
10
10
|
export { defaultTaskTypes } from "./taskTypes";
|
|
11
|
-
export {
|
|
12
|
-
export
|
|
11
|
+
export { prepareEditTask, parseTaskDates } from "./normalizeDates";
|
|
12
|
+
export { normalizeZoom } from "./scales";
|
|
13
|
+
export { isSegmentMoveAllowed, extendDragOptions } from "./tasks";
|
|
14
|
+
import { Calendar as _Calendar } from "@wx/lib-schedule";
|
|
15
|
+
export declare const Calendar: typeof _Calendar;
|
|
16
|
+
export type { TID, IApi, ITask, ILink, IConfig, IZoomConfig, IGanttColumn, TMethodsConfig, IGanttTask, IMarker, IScheduleConfig, ICriticalPathConfig, IScaleConfig, } from "./types";
|
package/dist/types/links.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IGanttTask, IGanttLink } from "./types";
|
|
1
|
+
import type { IGanttTask, IGanttLink, ILink } from "./types";
|
|
2
2
|
export declare const updateLink: (link: IGanttLink, startTask: IGanttTask, endTask: IGanttTask, height: number, baselines: boolean) => IGanttLink;
|
|
3
3
|
export declare function placeLink(box: {
|
|
4
4
|
left: number;
|
|
@@ -16,3 +16,10 @@ export declare function placeLink(box: {
|
|
|
16
16
|
top: number;
|
|
17
17
|
p: string;
|
|
18
18
|
};
|
|
19
|
+
export declare function normalizeLinks(links: ILink[]): {
|
|
20
|
+
id: import("@wx/lib-state").TID;
|
|
21
|
+
type: import("./types").TLinkType;
|
|
22
|
+
source: import("@wx/lib-state").TID;
|
|
23
|
+
target: import("@wx/lib-state").TID;
|
|
24
|
+
lag?: number;
|
|
25
|
+
}[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EventTracker } from "./EventTracker.pro";
|
|
2
|
+
import type { TID } from "../types";
|
|
3
|
+
export declare class AutoSchedulerModule extends EventTracker {
|
|
4
|
+
private taskTracker;
|
|
5
|
+
private linkTracker;
|
|
6
|
+
init(): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
schedule(id?: TID, deleteInvalidLinks?: boolean): void;
|
|
9
|
+
protected getDefaultTag(): string;
|
|
10
|
+
private setupScheduleHandler;
|
|
11
|
+
private setupTaskHandlers;
|
|
12
|
+
private setupLinkHandlers;
|
|
13
|
+
private deleteInvalidLinks;
|
|
14
|
+
private getInvalidLinks;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TID } from "../types";
|
|
2
|
+
export declare class ChangeTracker<T extends {
|
|
3
|
+
id?: TID;
|
|
4
|
+
}> {
|
|
5
|
+
private prevState;
|
|
6
|
+
track(id: TID, item: Partial<T>, properties: (keyof T)[]): void;
|
|
7
|
+
hasChanged(id: TID, item: Partial<T>, properties: (keyof T)[]): boolean;
|
|
8
|
+
clear(id?: TID): void;
|
|
9
|
+
getSnapshot(id: TID): Partial<T> | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventTracker } from "./EventTracker.pro";
|
|
2
|
+
export declare class CriticalPathModule extends EventTracker {
|
|
3
|
+
private taskTracker;
|
|
4
|
+
private linkTracker;
|
|
5
|
+
init(): void;
|
|
6
|
+
destroy(): void;
|
|
7
|
+
calculate(): void;
|
|
8
|
+
protected getDefaultTag(): string;
|
|
9
|
+
private setupTaskHandlers;
|
|
10
|
+
private setupLinkHandlers;
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EventBus } from "@wx/lib-state";
|
|
2
|
+
import type { TMethodsConfig, IData } from "../types";
|
|
3
|
+
export declare abstract class EventTracker {
|
|
4
|
+
protected in: EventBus<TMethodsConfig, keyof TMethodsConfig>;
|
|
5
|
+
protected getState: () => Partial<IData>;
|
|
6
|
+
protected setState: (state: Partial<IData>) => void;
|
|
7
|
+
protected getHistory: () => any;
|
|
8
|
+
private _timer;
|
|
9
|
+
private _tags;
|
|
10
|
+
constructor(eventBus: EventBus<TMethodsConfig, keyof TMethodsConfig>, stateGetter: () => Partial<IData>, stateSetter: (state: Partial<IData>) => void, historyGetter: () => any);
|
|
11
|
+
abstract init(): void;
|
|
12
|
+
abstract destroy(): void;
|
|
13
|
+
protected debounce(code: () => void, delay?: number): void;
|
|
14
|
+
protected shouldTrack(ev: any, noTrack?: Record<string, number>): boolean;
|
|
15
|
+
protected registerHandler<K extends keyof TMethodsConfig>(type: "on" | "intercept", event: K, handler: (ev: TMethodsConfig[K]) => void, tag?: string): void;
|
|
16
|
+
protected on<K extends keyof TMethodsConfig>(event: K, handler: (ev: TMethodsConfig[K]) => void, tag?: string): void;
|
|
17
|
+
protected intercept<K extends keyof TMethodsConfig>(event: K, handler: (ev: TMethodsConfig[K]) => void, tag?: string): void;
|
|
18
|
+
protected detachHandlers(): void;
|
|
19
|
+
protected abstract getDefaultTag(): string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IDataHash, TMethodsConfig } from "../types";
|
|
2
|
+
import { EventTracker } from "./EventTracker.pro";
|
|
3
|
+
type TActionType = keyof TMethodsConfig;
|
|
4
|
+
type TBatchAction = "batch";
|
|
5
|
+
type TAllActionTypes = TActionType | TBatchAction;
|
|
6
|
+
type TSubActionData = IDataHash & {
|
|
7
|
+
action?: TActionType;
|
|
8
|
+
};
|
|
9
|
+
interface IActionData<T extends TAllActionTypes> {
|
|
10
|
+
action: T;
|
|
11
|
+
data: T extends TActionType ? TMethodsConfig[T] | TSubActionData : IHistoryEntry[];
|
|
12
|
+
}
|
|
13
|
+
interface IHistoryEntry extends IActionData<TAllActionTypes> {
|
|
14
|
+
source: IActionData<TAllActionTypes>;
|
|
15
|
+
}
|
|
16
|
+
interface IActionHandlers {
|
|
17
|
+
handler: (ev: any) => IHistoryEntry;
|
|
18
|
+
getSnapshot?: (ev: any) => IDataHash;
|
|
19
|
+
progress?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class HistoryManager extends EventTracker {
|
|
22
|
+
private undo;
|
|
23
|
+
private redo;
|
|
24
|
+
private progress;
|
|
25
|
+
private _dataSnapshot;
|
|
26
|
+
private _batch;
|
|
27
|
+
private _isBatching;
|
|
28
|
+
init(): void;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
protected getDefaultTag(): string;
|
|
31
|
+
getHandlers(): {
|
|
32
|
+
[key: string]: IActionHandlers;
|
|
33
|
+
};
|
|
34
|
+
resetHistory(): void;
|
|
35
|
+
private setHandlers;
|
|
36
|
+
private setPrevData;
|
|
37
|
+
private getPrevData;
|
|
38
|
+
private addToHistory;
|
|
39
|
+
startBatch(): void;
|
|
40
|
+
endBatch(): void;
|
|
41
|
+
handleUndo(): void;
|
|
42
|
+
handleRedo(): void;
|
|
43
|
+
private executeHistoryEntry;
|
|
44
|
+
private resetStateHistory;
|
|
45
|
+
private setStateHistory;
|
|
46
|
+
private getOrder;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { ITask,
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function normalizeDates(task: Partial<ITask>,
|
|
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;
|
|
4
5
|
export declare function getFields(isBaseline: boolean): string[];
|
|
6
|
+
export declare function prepareEditTask(task: Partial<ITask>, state: Partial<IData>, key: string): void;
|
package/dist/types/scales.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { IScaleConfig, GanttScaleData, IZoomConfig, TLengthUnit } from "./types";
|
|
1
|
+
import type { IScaleConfig, GanttScaleData, IUnitFormats, IZoomConfig, TLengthUnit } from "./types";
|
|
2
2
|
import type GanttDataTree from "./GanttDataTree";
|
|
3
|
+
import { Day } from "date-fns";
|
|
3
4
|
export declare function getMinUnit(scales: IScaleConfig[]): IScaleConfig;
|
|
4
5
|
export declare const units: string[];
|
|
5
6
|
export declare function calcScales(prevStart: Date, prevEnd: Date, autoScale: boolean, minUnit?: string, tasks?: GanttDataTree): {
|
|
6
7
|
_start: Date;
|
|
7
8
|
_end: Date;
|
|
8
9
|
};
|
|
9
|
-
export declare function resetScales(start: Date, end: Date, lengthUnit: TLengthUnit, width: number, height: number, scales: IScaleConfig[]): GanttScaleData | null;
|
|
10
|
-
export declare function normalizeZoom(zoom: boolean | IZoomConfig, scales: IScaleConfig[], cellWidth: number): {
|
|
11
|
-
|
|
10
|
+
export declare function resetScales(start: Date, end: Date, lengthUnit: TLengthUnit, width: number, height: number, _weekStart: Day, scales: IScaleConfig[]): GanttScaleData | null;
|
|
11
|
+
export declare function normalizeZoom(zoom: boolean | IZoomConfig, unitFormats: IUnitFormats, scales: IScaleConfig[], cellWidth: number): {
|
|
12
|
+
zoom: IZoomConfig;
|
|
12
13
|
scales: IScaleConfig[];
|
|
13
14
|
cellWidth: number;
|
|
14
15
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ITask, IData, IParsedTask, IDataHash, Calendar } from "./types";
|
|
2
|
+
type TSegment = Partial<ITask>;
|
|
3
|
+
export declare function calcSplitDates(task: Partial<ITask>, stateOptions: Partial<IData>): void;
|
|
4
|
+
export declare function dragSplitTask(task: IParsedTask, ev: IDataHash): boolean;
|
|
5
|
+
export declare function updateSplitTask(task: IParsedTask, update: Partial<ITask | TSegment>, stateOptions: Partial<IData>, index?: number, diff?: number): Partial<ITask | Partial<ITask>>;
|
|
6
|
+
export declare function splitTask(task: IParsedTask, index: number | undefined, stateOptions: Partial<IData>): Partial<IParsedTask>;
|
|
7
|
+
export declare function isIndivisibleType(task: Partial<ITask>): boolean;
|
|
8
|
+
export declare function isIndivisible(task: IParsedTask, stateOptions: Partial<IData>, index?: number): boolean;
|
|
9
|
+
export declare function getEndAdder(unit: string, calendar: Calendar): (start: number | Date, step: number) => Date;
|
|
10
|
+
export declare function shiftNextSegments(segments: Partial<ITask>[], lengthUnit: string, index: number, calendar: Calendar, dir?: number): void;
|
|
11
|
+
export {};
|
package/dist/types/tasks.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function dragSummaryKids(task: IParsedTask, dx: number): void;
|
|
1
|
+
import { IGanttTask, GanttScaleData, IParsedTask, GanttDataTree, ITask, IData, IDataHash } from "./types";
|
|
2
|
+
export declare function dragSummaryKids(task: IParsedTask, dx: number, _scales: GanttScaleData, cellWidth: number): void;
|
|
3
3
|
export declare function dragSummary(tasks: GanttDataTree, task: IParsedTask, _scales: GanttScaleData, cellWidth: number): void;
|
|
4
|
-
export declare function setSummaryDates(task:
|
|
5
|
-
export declare function updateTask(t: IGanttTask, i: number,
|
|
4
|
+
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 isSegmentMoveAllowed(task: IGanttTask, moveOptions: IDataHash): boolean;
|
|
7
|
+
export declare function extendDragOptions(task: ITask, options: IDataHash): void;
|
package/dist/types/time.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { format } from "date-fns";
|
|
2
|
-
import type { GanttScaleUnit } from "./types";
|
|
1
|
+
import { format, Day } from "date-fns";
|
|
2
|
+
import type { GanttScaleUnit, Calendar } 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): {
|
|
5
|
+
export declare function getDiffer(unit: string, calendar?: Calendar, _weekStart?: Day): {
|
|
6
6
|
(start: Date, end: Date, lengthUnit?: string, unitSize?: boolean): number;
|
|
7
7
|
};
|
|
8
|
-
export declare function getAdder(unit: string): {
|
|
8
|
+
export declare function getAdder(unit: string, calendar?: Calendar): {
|
|
9
9
|
(start: number | Date, step: number): Date;
|
|
10
10
|
};
|
|
11
|
-
export declare function getUnitStart(unit: string, date: Date): Date;
|
|
12
|
-
export declare function getUnitEnd(unit: string, date: Date): Date;
|
|
13
|
-
export declare function isSameUnit(unit: string, a: Date, b: Date): boolean;
|
|
11
|
+
export declare function getUnitStart(unit: string, date: Date, _weekStart?: Day): Date;
|
|
12
|
+
export declare function getUnitEnd(unit: string, date: Date, _weekStart?: Day): Date;
|
|
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
17
|
export { format };
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IDataMethodsConfig } from "./DataStore";
|
|
2
2
|
import type { DataArray, TID, IEventBus, IPublicWritable, IEventConfig } from "@wx/lib-state";
|
|
3
3
|
import type GanttDataTree from "./GanttDataTree";
|
|
4
|
+
import { Day } from "date-fns";
|
|
4
5
|
import type DataStore from "./DataStore";
|
|
5
6
|
import type { IApi as ITableApi, IColumn } from "@wx/grid-store";
|
|
6
7
|
export type TMethodsConfig = IDataMethodsConfig;
|
|
@@ -18,10 +19,13 @@ export interface ILink {
|
|
|
18
19
|
type: TLinkType;
|
|
19
20
|
source: TID;
|
|
20
21
|
target: TID;
|
|
22
|
+
lag?: number;
|
|
21
23
|
}
|
|
22
24
|
export interface IGanttLink extends ILink {
|
|
23
25
|
id: TID;
|
|
24
26
|
$p: string;
|
|
27
|
+
$pl: number;
|
|
28
|
+
$critical?: boolean;
|
|
25
29
|
}
|
|
26
30
|
export interface ITask {
|
|
27
31
|
start?: Date;
|
|
@@ -39,6 +43,7 @@ export interface ITask {
|
|
|
39
43
|
type?: TTaskType;
|
|
40
44
|
parent?: TID;
|
|
41
45
|
unscheduled?: boolean;
|
|
46
|
+
segments?: Partial<ITask>[];
|
|
42
47
|
[key: string]: any;
|
|
43
48
|
}
|
|
44
49
|
export interface IParsedTask extends ITask {
|
|
@@ -55,6 +60,7 @@ export interface IGanttTask extends IParsedTask {
|
|
|
55
60
|
$x_base?: number;
|
|
56
61
|
$w_base?: number;
|
|
57
62
|
$reorder?: boolean;
|
|
63
|
+
$critical?: boolean;
|
|
58
64
|
}
|
|
59
65
|
export type TDispatch = <A extends keyof TMethodsConfig>(action: A, data: TMethodsConfig[A]) => void;
|
|
60
66
|
export interface IMethodsHash {
|
|
@@ -87,12 +93,58 @@ export interface IMarker {
|
|
|
87
93
|
css?: string;
|
|
88
94
|
left?: number;
|
|
89
95
|
}
|
|
96
|
+
export interface IHistory {
|
|
97
|
+
undo: number;
|
|
98
|
+
redo: number;
|
|
99
|
+
}
|
|
100
|
+
export interface ICriticalPathConfig {
|
|
101
|
+
type: "strict" | "flexible";
|
|
102
|
+
}
|
|
103
|
+
export interface ICriticalTasks {
|
|
104
|
+
[key: TID]: boolean;
|
|
105
|
+
}
|
|
106
|
+
type UnitFormatter = (date: Date) => string;
|
|
107
|
+
export interface IUnitFormats {
|
|
108
|
+
[unit: string]: UnitFormatter | string;
|
|
109
|
+
}
|
|
110
|
+
export interface IScheduleConfig {
|
|
111
|
+
type?: "forward";
|
|
112
|
+
auto?: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface ICalendarConfig {
|
|
115
|
+
name?: string;
|
|
116
|
+
weekHours?: {
|
|
117
|
+
sunday?: number;
|
|
118
|
+
monday?: number;
|
|
119
|
+
tuesday?: number;
|
|
120
|
+
wednesday?: number;
|
|
121
|
+
thursday?: number;
|
|
122
|
+
friday?: number;
|
|
123
|
+
saturday?: number;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export interface Calendar {
|
|
127
|
+
isWorkingDay(date: Date): boolean;
|
|
128
|
+
addRule(rule: (date: Date) => number): void;
|
|
129
|
+
clone(config?: ICalendarConfig): Calendar;
|
|
130
|
+
addWorkingDays(start: Date, days: number, excludeEndDate?: boolean): Date | null;
|
|
131
|
+
addWorkingHours(start: Date, hours: number): Date | null;
|
|
132
|
+
getNextWorkingDay(date: Date): Date | null;
|
|
133
|
+
getPreviousWorkingDay(date: Date): Date | null;
|
|
134
|
+
getWorkingDays(start: Date, end: Date, excludeEndDate?: boolean): number;
|
|
135
|
+
getWorkingHours(start: Date, end?: Date, excludeEndDate?: boolean): number;
|
|
136
|
+
setDayHours(date: Date, hours: number): void;
|
|
137
|
+
setRangeHours(start: Date, end: Date, hours: number): void;
|
|
138
|
+
}
|
|
90
139
|
export interface IConfig {
|
|
91
140
|
tasks?: ITask[];
|
|
92
141
|
links?: any[];
|
|
93
142
|
taskTypes?: ITaskType[];
|
|
94
143
|
selected?: TID[];
|
|
95
|
-
activeTask?: TID
|
|
144
|
+
activeTask?: TID | {
|
|
145
|
+
id: TID;
|
|
146
|
+
segmentIndex: number;
|
|
147
|
+
};
|
|
96
148
|
scales?: IScaleConfig[];
|
|
97
149
|
columns?: IGanttColumn[];
|
|
98
150
|
start?: Date;
|
|
@@ -104,19 +156,26 @@ export interface IConfig {
|
|
|
104
156
|
scaleHeight?: number;
|
|
105
157
|
zoom?: boolean | IZoomConfig;
|
|
106
158
|
autoScale?: boolean;
|
|
107
|
-
|
|
108
|
-
|
|
159
|
+
schedule?: IScheduleConfig;
|
|
160
|
+
undo?: boolean;
|
|
109
161
|
unscheduledTasks?: boolean;
|
|
110
162
|
baselines?: boolean;
|
|
111
163
|
markers?: IMarker[];
|
|
164
|
+
criticalPath?: ICriticalPathConfig;
|
|
165
|
+
projectStart?: Date;
|
|
166
|
+
projectEnd?: Date;
|
|
167
|
+
calendar?: Calendar;
|
|
168
|
+
splitTasks?: boolean;
|
|
112
169
|
}
|
|
113
|
-
export interface IDataConfig extends
|
|
170
|
+
export interface IDataConfig extends IConfig {
|
|
114
171
|
scrollLeft: number;
|
|
115
172
|
scrollTop: number;
|
|
116
173
|
area: IVisibleArea;
|
|
174
|
+
history?: IHistory;
|
|
117
175
|
_cellWidth?: number;
|
|
118
176
|
_sort?: TSort[];
|
|
119
177
|
_scrollTask?: TScrollTask;
|
|
178
|
+
_weekStart?: Day;
|
|
120
179
|
}
|
|
121
180
|
export interface IData extends Omit<IDataConfig, "tasks" | "links"> {
|
|
122
181
|
zoom?: IZoomConfig;
|
|
@@ -129,12 +188,14 @@ export interface IData extends Omit<IDataConfig, "tasks" | "links"> {
|
|
|
129
188
|
_start?: Date;
|
|
130
189
|
_end?: Date;
|
|
131
190
|
_scales?: GanttScaleData;
|
|
132
|
-
_markers?: IMarker[];
|
|
133
191
|
_scaleDate?: Date;
|
|
134
192
|
_zoomOffset?: number;
|
|
193
|
+
_weekStart?: Day;
|
|
194
|
+
_scrollTask?: TScrollTask;
|
|
195
|
+
_markers?: IMarker[];
|
|
135
196
|
}
|
|
136
|
-
export interface
|
|
137
|
-
[key: string]:
|
|
197
|
+
export interface IDataHash<T = any> {
|
|
198
|
+
[key: string]: T;
|
|
138
199
|
}
|
|
139
200
|
export type IScaleConfig = {
|
|
140
201
|
unit: TLengthUnit;
|
|
@@ -190,6 +251,7 @@ export type IGanttColumn = {
|
|
|
190
251
|
header?: IColumn["header"];
|
|
191
252
|
id?: string;
|
|
192
253
|
template?: IColumn["template"];
|
|
254
|
+
_template?: IColumn["template"];
|
|
193
255
|
sort?: boolean;
|
|
194
256
|
cell?: any;
|
|
195
257
|
editor?: IColumn["editor"];
|
|
@@ -202,6 +264,8 @@ export type TCommonShape = {
|
|
|
202
264
|
labelTemplate?: (value: any) => string;
|
|
203
265
|
config?: Record<string, any>;
|
|
204
266
|
[key: string]: any;
|
|
267
|
+
isHidden?: (task: Partial<ITask>) => boolean;
|
|
268
|
+
isDisabled?: (task: Partial<ITask>, state: IData) => boolean;
|
|
205
269
|
};
|
|
206
270
|
export type TTextFieldShape = TCommonShape & {
|
|
207
271
|
comp: "text" | "textarea";
|
|
@@ -236,7 +300,7 @@ export type ILinksShape = TCommonShape & {
|
|
|
236
300
|
export type ITwoStateShape = TCommonShape & {
|
|
237
301
|
comp: "twostate";
|
|
238
302
|
};
|
|
239
|
-
export type
|
|
303
|
+
export type TEditorItem = TTextFieldShape | TCounterShape | TComboFieldShape | TSliderShape | TDateFieldShape | TRadioShape | ILinksShape | ITwoStateShape;
|
|
240
304
|
export type ITaskType = {
|
|
241
305
|
id: TID;
|
|
242
306
|
label: string;
|
package/license.txt
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025 XB Software Sp. z o.o
|
|
3
|
+
Copyright (c) 2025 XB Software Sp. z o.o
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
11
6
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
14
8
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
"name": "@svar-ui/gantt-store",
|
|
3
|
+
"version": "2.4.0",
|
|
4
|
+
"description": "Internal state management used by SVAR Gantt component",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "vite build",
|
|
12
|
+
"watch": "vite build --mode development -w",
|
|
13
|
+
"lint": "yarn eslint ./src",
|
|
14
|
+
"test": "vitest --run",
|
|
15
|
+
"coverage": "vitest --run --coverage"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"licenses",
|
|
20
|
+
"license.txt"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"date-fns": "3.6.0",
|
|
24
|
+
"@svar-ui/lib-state": "1.9.6"
|
|
25
|
+
}
|
|
24
26
|
}
|
package/readme.md
ADDED