本文へ移動

API リファレンス ​

Vue Weave には 2 つのエントリーポイントがあります。@eightkk/vue-weave は Vue 用のエントリーで、コンポーネント、コンポーザブル、そしてコアのすべて(再エクスポート)を含みます。@eightkk/vue-weave/core はヘッドレスなコアで、Vue、DOM、ブラウザーのグローバルを使わない純粋な TypeScript です。Node.js 22.18 以降、Worker、サーバーで動きます。スタイルシートは @eightkk/vue-weave/style.css です。

ts
// Vue アプリケーションで
import { GanttChart, NetworkGraph, useEditHistory, scheduleTasks } from '@eightkk/vue-weave'
import '@eightkk/vue-weave/style.css'

// サーバーや Worker で(Vue は不要)
import { scheduleTasks, layoutLayeredGraph, toMsProjectXml } from '@eightkk/vue-weave/core'

各ページには、リポジトリの docs/ フォルダーにある手書きのリファレンス(npm パッケージにも含まれます)を表示しています。型リファレンスは TypeScript の宣言から生成したもので、エクスポートされたすべての関数、インターフェース、型を載せています(英語)。

API の全体像 ​

コンポーネント(@eightkk/vue-weave) ​

すべてのコンポーネントは制御コンポーネントです。プロップを自分で変更することはなく、ユーザーの編集は提案として emit され、アプリケーション側が適用します。

コンポーネント内容
NetworkGraphインタラクティブなネットワークグラフ: レイアウト、編集、グループ、スイムレーン、ミニマップ、エクスポート
GanttChart制御されたガントチャートとタイムライン: 依存関係、ベースライン、列、スプレッドシート編集、負荷ヒストグラム
TreeGrid行と列を同時に仮想化するツリーグリッドとマトリクス。セル、シート、行の編集
TaskBoard列、スイムレーン、WIP 制限を持つカンバンボード
EventCalendarリソースと繰り返しイベントに対応した日・週・月・予定リストのカレンダー
GraphPalette と PropertyInspectorNetworkGraph でダイアグラムエディターを作るための図形パレットとプロパティフォーム

コンポーザブル(@eightkk/vue-weave) ​

useLinkedSelection、useEditHistory、useEditTransaction、useTimelineView、useWindowedData、useAsyncGraphLayout はコアの状態を Vue につなぎます。ビュー間の連動選択、元に戻す・やり直す、サーバー経由の保存、検索・並べ替えしたタイムライン、部分的な読み込み、Worker でのレイアウトに使います。

コア(@eightkk/vue-weave/core) ​

分野主なエクスポート
コアのエントリーポイントコアのすべてのエクスポートの一覧表
グラフのレイアウトとルーティングlayoutLayeredGraph、追加のレイアウト、ポート、routeGraphEdges、増分配置、数量フロー、ビューポート
グラフのアルゴリズムと探索topologicalOrder、shortestGraphPath、中心性、コミュニティ、traverseGraph
タイムラインと時間軸createTimeScale、editTimeRange、行ツリー、型付きフィールドとタイムラインビュー
スケジューリングとリソースscheduleTasks、levelResources、calculateResourceLoad、実績、アーンドバリュー、診断、計画の比較
連動ビューとデータビューバインディング、時間範囲の探索、diffStructure、ウィンドウ化データ、グラフの展開、時間バケット
インターチェンジとエクスポートMS Project、iCalendar、CSV、Mermaid、GraphML、draw.io、スナップショット、SVG エクスポート

横断的なトピック ​

エントリーポイント ​

英語の詳細

ここから下の詳細なリファレンスは英語です。

Identifiers are nonempty strings and must be unique within their corresponding collection. Named port IDs are scoped to each node. Labels are rendered as Vue text. Escape/sanitize any HTML you supply in custom slots according to your application's trust boundaries.

The package is ESM-only. Import Vue components and shared types from @eightkk/vue-weave, headless calculations from @eightkk/vue-weave/core, and the stylesheet from @eightkk/vue-weave/style.css. Declarations support TypeScript's Bundler and NodeNext resolution. The core entry does not require Vue or browser globals at runtime. Node.js 22.18+ is the declared runtime baseline; Vue components require the Vue 3.5+ peer dependency. The package also exports @eightkk/vue-weave/package.json, so tools can read the installed version.

The stylesheet also ships opt-in vw-theme-dark and vw-theme-auto classes and forced-colors, reduced-motion and print rules; see docs/integration.md.

Compatibility and versioning ​

From 1.0.0, releases follow Semantic Versioning. A breaking change to the public API below is made only in a major release and is listed under "Breaking changes" in the changelog. Minor releases add backward-compatible, opt-in features; patch releases contain backward-compatible fixes.

The public API is:

  • The names exported from @eightkk/vue-weave and @eightkk/vue-weave/core, with the types and signatures of their published declarations, and the @eightkk/vue-weave/style.css and @eightkk/vue-weave/package.json entries.
  • The props (and their documented defaults), events and their payloads, slots and slot props, and exposed methods of NetworkGraph and GanttChart, as documented on this page.
  • The --vw-* CSS custom properties documented in Themes and localization, except those described there as internal (such as --vw-item-* and --vw-band-dash), and the classes you add yourself (vw-theme-dark, vw-theme-auto).
  • The snapshot format: a schemaVersion: 1 document written by a 1.x release is accepted by parseWeaveSnapshot and restoreWeaveSnapshot of every later 1.x release.

Not covered, and allowed to change in a minor or patch release (noted in the changelog):

  • The exact English text of error messages and of diagnostic message fields. The formats in Validation and errors describe the current texts. Branch on the error class (RangeError or Error) and on the code and id fields of diagnostics, not on message text.
  • The vw- classes that the components emit, the generated DOM and SVG structure, and the exact bytes of server-rendered markup and of SVG export (exportSvg, renderGraphSvg, renderTimelineSvg, renderTaskBoardSvg, renderEventCalendarSvg, renderTreeGridSvg). Output is deterministic for the same input and version, and server rendering hydrates cleanly with the same version on the client, but markup can change between releases. Custom stylesheets and tests that rely on these classes or that structure may need updates; prefer slots, --vw-* properties, and roles and accessible names in tests.
  • Undocumented modules and files inside dist/; import only the published entries.

Typed data ​

NetworkNode, GraphEdge, TimelineRow and TimelineBar take the type of their optional data as a type parameter that defaults to unknown: NetworkNode<D = unknown>, GraphEdge<D = unknown>, TimelineRow<D = unknown> and TimelineBar<D = unknown>. Both components are generic over the whole item types, so extra fields that an application adds to its items (for example NetworkNode<Owner> & { priority: number }) reach the slots and callbacks as well. Vue infers the parameters from the props in a template; nothing is written at the component. Without type arguments every type has unknown data.

ComponentType parametersInferred fromWhere the items come back
NetworkGraphN extends NetworkNode = NetworkNode, E extends GraphEdge = GraphEdge, G extends NetworkGroup = nevernodes, edges, groupsnode, edge, tooltip, node-toolbar, edge-toolbar, group and minimap-node slot props, layout, the exportSvg and exportPng label callbacks
GanttChartR extends TimelineRow = TimelineRow, B extends TimelineBar = TimelineBarrows, barsrow, cell, bar and tooltip slot props, columns (value, editable), creatable, the exportSvg and exportPng label callbacks

Events and validators carry IDs and intervals, not items (select(id), node-move, connect, edit, cell-edit, row-move, context-menu targets and the others), so their types do not change; look an item up by its ID in your own typed array.

A graph with groups can collapse them, and a collapsed group is drawn as a proxy node: a GraphCollapsedNode (NetworkNode<GraphCollapsedNodeData>), whose edges are re-attached and may merge into an edge without data. That is why the graph's slots and callbacks receive GraphShownNode<N, G> and GraphShownEdge<E, G>: N and E alone without groups (G is never), and with groups also the proxy node and a GraphEdge<never>. Narrow before reading application fields, for example with node.data && 'collapsedGroup' in node.data.

vue
<script setup lang="ts">
import { NetworkGraph, type GraphEdge, type NetworkNode } from '@eightkk/vue-weave'

interface Task { owner: string }
const nodes: NetworkNode<Task>[] = [{ id: 'cut', label: 'Cut', data: { owner: 'Ada' } }]
const edges: GraphEdge<{ weight: number }>[] = []
</script>

<template>
  <NetworkGraph :nodes="nodes" :edges="edges">
    <template #node="{ node, box }">
      <!-- node.data is Task | undefined -->
      <text :x="12" :y="box.height / 2">{{ node.label }} · {{ node.data?.owner }}</text>
    </template>
    <template #edge="{ edge, path }">
      <path :d="path" :stroke-width="edge.data?.weight ?? 1" />
    </template>
  </NetworkGraph>
</template>
vue
<script setup lang="ts">
import { GanttChart, type TimelineBar, type TimelineColumn, type TimelineRow } from '@eightkk/vue-weave'

type Team = TimelineRow<{ lead: string }>
const rows: Team[] = [{ id: 'core', label: 'Core', data: { lead: 'Grace' } }]
const bars: TimelineBar<{ cost: number }>[] = [{ id: 'b', rowId: 'core', label: 'Build', start: 0, end: 3_600_000, data: { cost: 4 } }]
const columns: TimelineColumn<Team>[] = [{ id: 'lead', label: 'Lead', width: 96, value: row => row.data?.lead ?? '' }]
</script>

<template>
  <GanttChart :rows="rows" :bars="bars" :columns="columns" :range="{ start: 0, end: 8 * 3_600_000 }">
    <template #bar="{ bar }">{{ bar.label }} ({{ bar.data?.cost }})</template>
  </GanttChart>
</template>

Template refs: in a single-file component, useTemplateRef('graph') (Vue 3.5) is inferred by vue-tsc from the template, including the item types. To declare the type yourself, use NetworkGraphExposed<N, E, G> and GanttChartExposed<R, B>, the methods each component exposes, with the same type arguments as the props. InstanceType<typeof NetworkGraph> and InstanceType<typeof GanttChart> keep working and give the component instance with the default item types, so their exportSvg callbacks receive unknown data.

ts
import { ref, useTemplateRef } from 'vue'
import type { GanttChartExposed, GraphEdge, NetworkGraphExposed, NetworkNode, TimelineBar, TimelineRow } from '@eightkk/vue-weave'

const graph = useTemplateRef('graph') // inferred from <NetworkGraph ref="graph" ...>
const typedGraph = ref<NetworkGraphExposed<NetworkNode<{ owner: string }>, GraphEdge>>()
const chart = ref<GanttChartExposed<TimelineRow, TimelineBar<{ cost: number }>>>()
typedGraph.value?.exportSvg({ nodeLabel: node => node.data?.owner ?? node.label })
chart.value?.exportSvg({ barLabel: bar => `${bar.label} ${bar.data?.cost}` })

The public component types are NetworkGraphComponent and GanttChartComponent. Core helpers that return the items they receive keep their types as well: moveTimelineRow, indentTimelineRow, outdentTimelineRow, removeTimelineBars, assignLanes, createTimelineRowTree, collapseGraphGroups, removeGraphElements, cloneGraphElements, searchGraphNodes and filterGraph, and the label callbacks of renderGraphSvg and renderTimelineSvg.

MIT ライセンスで公開しています。