@vmscloud/moz-ui-gantt-core 0.0.0-stage → 0.1.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/MozGantt.d.ts +52 -0
- package/dist/SearchController.d.ts +76 -0
- package/dist/data/GanttTaskStore.d.ts +49 -0
- package/dist/gantt/GanttCanvasRenderer.d.ts +160 -0
- package/dist/gantt/GanttEditor.d.ts +119 -0
- package/dist/gantt/GanttZoomController.d.ts +47 -0
- package/dist/gantt/IntervalIndex.d.ts +17 -0
- package/dist/gantt/TextBitmapCache.d.ts +49 -0
- package/dist/gantt/index.d.ts +6 -0
- package/dist/gantt/timeSidecar.d.ts +9 -0
- package/dist/index.cjs +5896 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5896 -0
- package/dist/pivotor/BatchScheduler.d.ts +25 -0
- package/dist/pivotor/ColumnAxis.d.ts +77 -0
- package/dist/pivotor/EventEmitter.d.ts +28 -0
- package/dist/pivotor/HeaderCellPool.d.ts +22 -0
- package/dist/pivotor/HeaderRenderer.d.ts +142 -0
- package/dist/pivotor/PivotEngine.d.ts +143 -0
- package/dist/pivotor/Pivotor.d.ts +334 -0
- package/dist/pivotor/RowAxis.d.ts +112 -0
- package/dist/pivotor/ScrollSync.d.ts +54 -0
- package/dist/pivotor/TimeAxisBuilder.d.ts +55 -0
- package/dist/pivotor/VirtualScroller.d.ts +43 -0
- package/dist/pivotor/aggregate.d.ts +11 -0
- package/dist/pivotor/index.d.ts +4 -0
- package/dist/pivotor/internal/timeUnit.d.ts +73 -0
- package/dist/pivotor/types.d.ts +821 -0
- package/dist/style.css +747 -0
- package/dist/types.d.ts +48 -0
- package/dist/validate.d.ts +6 -0
- package/package.json +51 -4
- package/README.md +0 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { GanttOptions, GanttRow, GanttRowId, GanttEvents, SearchState } from './types';
|
|
2
|
+
import { GanttTaskPatch } from './data/GanttTaskStore';
|
|
3
|
+
/** Framework-independent Canvas Gantt. No requests, persistence or application services. */
|
|
4
|
+
export declare class MozGantt {
|
|
5
|
+
readonly element: HTMLDivElement;
|
|
6
|
+
private readonly toolbar;
|
|
7
|
+
private readonly viewport;
|
|
8
|
+
private readonly status;
|
|
9
|
+
private readonly searchStatus;
|
|
10
|
+
private editor;
|
|
11
|
+
private searchController;
|
|
12
|
+
private options;
|
|
13
|
+
private store;
|
|
14
|
+
private buttons;
|
|
15
|
+
private emitter;
|
|
16
|
+
private controls;
|
|
17
|
+
private input;
|
|
18
|
+
private destroyed;
|
|
19
|
+
private selectedIndex;
|
|
20
|
+
private searchOff;
|
|
21
|
+
constructor(container: HTMLElement, options: GanttOptions);
|
|
22
|
+
private createViewer;
|
|
23
|
+
private get blocked();
|
|
24
|
+
private renderToolbar;
|
|
25
|
+
private makeStore;
|
|
26
|
+
private searchProjection;
|
|
27
|
+
/** 작은 설정 객체의 의미를 비교한다. 대량 data 배열은 참조 비교 후 저장소에서 diff한다. */
|
|
28
|
+
update(next: Partial<GanttOptions>): void;
|
|
29
|
+
private updateControls;
|
|
30
|
+
private commitData;
|
|
31
|
+
setData(data: readonly GanttRow[]): void;
|
|
32
|
+
/** ID 단위 원자적 추가/수정/삭제. 잘못된 patch는 데이터와 화면을 변경하지 않는다. */
|
|
33
|
+
applyDataPatch(patch: GanttTaskPatch): void;
|
|
34
|
+
/** 정규화된 불변 스냅샷. 새로운 options.data 스냅샷은 현재 patch 결과를 대체한다. */
|
|
35
|
+
getData(): readonly GanttRow[];
|
|
36
|
+
search(keyword: string): SearchState | null;
|
|
37
|
+
getSearchState(): SearchState | null;
|
|
38
|
+
findNext(): void;
|
|
39
|
+
findPrevious(): void;
|
|
40
|
+
clearSearch(): void;
|
|
41
|
+
getZoom(): number;
|
|
42
|
+
setZoom(width: number): void;
|
|
43
|
+
zoomIn(): void;
|
|
44
|
+
zoomOut(): void;
|
|
45
|
+
on<K extends keyof GanttEvents>(event: K, handler: (value: GanttEvents[K]) => void): () => void;
|
|
46
|
+
scrollToTask(id: GanttRowId): void;
|
|
47
|
+
private onClick;
|
|
48
|
+
private onKeyDown;
|
|
49
|
+
private describeRow;
|
|
50
|
+
private refreshStatus;
|
|
51
|
+
destroy(): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Row, RowId, Pivotor } from './pivotor';
|
|
2
|
+
export type SearchTextFn = (row: Row) => string | null | undefined;
|
|
3
|
+
export interface SearchOptions {
|
|
4
|
+
/** 기본 false (case-insensitive). */
|
|
5
|
+
caseSensitive?: boolean;
|
|
6
|
+
/** 기본 false. true 면 keyword 를 정규식으로 해석. invalid regex 면 literal substring 으로 fallback. */
|
|
7
|
+
useRegex?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface SearchMatch {
|
|
10
|
+
rowId: RowId;
|
|
11
|
+
/** searchTextFn 반환 텍스트 안 keyword substring 의 (start, end) 위치 배열 (1+). */
|
|
12
|
+
ranges: ReadonlyArray<{
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export interface SearchState {
|
|
18
|
+
keyword: string;
|
|
19
|
+
matches: readonly SearchMatch[];
|
|
20
|
+
/** matches 안 cursor 인덱스. 매치 0 이거나 cursor 미설정 시 -1. */
|
|
21
|
+
cursor: number;
|
|
22
|
+
/** 빠른 lookup 용 — renderer 가 매 frame 카드 별 `has(rowId)` 검사. */
|
|
23
|
+
matchedRowIds: ReadonlySet<RowId>;
|
|
24
|
+
/** cursor 가 가리키는 row 또는 null. */
|
|
25
|
+
current: {
|
|
26
|
+
rowId: RowId;
|
|
27
|
+
} | null;
|
|
28
|
+
}
|
|
29
|
+
export interface SearchControllerOptions {
|
|
30
|
+
pivotor: Pivotor;
|
|
31
|
+
searchTextFn?: SearchTextFn | null;
|
|
32
|
+
scrollToRow?: (id: RowId) => void;
|
|
33
|
+
/** facade가 변경을 일괄 반영하고 직접 refresh할 때 false. */
|
|
34
|
+
observeDataChanges?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface SearchControllerEvents {
|
|
37
|
+
/** state 가 바뀔 때마다 emit. clearSearch 시엔 null. */
|
|
38
|
+
'search:changed': SearchState | null;
|
|
39
|
+
}
|
|
40
|
+
export declare class SearchController {
|
|
41
|
+
private pivotor;
|
|
42
|
+
private textCache;
|
|
43
|
+
private searchTextFn;
|
|
44
|
+
private state;
|
|
45
|
+
/** 마지막 검색의 옵션 — data:changed 시 같은 옵션으로 재평가. */
|
|
46
|
+
private lastOpts;
|
|
47
|
+
private emitter;
|
|
48
|
+
private unsubDataChanged;
|
|
49
|
+
private scrollToRow;
|
|
50
|
+
constructor(opts: SearchControllerOptions);
|
|
51
|
+
setSearchTextFn(fn: SearchTextFn | null, options?: {
|
|
52
|
+
preserveState?: boolean;
|
|
53
|
+
}): void;
|
|
54
|
+
/**
|
|
55
|
+
* keyword 로 모든 row 검색. 빈 문자열 → clearSearch 와 동일.
|
|
56
|
+
* 반환: 갱신된 SearchState. 빈 검색어는 검색을 해제하고 null을 반환한다.
|
|
57
|
+
*/
|
|
58
|
+
search(keyword: string, opts?: SearchOptions): SearchState | null;
|
|
59
|
+
/**
|
|
60
|
+
* 새 행/변경 행의 검색 문자열과 매치 범위만 계산하며 결과는 현재 행 순서로 구성한다.
|
|
61
|
+
* 캐시만 갱신하고 이벤트 발행이나 스크롤은 하지 않는다.
|
|
62
|
+
*/
|
|
63
|
+
private computeMatches;
|
|
64
|
+
invalidateRows(ids: Iterable<RowId>): void;
|
|
65
|
+
resetCache(): void;
|
|
66
|
+
/** 현재 검색어를 유지해 재평가하되 사용자의 스크롤 위치를 강제 이동하지 않는다. */
|
|
67
|
+
refresh(): SearchState | null;
|
|
68
|
+
private handleDataChanged;
|
|
69
|
+
findNext(): SearchMatch | null;
|
|
70
|
+
findPrev(): SearchMatch | null;
|
|
71
|
+
clearSearch(): void;
|
|
72
|
+
getState(): SearchState | null;
|
|
73
|
+
on<K extends keyof SearchControllerEvents>(event: K, handler: (payload: SearchControllerEvents[K]) => void): () => void;
|
|
74
|
+
destroy(): void;
|
|
75
|
+
private compileMatcher;
|
|
76
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Row, RowId } from '../pivotor/types';
|
|
2
|
+
export interface GanttTaskPatch {
|
|
3
|
+
add?: readonly Row[];
|
|
4
|
+
update?: readonly {
|
|
5
|
+
id: RowId;
|
|
6
|
+
changes: Partial<Row>;
|
|
7
|
+
}[];
|
|
8
|
+
remove?: readonly RowId[];
|
|
9
|
+
}
|
|
10
|
+
export interface GanttTaskUpdate {
|
|
11
|
+
readonly id: RowId;
|
|
12
|
+
readonly before: Row;
|
|
13
|
+
readonly after: Row;
|
|
14
|
+
readonly changedFields: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export interface GanttTaskTransaction {
|
|
17
|
+
readonly added: readonly Row[];
|
|
18
|
+
readonly updated: readonly GanttTaskUpdate[];
|
|
19
|
+
readonly removed: readonly {
|
|
20
|
+
id: RowId;
|
|
21
|
+
row: Row;
|
|
22
|
+
}[];
|
|
23
|
+
readonly orderChanged: boolean;
|
|
24
|
+
readonly changed: boolean;
|
|
25
|
+
/** 검증 완료된 변경만 반영한다. 준비 이후 저장소가 변경되었으면 거부한다. */
|
|
26
|
+
commit(): void;
|
|
27
|
+
}
|
|
28
|
+
export interface GanttTaskStoreOptions {
|
|
29
|
+
idField: string;
|
|
30
|
+
normalize: (row: Row) => Row;
|
|
31
|
+
}
|
|
32
|
+
/** 업무 데이터의 소유권/검증을 렌더러와 분리한 ID 저장소. 값은 CellValue 단위의 불변 복사본이다. */
|
|
33
|
+
export declare class GanttTaskStore {
|
|
34
|
+
private readonly options;
|
|
35
|
+
private records;
|
|
36
|
+
private snapshot;
|
|
37
|
+
private revision;
|
|
38
|
+
constructor(options: GanttTaskStoreOptions);
|
|
39
|
+
get size(): number;
|
|
40
|
+
get rows(): readonly Row[];
|
|
41
|
+
get(id: RowId): Row | undefined;
|
|
42
|
+
values(): IterableIterator<Row>;
|
|
43
|
+
prepareReplace(rows: readonly Row[]): GanttTaskTransaction;
|
|
44
|
+
preparePatch(patch: GanttTaskPatch): GanttTaskTransaction;
|
|
45
|
+
private normalize;
|
|
46
|
+
private id;
|
|
47
|
+
private changedFields;
|
|
48
|
+
private transaction;
|
|
49
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ChangeScope, HitResult, PivotBodyRenderer, PivotorHandle, Row, RowId, ViewportContext } from '../pivotor/types';
|
|
2
|
+
/** dirty 상태 alias — types.ts 의 ViewportContext.getDirtyState 반환 타입과 동일. */
|
|
3
|
+
export type DirtyRowState = 'modified' | 'added' | 'removed' | 'reordered' | 'locked';
|
|
4
|
+
/** paintBar 인자 — pooled (allocation 0/frame). readonly 는 사용자 측면에서의 의미. */
|
|
5
|
+
export interface BarPaintContext {
|
|
6
|
+
readonly ctx: CanvasRenderingContext2D;
|
|
7
|
+
readonly row: Row;
|
|
8
|
+
readonly rowId: RowId;
|
|
9
|
+
/** canvas pixel 좌표 (이미 transform 적용 후, 좌→우 누적) */
|
|
10
|
+
readonly x: number;
|
|
11
|
+
readonly y: number;
|
|
12
|
+
readonly w: number;
|
|
13
|
+
readonly h: number;
|
|
14
|
+
readonly startMs: number;
|
|
15
|
+
readonly endMs: number;
|
|
16
|
+
readonly dirtyState: DirtyRowState | null;
|
|
17
|
+
readonly locked: boolean;
|
|
18
|
+
}
|
|
19
|
+
export type PaintBarFn = (paint: BarPaintContext) => void;
|
|
20
|
+
/**
|
|
21
|
+
* default paint 가 bar 안에 그릴 텍스트를 결정하는 함수.
|
|
22
|
+
* - 반환 string: bar 안에 그 텍스트 그림 (text bitmap cache 활용)
|
|
23
|
+
* - 반환 null/undefined: 텍스트 없이 사각형만
|
|
24
|
+
*
|
|
25
|
+
* 미지정 시 default = `String(rowId)`. 사용자 `paintBar` 를 직접 제공하면 이 옵션은 무시됨.
|
|
26
|
+
*
|
|
27
|
+
* 성능: 함수 호출 자체는 negligible (5k bar × 60fps ≈ 3ms/sec). 같은 row 의 텍스트가 안 바뀌면
|
|
28
|
+
* TextBitmapCache 가 적중하므로 추가 비용 없음. row 별 unique text 라도 cache capacity (기본 512)
|
|
29
|
+
* 안에선 hit ratio 높음.
|
|
30
|
+
*/
|
|
31
|
+
export type BarLabelFn = (row: Row, paint: BarPaintContext) => string | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* default paint 의 bar 색깔/텍스트 색깔 결정 콜백.
|
|
34
|
+
*
|
|
35
|
+
* 반환 형태:
|
|
36
|
+
* - **string**: bar fill 색만 지정. 텍스트는 내장 기본 (흰색) 사용. (간단형)
|
|
37
|
+
* - **`BarColors` 객체** `{ bar?, text? }`: bar fill / 텍스트 색 각각 독립 지정.
|
|
38
|
+
* 둘 다 또는 일부만 지정 가능. 미지정 필드는 내장 기본으로 폴백.
|
|
39
|
+
* - **`null` / `undefined`**: 둘 다 내장 기본 사용 (locked → 회색, dirty → 색상 강조, 그 외 → 파랑).
|
|
40
|
+
*
|
|
41
|
+
* `paint.row` (원본 데이터), `paint.dirtyState`, `paint.locked` 등 BarPaintContext 의 모든 필드를
|
|
42
|
+
* 참조해 동적으로 색 결정 가능. 사용자 `paintBar` 를 직접 제공하면 이 옵션은 무시됨.
|
|
43
|
+
*
|
|
44
|
+
* 성능: 호출 자체는 빠르지만 매 frame 모든 visible bar 마다 호출되므로, 콜백 안에서
|
|
45
|
+
* heavy 계산 / object allocation 은 피할 것. (가능하면 팔레트 등을 모듈 상수로 두고 색 string 만 반환)
|
|
46
|
+
*/
|
|
47
|
+
export type BarColorFn = (row: Row, paint: BarPaintContext) => string | BarColors | null | undefined;
|
|
48
|
+
export interface BarColors {
|
|
49
|
+
/**
|
|
50
|
+
* bar 사각형 fill.
|
|
51
|
+
* - **string**: solid fill 색
|
|
52
|
+
* - **`BarPattern` 객체**: background + stripe 무늬 (예: 대각선 줄무늬)
|
|
53
|
+
* - **null/undefined**: 내장 dirty/locked 기반 색상 사용
|
|
54
|
+
*/
|
|
55
|
+
bar?: string | BarPattern | null;
|
|
56
|
+
/** bar 안 라벨 텍스트 색. 미지정/null 시 내장 기본 (`#fff`) 사용. */
|
|
57
|
+
text?: string | null;
|
|
58
|
+
/** bar 사각형 border 색. 미지정/null 시 border 안 그림. 1 CSS px stroke. */
|
|
59
|
+
border?: string | null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 줄무늬 (stripe) bar 무늬 spec. `BarColors.bar` 에 string 대신 줄 수 있음.
|
|
63
|
+
*
|
|
64
|
+
* 렌더링: `background` 로 솔리드 fill 후, `stripe` 색의 줄무늬가 그 위에 overlay.
|
|
65
|
+
* 같은 spec 의 stripe 는 첫 호출 시 한 번 rasterize 되어 캐시됨 (매 frame 비용 0).
|
|
66
|
+
*/
|
|
67
|
+
export interface BarPattern {
|
|
68
|
+
/** 배경 fill 색 (CSS color) */
|
|
69
|
+
background: string;
|
|
70
|
+
/** stripe 색 (CSS color) */
|
|
71
|
+
stripe: string;
|
|
72
|
+
/** stripe 각도 (degree). 0=수평, 45=우상향 대각선, 90=수직. default 45. */
|
|
73
|
+
angle?: number;
|
|
74
|
+
/** stripe 두께 (CSS px). default 4. */
|
|
75
|
+
thickness?: number;
|
|
76
|
+
/** stripe 사이 빈 간격 (CSS px). default 8. */
|
|
77
|
+
gap?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface GanttCanvasRendererOptions {
|
|
80
|
+
startField: string;
|
|
81
|
+
endField: string;
|
|
82
|
+
paintBar?: PaintBarFn;
|
|
83
|
+
/** default paint 의 bar 라벨 텍스트 결정. paintBar 를 직접 줄 정도는 아니지만 라벨은 바꾸고 싶을 때. */
|
|
84
|
+
barLabel?: BarLabelFn;
|
|
85
|
+
/**
|
|
86
|
+
* default paint 의 bar 색깔 결정. 반환 null/undefined 시 내장 dirty/locked 기반 색상 사용.
|
|
87
|
+
* paintBar 를 직접 제공하면 무시됨.
|
|
88
|
+
*/
|
|
89
|
+
barColor?: BarColorFn;
|
|
90
|
+
/** lock 상태 표시 — `effective(id, field) === true` 면 locked. 미지정 시 항상 false. */
|
|
91
|
+
lockedByField?: string;
|
|
92
|
+
/**
|
|
93
|
+
* dirty state 가 `'removed'` (삭제 예정) 인 row 의 bar 를 paint 에서 스킵.
|
|
94
|
+
* 미지정/false 시 기존 동작 — removed row 도 일반 색(혹은 사용자 paintBar 결정) 으로 그려짐.
|
|
95
|
+
*/
|
|
96
|
+
hideRemovedBars?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Bar 라벨 텍스트 비트맵 캐시 capacity. default 4096.
|
|
99
|
+
*
|
|
100
|
+
* unique 라벨 종류가 capacity 를 초과하면 매 frame LRU 순환 + cache miss → rasterize 폭주로
|
|
101
|
+
* zoom-in 시 frame rate 저하. 데이터셋 라벨 다양성에 맞춰 상향 조정 권장 — 예: row 가 수만 개인데
|
|
102
|
+
* 라벨이 row 별로 거의 unique 면 (item_id 등) 8192 ~ 16384 까지 키우면 hit rate ≈ 100% 안정.
|
|
103
|
+
* 메모리 trade-off: 1 entry ≈ 1-2KB.
|
|
104
|
+
*/
|
|
105
|
+
textCacheCapacity?: number;
|
|
106
|
+
}
|
|
107
|
+
export declare class GanttCanvasRenderer implements PivotBodyRenderer {
|
|
108
|
+
private readonly opts;
|
|
109
|
+
private pivotor;
|
|
110
|
+
private hitRegions;
|
|
111
|
+
private hitCount;
|
|
112
|
+
private readonly timeFieldKey;
|
|
113
|
+
private readonly visibleTimeCols;
|
|
114
|
+
private readonly rowScratch;
|
|
115
|
+
private readonly intervalScratch;
|
|
116
|
+
private readonly overlayIndexes;
|
|
117
|
+
private overlayIndexRows;
|
|
118
|
+
clearTimeCache(): void;
|
|
119
|
+
invalidateTime(id: RowId): void;
|
|
120
|
+
invalidateRows(ids: readonly RowId[]): void;
|
|
121
|
+
/** 표시 설정만 변경하고 시간/행 인덱스와 Canvas 인스턴스를 유지한다. */
|
|
122
|
+
updateOptions(patch: Partial<Pick<GanttCanvasRendererOptions, 'barLabel' | 'barColor' | 'paintBar' | 'textCacheCapacity'>>): void;
|
|
123
|
+
private canvas;
|
|
124
|
+
private ctx2d;
|
|
125
|
+
private dpr;
|
|
126
|
+
/** allocation 0/frame — pooled context 1개를 mutate. */
|
|
127
|
+
private readonly paintCtx;
|
|
128
|
+
private readonly textCache;
|
|
129
|
+
/**
|
|
130
|
+
* BarPattern spec → CanvasPattern 캐시. (color|angle|thickness|gap) 별로 1회 생성 후 재사용.
|
|
131
|
+
* createPattern 은 매 frame 호출하면 비용이 큼 → 캐시 hit 시 비용 0.
|
|
132
|
+
*/
|
|
133
|
+
private patternCache;
|
|
134
|
+
/** 마지막 캔버스 크기 (overshoot resize guard). */
|
|
135
|
+
private canvasW;
|
|
136
|
+
private canvasH;
|
|
137
|
+
constructor(opts: GanttCanvasRendererOptions);
|
|
138
|
+
mount(container: HTMLElement, pivotor: PivotorHandle): void;
|
|
139
|
+
invalidate(scope: ChangeScope, rowIds?: readonly RowId[]): void;
|
|
140
|
+
renderViewport(ctx: ViewportContext): void;
|
|
141
|
+
destroy(): void;
|
|
142
|
+
onHitTest(x: number, y: number): HitResult | null;
|
|
143
|
+
private trimHitRegions;
|
|
144
|
+
private clearActiveHits;
|
|
145
|
+
private dropOverlayIndex;
|
|
146
|
+
private collectOverlayRows;
|
|
147
|
+
/** 사용자가 paintBar 미제공 시 사용. 사각형 + 텍스트 (rowId). */
|
|
148
|
+
private defaultPaint;
|
|
149
|
+
/**
|
|
150
|
+
* `BarPattern` spec 으로부터 `CanvasPattern` 생성 (또는 캐시 반환).
|
|
151
|
+
*
|
|
152
|
+
* 구현 — small tile 에 axis-aligned vertical stripe 1개 그린 후 `pattern.setTransform` 으로
|
|
153
|
+
* 각도 회전 + dpr 보정. 같은 (color/angle/thickness/gap) 조합은 재사용.
|
|
154
|
+
*
|
|
155
|
+
* 매 frame 호출되지만 캐시 hit 시 비용 0. miss 시 1회 OffscreenCanvas + draw — 미미.
|
|
156
|
+
*/
|
|
157
|
+
private getOrCreatePattern;
|
|
158
|
+
private resizeIfNeeded;
|
|
159
|
+
private dumpDevMetrics;
|
|
160
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { PivotConfigInput, Row, PivotorEvents, TimeAxisSpec } from '../pivotor/types';
|
|
2
|
+
import { Pivotor } from '../pivotor';
|
|
3
|
+
import { GanttTaskTransaction } from '../data/GanttTaskStore';
|
|
4
|
+
import { GanttCanvasRenderer, PaintBarFn, BarLabelFn, BarColorFn } from './GanttCanvasRenderer';
|
|
5
|
+
export interface GanttEditorOptions {
|
|
6
|
+
container: HTMLElement;
|
|
7
|
+
config: PivotConfigInput;
|
|
8
|
+
/** 조회 데이터 배열. */
|
|
9
|
+
data?: Row[];
|
|
10
|
+
/** Bar paint 콜백. 미제공 시 default (사각형 + rowId/barLabel 텍스트). */
|
|
11
|
+
paintBar?: PaintBarFn;
|
|
12
|
+
/**
|
|
13
|
+
* Default paint 의 bar 라벨 텍스트 결정 콜백. paintBar 를 직접 줄 정도는 아니지만 라벨만 바꾸고 싶을 때.
|
|
14
|
+
* `paintBar` 를 제공하면 이 옵션은 무시 (사용자가 직접 그리는 것이므로).
|
|
15
|
+
* `null/undefined` 또는 `''` 반환 시 텍스트 없이 사각형만.
|
|
16
|
+
*/
|
|
17
|
+
barLabel?: BarLabelFn;
|
|
18
|
+
/**
|
|
19
|
+
* Default paint 의 bar 색상 결정 콜백. row 데이터 + dirty/locked 등 BarPaintContext 를 받아
|
|
20
|
+
* CSS color string 반환. `null`/`undefined` 반환 시 내장 기본 (locked 회색 / dirty 강조 / 그 외 파랑).
|
|
21
|
+
* `paintBar` 를 제공하면 무시.
|
|
22
|
+
*/
|
|
23
|
+
barColor?: BarColorFn;
|
|
24
|
+
/** start/end 시각 field 이름 (Row 의 키). 필수. */
|
|
25
|
+
startField: string;
|
|
26
|
+
endField: string;
|
|
27
|
+
/** Row lock 상태 field. 지정 시 paintBar 에 `locked: true` 로 전달 → default paint 가 회색 표시. */
|
|
28
|
+
lockedByField?: string;
|
|
29
|
+
/**
|
|
30
|
+
* dirty state `'removed'` (소프트 삭제 대기) 인 row 의 bar 를 paint 에서 스킵.
|
|
31
|
+
* 미지정/false 시 기존 동작 — 일반 색(혹은 사용자 paintBar 결정) 으로 그려짐.
|
|
32
|
+
* commit 전 "삭제 예정" row 를 시각에서 즉시 사라지게 만들고 싶을 때.
|
|
33
|
+
*/
|
|
34
|
+
hideRemovedBars?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Bar 라벨 텍스트 비트맵 캐시 capacity. default 4096.
|
|
37
|
+
* row 수가 많고 라벨이 row 별로 unique 한 경우 (예: item_id 라벨) 더 키우면 zoom-in 시 cache
|
|
38
|
+
* thrashing 방지로 frame rate 안정. 메모리 trade-off: 1 entry ≈ 1-2KB.
|
|
39
|
+
*/
|
|
40
|
+
textCacheCapacity?: number;
|
|
41
|
+
/** zoom 활성 여부. 기본 true. false 면 controller 부착 안 함. */
|
|
42
|
+
enableZoom?: boolean;
|
|
43
|
+
onZoom?: (width: number) => void;
|
|
44
|
+
/** 최소 px per tick. 기본 20 (라벨 글자 겹침 방지). */
|
|
45
|
+
minPxPerTick?: number;
|
|
46
|
+
/** 최대 px per tick. 기본 2000. 더 큰 확대가 필요하면 override. */
|
|
47
|
+
maxPxPerTick?: number;
|
|
48
|
+
/** wheel 한 step 당 zoom factor. 기본 1.25. */
|
|
49
|
+
zoomStep?: number;
|
|
50
|
+
}
|
|
51
|
+
export declare class GanttEditor {
|
|
52
|
+
private readonly opts;
|
|
53
|
+
private pivotor;
|
|
54
|
+
readonly renderer: GanttCanvasRenderer;
|
|
55
|
+
private readonly startField;
|
|
56
|
+
private readonly endField;
|
|
57
|
+
private readonly container;
|
|
58
|
+
/** mutable config (zoom 시 columnFields 의 timeAxis.ticks.width 변경). */
|
|
59
|
+
private currentConfig;
|
|
60
|
+
private zoomController;
|
|
61
|
+
private destroyed;
|
|
62
|
+
private attachFrame;
|
|
63
|
+
constructor(opts: GanttEditorOptions);
|
|
64
|
+
/** 입력 상태 변경은 Canvas/배치/스크롤을 유지하고 wheel 구독만 교체한다. */
|
|
65
|
+
updateZoomOptions(next: Partial<Pick<GanttEditorOptions, 'enableZoom' | 'minPxPerTick' | 'maxPxPerTick' | 'zoomStep'>>): void;
|
|
66
|
+
updateAppearance(next: Partial<Pick<GanttEditorOptions, 'barLabel' | 'barColor' | 'paintBar' | 'textCacheCapacity'>>): void;
|
|
67
|
+
updateLayout(next: Pick<PivotConfigInput, 'rowFields' | 'rowExpansion'>): void;
|
|
68
|
+
updateTimeAxis(timeAxis: TimeAxisSpec): void;
|
|
69
|
+
applyDataChanges(changes: GanttTaskTransaction): void;
|
|
70
|
+
get rows(): readonly Row[];
|
|
71
|
+
/** 조회 데이터 교체 시 시간 캐시도 함께 무효화한다. */
|
|
72
|
+
setData(rows: Row[]): void;
|
|
73
|
+
on<K extends keyof PivotorEvents>(event: K, handler: (p: PivotorEvents[K]) => void): () => void;
|
|
74
|
+
/** 이스케이프 해치 — 내부 Pivotor 직접 접근 (사용 자제). */
|
|
75
|
+
get underlying(): Pivotor;
|
|
76
|
+
/**
|
|
77
|
+
* 시간축 해상도 (px per tick) 변경.
|
|
78
|
+
*
|
|
79
|
+
* 두 경로:
|
|
80
|
+
* - **Incremental** (unit 동일): col tree / header tree / hierarchy 모두 동일, width 만 변화.
|
|
81
|
+
* `pivotor.setAllTimeAxisTickWidths` 로 col width + prefix 만 갱신 → header reposition + body 재페인트.
|
|
82
|
+
* setConfig 의 fullRebuild 대비 ~10x 빠르고 UI 깜빡임 없음.
|
|
83
|
+
* - **Full rebuild** (unit 전환): tickLadder step 이 바뀌면 hierarchy depth 도 변하므로
|
|
84
|
+
* setConfig → ColumnAxis 재빌드 → fullRebuild 필요.
|
|
85
|
+
*
|
|
86
|
+
* Ladder 모드 — `pxPerTick` 가 현재 step 의 [minWidth, maxWidth] 를 벗어나면 인접 step (또는 더
|
|
87
|
+
* 멀리) 으로 자동 전환. 새 unit 의 pxPerTick 으로 환산되어 시각 연속성 유지 (mpp 보존).
|
|
88
|
+
*
|
|
89
|
+
* Cursor anchor 보존이 필요하면 ZoomController 가 호출하는 `applyZoomWithCursor` 사용.
|
|
90
|
+
* 외부 button UI 등에서 단순 zoom 만 원하면 이 API.
|
|
91
|
+
*/
|
|
92
|
+
setZoom(pxPerTick: number): void;
|
|
93
|
+
zoomAtCenter(width: number): void;
|
|
94
|
+
destroy(): void;
|
|
95
|
+
/** 현재 config 의 timeAxis 가 ladder 모드인지 검사. */
|
|
96
|
+
private isLadderMode;
|
|
97
|
+
/**
|
|
98
|
+
* 현재 timeAxis tier 의 활성 width (px/tick). 시간축 없으면 null.
|
|
99
|
+
* Ladder 모드 / 단일 모드 모두 normalizeTimeAxisSpec 의 `initial.width` 가 current state.
|
|
100
|
+
*/
|
|
101
|
+
getCurrentPxPerTick(): number | null;
|
|
102
|
+
/**
|
|
103
|
+
* body content 좌표 X → 시간 ms.
|
|
104
|
+
*
|
|
105
|
+
* cursor 가 시간축 영역 밖 (좌/우측 빈 공간 / categorical 영역) 이면 가장 가까운 끝 column 의
|
|
106
|
+
* edge 시간으로 fallback — 빈 공간 위에서도 Ctrl+wheel zoom 자체는 작동하도록.
|
|
107
|
+
*/
|
|
108
|
+
private cursorToMs;
|
|
109
|
+
/**
|
|
110
|
+
* Cursor-anchored zoom 적용:
|
|
111
|
+
* 1. setConfig 로 새 pxPerTick 적용 (sync, fullRebuild)
|
|
112
|
+
* 2. 새 cols 에서 anchorMs 가 어디 있는지 계산
|
|
113
|
+
* 3. body pane 의 scrollLeft = newAnchorContentX - cursorViewportX
|
|
114
|
+
*
|
|
115
|
+
* → cursor 아래 있던 시간이 zoom 후에도 같은 화면 위치에 머무름.
|
|
116
|
+
*/
|
|
117
|
+
private applyZoomWithCursor;
|
|
118
|
+
}
|
|
119
|
+
export type { PaintBarFn, BarPaintContext, BarLabelFn, BarColorFn, BarColors, BarPattern, GanttCanvasRendererOptions } from './GanttCanvasRenderer';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GanttZoomController — Ctrl/Cmd + wheel 로 시간축 해상도 (pxPerTick) 변경.
|
|
3
|
+
*
|
|
4
|
+
* UX 원칙:
|
|
5
|
+
* - **Ctrl 또는 Cmd 가 눌려있을 때만** wheel 가로채기. 그 외엔 normal scroll 통과.
|
|
6
|
+
* - **Cursor-anchored zoom** — zoom 전후 마우스 커서 아래의 시간이 화면상 같은 X 위치에 머무름.
|
|
7
|
+
* - **RAF debounce** — 한 frame 안 여러 wheel event 누적, 마지막 부호만 적용.
|
|
8
|
+
* - **Bounds clamp** — `[minPxPerTick, maxPxPerTick]` 범위 밖 zoom 차단.
|
|
9
|
+
*
|
|
10
|
+
* 의존성: bodyPane element 만 알면 됨. zoom 계산 / 적용은 콜백으로 위임 (테스트 용이성).
|
|
11
|
+
*/
|
|
12
|
+
export interface GanttZoomControllerOptions {
|
|
13
|
+
/** wheel listener 부착 대상. body pane element. */
|
|
14
|
+
bodyPane: HTMLElement;
|
|
15
|
+
/** `[min, max]` 픽셀 per tick. 외부에서 결정 (옵션 default). */
|
|
16
|
+
minPxPerTick: number;
|
|
17
|
+
maxPxPerTick: number;
|
|
18
|
+
/** wheel 한 step 당 zoom factor. 일반적 1.25. */
|
|
19
|
+
zoomStep: number;
|
|
20
|
+
/** 현재 pxPerTick 조회. 시간축이 없으면 null. */
|
|
21
|
+
getCurrentPxPerTick: () => number | null;
|
|
22
|
+
/**
|
|
23
|
+
* `cursorContentX` (body content 좌표계 X) 가 가리키는 시간 ms 계산.
|
|
24
|
+
* 시간축에 들어가지 않거나 cursor 가 categorical 영역이면 null.
|
|
25
|
+
*/
|
|
26
|
+
cursorToMs: (cursorContentX: number) => number | null;
|
|
27
|
+
/**
|
|
28
|
+
* 새 pxPerTick 적용 + cursor anchor 보존 scroll 보정.
|
|
29
|
+
* - `nextPxPerTick`: clamp 된 새 width
|
|
30
|
+
* - `cursorViewportX`: bodyPane 좌상단 기준 cursor X (scrollLeft 미포함)
|
|
31
|
+
* - `anchorMs`: cursor 아래 있던 시간. zoom 후에도 cursorViewportX 위치에 머물러야 함.
|
|
32
|
+
*/
|
|
33
|
+
applyZoom: (nextPxPerTick: number, cursorViewportX: number, anchorMs: number) => void;
|
|
34
|
+
}
|
|
35
|
+
export declare class GanttZoomController {
|
|
36
|
+
private opts;
|
|
37
|
+
private rafHandle;
|
|
38
|
+
private pendingDeltaY;
|
|
39
|
+
/** scrollLeft 포함된 content 좌표 (cursorToMs 입력) */
|
|
40
|
+
private pendingCursorContentX;
|
|
41
|
+
/** scrollLeft 미포함된 viewport 좌표 (applyZoom 의 cursorViewportX) */
|
|
42
|
+
private pendingCursorViewportX;
|
|
43
|
+
constructor(opts: GanttZoomControllerOptions);
|
|
44
|
+
destroy(): void;
|
|
45
|
+
private onWheel;
|
|
46
|
+
private flush;
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** 시간 범위와 겹치는 작업만 찾는 불변 인덱스. 출력 순서는 원래 painter 순서를 보존한다. */
|
|
2
|
+
export interface IntervalEntry<T> {
|
|
3
|
+
value: T;
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
order: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class IntervalIndex<T> {
|
|
9
|
+
private readonly entries;
|
|
10
|
+
private readonly maxEnds;
|
|
11
|
+
private readonly base;
|
|
12
|
+
constructor(entries: readonly IntervalEntry<T>[]);
|
|
13
|
+
get size(): number;
|
|
14
|
+
/** [start, end)와 교차. 왼쪽 경계에서 끝나는 작업/0길이 작업의 기존 2px 표시를 유지한다. */
|
|
15
|
+
query(start: number, end: number, output: IntervalEntry<T>[]): void;
|
|
16
|
+
private collect;
|
|
17
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextBitmapCache — `(text, font, color)` 키로 텍스트 비트맵 캐시.
|
|
3
|
+
*
|
|
4
|
+
* Canvas2D 의 `fillText` + `measureText` 는 매 호출 layout + glyph rasterize 가 발생.
|
|
5
|
+
* 같은 텍스트를 반복 그리는 paint loop 에서 hot path 가 됨.
|
|
6
|
+
* → OffscreenCanvas 에 한 번 그려 bitmap 으로 보관, 이후엔 `drawImage` 로 빠르게 합성.
|
|
7
|
+
*
|
|
8
|
+
* Safari < 16.4 등 OffscreenCanvas 미지원 환경에서는 일반 `<canvas>` element 로 fallback.
|
|
9
|
+
*
|
|
10
|
+
* LRU 정책: 캐시 size 가 capacity 초과하면 가장 오래된 entry 제거.
|
|
11
|
+
* Map 의 insertion order 특성 활용.
|
|
12
|
+
*/
|
|
13
|
+
interface CacheEntry {
|
|
14
|
+
bmp: ImageBitmap | HTMLCanvasElement;
|
|
15
|
+
/** CSS 픽셀 width — drawImage 의 dWidth 에 사용 (5-arg form). bmp 의 backing 은 width*dpr. */
|
|
16
|
+
width: number;
|
|
17
|
+
/** CSS 픽셀 height — 마찬가지. */
|
|
18
|
+
height: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class TextBitmapCache {
|
|
21
|
+
private map;
|
|
22
|
+
private capacity;
|
|
23
|
+
/** 통계 — instrumentation 에서 사용 */
|
|
24
|
+
misses: number;
|
|
25
|
+
hits: number;
|
|
26
|
+
/** OffscreenCanvas 사용 가능 여부 (생성자 시점 1회 결정). */
|
|
27
|
+
private readonly useOffscreen;
|
|
28
|
+
/** 캡처 시점 DPR — bitmap 을 backing-buffer 해상도로 rasterize 해 main canvas 의 dpr scaling 시 흐려짐 방지. */
|
|
29
|
+
private dpr;
|
|
30
|
+
constructor(capacity?: number);
|
|
31
|
+
/**
|
|
32
|
+
* `(text, font, color)` 비트맵 조회. 없으면 rasterize + 캐시.
|
|
33
|
+
* 반환 entry 는 `drawImage(bmp, x, y)` 로 그릴 수 있음.
|
|
34
|
+
*/
|
|
35
|
+
get(text: string, font: string, color: string): CacheEntry;
|
|
36
|
+
/**
|
|
37
|
+
* 캐시 통째 비우기. 폰트 변경 / 줌 변경 등 텍스트 metric 이 무효화될 때.
|
|
38
|
+
*/
|
|
39
|
+
clear(): void;
|
|
40
|
+
size(): number;
|
|
41
|
+
setCapacity(capacity: number): void;
|
|
42
|
+
private rasterize;
|
|
43
|
+
private measureCtx;
|
|
44
|
+
/** measure ctx 획득. jsdom 등 canvas 미지원 환경이면 null 반환 — caller 가 fallback bbox 사용. */
|
|
45
|
+
private getMeasureCtx;
|
|
46
|
+
private release;
|
|
47
|
+
private evictOldest;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { GanttEditor } from './GanttEditor';
|
|
2
|
+
export type { GanttEditorOptions, PaintBarFn, BarPaintContext, BarLabelFn, BarColorFn, BarColors, BarPattern, GanttCanvasRendererOptions, } from './GanttEditor';
|
|
3
|
+
export { GanttCanvasRenderer } from './GanttCanvasRenderer';
|
|
4
|
+
export { GanttZoomController } from './GanttZoomController';
|
|
5
|
+
export type { GanttZoomControllerOptions } from './GanttZoomController';
|
|
6
|
+
export { invalidateRowTimes } from './timeSidecar';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PivotorHandle, RowId } from '../pivotor/types';
|
|
2
|
+
export interface RowTimes {
|
|
3
|
+
startMs: number;
|
|
4
|
+
endMs: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function getRowTimes(owner: PivotorHandle, id: RowId, start: string, end: string, fieldKey?: string): RowTimes;
|
|
7
|
+
export declare function invalidateRowTimes(owner: PivotorHandle, id: RowId): void;
|
|
8
|
+
export declare function invalidateRowTimesAll(owner: PivotorHandle, ids: readonly RowId[]): void;
|
|
9
|
+
export declare function clearRowTimesCache(owner?: PivotorHandle): void;
|