@aiquants/directory-tree 3.0.4 → 3.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/src/types.ts ADDED
@@ -0,0 +1,619 @@
1
+ /**
2
+ * @file This file defines types related to the DirectoryTree component.
3
+ * このファイルは、DirectoryTree コンポーネントに関連する型を定義します。
4
+ */
5
+
6
+ import type { VirtualScroll } from "@aiquants/virtualscroll"
7
+ import type { ComponentProps, CSSProperties, ReactNode } from "react"
8
+
9
+ /**
10
+ * @type DirectoryEntry
11
+ * @description Represents an entry in the directory tree, which can be a file or a directory.
12
+ * ディレクトリツリー内のエントリを表す。ファイルまたはディレクトリの場合がある。
13
+ * @property {string} name - Name of the entry. エントリ名。
14
+ * @property {ReactNode} [label] - Optional label to render instead of name. 名前のかわりに描画する任意のラベル。
15
+ * @property {"file" | "directory"} type - Type of the entry. エントリの種別。
16
+ * @property {string} absolutePath - Absolute path of the entry. エントリの絶対パス。
17
+ * @property {string} relativePath - Relative path of the entry. エントリの相対パス。
18
+ * @property {DirectoryEntry[]} [children] - Child entries if it's a directory. ディレクトリの場合の子エントリ。
19
+ * @property {DirectoryTreeIconRenderer} [icon] - Optional icon renderer for the entry. エントリ用の任意のアイコン描画設定。
20
+ */
21
+ export type DirectoryEntry = {
22
+ name: string
23
+ label?: ReactNode
24
+ type: "file" | "directory"
25
+ absolutePath: string
26
+ relativePath: string
27
+ children?: DirectoryEntry[]
28
+ icon?: DirectoryTreeIconRenderer
29
+ /**
30
+ * Optional CSS class name for the entry.
31
+ * エントリ用のオプション CSS クラス名。
32
+ */
33
+ className?: string
34
+ /**
35
+ * Optional inline styles for the entry.
36
+ * エントリ用のオプションのインラインスタイル。
37
+ */
38
+ style?: CSSProperties
39
+ }
40
+
41
+ /**
42
+ * Row height for directory tree entries.
43
+ * Either a fixed pixel value applied to every row, or a function computing the
44
+ * height per entry (for variable-height rows). When a function is supplied it
45
+ * receives the entry and its flattened (visible) index.
46
+ *
47
+ * ディレクトリツリー各行の高さ。
48
+ * 全行に適用する固定ピクセル値、またはエントリごとに高さを算出する関数(可変高さ行)。
49
+ * 関数を渡す場合は、エントリとフラット化後(表示上)のインデックスが渡される。
50
+ *
51
+ * @remarks
52
+ * 関数を渡す場合は参照を安定させること(例: `useCallback`)。identity が毎レンダー
53
+ * 変わると仮想スクロールの高さモデルが都度再計算され、パフォーマンスが劣化する。
54
+ *
55
+ * 不正値(`NaN` / `Infinity` / `0` / 負値)を返した行は既定 20px にフォールバックする。
56
+ *
57
+ * 高さを実行時に変更する場合、可視外アイテムのスクロールバー総高は一時的に旧値のまま
58
+ * となり、スクロールに伴い自己修復される(表示中の行と接続線は即座に正確)。変更直後から
59
+ * 総高を厳密にしたい場合は `virtualScroll.behaviorOptions.resetOnGetItemHeightChange` を
60
+ * 有効化する。
61
+ */
62
+ export type ItemHeight = number | ((entry: DirectoryEntry, index: number) => number)
63
+
64
+ /**
65
+ * Context object passed to icon renderer functions.
66
+ * アイコン描画関数に渡されるコンテキストオブジェクト。
67
+ */
68
+ export type DirectoryTreeIconRenderContext = {
69
+ entry: DirectoryEntry
70
+ isDirectory: boolean
71
+ isExpanded: boolean
72
+ isSelected: boolean
73
+ isItemSelected: boolean
74
+ extension?: string
75
+ }
76
+
77
+ /**
78
+ * Type definition for icon renderer.
79
+ * アイコン描画ロジックの定義。
80
+ */
81
+ export type DirectoryTreeIconRenderer = ReactNode | ((context: DirectoryTreeIconRenderContext) => ReactNode)
82
+
83
+ /**
84
+ * Icon override options for directory tree entries.
85
+ * ディレクトリツリーエントリのアイコン差し替えオプション。
86
+ */
87
+ export type DirectoryTreeIconOverrides = {
88
+ directory?: DirectoryTreeIconRenderer
89
+ directoryExpanded?: DirectoryTreeIconRenderer
90
+ file?: DirectoryTreeIconRenderer
91
+ fileByExtension?: Record<string, DirectoryTreeIconRenderer>
92
+ }
93
+
94
+ /**
95
+ * Highlight styles configuration for hover and selection states.
96
+ * ホバー時および選択時のハイライトスタイルの設定。
97
+ */
98
+ export type HighlightStyles = {
99
+ /** CSS class name for hover state. / ホバー時の CSS クラス名。 */
100
+ hoverClassName?: string
101
+ /** Inline style for hover state. / ホバー時のインラインスタイル。 */
102
+ hoverStyle?: CSSProperties
103
+ /** CSS class name for selected directory. / ディレクトリ選択時の CSS クラス名。 */
104
+ directorySelectedClassName?: string
105
+ /** Inline style for selected directory. / ディレクトリ選択時のインラインスタイル。 */
106
+ directorySelectedStyle?: CSSProperties
107
+ /** CSS class name for selected item (file). / アイテム(ファイル)選択時の CSS クラス名。 */
108
+ itemSelectedClassName?: string
109
+ /** Inline style for selected item (file). / アイテム(ファイル)選択時のインラインスタイル。 */
110
+ itemSelectedStyle?: CSSProperties
111
+ }
112
+
113
+ /**
114
+ * Event object passed to the onEntryClick callback.
115
+ * onEntryClick コールバックに渡されるイベントオブジェクト。
116
+ */
117
+ export type DirectoryTreeClickEvent = {
118
+ /** The entry that was clicked. / クリックされたエントリ。 */
119
+ entry: DirectoryEntry
120
+ /** Whether the entry is a directory. / エントリがディレクトリかどうか。 */
121
+ isDirectory: boolean
122
+ /** Whether the directory is currently expanded (always false for files). / ディレクトリが展開中か (ファイルは常に false)。 */
123
+ isExpanded: boolean
124
+ /**
125
+ * Call to prevent the default behavior.
126
+ * For directories, this prevents the expand/collapse toggle.
127
+ * For files, this is a no-op (there is no default behavior to prevent).
128
+ *
129
+ * デフォルト動作を抑制する。
130
+ * ディレクトリの場合、展開/折りたたみのトグルを抑制する。
131
+ * ファイルの場合、抑制するデフォルト動作がないため何もしない。
132
+ */
133
+ preventDefault: () => void
134
+ }
135
+
136
+ /**
137
+ * Options for configuring virtual scroll behavior.
138
+ * 仮想スクロールの挙動を設定するためのオプション。
139
+ */
140
+ export type DirectoryTreeVirtualScrollOptions = Omit<ComponentProps<typeof VirtualScroll>, "itemCount" | "getItem" | "getItemHeight" | "children" | "viewportSize"> & {
141
+ /** Override for viewport height. / 内部計測をスキップするための任意の固定ビューポート高さ。 */
142
+ viewportHeightOverride?: number
143
+ }
144
+
145
+ /**
146
+ * A single column definition for the TreeGrid (columns) mode.
147
+ * `columns[0]` is always the name / tree column (indent + expand glyph + type icon live here).
148
+ *
149
+ * TreeGrid(列)モードの列定義。`columns[0]` は常に名前(ツリー)列。
150
+ *
151
+ * @remarks
152
+ * `render` / `footer` の関数は参照を安定させること(`useMemo` / `useCallback`)。
153
+ * identity が毎レンダー変わると行のメモ化が無効化され、可視行が毎回再描画されて
154
+ * 仮想スクロールの利点が失われる(`ItemHeight` と同じ制約)。
155
+ */
156
+ export type DirectoryTreeColumn = {
157
+ /** Unique column key (duplicates are flagged in dev). / 一意なキー(dev で重複検証)。 */
158
+ key: string
159
+ /** Column header content. / 列ヘッダ内容。 */
160
+ header?: ReactNode
161
+ /**
162
+ * Footer content. The function form receives **every node of the `entries` prop
163
+ * (including collapsed subtrees)**, not just the visible rows.
164
+ * フッタ内容。関数形は entries prop の全ノード(折り畳み subtree 含む)を受け取る。
165
+ */
166
+ footer?: ReactNode | ((allEntries: DirectoryEntry[]) => ReactNode)
167
+ /**
168
+ * Column width in px. The name column (`columns[0]`) uses this as its frozen width;
169
+ * numeric columns use it as the grid track width.
170
+ * 列幅(px)。名前列は凍結幅、数値列は grid track 幅として使用。
171
+ * 既定: 名前列 240、数値列 96。
172
+ */
173
+ width?: number
174
+ /** Cell text alignment. Default `left` (numeric columns should use `right`). / セル寄せ。既定 left。 */
175
+ align?: "left" | "right" | "center"
176
+ /** Extra class name for cells in this column. / この列のセルに付与する追加クラス。 */
177
+ className?: string
178
+ /**
179
+ * Cell content renderer. In the name column the indent / expand glyph / type icon are
180
+ * drawn by the library, and this render output is placed as the label content
181
+ * (falls back to `entry.name` when omitted).
182
+ * セル内容レンダラ。名前列では indent/glyph/icon はライブラリが描画し、本 render の
183
+ * 戻り値がラベル内容として配置される(省略時は `entry.name`)。
184
+ */
185
+ render?: (entry: DirectoryEntry, ctx: { indentLevel: number; isDirectory: boolean; isExpanded: boolean }) => ReactNode
186
+ }
187
+
188
+ /**
189
+ * TreeGrid (columns) mode configuration. When provided, the name column is frozen on the
190
+ * left (indent + connector lines confined there) and the remaining columns render as an
191
+ * aligned grid with an aligned header/footer and a horizontally scrollable numeric region.
192
+ * When omitted, the classic label-based tree rendering is used.
193
+ *
194
+ * TreeGrid(列)モード設定。指定時は名前列を凍結し数値列を整列グリッドで描画、整列ヘッダ/フッタと
195
+ * 数値領域の横スクロールを提供する。省略時は従来のラベルツリー描画。
196
+ *
197
+ * @remarks `columns` と各 `render` / `footer` は参照安定必須。
198
+ */
199
+ export type DirectoryTreeGrid = {
200
+ /** Column definitions (**stable reference required**). `columns[0]` is the name/tree column. / 列定義(参照安定必須)。 */
201
+ columns: DirectoryTreeColumn[]
202
+ /** Render the header row. Default true. / ヘッダ行表示。既定 true。 */
203
+ showHeader?: boolean
204
+ /** Render the footer row. Default false. / フッタ行表示。既定 false。 */
205
+ showFooter?: boolean
206
+ /** Extra class for the header row. / ヘッダ行の追加クラス。 */
207
+ headerClassName?: string
208
+ /** Extra class for the footer row. / フッタ行の追加クラス。 */
209
+ footerClassName?: string
210
+ /** Extra class (or per-entry factory) for body rows. / 行の追加クラス(またはエントリ別ファクトリ)。 */
211
+ rowClassName?: string | ((entry: DirectoryEntry) => string)
212
+ /**
213
+ * Vertical scrollbar width, used to keep the header/footer numeric viewport aligned with
214
+ * the body (whose width is reduced by the vertical scrollbar). Default 12.
215
+ * 縦スクロールバー幅。ヘッダ/フッタの数値ビューポート幅を本体と一致させるために使用。既定 12。
216
+ */
217
+ scrollBarWidth?: number
218
+ }
219
+
220
+ /**
221
+ * Represents the state and actions for a directory tree.
222
+ * ディレクトリツリーの状態とアクションを表します。
223
+ */
224
+ export type DirectoryTreeState = {
225
+ /**
226
+ * A set of strings representing the paths of the expanded directories.
227
+ * 展開されているディレクトリのパスを表す文字列のセット。
228
+ */
229
+ expanded: Set<string>
230
+ /**
231
+ * Toggles the expansion state of a directory.
232
+ * ディレクトリの展開状態を切り替えます。
233
+ * @param path - The path of the directory to toggle.
234
+ */
235
+ toggle: (path: string) => void
236
+ /**
237
+ * Expands a directory.
238
+ * ディレクトリを展開します。
239
+ * @param path - The path of the directory to expand.
240
+ */
241
+ expand: (path: string) => void
242
+ /**
243
+ * Collapses a directory.
244
+ * ディレクトリを折りたたみます。
245
+ * @param path - The path of the directory to collapse.
246
+ */
247
+ collapse: (path: string) => void
248
+ /**
249
+ * Collapses multiple specified directories.
250
+ * 指定された複数のディレクトリを折りたたみます。
251
+ * @param paths - An array of directory paths to collapse.
252
+ */
253
+ collapseMultiple: (paths: string[]) => void
254
+ /**
255
+ * Expands multiple specified directories.
256
+ * 指定された複数のディレクトリを展開します。
257
+ * @param paths - An array of directory paths to expand.
258
+ */
259
+ expandMultiple: (paths: string[]) => void
260
+ /**
261
+ * Collapses all directories.
262
+ * すべてのディレクトリを折りたたみます。
263
+ */
264
+ collapseAll: () => void
265
+ /**
266
+ * Checks if a directory is expanded.
267
+ * ディレクトリが展開されているかどうかを確認します。
268
+ * @param path - The path of the directory to check.
269
+ * @returns True if the directory is expanded, false otherwise.
270
+ */
271
+ isExpanded: (path: string) => boolean
272
+ /**
273
+ * A boolean that is true if a transition is pending.
274
+ * トランジションが保留中の場合に true となる真偽値。
275
+ */
276
+ isPending: boolean
277
+ }
278
+
279
+ /**
280
+ * @type DirectoryTreeProps
281
+ * @description Props for the DirectoryTree component.
282
+ * DirectoryTree コンポーネントの Props。
283
+ */
284
+ export type DirectoryTreeProps = {
285
+ /**
286
+ * The directory entries to display.
287
+ * 表示するディレクトリエンティティの配列。
288
+ */
289
+ entries: DirectoryEntry[]
290
+
291
+ /**
292
+ * Configuration for tree expansion state and behavior.
293
+ * ツリーの展開状態と動作の設定。
294
+ */
295
+ expansion: {
296
+ /**
297
+ * Function to toggle the expansion state of a directory.
298
+ * ディレクトリの展開状態を切り替える関数。
299
+ */
300
+ toggle: (path: string) => void
301
+ /**
302
+ * Function to check if a directory is expanded.
303
+ * ディレクトリが展開されているか確認する関数。
304
+ */
305
+ isExpanded: (path: string) => boolean
306
+ /**
307
+ * Function to expand multiple specified directories.
308
+ * 指定された複数のディレクトリを展開する関数。
309
+ */
310
+ expandMultiple: (paths: string[]) => void
311
+ /**
312
+ * Function to collapse all specified directories.
313
+ * 指定されたすべてのディレクトリを折りたたむ関数。
314
+ */
315
+ collapseMultiple: (paths: string[]) => void
316
+ /**
317
+ * Flag to indicate if the tree is in a pending state.
318
+ * ツリーが保留状態かどうかを示すフラグ。
319
+ */
320
+ isPending?: boolean
321
+ /**
322
+ * If true, all directories are always expanded.
323
+ * true の場合、すべてのディレクトリが常に展開されます。
324
+ */
325
+ alwaysExpanded?: boolean
326
+ /**
327
+ * The action to perform on double-clicking a directory.
328
+ * ディレクトリをダブルクリックしたときのアクション。
329
+ */
330
+ doubleClickAction?: "toggle" | "recursive"
331
+ }
332
+
333
+ /**
334
+ * Configuration for item selection.
335
+ * アイテム選択の設定。
336
+ */
337
+ selection: {
338
+ /**
339
+ * Selection mode for items.
340
+ * アイテムの選択モード。
341
+ */
342
+ mode?: "none" | "single" | "multiple"
343
+ /**
344
+ * The currently selected path.
345
+ * 現在選択されているパス。
346
+ */
347
+ selectedPath?: string | null
348
+ /**
349
+ * Set of paths for currently selected items.
350
+ * 現在選択されているアイテムのパスのセット。
351
+ */
352
+ selectedItems?: Set<string>
353
+ /**
354
+ * Callback when an entry (file or directory) is clicked.
355
+ * エントリ(ファイルまたはディレクトリ)がクリックされたときのコールバック。
356
+ *
357
+ * For files: called immediately on click.
358
+ * For directories: called immediately on click, then expand/collapse follows
359
+ * unless preventDefault() is called on the event.
360
+ *
361
+ * ファイルの場合: クリック時に即座に呼ばれる。
362
+ * ディレクトリの場合: クリック時に即座に呼ばれ、イベントで preventDefault() が
363
+ * 呼ばれない限り展開/折りたたみが続行される。
364
+ */
365
+ onEntryClick: (event: DirectoryTreeClickEvent) => void
366
+ /**
367
+ * Callback when item selection changes.
368
+ * アイテム選択状態変更時のコールバック。
369
+ */
370
+ onSelectionChange?: (entry: DirectoryEntry, isSelected: boolean) => void
371
+ }
372
+
373
+ /**
374
+ * Visual customization options.
375
+ * 表示のカスタマイズオプション。
376
+ */
377
+ visual?: {
378
+ /**
379
+ * Optional CSS class name for the container.
380
+ * コンテナ用のオプション CSS クラス名。
381
+ */
382
+ className?: string
383
+ /**
384
+ * Optional inline styles for the container.
385
+ * コンテナ用のオプションのインラインスタイル。
386
+ */
387
+ style?: CSSProperties
388
+ /**
389
+ * Line color for tree connections.
390
+ * ツリーラインの色。
391
+ */
392
+ lineColor?: string
393
+ /**
394
+ * Flag indicating whether to render tree connector lines.
395
+ * ツリーのコネクタラインをレンダリングするかどうかのフラグ。
396
+ */
397
+ showTreeLines?: boolean
398
+ /**
399
+ * Flag indicating whether to render directory expand icons.
400
+ * ディレクトリの展開アイコンを描画するかどうかのフラグ。
401
+ */
402
+ showExpandIcons?: boolean
403
+ /**
404
+ * Flag indicating whether to render directory type icons.
405
+ * ディレクトリアイコンを描画するかどうかのフラグ。
406
+ */
407
+ showDirectoryIcons?: boolean
408
+ /**
409
+ * Flag indicating whether to render file type icons.
410
+ * ファイルアイコンを描画するかどうかのフラグ。
411
+ */
412
+ showFileIcons?: boolean
413
+ /**
414
+ * Icon overrides applied globally.
415
+ * グローバルに適用するアイコン差し替え設定。
416
+ */
417
+ iconOverrides?: DirectoryTreeIconOverrides
418
+ /**
419
+ * Size of the expand icon.
420
+ * 展開アイコンのサイズ。
421
+ */
422
+ expandIconSize?: number
423
+ /**
424
+ * Row height in px, or a function computing the height per entry. Default 20.
425
+ * When a function is supplied, rows may have different heights and the tree
426
+ * connector lines follow each row's cumulative offset.
427
+ *
428
+ * 各行の高さ (px)、またはエントリごとに高さを算出する関数。既定 20。
429
+ * 関数を渡すと行ごとに高さを変えられ、ツリー接続線は各行の累積オフセットに追従する。
430
+ */
431
+ itemHeight?: ItemHeight
432
+ /**
433
+ * If true, removes the indentation and connector lines for root-level items.
434
+ * true の場合、ルートレベルのアイテムのインデントとコネクタラインを削除します。
435
+ */
436
+ removeRootIndent?: boolean
437
+ /**
438
+ * Highlight styles configuration for hover and selection states.
439
+ * ホバー時および選択時のハイライトスタイルの設定。
440
+ */
441
+ highlightStyles?: HighlightStyles
442
+ /** CSS class name for each entry. / 各エントリ(行)に適用する追加の CSS クラス名。 */
443
+ entryClassName?: string
444
+ /** Inline styles for each entry. / 各エントリ(行)に適用する追加のインラインスタイル。 */
445
+ entryStyle?: CSSProperties
446
+ /** CSS class name for the name (label) part. / 名前(ラベル)部分に適用する追加の CSS クラス名。 */
447
+ nameClassName?: string
448
+ /** Inline styles for the name (label) part. / 名前(ラベル)部分に適用する追加のインラインスタイル。 */
449
+ nameStyle?: CSSProperties
450
+ /** CSS class name specifically for directory names. / ディレクトリ名特有の追加の CSS クラス名。 */
451
+ directoryNameClassName?: string
452
+ /** Inline styles specifically for directory names. / ディレクトリ名特有の追加のインラインスタイル。 */
453
+ directoryNameStyle?: CSSProperties
454
+ /** CSS class name specifically for file names. / ファイル名特有の追加の CSS クラス名。 */
455
+ fileNameClassName?: string
456
+ /** Inline styles specifically for file names. / ファイル名特有の追加のインラインスタイル。 */
457
+ fileNameStyle?: CSSProperties
458
+ }
459
+
460
+ /**
461
+ * Additional options for VirtualScroll integration.
462
+ * VirtualScroll の設定を上書きするオプション。
463
+ */
464
+ virtualScroll?: DirectoryTreeVirtualScrollOptions
465
+
466
+ /**
467
+ * TreeGrid (columns) mode. When provided, the name column is frozen on the left and the
468
+ * remaining columns render as an aligned grid with header/footer and a horizontally
469
+ * scrollable numeric region. When omitted, the classic label-based tree is rendered.
470
+ *
471
+ * TreeGrid(列)モード。指定時は名前列を凍結し数値列を整列グリッドで描画する。省略時は従来のツリー。
472
+ *
473
+ * `grid.columns` と各 `render` / `footer` は参照安定必須(`itemHeight` と同じ制約)。
474
+ */
475
+ grid?: DirectoryTreeGrid
476
+ }
477
+
478
+ /**
479
+ * Props for the useDirectoryTreeState hook.
480
+ * useDirectoryTreeState フックのプロパティ。
481
+ */
482
+ export type UseDirectoryTreeStateProps = {
483
+ /**
484
+ * An optional set of initially expanded directory paths.
485
+ * 初期状態で展開されているディレクトリパスのオプションのセット。
486
+ */
487
+ initialExpanded?: Set<string>
488
+ /**
489
+ * An optional key to store the expanded state in localStorage.
490
+ * 展開状態を localStorage に保存するためのオプションのキー。
491
+ */
492
+ storageKey?: string
493
+ }
494
+
495
+ /**
496
+ * @type DirectoryEntryItemProps
497
+ * @description Props for the DirectoryEntryItem component.
498
+ * DirectoryEntryItem コンポーネントの Props。
499
+ */
500
+ export type DirectoryEntryItemProps = {
501
+ entry: DirectoryEntry
502
+ indentLevel: number
503
+ /** Resolved height of this row in px. / この行の解決済み高さ (px)。 */
504
+ rowHeight: number
505
+ isDirOpen: (path: string) => boolean
506
+
507
+ expansion: {
508
+ toggleDirectory: (path: string) => void
509
+ onToggleDirectoryRecursive: (entry: DirectoryEntry) => void
510
+ doubleClickAction?: "toggle" | "recursive"
511
+ }
512
+
513
+ selection: {
514
+ selectedPath: string | null
515
+ mode?: "none" | "single" | "multiple"
516
+ selectedItems?: Set<string>
517
+ onEntryClick: (event: DirectoryTreeClickEvent) => void
518
+ onSelectionChange?: (entry: DirectoryEntry, isSelected: boolean) => void
519
+ }
520
+
521
+ visual: {
522
+ showExpandIcons?: boolean
523
+ showDirectoryIcons?: boolean
524
+ showFileIcons?: boolean
525
+ iconOverrides?: DirectoryTreeIconOverrides
526
+ expandIconSize?: number
527
+ useCanvasExpandIcons?: boolean
528
+ highlightStyles?: HighlightStyles
529
+ entryClassName?: string
530
+ entryStyle?: CSSProperties
531
+ nameClassName?: string
532
+ nameStyle?: CSSProperties
533
+ directoryNameClassName?: string
534
+ directoryNameStyle?: CSSProperties
535
+ fileNameClassName?: string
536
+ fileNameStyle?: CSSProperties
537
+ }
538
+
539
+ parentIsLast: boolean[]
540
+ renderChildren?: boolean
541
+ }
542
+
543
+ /**
544
+ * Information for a single item in the tree line.
545
+ *
546
+ * ツリーラインの単一アイテムの情報。
547
+ */
548
+ export type TreeLineItemInfo = {
549
+ id: string // アイテムの一意な識別子
550
+ absolutePath: string // アイテムの絶対パス
551
+ name: string // アイテム名
552
+ indentLevel: number // アイテムのインデントレベル
553
+ isLastChild: boolean // アイテムが親の最後の子であるかどうか
554
+ ancestorIsLast: boolean[] // 各祖先が最後の子であるかを示す配列
555
+ isDirectory: boolean // アイテムがディレクトリであるかどうか
556
+ isOpen?: boolean // ディレクトリが開いているかどうか (任意)
557
+ isExpanded: boolean // ディレクトリが展開されているかどうか
558
+ hideLines?: boolean // ツリーラインを隠すかどうか
559
+ }
560
+
561
+ /**
562
+ * Segment data for TreeLine rendering.
563
+ *
564
+ * TreeLine 描画用のセグメントデータ。
565
+ */
566
+ export type TreeLineSegment = {
567
+ key: string // セグメントの一意なキー
568
+ x1: number // 線分の始点X座標
569
+ y1: number // 線分の始点Y座標
570
+ x2: number // 線分の終点X座標
571
+ y2: number // 線分の終点Y座標
572
+ itemIndex: number // セグメントが属するアイテムのインデックス
573
+ }
574
+
575
+ /**
576
+ * Glyph data for expand icons rendered on the tree line canvas.
577
+ *
578
+ * ツリーラインキャンバスに描画する展開アイコンのグリフ情報。
579
+ */
580
+ export type TreeLineGlyph = {
581
+ key: string // グリフの一意なキー
582
+ itemIndex: number // グリフが属するアイテムのインデックス
583
+ centerX: number // グリフの中心X座標
584
+ centerY: number // グリフの中心Y座標
585
+ size: number // グリフのサイズ
586
+ isExpanded: boolean // 展開状態かどうか
587
+ }
588
+
589
+ /**
590
+ * Geometric data for tree line rendering.
591
+ *
592
+ * ツリーライン描画用のジオメトリデータ。
593
+ */
594
+ export type TreeLineGeometry = {
595
+ segmentsByItem: TreeLineSegment[][] // アイテムごとの線分配列
596
+ glyphsByItem: TreeLineGlyph[][] // アイテムごとのグリフ配列
597
+ }
598
+
599
+ /**
600
+ * Props for the TreeLine component.
601
+ *
602
+ * TreeLine コンポーネントの Props。
603
+ */
604
+ export type TreeLineProps = {
605
+ segmentsByItem: TreeLineSegment[][] // アイテムごとのセグメント配列
606
+ glyphsByItem: TreeLineGlyph[][] // アイテムごとのグリフ配列
607
+ itemHeight: number // 各アイテムの高さ
608
+ width: number // SVG 領域の全体の幅
609
+ viewportHeight: number // ビューポートの高さ
610
+ scrollPosition: number // 現在のスクロール位置
611
+ color?: string // ツリーラインの色 (任意)
612
+ strokeWidth?: number // ツリーラインの線の太さ (任意)
613
+ renderStartIndex?: number // レンダリングを開始するインデックス (任意)
614
+ renderEndIndex?: number // レンダリングを終了するインデックス (任意)
615
+ lookaheadEndIndex?: number // 表示範囲外も考慮したインデックス上限 (任意)
616
+ devicePixelRatio?: number // デバイスピクセル比 (任意)
617
+ expandGlyphColor?: string // 展開アイコンの色 (任意)
618
+ expandGlyphSize?: number // 展開アイコンのサイズ (任意)
619
+ }