@vmscloud/moz-ui-gantt-core 0.1.0 → 0.3.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.
@@ -0,0 +1,98 @@
1
+ import { GanttTheme } from './features';
2
+ /** 이름 있는 단색. name이 비어 있지 않으면 실제로 칠한 막대가 범례 항목이 된다. */
3
+ export interface GanttNamedColor {
4
+ /**
5
+ * CSS 색(hex·rgb()·hsl()·이름 색·lab()·oklch()·color() 등). 반투명 색은 Gantt 표면(theme.surface) 위에 합성한 불투명 색으로
6
+ * 칠한다. Canvas가 해석하지 못하거나 글자 대비를 계산할 수 없는 값(`var()`, `color(rec2020 …)`, 표면을 알 수 없는 반투명 색 등)은
7
+ * 내장 상태색으로 폴백한다.
8
+ */
9
+ color: string;
10
+ /** 범례 이름. 생략·빈 문자열이면 범례 항목을 만들지 않는다. */
11
+ name?: string;
12
+ }
13
+ /** 선언형 색 결과: 이름 없는 CSS 색 문자열 또는 이름 있는 색. */
14
+ export type GanttColorValue = string | GanttNamedColor;
15
+ /** 규칙 비교값. 숫자는 유한해야 한다. */
16
+ export type GanttColorScalar = string | number | boolean;
17
+ /** 필드값의 명시적 매핑. `String(value)` 키를 map 자신의 속성에서만 찾는다. */
18
+ export interface GanttColorBy {
19
+ field: string;
20
+ map: Readonly<Record<string, GanttColorValue>>;
21
+ }
22
+ /**
23
+ * 조건 → 색. eq/neq/in은 타입 변환 없이(1과 '1'은 다름) 비교하고 gt/gte/lt/lte는 유한 number 필드만 비교한다.
24
+ * neq도 필드가 null·누락·객체이면 맞지 않는다.
25
+ */
26
+ export type GanttColorRule = {
27
+ field: string;
28
+ op: 'eq' | 'neq';
29
+ value: GanttColorScalar;
30
+ color: GanttColorValue;
31
+ } | {
32
+ field: string;
33
+ op: 'in';
34
+ value: readonly GanttColorScalar[];
35
+ color: GanttColorValue;
36
+ } | {
37
+ field: string;
38
+ op: 'gt' | 'gte' | 'lt' | 'lte';
39
+ value: number;
40
+ color: GanttColorValue;
41
+ };
42
+ /** 현재 기본 그리기 pass에서 실제로 칠한 이름 있는 색. color는 Canvas에 쓴 해석된 CSS 색이다. */
43
+ export interface GanttLegendEntry {
44
+ readonly name: string;
45
+ readonly color: string;
46
+ }
47
+ /** 범례 위치와 처음 접힘. 생략하면 위쪽·펼침이다. */
48
+ export interface GanttLegendOptions {
49
+ position?: 'top' | 'bottom';
50
+ /** 처음 접힌 상태. 값이 바뀐 update에서만 다시 적용하며 그 밖의 갱신은 사용자의 접힘을 유지한다. */
51
+ collapsed?: boolean;
52
+ }
53
+ /** `{ color: string }` 형태면 이름 있는 색이다. BarColors(`bar`/`text`/`border`)와 BarPattern에는 color가 없다. */
54
+ export declare function isNamedColor(value: unknown): value is GanttNamedColor;
55
+ export declare function matchColorRule(rule: GanttColorRule, value: unknown): boolean;
56
+ export declare function colorByValue(spec: GanttColorBy, value: unknown): GanttColorValue | undefined;
57
+ /** 생성·update에서 데이터·화면을 바꾸기 전에 구조를 확인한다. 필드 미존재·미매칭은 오류가 아니다. */
58
+ export declare function validateColorOptions(options: {
59
+ colorBy?: unknown;
60
+ colorRules?: unknown;
61
+ legend?: unknown;
62
+ }): void;
63
+ type Rgba = readonly [number, number, number, number];
64
+ /** WCAG 2 일반 글자 기준. */
65
+ export declare const MIN_TEXT_CONTRAST = 4.5;
66
+ /**
67
+ * Canvas가 직렬화한 색을 sRGB 채널(0~255)과 alpha(0~1)로 읽는다.
68
+ * - sRGB 표기: `#rgb[a]`, `#rrggbb[aa]`, `rgb[a](…)`.
69
+ * - CSS Color 4 표기: `lab()`·`lch()`·`oklab()`·`oklch()`와 `color()`의 srgb·srgb-linear·display-p3·a98-rgb·prophoto-rgb·xyz·xyz-d50·xyz-d65.
70
+ * sRGB 밖의 색은 sRGB Canvas처럼 채널별로 잘라 낸 값이다.
71
+ * 그 밖의 표기는 null이다. rec2020은 전달 함수 해석(BT.2020 곡선과 디스플레이 감마 2.4)에 따라 흰·검 글자 경계 부근의 휘도가
72
+ * 크게 달라(부호값 0.41에서 0.18과 0.12) 대비를 보장할 수 없으므로 읽지 않는다.
73
+ */
74
+ export declare function parseCssRgb(css: string): Rgba | null;
75
+ /** 두 불투명 색의 WCAG 대비율. */
76
+ export declare function contrastRatio(a: Rgba, b: Rgba): number;
77
+ /** 반투명 색을 불투명한 표면 위에 합성한 불투명 색. 렌더러가 실제로 칠하는 8비트 채널로 반올림한다. */
78
+ export declare function opaqueOver([r, g, b, a]: Rgba, [sr, sg, sb]: Rgba): Rgba;
79
+ /**
80
+ * 기본 글자색이 읽기 기준을 넘으면 유지하고, 아니면 흰색·검은색 중 대비가 큰 쪽을 쓴다(어떤 불투명 배경에서도 4.5:1 이상).
81
+ * 반투명 fill은 렌더러가 대신 칠하는 표면 위 불투명 합성색을 배경으로 본다.
82
+ */
83
+ export declare function readableTextColor(fill: Rgba, surface: Rgba, preferred: Rgba | null, preferredCss: string): string;
84
+ /** 새 색 경로에서 Canvas에 쓸 해석된 CSS 색과 명시하지 않은 라벨 글자색. */
85
+ export interface ResolvedFill {
86
+ readonly css: string;
87
+ readonly text: string;
88
+ }
89
+ /**
90
+ * 색 문자열을 Canvas 직렬화로 검증·정규화하고 결과를 캐시한다. 해석하지 못하거나 글자 대비를 계산할 수 없는 값은 null이며
91
+ * 호출자가 내장 상태색으로 폴백한다. 테마(표면·글자색)가 바뀌면 clear로 다시 계산한다.
92
+ */
93
+ export declare class GanttColorResolver {
94
+ private readonly cache;
95
+ clear(): void;
96
+ resolve(ctx: CanvasRenderingContext2D, value: string, theme: Required<GanttTheme>): ResolvedFill | null;
97
+ }
98
+ export {};
@@ -1,8 +1,13 @@
1
- import { PivotConfigInput, Row, PivotorEvents, TimeAxisSpec } from '../pivotor/types';
1
+ import { PivotConfigInput, Row, PivotorEvents, TimeUnit, TimeAxisSpec } from '../pivotor/types';
2
2
  import { Pivotor } from '../pivotor';
3
3
  import { GanttTaskTransaction } from '../data/GanttTaskStore';
4
- import { GanttCanvasRenderer, PaintBarFn, BarLabelFn, BarColorFn } from './GanttCanvasRenderer';
5
- export interface GanttEditorOptions {
4
+ import { GanttCanvasRenderer, GanttCanvasRendererOptions, PaintBarFn, BarLabelFn, BarColorFn } from './GanttCanvasRenderer';
5
+ /** 보기 복원의 가로 목표. 본문 왼쪽 끝을 time 의 x 에서 shift(CSS px, 왼쪽이 음수)만큼 옮긴 위치에 둔다. */
6
+ export interface ViewScrollTarget {
7
+ time: number;
8
+ shift: number;
9
+ }
10
+ export interface GanttEditorOptions extends Omit<GanttCanvasRendererOptions, 'startField' | 'endField'> {
6
11
  container: HTMLElement;
7
12
  config: PivotConfigInput;
8
13
  /** 조회 데이터 배열. */
@@ -60,13 +65,17 @@ export declare class GanttEditor {
60
65
  private zoomController;
61
66
  private destroyed;
62
67
  private attachFrame;
68
+ /** 옵션이 정한 시간축(줌 적용 전). 고정 tick 보기 복원이 다른 단위를 쓸 때 헤더 계층의 기준이다. */
69
+ private configuredAxis;
63
70
  constructor(opts: GanttEditorOptions);
64
71
  /** 입력 상태 변경은 Canvas/배치/스크롤을 유지하고 wheel 구독만 교체한다. */
65
72
  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;
73
+ updateAppearance(next: Partial<Omit<GanttCanvasRendererOptions, 'startField' | 'endField'>>): void;
74
+ updateLayout(next: Pick<PivotConfigInput, 'rowFields' | 'rowExpansion' | 'labels' | 'rowHeaderResizable' | 'headerBandHeight'>): void;
68
75
  updateTimeAxis(timeAxis: TimeAxisSpec): void;
69
- applyDataChanges(changes: GanttTaskTransaction): void;
76
+ /** 헤더 형식만 바꾼다. 활성 tick(현재 줌)과 스크롤을 유지한 채 시간 열 라벨을 다시 만든다. */
77
+ updateTimeFormat(next: Pick<TimeAxisSpec, 'format' | 'formats'>): void;
78
+ applyDataChanges(changes: Pick<GanttTaskTransaction, 'added' | 'updated' | 'removed'>): void;
70
79
  get rows(): readonly Row[];
71
80
  /** 조회 데이터 교체 시 시간 캐시도 함께 무효화한다. */
72
81
  setData(rows: Row[]): void;
@@ -90,8 +99,59 @@ export declare class GanttEditor {
90
99
  * 외부 button UI 등에서 단순 zoom 만 원하면 이 API.
91
100
  */
92
101
  setZoom(pxPerTick: number): void;
102
+ /** 활성 tick 너비를 바꾸고 실제 변경 여부를 반환한다. onZoom 알림은 호출자가 정한다. */
103
+ private applyTickWidth;
93
104
  zoomAtCenter(width: number): void;
105
+ /** 현재 시간 열과 압축 좌표에서 시각의 본문 x. timeAxis.range 밖은 가까운 끝으로 제한한다. 시간 열이 없으면 null. */
106
+ timeToContentX(ms: number): number | null;
107
+ /** 가로 위치만 바꾼다. 시각을 본문 폭의 시작·중앙·끝에 두고 실제 스크롤 한계로 제한한다. */
108
+ scrollToTime(ms: number, align: 'start' | 'center' | 'end'): void;
109
+ /**
110
+ * [startMs, endMs]가 현재 본문 폭을 채우도록 줌하고 시작 시각을 왼쪽에 둔다. 사용자 줌 잠금과 무관한 명시 초기 표시다.
111
+ * 고정 tick은 min/max, ladder는 단계 한계 안에서 가장 가까운 배율을 쓴다. 실제 배율이 바뀌면 onZoom을 한 번 알린다.
112
+ * 본문 폭이 0이면 아무것도 바꾸지 않고 false.
113
+ */
114
+ fitTimeRange(startMs: number, endMs: number): boolean;
115
+ /** 현재 활성 tick 단위·폭(px). 시간축이 없으면 null. */
116
+ getActiveTick(): {
117
+ unit: TimeUnit;
118
+ width: number;
119
+ } | null;
120
+ /**
121
+ * 저장한 활성 단위·폭을 함께 적용한다. ladder 는 현재 steps 에 있는 단위만 받아 그 step 의 min/max 로, 고정 tick 은 그 단위를
122
+ * 현재 range 에 적용해 minPxPerTick/maxPxPerTick 로 제한한다. range·calendar·timeZone·format·ladder 정의는 그대로 둔다.
123
+ * 단위를 바꾸는 조합이 현재 시간축 검증·열 상한을 통과하지 못하면 화면을 바꾸지 않고 'ignored'. onZoom 은 부르지 않으며
124
+ * 보기 복원 전체를 마친 호출자가 알린다.
125
+ */
126
+ restoreZoom(unit: TimeUnit, width: number): 'changed' | 'same' | 'ignored';
127
+ /** 본문 왼쪽 끝에 보이는 절대 시각. 시간 열이 없으면 null. */
128
+ viewportStartTime(): number | null;
129
+ /** 본문 x 의 절대 시각. 첫 열 앞은 첫 열 시작, 마지막 열 뒤는 마지막 열 끝이다. 시간 열이 없으면 null. */
130
+ timeAtX(x: number): number | null;
131
+ /**
132
+ * 시각의 본문 x. timeToContentX 와 달리 range 로 당기지 않아 첫·마지막 열의 range 바깥 시각도 그 위치다. 압축으로 빠진
133
+ * 비업무 시각은 직전 업무 경계, 첫 열 앞·마지막 열 뒤는 그 열 끝이다. 시간 열이 없으면 null.
134
+ */
135
+ xAtTime(ms: number): number | null;
136
+ /** 본문 pane 이 배치되어 양수 크기를 가졌는지. 0 크기에서 계산한 스크롤 한계는 실제 화면과 다르다. */
137
+ hasLayout(): boolean;
138
+ /**
139
+ * 보기 복원의 스크롤. left 는 본문 왼쪽 끝 목표로, time 의 x(xAtTime)에 shift(CSS px, 왼쪽이 음수)를 더한 위치다. 호출자는
140
+ * 현재 range 안으로 확인한 저장 시각과 그 range 끝 바깥 거리, 또는 복원 전 왼쪽 끝 시각만 넘긴다(null 은 현재 픽셀 유지).
141
+ * range 로 당기지 않아 첫 열의 range 앞부분에 있던 복원 전 시각도 그 위치를 유지하고, 범위 안의 비업무 시각은 기존 압축
142
+ * 투영(직전 업무 경계)을 따른다. top 은 현재 콘텐츠 높이 이하일 때만 적용한다. 무시한 항목은 현재 위치를 유지하며 두 값
143
+ * 모두 실제 스크롤 한계로 제한하고 헤더 transform 을 즉시 맞춘다.
144
+ */
145
+ restoreScroll(left: ViewScrollTarget | null, top: number | null): void;
146
+ /** 고정 tick 의 단위별 헤더 계층. 옵션 단위면 옵션 그대로, 다른 단위면 옵션 계층 중 더 큰 단위만 남긴다(끝 단위는 빌더가 붙인다). */
147
+ private hierarchyFor;
148
+ /** 마지막 시간 열 필드. 줌은 이 tier 의 활성 tick 을 바꾼다. */
149
+ private timeField;
94
150
  destroy(): void;
151
+ private bodyPane;
152
+ private timeRange;
153
+ /** 브라우저 clamp와 같은 [0, 콘텐츠 폭 - 본문 폭] 범위로 제한하고 헤더 동기화를 즉시 실행한다. */
154
+ private scrollBodyTo;
95
155
  /** 현재 config 의 timeAxis 가 ladder 모드인지 검사. */
96
156
  private isLadderMode;
97
157
  /**
@@ -0,0 +1,48 @@
1
+ import { GanttContextMenu, GanttOptions } from '../types';
2
+ import { GanttMessages } from '../locale';
3
+ import { GanttLegendEntry } from './GanttColorRules';
4
+ interface Host {
5
+ element: HTMLElement;
6
+ viewport: HTMLElement;
7
+ options(): GanttOptions<GanttContextMenu>;
8
+ blocked(): boolean;
9
+ labels(): Required<GanttMessages>;
10
+ }
11
+ /**
12
+ * 렌더러가 현재 기본 그리기 pass에서 집계한 이름 있는 색을 목록으로 표시한다. Canvas 색은 바꾸지 않는다.
13
+ * 위치·접힘·문구·차단 상태를 소유하며, 같은 목록의 반복 repaint는 DOM을 건드리지 않고 접기 버튼은 갱신만 해 포커스를 유지한다.
14
+ */
15
+ export declare class GanttLegend {
16
+ private readonly host;
17
+ private readonly root;
18
+ private readonly title;
19
+ private readonly list;
20
+ private readonly toggleHost;
21
+ private toggle;
22
+ /** 마지막으로 반영한 legend 설정. null이면 꺼짐. */
23
+ private config;
24
+ private entries;
25
+ private rendered;
26
+ private collapsed;
27
+ /** 한 번 보인 범례는 스크롤·줌·크기 변경으로 항목이 사라져도 높이를 유지한 채 숨겨 범례 크기 변화 ↔ 집계의 반복을 막는다. */
28
+ private shown;
29
+ /** 데이터·옵션의 명시적 변경 뒤 첫 결과가 비면 높이 유지 없이 완전히 숨긴다. */
30
+ private external;
31
+ private destroyed;
32
+ /** 렌더러 수신자. 목록이 바뀐 pass에서만 호출된다. */
33
+ readonly sink: (entries: readonly GanttLegendEntry[]) => void;
34
+ constructor(host: Host);
35
+ /**
36
+ * 데이터·옵션의 명시적 변경을 알린다. 다음 결과가 비면 높이를 유지하지 않고 숨긴다.
37
+ * 이미 빈 목록(높이 유지 중)이면 렌더러가 같은 빈 결과를 다시 알리지 않으므로 바로 숨긴다.
38
+ */
39
+ invalidate(): void;
40
+ /** 옵션·문구·차단 상태 반영. 위치나 명시 접힘 설정이 바뀔 때만 DOM 위치·접힘을 바꾼다. */
41
+ sync(): void;
42
+ destroy(): void;
43
+ private detach;
44
+ private updateToggle;
45
+ private flip;
46
+ private render;
47
+ }
48
+ export {};
@@ -0,0 +1,110 @@
1
+ import { PhysicalColumn, TimeRange, TimeUnit, ViewportContext } from '../pivotor/types';
2
+ import { GanttMessages } from '../locale';
3
+ import { GanttHeaderMetric, GanttMetric, GanttMetricContext, GanttMetricError, GanttRow, GanttTimeRange } from '../types';
4
+ /** 헤더 지표 한 줄 높이와 그 안의 값 글자 줄·그림 아래 여백(CSS px). */
5
+ export declare const HEADER_METRIC_HEIGHT = 40;
6
+ /** 행 지표 한 줄 높이(CSS px). 지표 수만큼 각 data·소계 슬롯 아래에 더한다. */
7
+ export declare const ROW_METRIC_HEIGHT = 18;
8
+ type TimeColumn = PhysicalColumn & {
9
+ tickStartMs: number;
10
+ tickEndMs: number;
11
+ };
12
+ /** 집계 구간. segments는 압축 달력의 업무 구간이며 없으면 [startMs, endMs) 하나다. 동결된 값이다. */
13
+ export interface MetricBucket {
14
+ readonly key: string;
15
+ readonly startMs: number;
16
+ readonly endMs: number;
17
+ readonly segments: readonly GanttTimeRange[];
18
+ readonly unit: TimeUnit;
19
+ }
20
+ /** 실제 시간 열의 집계 구간. 일부만 보이는 열도 열 전체 구간이다. */
21
+ export declare function metricBucket(col: TimeColumn, unit: TimeUnit): MetricBucket;
22
+ /**
23
+ * 작업 [start, end)가 구간 segments 중 하나와 반열린 구간으로 겹치는지. 0길이 작업·마일스톤은 시각이 [segment.start, segment.end)
24
+ * 안일 때만 포함해 경계 시각이 정확히 한 열에만 속한다. 기존 hasVisibleTime과 같은 경계 의미다.
25
+ */
26
+ export declare function overlapsBucket(start: number, end: number, segments: readonly Readonly<TimeRange>[]): boolean;
27
+ /** 집계 모집단의 필드 해석. skip은 hideRemovedBars로 숨긴 작업이다. */
28
+ export interface MetricFields {
29
+ readonly idField: string;
30
+ readonly startField: string;
31
+ readonly endField: string;
32
+ readonly skip: ((row: GanttRow) => boolean) | null;
33
+ }
34
+ /** 집계 모집단. 작은 집합은 선형 조회, 큰 집합은 시간 구간 인덱스로 후보를 찾은 뒤 정확한 반열린 교차와 ID 중복 제거로 거른다. */
35
+ export declare class MetricRowSet {
36
+ private readonly fields;
37
+ private readonly rows;
38
+ private index;
39
+ private readonly scratch;
40
+ constructor(rows: Iterable<GanttRow>, fields: MetricFields);
41
+ get size(): number;
42
+ /** 구간과 겹치는 고유 작업을 원본 순서로 반환한다. 같은 ID가 여러 번 수집돼도 한 번만 센다. */
43
+ collect(bucket: MetricBucket): GanttRow[];
44
+ }
45
+ /**
46
+ * 지표 하나를 구간의 작업으로 계산한다. count·sum은 내장 규칙, 함수는 동결된 입력으로 동기 호출한다.
47
+ * 비유한 결과·Promise 등 지원하지 않는 반환은 예외로 던져 호출자가 그 구간만 계산 불가로 둔다.
48
+ */
49
+ export declare function computeMetric(metric: GanttMetric, rows: readonly GanttRow[], context: Omit<GanttMetricContext, 'rows' | 'metric'>): number;
50
+ export interface GanttMetricsHost {
51
+ /** Pivotor 컨테이너. 헤더 pane·본문 콘텐츠를 여기서 찾는다(뷰어가 재생성돼도 현재 DOM에 붙는다). */
52
+ readonly viewport: HTMLElement;
53
+ headerMetrics(): readonly GanttHeaderMetric[];
54
+ rowMetrics(): readonly GanttMetric[];
55
+ /** 헤더 지표 모집단: 필터를 통과한 현재 스냅샷. */
56
+ rows(): readonly GanttRow[];
57
+ fields(): MetricFields & {
58
+ readonly labelField: string;
59
+ };
60
+ labels(): Required<GanttMessages>;
61
+ locale(): string;
62
+ timeZone(): string;
63
+ emit(error: GanttMetricError): void;
64
+ }
65
+ /** MozGantt 하나의 헤더·행 지표 DOM과 결과 캐시. 다른 인스턴스와 상태를 공유하지 않는다. */
66
+ export declare class GanttMetrics {
67
+ private readonly host;
68
+ private destroyed;
69
+ private header;
70
+ private rowLayer;
71
+ private headerCache;
72
+ private rowCache;
73
+ private headerSet;
74
+ private groupSets;
75
+ private subtotalGroups;
76
+ private buckets;
77
+ private numberFormat;
78
+ private rangeFormat;
79
+ constructor(host: GanttMetricsHost);
80
+ /** 헤더 띠 높이. 헤더 지표가 없으면 0이라 기존 배치와 같다. */
81
+ headerHeight(): number;
82
+ /** 각 data·소계 슬롯 아래 예약 높이. 행 지표가 없으면 0이다. */
83
+ rowFooterHeight(): number;
84
+ /** 데이터·필터·필드 매핑·시간축·지표 정의·문구가 바뀌면 결과와 모집단 색인을 버린다. 다음 렌더가 가시 구간만 다시 계산한다. */
85
+ invalidate(): void;
86
+ /** 본문 렌더 뒤 같은 가시 영역으로 헤더 띠·행 값을 맞춘다. 새 계산 실패는 DOM 반영 뒤 한 번씩 알린다. */
87
+ readonly render: (ctx: ViewportContext) => void;
88
+ destroy(): void;
89
+ private renderHeader;
90
+ private renderLane;
91
+ private headerResult;
92
+ private headerCell;
93
+ /** 선 표시. 계산 불가 구간에서 선을 끊고 점마다 작은 원을 그린다. points가 null이면 선을 지운다. */
94
+ private drawLine;
95
+ private mountHeader;
96
+ private removeHeader;
97
+ private renderRows;
98
+ /** 표시 행의 집계 범위. separate 슬롯은 그 작업, overlay는 그룹, 소계는 상위 그룹(행 축과 같은 경로 키)의 표시 작업이다. */
99
+ private rowScope;
100
+ private groupSet;
101
+ /** 소계 깊이의 그룹 경로 키 → 표시 작업. 행 축과 같은 pathKey(값의 문자열 결합)로 묶어 데이터 행과 소계 구성이 일치한다. */
102
+ private subtotalRows;
103
+ private removeRows;
104
+ private bucket;
105
+ /** 계산과 표시 문자열 생성. 실패는 그 구간 결과로 격리하고 errors에 모은다. */
106
+ private evaluate;
107
+ private formatNumber;
108
+ private rangeText;
109
+ }
110
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Row, RowHeaderDecoration, RowHeaderTarget } from '../pivotor/types';
2
+ import { GanttContextMenu, GanttOptions } from '../types';
3
+ interface Host {
4
+ /** 현재 데이터 스냅샷. 변경을 commit할 때마다 새 배열이다. */
5
+ rows(): readonly Row[];
6
+ options(): GanttOptions<GanttContextMenu>;
7
+ }
8
+ /**
9
+ * 행 머리글의 선언형 icon·subFields와 rowTooltip이 함께 쓰는 대표 행 해석.
10
+ * - 그룹 열: 현재 데이터 스냅샷에서 그 그룹 경로(prefix)에 속하는 첫 행. 스크롤·정렬·접기와 무관하다.
11
+ * - displayFromSlotIndex 열: 그 slot에 놓인 행 중 스냅샷 순서상 첫 행. 소계·빈 slot은 대표 행이 없다.
12
+ * 색인은 스냅샷·필드 구성이 바뀐 뒤 처음 필요할 때 한 번 만들고, 셀 렌더·포인터 이동에서는 조회만 한다.
13
+ */
14
+ export declare class GanttRowHeaders {
15
+ private host;
16
+ private index;
17
+ constructor(host: Host);
18
+ /** HeaderRenderer의 rowHeaderDecoration. 선언이 없는 열은 색인을 만들지 않고 기존 표시를 유지한다. */
19
+ readonly decorate: (target: RowHeaderTarget) => RowHeaderDecoration | null;
20
+ /** 행 툴팁 문자열. 꺼져 있거나 대표 행이 없거나 결과가 비면 빈 문자열이며 툴팁을 열지 않는다. */
21
+ tooltip(target: RowHeaderTarget): string;
22
+ representative(target: RowHeaderTarget): Row | null;
23
+ private current;
24
+ }
25
+ export {};
@@ -0,0 +1,43 @@
1
+ import { GanttRowId } from '../types';
2
+ /**
3
+ * 한 번의 사용자 입력이 선택에 주는 효과.
4
+ * - replace: 대상 한 개로 교체(일반 클릭·방향키)
5
+ * - toggle: 대상만 추가/해제(Ctrl/Cmd 클릭·Ctrl/Cmd+Space)
6
+ * - range / rangeAdd: anchor~대상 표시 순서 범위로 교체 / 기존 선택에 합침(Shift, Ctrl/Cmd+Shift)
7
+ * - cursor: 선택은 그대로 두고 키보드 탐색 위치만 이동(Ctrl/Cmd+방향키)
8
+ * - context: 선택된 작업이면 목록 보존, 아니면 한 개로 교체(우클릭·Shift+F10)
9
+ */
10
+ export type GanttSelectionGesture = 'replace' | 'toggle' | 'range' | 'rangeAdd' | 'cursor' | 'context';
11
+ /**
12
+ * 선택 목록(추가 순서)·대표·범위 anchor·키보드 cursor를 구별해 보관한다. DOM·이벤트·데이터 저장소와 독립이다.
13
+ * 대표는 목록에서만 정해진다(목록의 마지막 ID, 비면 null). 입력 대상·anchor·cursor는 대표를 바꾸지 않는다.
14
+ */
15
+ export declare class GanttSelectionState {
16
+ private list;
17
+ private members;
18
+ /** Shift 범위의 기준. 일반 선택·토글·API 교체가 갱신하고 연속 Shift는 유지한다. */
19
+ anchor: GanttRowId | null;
20
+ /** 키보드 탐색·활성화 대상. 선택 목록과 별개이며 바뀌어도 selectionChange를 내지 않는다. */
21
+ cursor: GanttRowId | null;
22
+ get ids(): readonly GanttRowId[];
23
+ get size(): number;
24
+ /**
25
+ * 대표: 가장 최근 선택에 추가된 작업. 목록은 추가 순서(교체는 새 목록 순서, 합치기는 새 작업을 끝에 붙임)라
26
+ * 목록의 마지막 ID와 같다. 그 작업이 빠지면 남은 목록의 마지막, 비면 null이다.
27
+ */
28
+ get primary(): GanttRowId | null;
29
+ has(id: GanttRowId): boolean;
30
+ /** 렌더러에 넘길 membership. 호출마다 새 Set이라 이후 상태 변경과 격리된다. */
31
+ memberSet(): ReadonlySet<GanttRowId>;
32
+ /** 목록을 추가 순서 그대로 교체하고 목록(따라서 대표)이 실제로 달라졌는지 반환한다. */
33
+ set(ids: readonly GanttRowId[]): boolean;
34
+ /** 모든 선택과 anchor·cursor를 비운다. 선택이 있었으면 true. */
35
+ clear(): boolean;
36
+ /** 존재하는 ID만 순서대로 남긴다(대표가 빠지면 남은 마지막). 사라진 anchor·cursor는 비운다. 목록이 달라졌으면 true. */
37
+ retain(exists: (id: GanttRowId) => boolean): boolean;
38
+ /**
39
+ * 대상 id에 입력 효과를 적용한다. order는 범위용 현재 표시 순서 ID이며 range 계열에서만 호출한다.
40
+ * 선택 목록(따라서 대표)이 바뀌었으면 true(cursor만 움직이면 false).
41
+ */
42
+ apply(id: GanttRowId, gesture: GanttSelectionGesture, order: () => readonly GanttRowId[]): boolean;
43
+ }
@@ -0,0 +1,48 @@
1
+ import { GanttContextMenu, GanttOptions } from '../types';
2
+ import { GanttNowMarker, GanttTimeMarkerSource } from './GanttCanvasRenderer';
3
+ interface Host {
4
+ element: HTMLElement;
5
+ viewport: HTMLElement;
6
+ options(): GanttOptions<GanttContextMenu>;
7
+ blocked(): boolean;
8
+ /** 기존 viewport 렌더 요청(RAF 병합). */
9
+ render(): void;
10
+ }
11
+ /**
12
+ * 현재 시각선의 주기 작업, 본문 포인터 위치와 비-live 보조 텍스트를 소유한다. 그리기는 Canvas 렌더러가 담당한다.
13
+ * tooltip 옵션이나 프레임워크 timer와 독립이며, 뷰어를 재생성해도 같은 인스턴스를 렌더러에 다시 연결한다.
14
+ */
15
+ export declare class GanttTimeMarkers implements GanttTimeMarkerSource {
16
+ private readonly host;
17
+ private timer;
18
+ private pane;
19
+ private clientX;
20
+ private clientY;
21
+ private label;
22
+ private labelSource;
23
+ private destroyed;
24
+ private readonly point;
25
+ private readonly marker;
26
+ private readonly text;
27
+ constructor(host: Host);
28
+ get enabled(): boolean;
29
+ now(): GanttNowMarker | null;
30
+ cursor(): {
31
+ x: number;
32
+ y: number;
33
+ } | null;
34
+ formatCursor(ms: number): string;
35
+ /** 옵션·차단 상태 반영. 실시간 선일 때만 주기 작업 하나를 유지한다. */
36
+ sync(): void;
37
+ destroy(): void;
38
+ /** 옵션 객체가 바뀔 때만 기본 문구를 다시 계산한다. 같은 update 중의 렌더도 최신 언어를 쓴다. */
39
+ private defaultLabel;
40
+ private live;
41
+ private stop;
42
+ private tick;
43
+ private move;
44
+ private leave;
45
+ /** Canvas 선을 보완하는 비-live 텍스트. 실시간 값은 분 단위로만 바꿔 tick마다 DOM을 갱신하지 않는다. */
46
+ private describe;
47
+ }
48
+ export {};
@@ -1,25 +1,29 @@
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 {
1
+ import { BarFieldGlyphs } from './barFields';
2
+ export interface CacheEntry {
14
3
  bmp: ImageBitmap | HTMLCanvasElement;
15
4
  /** CSS 픽셀 width — drawImage 의 dWidth 에 사용 (5-arg form). bmp 의 backing 은 width*dpr. */
16
5
  width: number;
17
6
  /** CSS 픽셀 height — 마찬가지. */
18
7
  height: number;
8
+ /** 비트맵 위쪽에서 alphabetic baseline 까지의 CSS 픽셀. 한 줄의 여러 비트맵을 baseline 으로 맞출 때 사용. */
9
+ baseline: number;
10
+ readonly text: string;
11
+ readonly font: string;
12
+ /** 잘라 그릴 때만 계산하는 글자 경계. entry 와 함께 LRU·clear 로 해제된다. */
13
+ glyphs?: BarFieldGlyphs;
14
+ }
15
+ /** 글꼴의 한 줄 높이 기준. 글자와 무관한 font metric 이 없으면 대표 글자의 bbox 를 쓴다. */
16
+ export interface FontLineMetrics {
17
+ ascent: number;
18
+ descent: number;
19
19
  }
20
20
  export declare class TextBitmapCache {
21
21
  private map;
22
+ private fonts;
22
23
  private capacity;
24
+ /** hold 동안 목록에서 빠졌지만 아직 그려질 수 있어 close 를 미룬 entry. unhold 에서 닫는다. */
25
+ private readonly retired;
26
+ private holding;
23
27
  /** 통계 — instrumentation 에서 사용 */
24
28
  misses: number;
25
29
  hits: number;
@@ -38,6 +42,21 @@ export declare class TextBitmapCache {
38
42
  */
39
43
  clear(): void;
40
44
  size(): number;
45
+ /**
46
+ * 여러 entry 를 먼저 가져온 뒤 함께 그리는 구간(막대 하나의 다중 필드)을 감싼다. 용량이 그 수보다 작으면 뒤 entry 를
47
+ * 가져올 때 앞 entry 가 LRU 로 밀려난다. 그 사이에는 목록에서만 지워 용량 상한을 지키고, 닫힌 ImageBitmap 은 그릴 수
48
+ * 없으므로 비트맵 close 는 unhold 까지 미룬다.
49
+ */
50
+ hold(): void;
51
+ /** hold 구간을 끝내고 미뤄 둔 비트맵을 닫는다. */
52
+ unhold(): void;
53
+ /**
54
+ * entry 문자열의 글자(코드 포인트)별 오른쪽 끝 위치. 비트맵은 x=1 에서 그리므로 끝 위치도 1 을 더한다.
55
+ * 처음 요청할 때 접두 문자열을 측정하며 이후 같은 entry 는 측정하지 않는다.
56
+ */
57
+ glyphs(entry: CacheEntry): BarFieldGlyphs;
58
+ /** 글꼴 한 줄의 ascent/descent. 테마·DPR 변경(clear)까지 글꼴별로 한 번 측정한다. */
59
+ lineMetrics(font: string): FontLineMetrics;
41
60
  setCapacity(capacity: number): void;
42
61
  private rasterize;
43
62
  private measureCtx;
@@ -46,4 +65,3 @@ export declare class TextBitmapCache {
46
65
  private release;
47
66
  private evictOldest;
48
67
  }
49
- export {};
@@ -0,0 +1,54 @@
1
+ import { Row, RowId } from '../pivotor/types';
2
+ /** 층에 놓인 작업. order는 그룹 원본 순서(painter 순서)다. */
3
+ export interface AutoLevelEntry {
4
+ readonly row: Row;
5
+ readonly id: RowId;
6
+ readonly start: number;
7
+ readonly end: number;
8
+ readonly order: number;
9
+ }
10
+ /** 한 그룹의 배치 결과. 불변으로 취급한다. */
11
+ export interface AutoLevelLayout {
12
+ /** 층 수. 배치할 작업이 없어도 1이다. */
13
+ readonly count: number;
14
+ /** ID → 1-based 층. 배치에서 제외된(숨긴 removed·시간 없음) 작업은 없다. 문자열 '1'과 숫자 1은 다른 키다. */
15
+ readonly levels: ReadonlyMap<RowId, number>;
16
+ /**
17
+ * 0-based 층마다 시작 오름차순 작업. 한 층 안의 작업은 서로 충돌하지 않으므로 시작·끝이 모두 정렬되어 있어
18
+ * 세로로 보이는 층만 골라 시간 구간을 이진 탐색할 수 있다.
19
+ */
20
+ readonly lanes: readonly (readonly AutoLevelEntry[])[];
21
+ }
22
+ /** 배치 입력 해석. 행 필드는 정규화된 epoch ms 숫자다. */
23
+ export interface AutoLevelFields {
24
+ readonly startField: string;
25
+ readonly endField: string;
26
+ /** 행의 ID. 없으면 배치하지 않는다. */
27
+ readonly id: (row: Row) => RowId | null | undefined;
28
+ /** true면 층을 차지하지 않는다(hideRemovedBars로 숨긴 removed). */
29
+ readonly skip?: ((row: Row) => boolean) | null;
30
+ }
31
+ /** 그룹 행(rowFields leaf의 sourceRowsByCol)으로 배치를 계산한다. */
32
+ export declare function layoutAutoLevels(groups: Iterable<readonly Row[]>, fields: AutoLevelFields): AutoLevelLayout;
33
+ /** 숫자 ID < 문자열 ID. 같은 형식이면 숫자는 값, 문자열은 코드 단위 순이다. */
34
+ export declare function compareIds(a: RowId, b: RowId): number;
35
+ /** Canvas·행 축·탐색이 같은 배치를 읽는 공급자. */
36
+ export interface GanttAutoLevelSource {
37
+ /** 그룹 행 Map의 배치. 같은 Map이면 캐시를 재사용한다. */
38
+ get(rows: ReadonlyMap<string, readonly Row[]>): AutoLevelLayout;
39
+ }
40
+ /**
41
+ * 그룹 행 Map 단위 배치 캐시. PivotEngine은 그룹 구성·작업 시간이 바뀌면 그 그룹에 새 Map을 만들므로 Map 동일성으로
42
+ * 유효성을 판단한다(행 수가 달라진 같은 Map도 다시 계산). 스크롤·줌·시간축·언어·테마는 Map을 바꾸지 않아 다시 계산하지 않는다.
43
+ * 설정(필드·숨김 정책)이 바뀌면 소유자가 새 인스턴스로 교체한다. 폐기된 Map의 결과는 WeakMap이라 붙잡지 않는다.
44
+ */
45
+ export declare class GanttAutoLevels implements GanttAutoLevelSource {
46
+ private readonly fields;
47
+ private cache;
48
+ /** 실제 배치 계산 횟수(검증·측정용). 캐시 적중은 세지 않는다. */
49
+ computations: number;
50
+ constructor(fields: AutoLevelFields);
51
+ get(rows: ReadonlyMap<string, readonly Row[]>): AutoLevelLayout;
52
+ /** 모든 그룹 결과를 버린다. */
53
+ clear(): void;
54
+ }