@mogura/moguchart-core 0.5.2
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/LICENSE +21 -0
- package/README.en.md +491 -0
- package/README.md +470 -0
- package/dist/components/gantt-bar.d.ts +38 -0
- package/dist/components/gantt-calendar.d.ts +43 -0
- package/dist/components/gantt-chart-dependency-path.d.ts +15 -0
- package/dist/components/gantt-chart-export.d.ts +20 -0
- package/dist/components/gantt-chart-styles.d.ts +11 -0
- package/dist/components/gantt-chart.d.ts +169 -0
- package/dist/components/gantt-row-background.d.ts +21 -0
- package/dist/components/gantt-row.d.ts +53 -0
- package/dist/core/constants.d.ts +14 -0
- package/dist/core/i18n.d.ts +52 -0
- package/dist/core/patterns.d.ts +21 -0
- package/dist/core/theme.d.ts +2 -0
- package/dist/core/types.d.ts +612 -0
- package/dist/core/utils.d.ts +57 -0
- package/dist/favicon.png +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/moguchart-core.mjs +3163 -0
- package/dist/moguchart-core.umd.js +1115 -0
- package/package.json +76 -0
package/README.md
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
# @mogura/moguchart-core
|
|
2
|
+
|
|
3
|
+
[English](./README.en.md)
|
|
4
|
+
|
|
5
|
+
Vue, React, Angular, Svelte など、どのフレームワークでも動作する、軽量で高機能な Web Components 製ガントチャートコンポーネントです。Lit で構築されています。
|
|
6
|
+
|
|
7
|
+
## 特徴
|
|
8
|
+
|
|
9
|
+
- 🚀 **フレームワーク非依存**: Web Components (Custom Elements) として実装されており、あらゆる環境で動作します。
|
|
10
|
+
- ⚡ **仮想スクロール**: 大量のタスクや行があってもスムーズに動作します。
|
|
11
|
+
- 🖱️ **インタラクティブ**:
|
|
12
|
+
- ドラッグ&ドロップによるタスク移動(行間移動対応)
|
|
13
|
+
- ハンドル操作による期間リサイズ
|
|
14
|
+
- ドラッグ&ドロップによる行の並び替え
|
|
15
|
+
- 列ヘッダーの幅リサイズ
|
|
16
|
+
- 複数タスクの選択&一括ドラッグ(Ctrl/Cmd + クリック)
|
|
17
|
+
- ダブルクリックや右クリックイベントのハンドリング
|
|
18
|
+
- 🎨 **高度なカスタマイズ**:
|
|
19
|
+
- タスクバー、行ヘッダー、ツールチップ、ドラッグ情報のコンテンツを自由にレンダリング可能
|
|
20
|
+
- ライト/ダーク/システムテーマの切り替え+カスタムカラーテーマ
|
|
21
|
+
- タスクバーの塗りつぶしパターン(ストライプ、ドット、チェッカーボードなど13種類)
|
|
22
|
+
- CSSによるスタイリング
|
|
23
|
+
- 🔗 **依存関係の表示**: タスク間の依存関係を矢印付き曲線で可視化(S字カーブ対応)
|
|
24
|
+
- 📅 **柔軟なカレンダー**:
|
|
25
|
+
- 日単位 / 週単位 / 月単位の表示切り替え
|
|
26
|
+
- ズームレベル(1日・1ヶ月あたりの幅)や表示期間の調整が可能
|
|
27
|
+
- 現在時刻ラインの表示(バッジ付き、自動更新対応)
|
|
28
|
+
- 祝日判定のカスタムロジック
|
|
29
|
+
- 週の始まり曜日の設定
|
|
30
|
+
- ロケール対応(日本語・英語、カスタムロケールも可能)
|
|
31
|
+
- 🏁 **マイルストーン**: チャート上にマイルストーン(縦線+名前バッジ)を表示
|
|
32
|
+
- 📍 **マーカー**: 行のタイムライン上に三角形アイコンとラベルで目印を表示
|
|
33
|
+
- ✨ **高度な連携**:
|
|
34
|
+
- 外部からのドラッグ&ドロップによるタスク作成
|
|
35
|
+
- タスクの移動/コピーモード
|
|
36
|
+
- スナップ機能(時間単位でのグリッドスナップ)
|
|
37
|
+
- 座標から行・日時を取得する `hitTest` メソッド
|
|
38
|
+
- プログラムによるタスク選択+自動スクロール (`selectTask`)
|
|
39
|
+
- ⌨️ **キーボード操作**: 矢印キーでのナビゲーション・選択・Shift+矢印キーでのタスク移動・Deleteキーでの削除
|
|
40
|
+
|
|
41
|
+
## インストール
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pnpm add @mogura/moguchart-core
|
|
45
|
+
# または
|
|
46
|
+
npm install @mogura/moguchart-core
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## APIリファレンス
|
|
50
|
+
|
|
51
|
+
詳細な API リファレンスは [API.md](./doc/API.md) を参照してください。
|
|
52
|
+
|
|
53
|
+
## Vue.js での使用例
|
|
54
|
+
|
|
55
|
+
Vue.js (Vue 3) で使用する場合のサンプルです。
|
|
56
|
+
Web Components を使用するため、`vite.config.ts` などでカスタム要素として認識させる設定が必要な場合があります。
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<script setup lang="ts">
|
|
60
|
+
import { ref } from 'vue'
|
|
61
|
+
import '@mogura/moguchart-core'
|
|
62
|
+
import type {
|
|
63
|
+
GanttRow,
|
|
64
|
+
GanttChartOption,
|
|
65
|
+
TaskUpdateEventDetail,
|
|
66
|
+
} from '@mogura/moguchart-core'
|
|
67
|
+
|
|
68
|
+
const rows = ref<GanttRow[]>([
|
|
69
|
+
{
|
|
70
|
+
id: 'row-1',
|
|
71
|
+
name: 'Project A',
|
|
72
|
+
tasks: [
|
|
73
|
+
{
|
|
74
|
+
id: 't-1',
|
|
75
|
+
name: 'Task 1',
|
|
76
|
+
start: new Date('2024-01-01'),
|
|
77
|
+
end: new Date('2024-01-05'),
|
|
78
|
+
style: 'background-color: #60a5fa',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
markers: [
|
|
82
|
+
{
|
|
83
|
+
id: 'marker-1',
|
|
84
|
+
name: 'レビュー期限',
|
|
85
|
+
date: new Date('2024-01-03'),
|
|
86
|
+
type: 'triangle-down',
|
|
87
|
+
color: '#ef4444',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
])
|
|
92
|
+
|
|
93
|
+
const option = ref<GanttChartOption>({
|
|
94
|
+
calendar: {
|
|
95
|
+
start: new Date('2024-01-01'),
|
|
96
|
+
end: new Date('2024-03-31'),
|
|
97
|
+
pxPerDay: 30,
|
|
98
|
+
showCurrentTime: true,
|
|
99
|
+
milestones: [
|
|
100
|
+
{
|
|
101
|
+
id: 'ms-1',
|
|
102
|
+
name: 'リリース',
|
|
103
|
+
start: new Date('2024-02-01'),
|
|
104
|
+
color: '#8b5cf6',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
bar: { height: 28 },
|
|
109
|
+
rowHeader: { width: 200 },
|
|
110
|
+
theme: 'system',
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
const handleTaskUpdate = (e: Event) => {
|
|
114
|
+
const detail = (e as CustomEvent<TaskUpdateEventDetail>).detail
|
|
115
|
+
console.log('Task updated:', detail)
|
|
116
|
+
}
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<template>
|
|
120
|
+
<div style="height: 500px;">
|
|
121
|
+
<gantt-chart
|
|
122
|
+
:rows="rows"
|
|
123
|
+
:option="option"
|
|
124
|
+
@task-update="handleTaskUpdate"
|
|
125
|
+
></gantt-chart>
|
|
126
|
+
</div>
|
|
127
|
+
</template>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## React での使用例
|
|
131
|
+
|
|
132
|
+
React で使用する場合のサンプルです。
|
|
133
|
+
Web Components のプロパティやイベントを扱うため、`ref` を使用して実装します。
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { useEffect, useRef, useState } from 'react'
|
|
137
|
+
import '@mogura/moguchart-core'
|
|
138
|
+
import type {
|
|
139
|
+
GanttRow,
|
|
140
|
+
GanttChartOption,
|
|
141
|
+
TaskUpdateEventDetail,
|
|
142
|
+
} from '@mogura/moguchart-core'
|
|
143
|
+
|
|
144
|
+
// TypeScript で使用する場合の型定義
|
|
145
|
+
declare global {
|
|
146
|
+
namespace JSX {
|
|
147
|
+
interface IntrinsicElements {
|
|
148
|
+
'gantt-chart': any
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default function App() {
|
|
154
|
+
const chartRef = useRef<any>(null)
|
|
155
|
+
|
|
156
|
+
const [rows] = useState<GanttRow[]>([
|
|
157
|
+
{
|
|
158
|
+
id: 'row-1',
|
|
159
|
+
name: 'Project A',
|
|
160
|
+
tasks: [
|
|
161
|
+
{
|
|
162
|
+
id: 't-1',
|
|
163
|
+
name: 'Task 1',
|
|
164
|
+
start: new Date('2024-01-01'),
|
|
165
|
+
end: new Date('2024-01-05'),
|
|
166
|
+
style: 'background-color: #60a5fa',
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
markers: [
|
|
170
|
+
{
|
|
171
|
+
id: 'marker-1',
|
|
172
|
+
name: 'レビュー期限',
|
|
173
|
+
date: new Date('2024-01-03'),
|
|
174
|
+
type: 'triangle-down',
|
|
175
|
+
color: '#ef4444',
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
])
|
|
180
|
+
|
|
181
|
+
const [option] = useState<GanttChartOption>({
|
|
182
|
+
calendar: {
|
|
183
|
+
start: new Date('2024-01-01'),
|
|
184
|
+
end: new Date('2024-03-31'),
|
|
185
|
+
pxPerDay: 30,
|
|
186
|
+
showCurrentTime: true,
|
|
187
|
+
milestones: [
|
|
188
|
+
{
|
|
189
|
+
id: 'ms-1',
|
|
190
|
+
name: 'リリース',
|
|
191
|
+
start: new Date('2024-02-01'),
|
|
192
|
+
color: '#8b5cf6',
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
bar: { height: 28 },
|
|
197
|
+
rowHeader: { width: 200 },
|
|
198
|
+
theme: 'system',
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
const chart = chartRef.current
|
|
203
|
+
if (!chart) return
|
|
204
|
+
|
|
205
|
+
// プロパティの設定
|
|
206
|
+
chart.rows = rows
|
|
207
|
+
chart.option = option
|
|
208
|
+
|
|
209
|
+
// イベントリスナーの設定
|
|
210
|
+
const handleTaskUpdate = (e: Event) => {
|
|
211
|
+
const detail = (e as CustomEvent<TaskUpdateEventDetail>).detail
|
|
212
|
+
console.log('Task updated:', detail)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
chart.addEventListener('task-update', handleTaskUpdate)
|
|
216
|
+
|
|
217
|
+
return () => {
|
|
218
|
+
chart.removeEventListener('task-update', handleTaskUpdate)
|
|
219
|
+
}
|
|
220
|
+
}, [rows, option])
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<div style={{ height: '500px' }}>
|
|
224
|
+
<gantt-chart ref={chartRef}></gantt-chart>
|
|
225
|
+
</div>
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## 主要機能
|
|
231
|
+
|
|
232
|
+
### テーマ
|
|
233
|
+
|
|
234
|
+
ライト/ダーク/システムの3つのテーマモードをサポートしています。`customTheme` で個別のカラーを上書きすることも可能です。
|
|
235
|
+
|
|
236
|
+
```javascript
|
|
237
|
+
const option = {
|
|
238
|
+
theme: 'dark', // 'light' | 'dark' | 'system'
|
|
239
|
+
customTheme: {
|
|
240
|
+
bg: '#1a1a2e',
|
|
241
|
+
text: '#e0e0e0',
|
|
242
|
+
currentTimeLine: '#ff6b6b',
|
|
243
|
+
},
|
|
244
|
+
// ...
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### マイルストーン
|
|
249
|
+
|
|
250
|
+
`calendar.milestones` にマイルストーンの配列を渡すことで、チャート上に縦線とバッジを表示できます。マウスオーバーで透明度が変化するホバーエフェクト付きです。
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
option.calendar.milestones = [
|
|
254
|
+
{
|
|
255
|
+
id: 'ms-1',
|
|
256
|
+
name: 'α版リリース',
|
|
257
|
+
start: new Date('2025-04-08'),
|
|
258
|
+
color: '#8b5cf6',
|
|
259
|
+
width: 4,
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
id: 'ms-2',
|
|
263
|
+
name: '正式リリース',
|
|
264
|
+
start: new Date('2025-05-01'),
|
|
265
|
+
color: '#10b981',
|
|
266
|
+
},
|
|
267
|
+
]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### マーカー
|
|
271
|
+
|
|
272
|
+
各行の `markers` プロパティにマーカーの配列を渡すことで、タイムライン上に三角形アイコンとラベルを表示できます。
|
|
273
|
+
|
|
274
|
+
```javascript
|
|
275
|
+
const rows = [
|
|
276
|
+
{
|
|
277
|
+
id: 'row-1',
|
|
278
|
+
name: 'タスクA',
|
|
279
|
+
tasks: [/* ... */],
|
|
280
|
+
markers: [
|
|
281
|
+
{
|
|
282
|
+
id: 'marker-1',
|
|
283
|
+
name: 'レビュー期限',
|
|
284
|
+
date: new Date('2025-04-10'),
|
|
285
|
+
anchor: 'end',
|
|
286
|
+
type: 'triangle-right',
|
|
287
|
+
color: '#ef4444',
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
]
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### タスクバーのパターン
|
|
295
|
+
|
|
296
|
+
タスクバーに13種類の塗りつぶしパターンを適用できます。プリセット定数も用意されています。
|
|
297
|
+
|
|
298
|
+
```javascript
|
|
299
|
+
import { PATTERN_DIAGONAL_STRIPE } from '@mogura/moguchart-core'
|
|
300
|
+
|
|
301
|
+
const task = {
|
|
302
|
+
id: 't-1',
|
|
303
|
+
name: 'WIP',
|
|
304
|
+
start: new Date('2024-01-01'),
|
|
305
|
+
end: new Date('2024-01-05'),
|
|
306
|
+
style: 'background-color: #60a5fa',
|
|
307
|
+
pattern: PATTERN_DIAGONAL_STRIPE, // プリセット使用
|
|
308
|
+
// または直接指定:
|
|
309
|
+
// pattern: { type: 'checkerboard', color: '#ffffff80' }
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
利用可能なパターン: `diagonal-stripe` `diagonal-stripe-thin` `diagonal-stripe-thick` `diagonal-stripe-reverse` `vertical-stripe` `horizontal-stripe` `checkerboard` `dots` `dots-dense` `triangle` `circle` `grid` `diagonal-grid`
|
|
314
|
+
|
|
315
|
+
### 行の並び替え
|
|
316
|
+
|
|
317
|
+
`enableRowReordering: true` でドラッグ&ドロップによる行の並び替えが有効になります。
|
|
318
|
+
|
|
319
|
+
```javascript
|
|
320
|
+
const option = {
|
|
321
|
+
enableRowReordering: true,
|
|
322
|
+
// ...
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
chart.addEventListener('row-reordered', (e) => {
|
|
326
|
+
console.log('並び替え後の行データ:', e.detail.rows)
|
|
327
|
+
})
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### 複数タスクの選択&一括操作
|
|
331
|
+
|
|
332
|
+
`Ctrl`(Mac: `Cmd`)キーを押しながらタスクバーをクリックして複数選択し、一括でドラッグ移動できます。
|
|
333
|
+
|
|
334
|
+
```javascript
|
|
335
|
+
chart.addEventListener('task-update', (e) => {
|
|
336
|
+
const detail = e.detail
|
|
337
|
+
if (!detail.isDragging && detail.selectedTaskIds?.length > 1) {
|
|
338
|
+
// 複数選択ドラッグのドロップ: 全選択タスクに同じdxを適用
|
|
339
|
+
for (const taskId of detail.selectedTaskIds) {
|
|
340
|
+
applyDxToTask(taskId, detail.dx)
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### スナップ機能
|
|
347
|
+
|
|
348
|
+
`snapDuration`(分単位)でタスクのドラッグ時のスナップ間隔を制御できます。月表示モード(`pxPerMonth` 指定時)では、スナップは自動的に月単位になります。
|
|
349
|
+
|
|
350
|
+
```javascript
|
|
351
|
+
const option = {
|
|
352
|
+
snapDuration: 60, // 1時間ごとにスナップ (デフォルト: 1440 = 1日)
|
|
353
|
+
// ...
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### 表示モード
|
|
358
|
+
|
|
359
|
+
#### 週表示モード
|
|
360
|
+
|
|
361
|
+
`calendar.showWeeks: true` で週番号表示の2段カレンダーになります。`pxPerDay` が20未満の場合は自動的に有効化されます。
|
|
362
|
+
|
|
363
|
+
```javascript
|
|
364
|
+
const option = {
|
|
365
|
+
calendar: {
|
|
366
|
+
start: new Date('2025-01-01'),
|
|
367
|
+
end: new Date('2025-12-31'),
|
|
368
|
+
pxPerDay: 15,
|
|
369
|
+
showWeeks: true,
|
|
370
|
+
weekStartDay: 1, // 1=月曜始まり (デフォルト)
|
|
371
|
+
weekFormat: (weekNum) => `W${weekNum}`,
|
|
372
|
+
},
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
#### 月表示モード
|
|
377
|
+
|
|
378
|
+
`calendar.pxPerMonth` を設定すると、各月が等幅で表示される月単位ビューになります。
|
|
379
|
+
|
|
380
|
+
```javascript
|
|
381
|
+
const option = {
|
|
382
|
+
calendar: {
|
|
383
|
+
start: new Date('2025-01-01'),
|
|
384
|
+
end: new Date('2027-12-31'),
|
|
385
|
+
pxPerDay: 1,
|
|
386
|
+
pxPerMonth: 120, // 1ヶ月あたり120px
|
|
387
|
+
showMonthsRow: true, // 上段=年、下段=月の2段ヘッダー
|
|
388
|
+
},
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### 依存関係線の設定
|
|
393
|
+
|
|
394
|
+
`dependency` オプションで依存関係線の表示をカスタマイズできます。矢印の表示/非表示や大きさを制御できます。
|
|
395
|
+
右→左方向の依存関係では自動的にS字カーブで描画され、接触箇所は常に水平に接続します。
|
|
396
|
+
|
|
397
|
+
```javascript
|
|
398
|
+
const option = {
|
|
399
|
+
dependency: {
|
|
400
|
+
showArrows: true, // 矢印を表示するかどうか (デフォルト: true)
|
|
401
|
+
arrowSize: 12, // 矢印の大きさ (px、デフォルト: 8)
|
|
402
|
+
},
|
|
403
|
+
// ...
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### ロケール
|
|
408
|
+
|
|
409
|
+
ツールチップやドラッグオーバーレイの表示文字列を変更できます。`jaLocale`(デフォルト)と `enLocale` が内蔵されています。
|
|
410
|
+
|
|
411
|
+
```javascript
|
|
412
|
+
import { enLocale } from '@mogura/moguchart-core'
|
|
413
|
+
|
|
414
|
+
const option = {
|
|
415
|
+
locale: enLocale,
|
|
416
|
+
// ...
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### パブリックメソッド
|
|
421
|
+
|
|
422
|
+
#### selectTask
|
|
423
|
+
|
|
424
|
+
指定したIDのタスクを選択状態にし、画面外の場合は自動スクロールします。
|
|
425
|
+
|
|
426
|
+
```javascript
|
|
427
|
+
const chart = document.querySelector('gantt-chart')
|
|
428
|
+
const found = chart.selectTask('task-1')
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
#### hitTest
|
|
432
|
+
|
|
433
|
+
クライアント座標(画面上のピクセル位置)から、対応する行IDと日時を返します。
|
|
434
|
+
|
|
435
|
+
```javascript
|
|
436
|
+
document.addEventListener('mousemove', (e) => {
|
|
437
|
+
const result = chart.hitTest(e.clientX, e.clientY)
|
|
438
|
+
if (result) {
|
|
439
|
+
console.log(`行: ${result.rowId}, 日付: ${result.date}`)
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### キーボード操作
|
|
445
|
+
|
|
446
|
+
ガントチャートにフォーカスがある状態で、キーボードによるタスクのナビゲーション・選択・移動・削除が可能です。
|
|
447
|
+
|
|
448
|
+
| キー | 動作 |
|
|
449
|
+
| :--- | :--- |
|
|
450
|
+
| `←` `→` | フォーカスをタスク間で移動 |
|
|
451
|
+
| `↑` `↓` | フォーカスを別の行に移動 |
|
|
452
|
+
| `Enter` / `Space` | フォーカス中のタスクを選択 |
|
|
453
|
+
| `Ctrl/Cmd + Enter` | 選択をトグル(複数選択) |
|
|
454
|
+
| `Shift + ←` `→` | 選択中のタスクを移動 |
|
|
455
|
+
| `Delete` / `Backspace` | `task-delete` イベントを発火 |
|
|
456
|
+
| `Escape` | 選択・フォーカスをクリア |
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
const option = {
|
|
460
|
+
keyboard: {
|
|
461
|
+
enabled: true, // デフォルト: true
|
|
462
|
+
moveStep: 60, // Shift+矢印キーでの移動量(分)
|
|
463
|
+
},
|
|
464
|
+
// ...
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## ライセンス
|
|
469
|
+
|
|
470
|
+
MIT
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
import type { GanttTask, GanttChartOption } from '../core/types';
|
|
3
|
+
export declare class GanttBarElement extends LitElement {
|
|
4
|
+
task: GanttTask;
|
|
5
|
+
option: GanttChartOption;
|
|
6
|
+
lane: number;
|
|
7
|
+
selected: boolean;
|
|
8
|
+
focused: boolean;
|
|
9
|
+
multiDragDx: number;
|
|
10
|
+
multiDragActive: boolean;
|
|
11
|
+
connectorDropTarget: boolean;
|
|
12
|
+
isExporting: boolean;
|
|
13
|
+
private _currentDragCursor;
|
|
14
|
+
private _dragAnimationFrame;
|
|
15
|
+
private _wasDragging;
|
|
16
|
+
static styles: import("lit").CSSResult;
|
|
17
|
+
private getX;
|
|
18
|
+
private setupDragEvents;
|
|
19
|
+
private onResizeStart;
|
|
20
|
+
private onMoveStart;
|
|
21
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
22
|
+
disconnectedCallback(): void;
|
|
23
|
+
private handleKeyDown;
|
|
24
|
+
private handleKeyUp;
|
|
25
|
+
private updateCursor;
|
|
26
|
+
private onMouseEnter;
|
|
27
|
+
private onMouseLeave;
|
|
28
|
+
private onDblClick;
|
|
29
|
+
private onClick;
|
|
30
|
+
private onConnectorDragStart;
|
|
31
|
+
private onContextMenu;
|
|
32
|
+
render(): import("lit").TemplateResult<1>;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'gantt-bar': GanttBarElement;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { GanttChartOption, CalendarMonthCellContext, CalendarDayCellContext, CalendarWeekCellContext, CalendarHourCellContext } from '../core/types';
|
|
3
|
+
export declare class GanttCalendarElement extends LitElement {
|
|
4
|
+
option: GanttChartOption;
|
|
5
|
+
theme: 'light' | 'dark';
|
|
6
|
+
currentTime: Date;
|
|
7
|
+
hoveredMilestoneId: string | null;
|
|
8
|
+
cornerContent?: () => string | unknown;
|
|
9
|
+
calendarMonthContent?: (context: CalendarMonthCellContext) => string | unknown;
|
|
10
|
+
calendarDayContent?: (context: CalendarDayCellContext) => string | unknown;
|
|
11
|
+
calendarWeekContent?: (context: CalendarWeekCellContext) => string | unknown;
|
|
12
|
+
calendarHourContent?: (context: CalendarHourCellContext) => string | unknown;
|
|
13
|
+
/**
|
|
14
|
+
* カスタムレンダリング関数の返却値をターゲット要素に注入するヘルパー
|
|
15
|
+
* HTMLElement の場合は appendChild、文字列の場合は innerHTML に設定する
|
|
16
|
+
*/
|
|
17
|
+
private injectCustomContent;
|
|
18
|
+
protected updated(): void;
|
|
19
|
+
/**
|
|
20
|
+
* カレンダーセルのカスタムレンダリングコンテンツを注入する
|
|
21
|
+
*/
|
|
22
|
+
private injectCalendarCustomContent;
|
|
23
|
+
private _cachedDays;
|
|
24
|
+
private _cachedMonths;
|
|
25
|
+
private _cachedYears;
|
|
26
|
+
private _cachedWeeks;
|
|
27
|
+
private _cachedStartTime;
|
|
28
|
+
private _cachedEndTime;
|
|
29
|
+
private _cachedPxPerDay;
|
|
30
|
+
private _cachedPxPerMonth;
|
|
31
|
+
private _cachedWeekStartDay;
|
|
32
|
+
private get totalDays();
|
|
33
|
+
static styles: import("lit").CSSResult;
|
|
34
|
+
private getDateX;
|
|
35
|
+
private formatTime;
|
|
36
|
+
private _buildWeeks;
|
|
37
|
+
render(): import("lit").TemplateResult<1>;
|
|
38
|
+
}
|
|
39
|
+
declare global {
|
|
40
|
+
interface HTMLElementTagNameMap {
|
|
41
|
+
'gantt-calendar': GanttCalendarElement;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 直角折れ線(角丸)の SVG パスを生成するヘルパー関数。
|
|
3
|
+
* @param startX 接続元 X(バー右端)
|
|
4
|
+
* @param startY 接続元 Y(バー中央)
|
|
5
|
+
* @param endX 接続先 X(バー左端、矢印なし時と共通)
|
|
6
|
+
* @param endY 接続先 Y(バー中央)
|
|
7
|
+
* @param adjustedEndX 矢印表示時の終端 X(矢印サイズ分手前)
|
|
8
|
+
* @param barHeight バー高さ(迂回ルート計算用)
|
|
9
|
+
* @param barMargin バーマージン(迂回ルート計算用)
|
|
10
|
+
* @param r 角丸半径 (px)
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildOrthogonalPath(startX: number, startY: number, endX: number, endY: number, adjustedEndX: number, barHeight: number, barMargin: number, r: number): {
|
|
13
|
+
pathD: string;
|
|
14
|
+
hitPathD: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ガントチャートを SVG または PNG 画像としてエクスポートするユーティリティ。
|
|
3
|
+
*
|
|
4
|
+
* Shadow DOM の cloneNode では内部コンテンツがコピーされないため、
|
|
5
|
+
* rows / option / theme などのデータから SVG を直接描画します。
|
|
6
|
+
*/
|
|
7
|
+
export interface ExportImageOptions {
|
|
8
|
+
/** ダウンロード時のファイル名(拡張子なし)。省略時は 'gantt-chart' */
|
|
9
|
+
filename?: string;
|
|
10
|
+
/** true の場合、自動的にファイルダウンロードを開始する。デフォルト: false */
|
|
11
|
+
download?: boolean;
|
|
12
|
+
/** PNG 出力時のスケール倍率(高解像度化)。デフォルト: 2 */
|
|
13
|
+
scale?: number;
|
|
14
|
+
/** 画像を指定したピクセル数で縦に分割し、分割位置にカレンダー(ヘッダー)を挿入する。未指定時は分割しない */
|
|
15
|
+
splitHeight?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* html2canvas-pro を使用してエクスポートする(Shadow DOMネイティブ対応版)
|
|
19
|
+
*/
|
|
20
|
+
export declare function exportGanttWithHtml2Canvas(chartElement: HTMLElement, format?: 'png' | 'pdf', options?: ExportImageOptions): Promise<string | Blob>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ThemeColorPalette } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* GanttChartElement の Static CSS スタイル。
|
|
4
|
+
* Shadow DOM 内に適用される固定スタイルです。
|
|
5
|
+
*/
|
|
6
|
+
export declare const ganttChartStyles: import("lit").CSSResult;
|
|
7
|
+
/**
|
|
8
|
+
* テーマに応じた動的インラインスタイル文字列を生成する。
|
|
9
|
+
* render() 内の <style> タグで使用します。
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildDynamicStyles(theme: 'light' | 'dark', customTheme?: Partial<ThemeColorPalette>): string;
|