gantt-source_management 3.37.5
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/.editorconfig +9 -0
- package/.eslintrc.json +39 -0
- package/.prettierrc.cjs +5 -0
- package/README.md +129 -0
- package/cypress/e2e/add-rows-items.test.ts +26 -0
- package/cypress/e2e/basic.test.ts +173 -0
- package/cypress/e2e/calculated-zoom-mode.test.ts +163 -0
- package/cypress/e2e/calendar-dates.test.ts +285 -0
- package/cypress/e2e/dst.test.ts +691 -0
- package/cypress/e2e/grid-cells.test.ts +72 -0
- package/cypress/e2e/items-vertical.test.ts +305 -0
- package/cypress/e2e/items.test.ts +501 -0
- package/cypress/e2e/list-columns-toggle.test.ts +124 -0
- package/cypress/e2e/list-header-resize.test.ts +30 -0
- package/cypress/e2e/locale.test.ts +102 -0
- package/cypress/e2e/move-items-outside.test.ts +437 -0
- package/cypress/e2e/rows.test.ts +50 -0
- package/cypress/e2e/scroll-bar.test.ts +357 -0
- package/cypress/e2e/time-bookmarks.test.ts +92 -0
- package/cypress/e2e/utc-mode.test.ts +51 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/helpers.ts +12 -0
- package/cypress/plugins/index.js +22 -0
- package/cypress/support/commands.ts +175 -0
- package/cypress/support/e2e.ts +31 -0
- package/cypress.config.js +24 -0
- package/dist/api/api.d.ts +182 -0
- package/dist/api/helpers.d.ts +9 -0
- package/dist/api/id.d.ts +14 -0
- package/dist/api/locale.d.ts +3 -0
- package/dist/api/main.d.ts +47 -0
- package/dist/api/public.d.ts +32 -0
- package/dist/api/slots.d.ts +22 -0
- package/dist/api/time.d.ts +104 -0
- package/dist/assets/2f1f893a.wasm +0 -0
- package/dist/gstc.d.ts +708 -0
- package/dist/gstc.esm.min.d.ts +708 -0
- package/dist/gstc.esm.min.js +574 -0
- package/dist/gstc.umd.min.d.ts +708 -0
- package/dist/gstc.umd.min.js +701 -0
- package/dist/gstc.wasm.esm.min.d.ts +708 -0
- package/dist/gstc.wasm.esm.min.js +574 -0
- package/dist/gstc.wasm.umd.min.d.ts +708 -0
- package/dist/gstc.wasm.umd.min.js +701 -0
- package/dist/plugins/calendar-scroll.d.ts +15 -0
- package/dist/plugins/calendar-scroll.esm.min.d.ts +15 -0
- package/dist/plugins/calendar-scroll.esm.min.js +13 -0
- package/dist/plugins/calendar-scroll.umd.min.d.ts +15 -0
- package/dist/plugins/calendar-scroll.umd.min.js +13 -0
- package/dist/plugins/dependency-lines.d.ts +47 -0
- package/dist/plugins/dependency-lines.esm.min.d.ts +47 -0
- package/dist/plugins/dependency-lines.esm.min.js +38 -0
- package/dist/plugins/dependency-lines.umd.min.d.ts +47 -0
- package/dist/plugins/dependency-lines.umd.min.js +38 -0
- package/dist/plugins/export-image.d.ts +12 -0
- package/dist/plugins/export-image.esm.min.d.ts +12 -0
- package/dist/plugins/export-image.esm.min.js +28 -0
- package/dist/plugins/export-image.umd.min.d.ts +12 -0
- package/dist/plugins/export-image.umd.min.js +34 -0
- package/dist/plugins/export-pdf.d.ts +12 -0
- package/dist/plugins/export-pdf.esm.min.d.ts +12 -0
- package/dist/plugins/export-pdf.esm.min.js +389 -0
- package/dist/plugins/export-pdf.umd.min.d.ts +12 -0
- package/dist/plugins/export-pdf.umd.min.js +511 -0
- package/dist/plugins/grab-scroll.d.ts +14 -0
- package/dist/plugins/grab-scroll.esm.min.d.ts +14 -0
- package/dist/plugins/grab-scroll.umd.min.d.ts +14 -0
- package/dist/plugins/highlight-weekends.d.ts +12 -0
- package/dist/plugins/highlight-weekends.esm.min.d.ts +12 -0
- package/dist/plugins/highlight-weekends.esm.min.js +14 -0
- package/dist/plugins/highlight-weekends.umd.min.d.ts +12 -0
- package/dist/plugins/highlight-weekends.umd.min.js +14 -0
- package/dist/plugins/item-movement.d.ts +97 -0
- package/dist/plugins/item-movement.esm.min.d.ts +97 -0
- package/dist/plugins/item-movement.esm.min.js +25 -0
- package/dist/plugins/item-movement.umd.min.d.ts +97 -0
- package/dist/plugins/item-movement.umd.min.js +25 -0
- package/dist/plugins/item-resizing.d.ts +102 -0
- package/dist/plugins/item-resizing.esm.min.d.ts +102 -0
- package/dist/plugins/item-resizing.esm.min.js +37 -0
- package/dist/plugins/item-resizing.umd.min.d.ts +102 -0
- package/dist/plugins/item-resizing.umd.min.js +37 -0
- package/dist/plugins/item-types.d.ts +13 -0
- package/dist/plugins/item-types.esm.min.d.ts +13 -0
- package/dist/plugins/item-types.esm.min.js +127 -0
- package/dist/plugins/item-types.umd.min.d.ts +13 -0
- package/dist/plugins/item-types.umd.min.js +127 -0
- package/dist/plugins/progress-bar.d.ts +13 -0
- package/dist/plugins/progress-bar.esm.min.d.ts +13 -0
- package/dist/plugins/progress-bar.esm.min.js +27 -0
- package/dist/plugins/progress-bar.umd.min.d.ts +13 -0
- package/dist/plugins/progress-bar.umd.min.js +27 -0
- package/dist/plugins/selection.d.ts +94 -0
- package/dist/plugins/selection.esm.min.d.ts +94 -0
- package/dist/plugins/selection.esm.min.js +26 -0
- package/dist/plugins/selection.umd.min.d.ts +94 -0
- package/dist/plugins/selection.umd.min.js +26 -0
- package/dist/plugins/time-bookmarks.d.ts +38 -0
- package/dist/plugins/time-bookmarks.esm.min.d.ts +38 -0
- package/dist/plugins/time-bookmarks.esm.min.js +50 -0
- package/dist/plugins/time-bookmarks.umd.min.d.ts +38 -0
- package/dist/plugins/time-bookmarks.umd.min.js +50 -0
- package/dist/plugins/timeline-pointer.d.ts +83 -0
- package/dist/plugins/timeline-pointer.esm.min.d.ts +83 -0
- package/dist/plugins/timeline-pointer.esm.min.js +13 -0
- package/dist/plugins/timeline-pointer.umd.min.d.ts +83 -0
- package/dist/plugins/timeline-pointer.umd.min.js +13 -0
- package/dist/style.css +811 -0
- package/dist/vendor.esm.min.js +128 -0
- package/examples/complex-1/faces/face-1.jpg +0 -0
- package/examples/complex-1/faces/face-10.jpg +0 -0
- package/examples/complex-1/faces/face-11.jpg +0 -0
- package/examples/complex-1/faces/face-12.jpg +0 -0
- package/examples/complex-1/faces/face-13.jpg +0 -0
- package/examples/complex-1/faces/face-14.jpg +0 -0
- package/examples/complex-1/faces/face-15.jpg +0 -0
- package/examples/complex-1/faces/face-16.jpg +0 -0
- package/examples/complex-1/faces/face-17.jpg +0 -0
- package/examples/complex-1/faces/face-18.jpg +0 -0
- package/examples/complex-1/faces/face-19.jpg +0 -0
- package/examples/complex-1/faces/face-2.jpg +0 -0
- package/examples/complex-1/faces/face-20.jpg +0 -0
- package/examples/complex-1/faces/face-21.jpg +0 -0
- package/examples/complex-1/faces/face-22.jpg +0 -0
- package/examples/complex-1/faces/face-23.jpg +0 -0
- package/examples/complex-1/faces/face-24.jpg +0 -0
- package/examples/complex-1/faces/face-25.jpg +0 -0
- package/examples/complex-1/faces/face-26.jpg +0 -0
- package/examples/complex-1/faces/face-27.jpg +0 -0
- package/examples/complex-1/faces/face-28.jpg +0 -0
- package/examples/complex-1/faces/face-29.jpg +0 -0
- package/examples/complex-1/faces/face-3.jpg +0 -0
- package/examples/complex-1/faces/face-30.jpg +0 -0
- package/examples/complex-1/faces/face-31.jpg +0 -0
- package/examples/complex-1/faces/face-32.jpg +0 -0
- package/examples/complex-1/faces/face-33.jpg +0 -0
- package/examples/complex-1/faces/face-34.jpg +0 -0
- package/examples/complex-1/faces/face-35.jpg +0 -0
- package/examples/complex-1/faces/face-36.jpg +0 -0
- package/examples/complex-1/faces/face-37.jpg +0 -0
- package/examples/complex-1/faces/face-38.jpg +0 -0
- package/examples/complex-1/faces/face-39.jpg +0 -0
- package/examples/complex-1/faces/face-4.jpg +0 -0
- package/examples/complex-1/faces/face-40.jpg +0 -0
- package/examples/complex-1/faces/face-41.jpg +0 -0
- package/examples/complex-1/faces/face-42.jpg +0 -0
- package/examples/complex-1/faces/face-43.jpg +0 -0
- package/examples/complex-1/faces/face-44.jpg +0 -0
- package/examples/complex-1/faces/face-45.jpg +0 -0
- package/examples/complex-1/faces/face-46.jpg +0 -0
- package/examples/complex-1/faces/face-47.jpg +0 -0
- package/examples/complex-1/faces/face-48.jpg +0 -0
- package/examples/complex-1/faces/face-49.jpg +0 -0
- package/examples/complex-1/faces/face-5.jpg +0 -0
- package/examples/complex-1/faces/face-50.jpg +0 -0
- package/examples/complex-1/faces/face-6.jpg +0 -0
- package/examples/complex-1/faces/face-7.jpg +0 -0
- package/examples/complex-1/faces/face-8.jpg +0 -0
- package/examples/complex-1/faces/face-9.jpg +0 -0
- package/examples/complex-1/index.html +61 -0
- package/examples/complex-1/index.js +923 -0
- package/examples/index.html +22 -0
- package/examples/reset.css +455 -0
- package/examples/server.js +18 -0
- package/package.json +150 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GrabScroll plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido } from '../gstc';
|
|
7
|
+
export declare const pluginName = "GrabScroll";
|
|
8
|
+
export declare const pluginPath: string;
|
|
9
|
+
export declare const templatePath = "config.templates.chart-timeline-items-row-item";
|
|
10
|
+
export interface Options {
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
14
|
+
//# sourceMappingURL=grab-scroll.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GrabScroll plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido } from '../gstc';
|
|
7
|
+
export declare const pluginName = "GrabScroll";
|
|
8
|
+
export declare const pluginPath: string;
|
|
9
|
+
export declare const templatePath = "config.templates.chart-timeline-items-row-item";
|
|
10
|
+
export interface Options {
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
14
|
+
//# sourceMappingURL=grab-scroll.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GrabScroll plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido } from '../gstc';
|
|
7
|
+
export declare const pluginName = "GrabScroll";
|
|
8
|
+
export declare const pluginPath: string;
|
|
9
|
+
export declare const templatePath = "config.templates.chart-timeline-items-row-item";
|
|
10
|
+
export interface Options {
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
14
|
+
//# sourceMappingURL=grab-scroll.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HighlightWeekends plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido } from '../gstc';
|
|
7
|
+
export interface Options {
|
|
8
|
+
weekdays?: number[];
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
12
|
+
//# sourceMappingURL=highlight-weekends.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HighlightWeekends plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido } from '../gstc';
|
|
7
|
+
export interface Options {
|
|
8
|
+
weekdays?: number[];
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
12
|
+
//# sourceMappingURL=highlight-weekends.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class t{constructor(){this.isAction=!0}}
|
|
2
|
+
/**
|
|
3
|
+
* HighlightWeekends plugin
|
|
4
|
+
*
|
|
5
|
+
* @copyright NEURONET - Rafal Pospiech
|
|
6
|
+
* @author Rafal Pospiech <neuronet.io@gmail.com>
|
|
7
|
+
* @module gantt-schedule-timeline-calendar
|
|
8
|
+
* @link https://github.com/neuronetio/gantt-schedule-timeline-calendar
|
|
9
|
+
* @link https://gantt-schedule-timeline-calendar.neuronet.io
|
|
10
|
+
* @version 3.37.5
|
|
11
|
+
* @released 2024-07-19
|
|
12
|
+
* @license SEE LICENSE IN LICENSE FILE
|
|
13
|
+
*/
|
|
14
|
+
function e(e={}){const i=e.weekdays||[6,0];let s,a,n=!0;class c extends t{constructor(t,e){super(),this.highlight(t,e.time.leftGlobalDate)}update(t,e){this.highlight(t,e.time.leftGlobalDate)}highlight(t,e){const a=t.classList.contains(s);if(!n)return void(a&&t.classList.remove(s));const c=i.includes(e.day());!a&&c?t.classList.add(s):a&&!c&&t.classList.remove(s)}}return function(t){const i=t.api.mergeDeep,l=[];a=t.api,s=e.className||a.getClass("chart-timeline-grid-row-cell")+"--weekend";const o=t.state.get("config.plugin.HighlightWeekends");return o&&(e=i({},e,o)),l.push(t.state.subscribe("$data.chart.time.format.period",(t=>n="day"===t))),t.state.update("config.actions.chart-timeline-grid-row-cell",(t=>(t.push(c),t))),a.pluginInitialized("HighlightWeekends"),function(){l.forEach((t=>t())),t.state.update("config.actions.chart-timeline-grid-row-cell",(t=>t.filter((t=>t!==c)))),a.pluginDestroyed("HighlightWeekends")}}}t.prototype.isAction=!0;export{e as Plugin};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HighlightWeekends plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido } from '../gstc';
|
|
7
|
+
export interface Options {
|
|
8
|
+
weekdays?: number[];
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
12
|
+
//# sourceMappingURL=highlight-weekends.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).HighlightWeekends={})}(this,(function(e){"use strict";class t{constructor(){this.isAction=!0}}t.prototype.isAction=!0,e.Plugin=
|
|
2
|
+
/**
|
|
3
|
+
* HighlightWeekends plugin
|
|
4
|
+
*
|
|
5
|
+
* @copyright NEURONET - Rafal Pospiech
|
|
6
|
+
* @author Rafal Pospiech <neuronet.io@gmail.com>
|
|
7
|
+
* @module gantt-schedule-timeline-calendar
|
|
8
|
+
* @link https://github.com/neuronetio/gantt-schedule-timeline-calendar
|
|
9
|
+
* @link https://gantt-schedule-timeline-calendar.neuronet.io
|
|
10
|
+
* @version 3.37.5
|
|
11
|
+
* @released 2024-07-19
|
|
12
|
+
* @license SEE LICENSE IN LICENSE FILE
|
|
13
|
+
*/
|
|
14
|
+
function(e={}){const i=e.weekdays||[6,0];let s,n,o=!0;class l extends t{constructor(e,t){super(),this.highlight(e,t.time.leftGlobalDate)}update(e,t){this.highlight(e,t.time.leftGlobalDate)}highlight(e,t){const n=e.classList.contains(s);if(!o)return void(n&&e.classList.remove(s));const l=i.includes(t.day());!n&&l?e.classList.add(s):n&&!l&&e.classList.remove(s)}}return function(t){const i=t.api.mergeDeep,c=[];n=t.api,s=e.className||n.getClass("chart-timeline-grid-row-cell")+"--weekend";const a=t.state.get("config.plugin.HighlightWeekends");return a&&(e=i({},e,a)),c.push(t.state.subscribe("$data.chart.time.format.period",(e=>o="day"===e))),t.state.update("config.actions.chart-timeline-grid-row-cell",(e=>(e.push(l),e))),n.pluginInitialized("HighlightWeekends"),function(){c.forEach((e=>e())),t.state.update("config.actions.chart-timeline-grid-row-cell",(e=>e.filter((e=>e!==l)))),n.pluginDestroyed("HighlightWeekends")}}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ItemMovement plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido, Item, DataChartTime, ItemData, DataItems, DataScrollVertical, DataScrollHorizontal } from '../gstc';
|
|
7
|
+
import type DeepState from 'deep-state-observer';
|
|
8
|
+
import type { Dayjs } from 'dayjs';
|
|
9
|
+
export interface SnapArg {
|
|
10
|
+
time: DataChartTime;
|
|
11
|
+
item: Item | null;
|
|
12
|
+
movement: Movement;
|
|
13
|
+
vido: Vido;
|
|
14
|
+
}
|
|
15
|
+
export interface SnapStartArg extends SnapArg {
|
|
16
|
+
startTime: Dayjs;
|
|
17
|
+
}
|
|
18
|
+
export interface SnapEndArg extends SnapArg {
|
|
19
|
+
endTime: Dayjs;
|
|
20
|
+
}
|
|
21
|
+
export interface Movement {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
time: number;
|
|
25
|
+
}
|
|
26
|
+
export interface SnapToTime {
|
|
27
|
+
start?: (snapStartArgs: SnapStartArg) => Dayjs;
|
|
28
|
+
end?: (snapEndArgs: SnapEndArg) => Dayjs;
|
|
29
|
+
}
|
|
30
|
+
export interface BeforeAfterInitialItems {
|
|
31
|
+
initial: Item[];
|
|
32
|
+
before: Item[];
|
|
33
|
+
after: Item[];
|
|
34
|
+
targetData: Item | null;
|
|
35
|
+
}
|
|
36
|
+
export interface OnArg {
|
|
37
|
+
items: BeforeAfterInitialItems;
|
|
38
|
+
addedDependantIds: string[];
|
|
39
|
+
selectedIds: string[];
|
|
40
|
+
vido: Vido;
|
|
41
|
+
state: DeepState;
|
|
42
|
+
time: DataChartTime;
|
|
43
|
+
}
|
|
44
|
+
export interface Events {
|
|
45
|
+
onStart?: (onArg: OnArg) => Item[];
|
|
46
|
+
onMove?: (onArg: OnArg) => Item[];
|
|
47
|
+
onEnd?: (onArg: OnArg) => Item[];
|
|
48
|
+
}
|
|
49
|
+
export interface Threshold {
|
|
50
|
+
horizontal?: number;
|
|
51
|
+
vertical?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface ScrollSpeed {
|
|
54
|
+
horizontal?: number;
|
|
55
|
+
vertical?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface AutoScroll {
|
|
58
|
+
speed?: ScrollSpeed;
|
|
59
|
+
edgeThreshold?: Threshold;
|
|
60
|
+
}
|
|
61
|
+
export interface Options {
|
|
62
|
+
enabled?: boolean;
|
|
63
|
+
dependant?: boolean;
|
|
64
|
+
moveDependantVertically?: boolean;
|
|
65
|
+
debug?: boolean;
|
|
66
|
+
bodyClass?: string;
|
|
67
|
+
itemClass?: string;
|
|
68
|
+
events?: Events;
|
|
69
|
+
snapToTime?: SnapToTime;
|
|
70
|
+
threshold?: Threshold;
|
|
71
|
+
autoScroll?: AutoScroll;
|
|
72
|
+
ignoreMissingDates?: boolean;
|
|
73
|
+
allowItemsToGoOutsideTheArea?: boolean;
|
|
74
|
+
shouldMuteNotNeededMethods?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export type State = 'start' | 'move' | 'end' | '';
|
|
77
|
+
export interface ThresholdReached {
|
|
78
|
+
horizontal: boolean;
|
|
79
|
+
vertical: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface PluginData extends Options {
|
|
82
|
+
isMoving: boolean;
|
|
83
|
+
initialItems: Item[];
|
|
84
|
+
initialItemsData: DataItems;
|
|
85
|
+
addedDependantIds: string[];
|
|
86
|
+
selectedIds: string[];
|
|
87
|
+
clickedItem: Item;
|
|
88
|
+
clickedItemData: ItemData;
|
|
89
|
+
initialVerticalScroll: DataScrollVertical;
|
|
90
|
+
initialHorizontalScroll: DataScrollHorizontal;
|
|
91
|
+
initialPointerTime: Dayjs | null;
|
|
92
|
+
thresholdReached: ThresholdReached;
|
|
93
|
+
state: State;
|
|
94
|
+
movement: Movement;
|
|
95
|
+
}
|
|
96
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
97
|
+
//# sourceMappingURL=item-movement.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ItemMovement plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido, Item, DataChartTime, ItemData, DataItems, DataScrollVertical, DataScrollHorizontal } from '../gstc';
|
|
7
|
+
import type DeepState from 'deep-state-observer';
|
|
8
|
+
import type { Dayjs } from 'dayjs';
|
|
9
|
+
export interface SnapArg {
|
|
10
|
+
time: DataChartTime;
|
|
11
|
+
item: Item | null;
|
|
12
|
+
movement: Movement;
|
|
13
|
+
vido: Vido;
|
|
14
|
+
}
|
|
15
|
+
export interface SnapStartArg extends SnapArg {
|
|
16
|
+
startTime: Dayjs;
|
|
17
|
+
}
|
|
18
|
+
export interface SnapEndArg extends SnapArg {
|
|
19
|
+
endTime: Dayjs;
|
|
20
|
+
}
|
|
21
|
+
export interface Movement {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
time: number;
|
|
25
|
+
}
|
|
26
|
+
export interface SnapToTime {
|
|
27
|
+
start?: (snapStartArgs: SnapStartArg) => Dayjs;
|
|
28
|
+
end?: (snapEndArgs: SnapEndArg) => Dayjs;
|
|
29
|
+
}
|
|
30
|
+
export interface BeforeAfterInitialItems {
|
|
31
|
+
initial: Item[];
|
|
32
|
+
before: Item[];
|
|
33
|
+
after: Item[];
|
|
34
|
+
targetData: Item | null;
|
|
35
|
+
}
|
|
36
|
+
export interface OnArg {
|
|
37
|
+
items: BeforeAfterInitialItems;
|
|
38
|
+
addedDependantIds: string[];
|
|
39
|
+
selectedIds: string[];
|
|
40
|
+
vido: Vido;
|
|
41
|
+
state: DeepState;
|
|
42
|
+
time: DataChartTime;
|
|
43
|
+
}
|
|
44
|
+
export interface Events {
|
|
45
|
+
onStart?: (onArg: OnArg) => Item[];
|
|
46
|
+
onMove?: (onArg: OnArg) => Item[];
|
|
47
|
+
onEnd?: (onArg: OnArg) => Item[];
|
|
48
|
+
}
|
|
49
|
+
export interface Threshold {
|
|
50
|
+
horizontal?: number;
|
|
51
|
+
vertical?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface ScrollSpeed {
|
|
54
|
+
horizontal?: number;
|
|
55
|
+
vertical?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface AutoScroll {
|
|
58
|
+
speed?: ScrollSpeed;
|
|
59
|
+
edgeThreshold?: Threshold;
|
|
60
|
+
}
|
|
61
|
+
export interface Options {
|
|
62
|
+
enabled?: boolean;
|
|
63
|
+
dependant?: boolean;
|
|
64
|
+
moveDependantVertically?: boolean;
|
|
65
|
+
debug?: boolean;
|
|
66
|
+
bodyClass?: string;
|
|
67
|
+
itemClass?: string;
|
|
68
|
+
events?: Events;
|
|
69
|
+
snapToTime?: SnapToTime;
|
|
70
|
+
threshold?: Threshold;
|
|
71
|
+
autoScroll?: AutoScroll;
|
|
72
|
+
ignoreMissingDates?: boolean;
|
|
73
|
+
allowItemsToGoOutsideTheArea?: boolean;
|
|
74
|
+
shouldMuteNotNeededMethods?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export type State = 'start' | 'move' | 'end' | '';
|
|
77
|
+
export interface ThresholdReached {
|
|
78
|
+
horizontal: boolean;
|
|
79
|
+
vertical: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface PluginData extends Options {
|
|
82
|
+
isMoving: boolean;
|
|
83
|
+
initialItems: Item[];
|
|
84
|
+
initialItemsData: DataItems;
|
|
85
|
+
addedDependantIds: string[];
|
|
86
|
+
selectedIds: string[];
|
|
87
|
+
clickedItem: Item;
|
|
88
|
+
clickedItemData: ItemData;
|
|
89
|
+
initialVerticalScroll: DataScrollVertical;
|
|
90
|
+
initialHorizontalScroll: DataScrollHorizontal;
|
|
91
|
+
initialPointerTime: Dayjs | null;
|
|
92
|
+
thresholdReached: ThresholdReached;
|
|
93
|
+
state: State;
|
|
94
|
+
movement: Movement;
|
|
95
|
+
}
|
|
96
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
97
|
+
//# sourceMappingURL=item-movement.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TimelinePointer plugin
|
|
3
|
+
*
|
|
4
|
+
* @copyright NEURONET - Rafal Pospiech
|
|
5
|
+
* @author Rafal Pospiech <neuronet.io@gmail.com>
|
|
6
|
+
* @module gantt-schedule-timeline-calendar
|
|
7
|
+
* @link https://github.com/neuronetio/gantt-schedule-timeline-calendar
|
|
8
|
+
* @link https://gantt-schedule-timeline-calendar.neuronet.io
|
|
9
|
+
* @version 3.37.5
|
|
10
|
+
* @released 2024-07-19
|
|
11
|
+
* @license SEE LICENSE IN LICENSE FILE
|
|
12
|
+
*/
|
|
13
|
+
const t="chart-timeline-items-row-item";
|
|
14
|
+
/**
|
|
15
|
+
* ItemMovement plugin
|
|
16
|
+
*
|
|
17
|
+
* @copyright NEURONET - Rafal Pospiech
|
|
18
|
+
* @author Rafal Pospiech <neuronet.io@gmail.com>
|
|
19
|
+
* @module gantt-schedule-timeline-calendar
|
|
20
|
+
* @link https://github.com/neuronetio/gantt-schedule-timeline-calendar
|
|
21
|
+
* @link https://gantt-schedule-timeline-calendar.neuronet.io
|
|
22
|
+
* @version 3.37.5
|
|
23
|
+
* @released 2024-07-19
|
|
24
|
+
* @license SEE LICENSE IN LICENSE FILE
|
|
25
|
+
*/const e="config.plugin.ItemMovement";class i{constructor(t,e){this.onDestroy=[],this.scrollWaiting=0,this.vido=t,this.state=t.state,this.api=t.api,this.data=function(t={}){const e={onStart:({items:t})=>t.after,onMove:({items:t})=>t.after,onEnd:({items:t})=>t.after},i={start:({startTime:t,time:e,vido:i})=>i.api.time.findOrCreateMainDateAtTime(t.valueOf(),e).leftGlobalDate,end:({endTime:t})=>t},a={speed:{horizontal:1,vertical:1},edgeThreshold:{horizontal:60,vertical:0}},s=Object.assign({enabled:!0,dependant:!0,moveDependantVertically:!1,addedDependantIds:[],selectedIds:[],debug:!1,state:"",bodyClass:"gstc-items-moving",itemClass:"",movement:{x:0,y:0,time:0},threshold:{horizontal:10,vertical:10},initialItems:[],initialItemsData:{},clickedItem:null,clickedItemData:null,initialVerticalScroll:null,initialHorizontalScroll:null,initialPointerTime:null,isMoving:!1,events:Object.assign({},e),snapToTime:Object.assign({},i),autoScroll:Object.assign({},a),ignoreMissingDates:!0,allowItemsToGoOutsideTheArea:!0,thresholdReached:{horizontal:!1,vertical:!1},shouldMuteNotNeededMethods:!0},t);return t.snapToTime&&(s.snapToTime=Object.assign(Object.assign({},i),t.snapToTime)),t.events&&(s.events=Object.assign(Object.assign({},e),t.events)),t.autoScroll&&(s.autoScroll=Object.assign(Object.assign({},a),t.autoScroll),t.autoScroll.edgeThreshold&&(s.autoScroll.edgeThreshold=Object.assign(Object.assign({},a.edgeThreshold),t.autoScroll.edgeThreshold)),t.autoScroll.speed&&(s.autoScroll.speed=Object.assign(Object.assign({},a.speed),t.autoScroll.speed))),s}(e),this.data.itemClass||(this.data.itemClass=this.api.getClass("timeline-chart-items-row-item")+"--moving"),this.destroy=this.destroy.bind(this),this.itemUpdateAction=this.itemUpdateAction.bind(this),this.onDestroy.push(this.state.subscribe("$data.elements.chart-timeline",(t=>this.timelineElement=t))),this.updateData(),this.onDestroy.push(this.state.subscribe("config.plugin.ItemMovement",(t=>{t.enabled&&t.isMoving?document.body.classList.add(t.bodyClass):document.body.classList.remove(t.bodyClass),this.data=t}))),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onTimelinePointerDown=this.onTimelinePointerDown.bind(this),this.onTimelinePointerMove=this.onTimelinePointerMove.bind(this),this.onTimelinePointerUp=this.onTimelinePointerUp.bind(this),this.api.plugins.TimelinePointer.addPointerListener("move",this.onTimelinePointerMove),this.api.plugins.TimelinePointer.addPointerListener("down",this.onTimelinePointerDown),this.api.plugins.TimelinePointer.addPointerListener("up",this.onTimelinePointerUp)}destroy(){this.onDestroy.forEach((t=>t())),this.api.plugins.TimelinePointer.removePointerListener("move",this.onTimelinePointerMove),this.api.plugins.TimelinePointer.removePointerListener("down",this.onTimelinePointerDown),this.api.plugins.TimelinePointer.removePointerListener("up",this.onTimelinePointerUp),this.api.pluginDestroyed("ItemMovement")}updateData(){this.state.update(e,this.data)}getSelectedItems(e=!1){return this.state.get(`config.plugin.Selection.selected.${t}`).map((t=>{let i=this.api.getItem(t);if(e)for(const e of this.data.initialItems)if(e.id===t){i=e;break}return this.api.mergeDeep({},i)}))}getSelectedItemsData(t){const e={};for(const i of t)e[i.id]=this.api.mergeDeep({},this.api.getItemData(i.id));return e}getEventArgument(t,e){const i=this.api.getAllItems(),a=[];for(const e of t)a.push(this.api.mergeDeep({},i[e.id]));return{items:{initial:this.data.initialItems,before:a,after:t,targetData:e.targetData},addedDependantIds:this.data.addedDependantIds,selectedIds:this.data.selectedIds,vido:this.vido,state:this.state,time:this.state.get("$data.chart.time")}}getDependantItems(t,e){const i=[],a=this.api.getItemsData();for(const e of t)for(const t of a[e.id].dependant)i.includes(t)||i.push(t);const s=this.state.get("config.chart.items");let o;return o=e?i.map((t=>this.data.initialItems.find((e=>e.id===t)))):i.map((t=>s[t])),o.map((t=>this.api.mergeDeep({},t)))}dispatchEvent(t,e,i,a=null){"onStart"===t&&this.data.shouldMuteNotNeededMethods&&(this.api.muteMethod("fixOverlapped"),this.api.muteMethod("fullReload"),this.api.muteMethod("measureRows"),this.api.muteMethod("getLastPageRowsHeight"),this.api.muteMethod("calculateVerticalScrollArea"),this.api.muteMethod("heightChange"),this.api.muteMethod("calculateRowsHeight"),this.api.muteMethod("calculateVisibleRowsHeights"),this.api.muteMethod("updateVisibleItemsListener"),this.api.muteMethod("prepareExpanded"),0===this.data.autoScroll.speed.horizontal&&0===this.data.autoScroll.speed.vertical&&(this.api.muteMethod("generateVisibleRowsAndItems"),this.api.muteMethod("prepareExpanded"))),"onEnd"===t&&this.data.shouldMuteNotNeededMethods&&(this.api.unmuteMethod("fixOverlapped"),this.api.unmuteMethod("heightChange"),this.api.unmuteMethod("calculateVerticalScrollArea"),this.api.unmuteMethod("getLastPageRowsHeight"),this.api.unmuteMethod("fullReload"),this.api.unmuteMethod("measureRows"),this.api.unmuteMethod("calculateRowsHeight"),this.api.unmuteMethod("calculateVisibleRowsHeights"),this.api.unmuteMethod("updateVisibleItemsListener"),this.api.unmuteMethod("prepareExpanded"),0===this.data.autoScroll.speed.horizontal&&0===this.data.autoScroll.speed.vertical&&(this.api.unmuteMethod("generateVisibleRowsAndItems"),this.api.unmuteMethod("prepareExpanded"))),e=e.map((t=>this.api.mergeDeep({},t)));const s=this.data.events[t](this.getEventArgument(e,i));let o=this.state.multi(!0);const l=this.state.get("config.chart.items");for(let t of s){t=this.api.mergeDeep({},t);const e=l[t.id];let i=!1;t.time.start===e.time.start&&t.time.end===e.time.end||(i=!0,o=o.update(`config.chart.items.${t.id}.time`,Object.assign({},t.time)));let s=!1;e.rowId!==t.rowId&&(s=!0,o=o.update(`config.chart.items.${t.id}.rowId`,t.rowId),this.api.updateItemRowMapForItem(t.id,t.rowId)),a&&(i||s)&&(o=o.update(`$data.chart.items.${t.id}`,this.api.mergeDeep({},a[t.id])))}o.done(),"onEnd"===t&&this.api.main.partialReload(!1)}getItemsForDiff(){const t=this.getSelectedItems()[0],e=this.data.initialItems.find((e=>e.id===t.id));return{modified:t,original:e}}onTimelinePointerDown(e){this.data.enabled&&(e.targetType!==t||this.api.plugins.TimelinePointer.isLocked("down")||this.onPointerDown(e))}onTimelinePointerMove(e){this.data.enabled&&e.targetType===t&&"item-movement"===this.api.plugins.TimelinePointer.isLocked("move")&&this.onPointerMove(e)}onTimelinePointerUp(e){this.data.enabled&&e.targetType===t&&"item-movement"===this.api.plugins.TimelinePointer.isLocked("up")&&this.onPointerUp(e)}onPointerDown(t){if(document.body.classList.add(this.data.bodyClass),this.api.plugins.TimelinePointer.lock("down","item-movement"),this.api.plugins.TimelinePointer.lock("move","item-movement"),this.api.plugins.TimelinePointer.lock("up","item-movement"),this.data.isMoving=!0,this.data.dependant){const t=this.getSelectedItems();this.data.selectedIds=t.map((t=>t.id));const e=this.getDependantItems(t,!1).filter((t=>!this.data.selectedIds.includes(t.id)));this.data.addedDependantIds=e.map((t=>t.id)),this.data.initialItems=[...t,...e]}else this.data.addedDependantIds=[],this.data.initialItems=this.getSelectedItems(),this.data.selectedIds=this.data.initialItems.map((t=>t.id));this.data.initialItemsData=this.getSelectedItemsData(this.data.initialItems),this.data.clickedItem=this.api.mergeDeep({},t.targetData),this.data.clickedItemData=this.api.mergeDeep({},this.api.getItemData(this.data.clickedItem.id)),this.data.initialVerticalScroll=this.api.mergeDeep({},this.state.get("$data.scroll.vertical")),this.data.initialHorizontalScroll=this.api.mergeDeep({},this.state.get("$data.scroll.horizontal")),this.data.initialPointerTime=this.api.time.date(this.api.time.getTimeFromOffsetPx(t.initialPosition.x,!0)),this.scrollWaiting=0,this.data.thresholdReached.horizontal=!1,this.data.thresholdReached.vertical=!1,""!==this.data.state&&"end"!==this.data.state||(this.data.state="move"),this.dispatchEvent("onStart",this.data.initialItems,t),this.updateData()}scrollLeft(){if(!this.data.autoScroll.speed.horizontal)return;if(this.state.get("config.chart.time.calculatedZoomMode"))return;this.scrollWaiting++;const t=this.state.get("config.scroll.horizontal");if(this.data.autoScroll.speed.horizontal<0){if(this.scrollWaiting-1<Math.abs(this.data.autoScroll.speed.horizontal))return;const e=this.api.getScrollLeft();t.byPixels?this.api.setScrollLeft(e.absolutePosPx-120*t.multiplier):this.api.setScrollLeft(e.dataIndex-1)}else if(this.data.autoScroll.speed.horizontal>0){const e=this.api.getScrollLeft();t.byPixels?this.api.setScrollLeft(e.absolutePosPx-120*this.data.autoScroll.speed.horizontal*t.multiplier):this.api.setScrollLeft(e.dataIndex-this.data.autoScroll.speed.horizontal)}this.scrollWaiting=0}scrollRight(){if(!this.data.autoScroll.speed.horizontal)return;if(this.state.get("config.chart.time.calculatedZoomMode"))return;this.scrollWaiting++;const t=this.state.get("config.scroll.horizontal");if(this.data.autoScroll.speed.horizontal<0){if(this.scrollWaiting-1<Math.abs(this.data.autoScroll.speed.horizontal))return;const e=this.api.getScrollLeft();t.byPixels?this.api.setScrollLeft(e.absolutePosPx+120*t.multiplier):this.api.setScrollLeft(e.dataIndex+1)}else if(this.data.autoScroll.speed.horizontal>0){const e=this.api.getScrollLeft();t.byPixels?this.api.setScrollLeft(e.absolutePosPx+120*this.data.autoScroll.speed.horizontal*t.multiplier):this.api.setScrollLeft(e.dataIndex+this.data.autoScroll.speed.horizontal)}this.scrollWaiting=0}scrollTop(){if(this.data.autoScroll.speed.vertical){if(this.scrollWaiting++,this.data.autoScroll.speed.vertical<0){if(this.scrollWaiting-1<Math.abs(this.data.autoScroll.speed.vertical))return;const t=this.api.getScrollTop(),e=this.state.get("config.scroll.vertical");e.byPixels?this.api.setScrollTop(t.absolutePosPx-120*e.multiplier):this.api.setScrollTop(t.dataIndex-1)}else if(this.data.autoScroll.speed.vertical>0){const t=this.api.getScrollTop(),e=this.state.get("config.scroll.vertical");e.byPixels?this.api.setScrollTop(t.absolutePosPx-120*this.data.autoScroll.speed.vertical*e.multiplier):this.api.setScrollTop(t.dataIndex-this.data.autoScroll.speed.vertical)}this.scrollWaiting=0}}scrollBottom(){if(this.data.autoScroll.speed.vertical){if(this.scrollWaiting++,this.data.autoScroll.speed.vertical<0){if(this.scrollWaiting-1<Math.abs(this.data.autoScroll.speed.vertical))return;const t=this.api.getScrollTop(),e=this.state.get("config.scroll.vertical");e.byPixels?this.api.setScrollTop(t.absolutePosPx-120*e.multiplier):this.api.setScrollTop(t.dataIndex+1)}else if(this.data.autoScroll.speed.vertical>0){const t=this.api.getScrollTop(),e=this.state.get("config.scroll.vertical");e.byPixels?this.api.setScrollTop(t.absolutePosPx+120*this.data.autoScroll.speed.vertical*e.multiplier):this.api.setScrollTop(t.dataIndex+this.data.autoScroll.speed.vertical)}this.scrollWaiting=0}}autoScroll(t){if(!this.timelineElement)return;const e=t.currentPosition.x,i=t.currentPosition.y,a=this.state.get("$data.chart.dimensions");e<this.data.autoScroll.edgeThreshold.horizontal?this.scrollLeft():e>a.widthWithoutScrollBar-this.data.autoScroll.edgeThreshold.horizontal?this.scrollRight():i<this.data.autoScroll.edgeThreshold.vertical?this.scrollTop():i>a.innerHeight-this.data.autoScroll.edgeThreshold.vertical&&this.scrollBottom()}moveItemVertically(t,e,i){if(this.data.addedDependantIds.includes(t.id)&&!this.data.moveDependantVertically)return;const a=this.state.get("$data.scroll.vertical").absolutePosPx-this.data.initialVerticalScroll.absolutePosPx,s=i.currentPosition.y-i.initialPosition.y,o=this.data.threshold.vertical;if(Math.abs(s)>=o&&(this.data.thresholdReached.vertical=!0),!this.data.thresholdReached.vertical)return;const l=this.data.clickedItemData.position.viewTop-i.initialPosition.y-this.data.clickedItemData.position.rowTop;let n=e.position.top+s+a-l;n<0&&(n=0);const d=this.api.getRowInfoFromTop(n);d.row.id!==t.rowId&&(t.rowId=d.row.id,e.position.viewTop=this.api.getRowViewTop(t.rowId),e.position.rowTop=0)}getItemsToMove(t=!1){let e,i=[];if(this.data.dependant){const a=this.getSelectedItems(t),s=a.map((t=>t.id)),o=this.getDependantItems(a,t).filter((t=>!s.includes(t.id)));i=o.map((t=>t.id)),e=[...a,...o]}else e=this.getSelectedItems(t);return{itemsToMove:e,dependantIds:i}}calculateFinalLeftGlobal({diffPx:t,initialItemData:e,initialItem:i,isDependant:a,movement:s,itemDataToSave:o,time:l}){const n=e.position.left+t;let d=this.api.time.getTimeFromOffsetPx(n,!0,l);if(a){const t=this.data.initialItems.find((t=>{var e;return null===(e=t.dependant)||void 0===e?void 0:e.includes(i.id)})),a=this.data.initialItemsData[t.id],s=o[a.id],n=this.api.time.getDatesDiffMs(a.time.endDate,s.time.endDate,l,!0);let h=-this.api.time.getDSTDiffForLevel(l.level,a.time.endDate.valueOf(),e.time.startDate.valueOf(),l);d=this.api.time.addTimeFromDates(e.time.startDate.valueOf(),n+h,l),h=this.api.time.getDSTDiffForLevel(l.level,s.time.endDate.valueOf(),d,l),d+=h}const h=this.api.time.date(d);let r=h;return a||(r=this.data.snapToTime.start({startTime:h,item:i,time:l,movement:s,vido:this.vido})),r}calculateFinalRightGlobal({finalLeftGlobalDate:t,initialItemData:e,initialItem:i,isDependant:a,movement:s,time:o}){const l=this.api.time.getViewOffsetPxFromDates(t,!1,o);let n=-this.api.time.getDSTDiffForLevel(o.level,i.time.start,i.time.end,o);const d=l+e.timeWidth;let h;const r=i.time.end-i.time.start;h=this.data.ignoreMissingDates?this.api.time.date(this.api.time.getTimeFromOffsetPx(d,!0,o)):this.api.time.date(t.valueOf()+r),n+=this.api.time.getDSTDiffForLevel(o.level,t.valueOf(),h.valueOf(),o),h=h.add(n,"ms");let m=h;return a||(m=this.data.snapToTime.end({endTime:h,item:i,time:o,movement:s,vido:this.vido})),m}onPointerMove(t){if(!this.data.enabled)return;if(!this.data.isMoving)return;const{original:e,modified:i}=this.getItemsForDiff();if(!e)return;const a=this.data.movement=Object.assign(Object.assign({},t.movement),{time:i.time.start-e.time.start}),s=this.data.threshold.horizontal,o=this.data.threshold.vertical;if(this.data.thresholdReached.horizontal=this.data.thresholdReached.horizontal||Math.abs(a.x)>=s,this.data.thresholdReached.vertical=this.data.thresholdReached.vertical||Math.abs(a.y)>=o,!this.data.thresholdReached.horizontal&&!this.data.thresholdReached.vertical)return;"move"!==this.data.state&&"start"!==this.data.state||(this.data.state="move");const{itemsToMove:l,dependantIds:n}=this.getItemsToMove(!0),d={},h=this.state.get("$data.chart.time"),r=[],m=this.data.snapToTime.start({startTime:this.data.initialPointerTime,item:null,time:h,movement:a,vido:this.vido}),c=this.state.get("$data.scroll.horizontal"),p=this.api.time.getDatesDiffPx(c.data.leftGlobalDate.subtract(c.preciseOffset*h.timePerPixel,"ms"),this.data.initialHorizontalScroll.data.leftGlobalDate.subtract(this.data.initialHorizontalScroll.preciseOffset*h.timePerPixel,"ms"),h,!0),u=this.api.time.date(this.api.time.getTimeFromOffsetPx(t.currentPosition.x+p,!0,h)),g=this.api.time.getDatesDiffPx(m,u,h,!0);for(let e=0,i=l.length;e<i;e++){const i=this.api.mergeDeep({},l[e]),s=this.api.mergeDeep({},this.data.initialItemsData[i.id]),o=n.includes(i.id);if(this.moveItemVertically(i,s,t),this.data.thresholdReached.horizontal){const t=this.calculateFinalLeftGlobal({diffPx:g,initialItemData:s,initialItem:i,isDependant:o,movement:a,itemDataToSave:d,time:h}),e=this.calculateFinalRightGlobal({finalLeftGlobalDate:t,initialItemData:s,initialItem:i,isDependant:o,movement:a,time:h});if(!(t.valueOf()<h.from||e.valueOf()>h.to)||"function"!=typeof h.format.periodIncrement&&this.data.allowItemsToGoOutsideTheArea)i.time.start=t.valueOf(),i.time.end=e.valueOf(),s.time.startDate=t,s.time.endDate=e;else{const t=this.api.getItem(i.id);i.time.start=t.time.start,i.time.end=t.time.end,s.time.startDate=this.api.time.date(i.time.start),s.time.endDate=this.api.time.date(i.time.end)}}d[i.id]=s,r.push(i)}(this.data.thresholdReached.horizontal||this.data.thresholdReached.vertical)&&this.dispatchEvent("onMove",r,t,d),g&&(this.data.thresholdReached.horizontal||this.data.thresholdReached.vertical)&&this.autoScroll(t),this.updateData()}onEnd(t){const{itemsToMove:e}=this.getItemsToMove(!1);this.dispatchEvent("onEnd",e,t)}onPointerUp(t){document.body.classList.remove(this.data.bodyClass),this.data.enabled&&this.data.isMoving&&("move"===this.data.state&&(this.data.state="end"),this.data.isMoving=!1,this.onEnd(t),this.updateData(),this.api.plugins.TimelinePointer.unlock("down"),this.api.plugins.TimelinePointer.unlock("move"),this.api.plugins.TimelinePointer.unlock("up"))}itemUpdateAction(t,e){this.data.initialItems.find((t=>t.id===e.item.id))&&this.data.isMoving?t.classList.add(this.data.itemClass):t.classList.remove(this.data.itemClass)}}function a(t={}){return function(a){const s=a.api;if(!s.isPluginInitialized("TimelinePointer"))throw new Error("TimelinePointer plugin must be initialized before ItemMovement plugin.");if(!s.isPluginInitialized("Selection"))throw new Error("Selection plugin must be initialized before ItemMovement plugin.");const o=a.state.get(e);o&&(t=a.api.mergeDeep({},t,o));const l=new i(a,t);return s.pluginInitialized("ItemMovement"),l.destroy}}export{a as Plugin};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ItemMovement plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido, Item, DataChartTime, ItemData, DataItems, DataScrollVertical, DataScrollHorizontal } from '../gstc';
|
|
7
|
+
import type DeepState from 'deep-state-observer';
|
|
8
|
+
import type { Dayjs } from 'dayjs';
|
|
9
|
+
export interface SnapArg {
|
|
10
|
+
time: DataChartTime;
|
|
11
|
+
item: Item | null;
|
|
12
|
+
movement: Movement;
|
|
13
|
+
vido: Vido;
|
|
14
|
+
}
|
|
15
|
+
export interface SnapStartArg extends SnapArg {
|
|
16
|
+
startTime: Dayjs;
|
|
17
|
+
}
|
|
18
|
+
export interface SnapEndArg extends SnapArg {
|
|
19
|
+
endTime: Dayjs;
|
|
20
|
+
}
|
|
21
|
+
export interface Movement {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
time: number;
|
|
25
|
+
}
|
|
26
|
+
export interface SnapToTime {
|
|
27
|
+
start?: (snapStartArgs: SnapStartArg) => Dayjs;
|
|
28
|
+
end?: (snapEndArgs: SnapEndArg) => Dayjs;
|
|
29
|
+
}
|
|
30
|
+
export interface BeforeAfterInitialItems {
|
|
31
|
+
initial: Item[];
|
|
32
|
+
before: Item[];
|
|
33
|
+
after: Item[];
|
|
34
|
+
targetData: Item | null;
|
|
35
|
+
}
|
|
36
|
+
export interface OnArg {
|
|
37
|
+
items: BeforeAfterInitialItems;
|
|
38
|
+
addedDependantIds: string[];
|
|
39
|
+
selectedIds: string[];
|
|
40
|
+
vido: Vido;
|
|
41
|
+
state: DeepState;
|
|
42
|
+
time: DataChartTime;
|
|
43
|
+
}
|
|
44
|
+
export interface Events {
|
|
45
|
+
onStart?: (onArg: OnArg) => Item[];
|
|
46
|
+
onMove?: (onArg: OnArg) => Item[];
|
|
47
|
+
onEnd?: (onArg: OnArg) => Item[];
|
|
48
|
+
}
|
|
49
|
+
export interface Threshold {
|
|
50
|
+
horizontal?: number;
|
|
51
|
+
vertical?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface ScrollSpeed {
|
|
54
|
+
horizontal?: number;
|
|
55
|
+
vertical?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface AutoScroll {
|
|
58
|
+
speed?: ScrollSpeed;
|
|
59
|
+
edgeThreshold?: Threshold;
|
|
60
|
+
}
|
|
61
|
+
export interface Options {
|
|
62
|
+
enabled?: boolean;
|
|
63
|
+
dependant?: boolean;
|
|
64
|
+
moveDependantVertically?: boolean;
|
|
65
|
+
debug?: boolean;
|
|
66
|
+
bodyClass?: string;
|
|
67
|
+
itemClass?: string;
|
|
68
|
+
events?: Events;
|
|
69
|
+
snapToTime?: SnapToTime;
|
|
70
|
+
threshold?: Threshold;
|
|
71
|
+
autoScroll?: AutoScroll;
|
|
72
|
+
ignoreMissingDates?: boolean;
|
|
73
|
+
allowItemsToGoOutsideTheArea?: boolean;
|
|
74
|
+
shouldMuteNotNeededMethods?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export type State = 'start' | 'move' | 'end' | '';
|
|
77
|
+
export interface ThresholdReached {
|
|
78
|
+
horizontal: boolean;
|
|
79
|
+
vertical: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface PluginData extends Options {
|
|
82
|
+
isMoving: boolean;
|
|
83
|
+
initialItems: Item[];
|
|
84
|
+
initialItemsData: DataItems;
|
|
85
|
+
addedDependantIds: string[];
|
|
86
|
+
selectedIds: string[];
|
|
87
|
+
clickedItem: Item;
|
|
88
|
+
clickedItemData: ItemData;
|
|
89
|
+
initialVerticalScroll: DataScrollVertical;
|
|
90
|
+
initialHorizontalScroll: DataScrollHorizontal;
|
|
91
|
+
initialPointerTime: Dayjs | null;
|
|
92
|
+
thresholdReached: ThresholdReached;
|
|
93
|
+
state: State;
|
|
94
|
+
movement: Movement;
|
|
95
|
+
}
|
|
96
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
97
|
+
//# sourceMappingURL=item-movement.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ItemMovement={})}(this,(function(t){"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TimelinePointer plugin
|
|
4
|
+
*
|
|
5
|
+
* @copyright NEURONET - Rafal Pospiech
|
|
6
|
+
* @author Rafal Pospiech <neuronet.io@gmail.com>
|
|
7
|
+
* @module gantt-schedule-timeline-calendar
|
|
8
|
+
* @link https://github.com/neuronetio/gantt-schedule-timeline-calendar
|
|
9
|
+
* @link https://gantt-schedule-timeline-calendar.neuronet.io
|
|
10
|
+
* @version 3.37.5
|
|
11
|
+
* @released 2024-07-19
|
|
12
|
+
* @license SEE LICENSE IN LICENSE FILE
|
|
13
|
+
*/const e="chart-timeline-items-row-item";
|
|
14
|
+
/**
|
|
15
|
+
* ItemMovement plugin
|
|
16
|
+
*
|
|
17
|
+
* @copyright NEURONET - Rafal Pospiech
|
|
18
|
+
* @author Rafal Pospiech <neuronet.io@gmail.com>
|
|
19
|
+
* @module gantt-schedule-timeline-calendar
|
|
20
|
+
* @link https://github.com/neuronetio/gantt-schedule-timeline-calendar
|
|
21
|
+
* @link https://gantt-schedule-timeline-calendar.neuronet.io
|
|
22
|
+
* @version 3.37.5
|
|
23
|
+
* @released 2024-07-19
|
|
24
|
+
* @license SEE LICENSE IN LICENSE FILE
|
|
25
|
+
*/const i="config.plugin.ItemMovement";class a{constructor(t,e){this.onDestroy=[],this.scrollWaiting=0,this.vido=t,this.state=t.state,this.api=t.api,this.data=function(t={}){const e={onStart:({items:t})=>t.after,onMove:({items:t})=>t.after,onEnd:({items:t})=>t.after},i={start:({startTime:t,time:e,vido:i})=>i.api.time.findOrCreateMainDateAtTime(t.valueOf(),e).leftGlobalDate,end:({endTime:t})=>t},a={speed:{horizontal:1,vertical:1},edgeThreshold:{horizontal:60,vertical:0}},s=Object.assign({enabled:!0,dependant:!0,moveDependantVertically:!1,addedDependantIds:[],selectedIds:[],debug:!1,state:"",bodyClass:"gstc-items-moving",itemClass:"",movement:{x:0,y:0,time:0},threshold:{horizontal:10,vertical:10},initialItems:[],initialItemsData:{},clickedItem:null,clickedItemData:null,initialVerticalScroll:null,initialHorizontalScroll:null,initialPointerTime:null,isMoving:!1,events:Object.assign({},e),snapToTime:Object.assign({},i),autoScroll:Object.assign({},a),ignoreMissingDates:!0,allowItemsToGoOutsideTheArea:!0,thresholdReached:{horizontal:!1,vertical:!1},shouldMuteNotNeededMethods:!0},t);return t.snapToTime&&(s.snapToTime=Object.assign(Object.assign({},i),t.snapToTime)),t.events&&(s.events=Object.assign(Object.assign({},e),t.events)),t.autoScroll&&(s.autoScroll=Object.assign(Object.assign({},a),t.autoScroll),t.autoScroll.edgeThreshold&&(s.autoScroll.edgeThreshold=Object.assign(Object.assign({},a.edgeThreshold),t.autoScroll.edgeThreshold)),t.autoScroll.speed&&(s.autoScroll.speed=Object.assign(Object.assign({},a.speed),t.autoScroll.speed))),s}(e),this.data.itemClass||(this.data.itemClass=this.api.getClass("timeline-chart-items-row-item")+"--moving"),this.destroy=this.destroy.bind(this),this.itemUpdateAction=this.itemUpdateAction.bind(this),this.onDestroy.push(this.state.subscribe("$data.elements.chart-timeline",(t=>this.timelineElement=t))),this.updateData(),this.onDestroy.push(this.state.subscribe("config.plugin.ItemMovement",(t=>{t.enabled&&t.isMoving?document.body.classList.add(t.bodyClass):document.body.classList.remove(t.bodyClass),this.data=t}))),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onTimelinePointerDown=this.onTimelinePointerDown.bind(this),this.onTimelinePointerMove=this.onTimelinePointerMove.bind(this),this.onTimelinePointerUp=this.onTimelinePointerUp.bind(this),this.api.plugins.TimelinePointer.addPointerListener("move",this.onTimelinePointerMove),this.api.plugins.TimelinePointer.addPointerListener("down",this.onTimelinePointerDown),this.api.plugins.TimelinePointer.addPointerListener("up",this.onTimelinePointerUp)}destroy(){this.onDestroy.forEach((t=>t())),this.api.plugins.TimelinePointer.removePointerListener("move",this.onTimelinePointerMove),this.api.plugins.TimelinePointer.removePointerListener("down",this.onTimelinePointerDown),this.api.plugins.TimelinePointer.removePointerListener("up",this.onTimelinePointerUp),this.api.pluginDestroyed("ItemMovement")}updateData(){this.state.update(i,this.data)}getSelectedItems(t=!1){return this.state.get(`config.plugin.Selection.selected.${e}`).map((e=>{let i=this.api.getItem(e);if(t)for(const t of this.data.initialItems)if(t.id===e){i=t;break}return this.api.mergeDeep({},i)}))}getSelectedItemsData(t){const e={};for(const i of t)e[i.id]=this.api.mergeDeep({},this.api.getItemData(i.id));return e}getEventArgument(t,e){const i=this.api.getAllItems(),a=[];for(const e of t)a.push(this.api.mergeDeep({},i[e.id]));return{items:{initial:this.data.initialItems,before:a,after:t,targetData:e.targetData},addedDependantIds:this.data.addedDependantIds,selectedIds:this.data.selectedIds,vido:this.vido,state:this.state,time:this.state.get("$data.chart.time")}}getDependantItems(t,e){const i=[],a=this.api.getItemsData();for(const e of t)for(const t of a[e.id].dependant)i.includes(t)||i.push(t);const s=this.state.get("config.chart.items");let o;return o=e?i.map((t=>this.data.initialItems.find((e=>e.id===t)))):i.map((t=>s[t])),o.map((t=>this.api.mergeDeep({},t)))}dispatchEvent(t,e,i,a=null){"onStart"===t&&this.data.shouldMuteNotNeededMethods&&(this.api.muteMethod("fixOverlapped"),this.api.muteMethod("fullReload"),this.api.muteMethod("measureRows"),this.api.muteMethod("getLastPageRowsHeight"),this.api.muteMethod("calculateVerticalScrollArea"),this.api.muteMethod("heightChange"),this.api.muteMethod("calculateRowsHeight"),this.api.muteMethod("calculateVisibleRowsHeights"),this.api.muteMethod("updateVisibleItemsListener"),this.api.muteMethod("prepareExpanded"),0===this.data.autoScroll.speed.horizontal&&0===this.data.autoScroll.speed.vertical&&(this.api.muteMethod("generateVisibleRowsAndItems"),this.api.muteMethod("prepareExpanded"))),"onEnd"===t&&this.data.shouldMuteNotNeededMethods&&(this.api.unmuteMethod("fixOverlapped"),this.api.unmuteMethod("heightChange"),this.api.unmuteMethod("calculateVerticalScrollArea"),this.api.unmuteMethod("getLastPageRowsHeight"),this.api.unmuteMethod("fullReload"),this.api.unmuteMethod("measureRows"),this.api.unmuteMethod("calculateRowsHeight"),this.api.unmuteMethod("calculateVisibleRowsHeights"),this.api.unmuteMethod("updateVisibleItemsListener"),this.api.unmuteMethod("prepareExpanded"),0===this.data.autoScroll.speed.horizontal&&0===this.data.autoScroll.speed.vertical&&(this.api.unmuteMethod("generateVisibleRowsAndItems"),this.api.unmuteMethod("prepareExpanded"))),e=e.map((t=>this.api.mergeDeep({},t)));const s=this.data.events[t](this.getEventArgument(e,i));let o=this.state.multi(!0);const l=this.state.get("config.chart.items");for(let t of s){t=this.api.mergeDeep({},t);const e=l[t.id];let i=!1;t.time.start===e.time.start&&t.time.end===e.time.end||(i=!0,o=o.update(`config.chart.items.${t.id}.time`,Object.assign({},t.time)));let s=!1;e.rowId!==t.rowId&&(s=!0,o=o.update(`config.chart.items.${t.id}.rowId`,t.rowId),this.api.updateItemRowMapForItem(t.id,t.rowId)),a&&(i||s)&&(o=o.update(`$data.chart.items.${t.id}`,this.api.mergeDeep({},a[t.id])))}o.done(),"onEnd"===t&&this.api.main.partialReload(!1)}getItemsForDiff(){const t=this.getSelectedItems()[0],e=this.data.initialItems.find((e=>e.id===t.id));return{modified:t,original:e}}onTimelinePointerDown(t){this.data.enabled&&(t.targetType!==e||this.api.plugins.TimelinePointer.isLocked("down")||this.onPointerDown(t))}onTimelinePointerMove(t){this.data.enabled&&t.targetType===e&&"item-movement"===this.api.plugins.TimelinePointer.isLocked("move")&&this.onPointerMove(t)}onTimelinePointerUp(t){this.data.enabled&&t.targetType===e&&"item-movement"===this.api.plugins.TimelinePointer.isLocked("up")&&this.onPointerUp(t)}onPointerDown(t){if(document.body.classList.add(this.data.bodyClass),this.api.plugins.TimelinePointer.lock("down","item-movement"),this.api.plugins.TimelinePointer.lock("move","item-movement"),this.api.plugins.TimelinePointer.lock("up","item-movement"),this.data.isMoving=!0,this.data.dependant){const t=this.getSelectedItems();this.data.selectedIds=t.map((t=>t.id));const e=this.getDependantItems(t,!1).filter((t=>!this.data.selectedIds.includes(t.id)));this.data.addedDependantIds=e.map((t=>t.id)),this.data.initialItems=[...t,...e]}else this.data.addedDependantIds=[],this.data.initialItems=this.getSelectedItems(),this.data.selectedIds=this.data.initialItems.map((t=>t.id));this.data.initialItemsData=this.getSelectedItemsData(this.data.initialItems),this.data.clickedItem=this.api.mergeDeep({},t.targetData),this.data.clickedItemData=this.api.mergeDeep({},this.api.getItemData(this.data.clickedItem.id)),this.data.initialVerticalScroll=this.api.mergeDeep({},this.state.get("$data.scroll.vertical")),this.data.initialHorizontalScroll=this.api.mergeDeep({},this.state.get("$data.scroll.horizontal")),this.data.initialPointerTime=this.api.time.date(this.api.time.getTimeFromOffsetPx(t.initialPosition.x,!0)),this.scrollWaiting=0,this.data.thresholdReached.horizontal=!1,this.data.thresholdReached.vertical=!1,""!==this.data.state&&"end"!==this.data.state||(this.data.state="move"),this.dispatchEvent("onStart",this.data.initialItems,t),this.updateData()}scrollLeft(){if(!this.data.autoScroll.speed.horizontal)return;if(this.state.get("config.chart.time.calculatedZoomMode"))return;this.scrollWaiting++;const t=this.state.get("config.scroll.horizontal");if(this.data.autoScroll.speed.horizontal<0){if(this.scrollWaiting-1<Math.abs(this.data.autoScroll.speed.horizontal))return;const e=this.api.getScrollLeft();t.byPixels?this.api.setScrollLeft(e.absolutePosPx-120*t.multiplier):this.api.setScrollLeft(e.dataIndex-1)}else if(this.data.autoScroll.speed.horizontal>0){const e=this.api.getScrollLeft();t.byPixels?this.api.setScrollLeft(e.absolutePosPx-120*this.data.autoScroll.speed.horizontal*t.multiplier):this.api.setScrollLeft(e.dataIndex-this.data.autoScroll.speed.horizontal)}this.scrollWaiting=0}scrollRight(){if(!this.data.autoScroll.speed.horizontal)return;if(this.state.get("config.chart.time.calculatedZoomMode"))return;this.scrollWaiting++;const t=this.state.get("config.scroll.horizontal");if(this.data.autoScroll.speed.horizontal<0){if(this.scrollWaiting-1<Math.abs(this.data.autoScroll.speed.horizontal))return;const e=this.api.getScrollLeft();t.byPixels?this.api.setScrollLeft(e.absolutePosPx+120*t.multiplier):this.api.setScrollLeft(e.dataIndex+1)}else if(this.data.autoScroll.speed.horizontal>0){const e=this.api.getScrollLeft();t.byPixels?this.api.setScrollLeft(e.absolutePosPx+120*this.data.autoScroll.speed.horizontal*t.multiplier):this.api.setScrollLeft(e.dataIndex+this.data.autoScroll.speed.horizontal)}this.scrollWaiting=0}scrollTop(){if(this.data.autoScroll.speed.vertical){if(this.scrollWaiting++,this.data.autoScroll.speed.vertical<0){if(this.scrollWaiting-1<Math.abs(this.data.autoScroll.speed.vertical))return;const t=this.api.getScrollTop(),e=this.state.get("config.scroll.vertical");e.byPixels?this.api.setScrollTop(t.absolutePosPx-120*e.multiplier):this.api.setScrollTop(t.dataIndex-1)}else if(this.data.autoScroll.speed.vertical>0){const t=this.api.getScrollTop(),e=this.state.get("config.scroll.vertical");e.byPixels?this.api.setScrollTop(t.absolutePosPx-120*this.data.autoScroll.speed.vertical*e.multiplier):this.api.setScrollTop(t.dataIndex-this.data.autoScroll.speed.vertical)}this.scrollWaiting=0}}scrollBottom(){if(this.data.autoScroll.speed.vertical){if(this.scrollWaiting++,this.data.autoScroll.speed.vertical<0){if(this.scrollWaiting-1<Math.abs(this.data.autoScroll.speed.vertical))return;const t=this.api.getScrollTop(),e=this.state.get("config.scroll.vertical");e.byPixels?this.api.setScrollTop(t.absolutePosPx-120*e.multiplier):this.api.setScrollTop(t.dataIndex+1)}else if(this.data.autoScroll.speed.vertical>0){const t=this.api.getScrollTop(),e=this.state.get("config.scroll.vertical");e.byPixels?this.api.setScrollTop(t.absolutePosPx+120*this.data.autoScroll.speed.vertical*e.multiplier):this.api.setScrollTop(t.dataIndex+this.data.autoScroll.speed.vertical)}this.scrollWaiting=0}}autoScroll(t){if(!this.timelineElement)return;const e=t.currentPosition.x,i=t.currentPosition.y,a=this.state.get("$data.chart.dimensions");e<this.data.autoScroll.edgeThreshold.horizontal?this.scrollLeft():e>a.widthWithoutScrollBar-this.data.autoScroll.edgeThreshold.horizontal?this.scrollRight():i<this.data.autoScroll.edgeThreshold.vertical?this.scrollTop():i>a.innerHeight-this.data.autoScroll.edgeThreshold.vertical&&this.scrollBottom()}moveItemVertically(t,e,i){if(this.data.addedDependantIds.includes(t.id)&&!this.data.moveDependantVertically)return;const a=this.state.get("$data.scroll.vertical").absolutePosPx-this.data.initialVerticalScroll.absolutePosPx,s=i.currentPosition.y-i.initialPosition.y,o=this.data.threshold.vertical;if(Math.abs(s)>=o&&(this.data.thresholdReached.vertical=!0),!this.data.thresholdReached.vertical)return;const l=this.data.clickedItemData.position.viewTop-i.initialPosition.y-this.data.clickedItemData.position.rowTop;let n=e.position.top+s+a-l;n<0&&(n=0);const d=this.api.getRowInfoFromTop(n);d.row.id!==t.rowId&&(t.rowId=d.row.id,e.position.viewTop=this.api.getRowViewTop(t.rowId),e.position.rowTop=0)}getItemsToMove(t=!1){let e,i=[];if(this.data.dependant){const a=this.getSelectedItems(t),s=a.map((t=>t.id)),o=this.getDependantItems(a,t).filter((t=>!s.includes(t.id)));i=o.map((t=>t.id)),e=[...a,...o]}else e=this.getSelectedItems(t);return{itemsToMove:e,dependantIds:i}}calculateFinalLeftGlobal({diffPx:t,initialItemData:e,initialItem:i,isDependant:a,movement:s,itemDataToSave:o,time:l}){const n=e.position.left+t;let d=this.api.time.getTimeFromOffsetPx(n,!0,l);if(a){const t=this.data.initialItems.find((t=>{var e;return null===(e=t.dependant)||void 0===e?void 0:e.includes(i.id)})),a=this.data.initialItemsData[t.id],s=o[a.id],n=this.api.time.getDatesDiffMs(a.time.endDate,s.time.endDate,l,!0);let h=-this.api.time.getDSTDiffForLevel(l.level,a.time.endDate.valueOf(),e.time.startDate.valueOf(),l);d=this.api.time.addTimeFromDates(e.time.startDate.valueOf(),n+h,l),h=this.api.time.getDSTDiffForLevel(l.level,s.time.endDate.valueOf(),d,l),d+=h}const h=this.api.time.date(d);let r=h;return a||(r=this.data.snapToTime.start({startTime:h,item:i,time:l,movement:s,vido:this.vido})),r}calculateFinalRightGlobal({finalLeftGlobalDate:t,initialItemData:e,initialItem:i,isDependant:a,movement:s,time:o}){const l=this.api.time.getViewOffsetPxFromDates(t,!1,o);let n=-this.api.time.getDSTDiffForLevel(o.level,i.time.start,i.time.end,o);const d=l+e.timeWidth;let h;const r=i.time.end-i.time.start;h=this.data.ignoreMissingDates?this.api.time.date(this.api.time.getTimeFromOffsetPx(d,!0,o)):this.api.time.date(t.valueOf()+r),n+=this.api.time.getDSTDiffForLevel(o.level,t.valueOf(),h.valueOf(),o),h=h.add(n,"ms");let m=h;return a||(m=this.data.snapToTime.end({endTime:h,item:i,time:o,movement:s,vido:this.vido})),m}onPointerMove(t){if(!this.data.enabled)return;if(!this.data.isMoving)return;const{original:e,modified:i}=this.getItemsForDiff();if(!e)return;const a=this.data.movement=Object.assign(Object.assign({},t.movement),{time:i.time.start-e.time.start}),s=this.data.threshold.horizontal,o=this.data.threshold.vertical;if(this.data.thresholdReached.horizontal=this.data.thresholdReached.horizontal||Math.abs(a.x)>=s,this.data.thresholdReached.vertical=this.data.thresholdReached.vertical||Math.abs(a.y)>=o,!this.data.thresholdReached.horizontal&&!this.data.thresholdReached.vertical)return;"move"!==this.data.state&&"start"!==this.data.state||(this.data.state="move");const{itemsToMove:l,dependantIds:n}=this.getItemsToMove(!0),d={},h=this.state.get("$data.chart.time"),r=[],m=this.data.snapToTime.start({startTime:this.data.initialPointerTime,item:null,time:h,movement:a,vido:this.vido}),c=this.state.get("$data.scroll.horizontal"),p=this.api.time.getDatesDiffPx(c.data.leftGlobalDate.subtract(c.preciseOffset*h.timePerPixel,"ms"),this.data.initialHorizontalScroll.data.leftGlobalDate.subtract(this.data.initialHorizontalScroll.preciseOffset*h.timePerPixel,"ms"),h,!0),u=this.api.time.date(this.api.time.getTimeFromOffsetPx(t.currentPosition.x+p,!0,h)),g=this.api.time.getDatesDiffPx(m,u,h,!0);for(let e=0,i=l.length;e<i;e++){const i=this.api.mergeDeep({},l[e]),s=this.api.mergeDeep({},this.data.initialItemsData[i.id]),o=n.includes(i.id);if(this.moveItemVertically(i,s,t),this.data.thresholdReached.horizontal){const t=this.calculateFinalLeftGlobal({diffPx:g,initialItemData:s,initialItem:i,isDependant:o,movement:a,itemDataToSave:d,time:h}),e=this.calculateFinalRightGlobal({finalLeftGlobalDate:t,initialItemData:s,initialItem:i,isDependant:o,movement:a,time:h});if(!(t.valueOf()<h.from||e.valueOf()>h.to)||"function"!=typeof h.format.periodIncrement&&this.data.allowItemsToGoOutsideTheArea)i.time.start=t.valueOf(),i.time.end=e.valueOf(),s.time.startDate=t,s.time.endDate=e;else{const t=this.api.getItem(i.id);i.time.start=t.time.start,i.time.end=t.time.end,s.time.startDate=this.api.time.date(i.time.start),s.time.endDate=this.api.time.date(i.time.end)}}d[i.id]=s,r.push(i)}(this.data.thresholdReached.horizontal||this.data.thresholdReached.vertical)&&this.dispatchEvent("onMove",r,t,d),g&&(this.data.thresholdReached.horizontal||this.data.thresholdReached.vertical)&&this.autoScroll(t),this.updateData()}onEnd(t){const{itemsToMove:e}=this.getItemsToMove(!1);this.dispatchEvent("onEnd",e,t)}onPointerUp(t){document.body.classList.remove(this.data.bodyClass),this.data.enabled&&this.data.isMoving&&("move"===this.data.state&&(this.data.state="end"),this.data.isMoving=!1,this.onEnd(t),this.updateData(),this.api.plugins.TimelinePointer.unlock("down"),this.api.plugins.TimelinePointer.unlock("move"),this.api.plugins.TimelinePointer.unlock("up"))}itemUpdateAction(t,e){this.data.initialItems.find((t=>t.id===e.item.id))&&this.data.isMoving?t.classList.add(this.data.itemClass):t.classList.remove(this.data.itemClass)}}t.Plugin=function(t={}){return function(e){const s=e.api;if(!s.isPluginInitialized("TimelinePointer"))throw new Error("TimelinePointer plugin must be initialized before ItemMovement plugin.");if(!s.isPluginInitialized("Selection"))throw new Error("Selection plugin must be initialized before ItemMovement plugin.");const o=e.state.get(i);o&&(t=e.api.mergeDeep({},t,o));const l=new a(e,t);return s.pluginInitialized("ItemMovement"),l.destroy}},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ItemResizing plugin
|
|
3
|
+
*
|
|
4
|
+
* @header --gstc--header--
|
|
5
|
+
*/
|
|
6
|
+
import type { Vido, htmlResult, Item, DataChartTime, DataItems, DataScrollHorizontal } from '../gstc';
|
|
7
|
+
import type DeepState from 'deep-state-observer';
|
|
8
|
+
import type { Dayjs } from 'dayjs';
|
|
9
|
+
export interface Handle {
|
|
10
|
+
width?: number;
|
|
11
|
+
outsideWidth?: number;
|
|
12
|
+
horizontalMargin?: number;
|
|
13
|
+
outsideHorizontalMargin?: number;
|
|
14
|
+
verticalMargin?: number;
|
|
15
|
+
outside?: boolean;
|
|
16
|
+
onlyWhenSelected?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface SnapArg {
|
|
19
|
+
item: Item;
|
|
20
|
+
time: DataChartTime;
|
|
21
|
+
vido: Vido;
|
|
22
|
+
movement: Movement;
|
|
23
|
+
}
|
|
24
|
+
export interface SnapStartArg extends SnapArg {
|
|
25
|
+
startTime: Dayjs;
|
|
26
|
+
}
|
|
27
|
+
export interface SnapEndArg extends SnapArg {
|
|
28
|
+
endTime: Dayjs;
|
|
29
|
+
}
|
|
30
|
+
export interface Movement {
|
|
31
|
+
px: number;
|
|
32
|
+
time: number;
|
|
33
|
+
}
|
|
34
|
+
export interface SnapToTime {
|
|
35
|
+
start?: (snapStartArgs: SnapStartArg) => Dayjs;
|
|
36
|
+
end?: (snapEndArgs: SnapEndArg) => Dayjs;
|
|
37
|
+
}
|
|
38
|
+
export interface BeforeAfterInitialItems {
|
|
39
|
+
initial: Item[];
|
|
40
|
+
before: Item[];
|
|
41
|
+
after: Item[];
|
|
42
|
+
}
|
|
43
|
+
export interface OnArg {
|
|
44
|
+
items: BeforeAfterInitialItems;
|
|
45
|
+
addedDependantIds: string[];
|
|
46
|
+
selectedIds: string[];
|
|
47
|
+
vido: Vido;
|
|
48
|
+
state: DeepState;
|
|
49
|
+
time: DataChartTime;
|
|
50
|
+
}
|
|
51
|
+
export interface Events {
|
|
52
|
+
onStart?: (onArg: OnArg) => Item[];
|
|
53
|
+
onResize?: (onArg: OnArg) => Item[];
|
|
54
|
+
onEnd?: (onArg: OnArg) => Item[];
|
|
55
|
+
}
|
|
56
|
+
export interface AutoScroll {
|
|
57
|
+
speed?: number;
|
|
58
|
+
edgeThreshold?: number;
|
|
59
|
+
}
|
|
60
|
+
export interface HandleContentObject {
|
|
61
|
+
left: htmlResult;
|
|
62
|
+
right: htmlResult;
|
|
63
|
+
}
|
|
64
|
+
export type HandleContentFunctionArgument = {
|
|
65
|
+
item: Item;
|
|
66
|
+
vido: Vido;
|
|
67
|
+
};
|
|
68
|
+
export type HandleContentFunction = (arg: HandleContentFunctionArgument) => HandleContentObject;
|
|
69
|
+
export type HandleContent = HandleContentObject | HandleContentFunction | htmlResult;
|
|
70
|
+
export interface Options {
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
dependant?: boolean;
|
|
73
|
+
debug?: boolean;
|
|
74
|
+
handle?: Handle;
|
|
75
|
+
content?: HandleContent;
|
|
76
|
+
bodyClass?: string;
|
|
77
|
+
bodyClassLeft?: string;
|
|
78
|
+
bodyClassRight?: string;
|
|
79
|
+
events?: Events;
|
|
80
|
+
snapToTime?: SnapToTime;
|
|
81
|
+
outsideWidthThreshold?: number;
|
|
82
|
+
autoScroll?: AutoScroll;
|
|
83
|
+
ignoreMissingDates?: boolean;
|
|
84
|
+
allowItemsToGoOutsideTheArea?: boolean;
|
|
85
|
+
threshold?: number;
|
|
86
|
+
shouldMuteNotNeededMethods?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export type State = 'start' | 'resize' | 'end' | '';
|
|
89
|
+
export interface PluginData extends Options {
|
|
90
|
+
leftIsMoving: boolean;
|
|
91
|
+
rightIsMoving: boolean;
|
|
92
|
+
initialItems: Item[];
|
|
93
|
+
initialItemsData: DataItems;
|
|
94
|
+
addedDependantIds: string[];
|
|
95
|
+
selectedIds: string[];
|
|
96
|
+
initialHorizontalScroll: DataScrollHorizontal;
|
|
97
|
+
state: State;
|
|
98
|
+
movement: Movement;
|
|
99
|
+
thresholdReached: boolean;
|
|
100
|
+
}
|
|
101
|
+
export declare function Plugin(options?: Options): (vidoInstance: Vido) => () => void;
|
|
102
|
+
//# sourceMappingURL=item-resizing.d.ts.map
|