@eventcatalog/visualizer

中文文档
0.0.6发布于 2025/09/19MITTypeScriptESM + CJS近 30 天下载 2470

ReactFlow nodes and visualizer components for EventCatalog Visualizer and Studio

原始使用文档
文档目录14 节
  1. Installation
  2. Setup
  3. 1. Import the CSS (Required)
  4. 2. Configure Tailwind (Required for proper styling)
  5. Usage
  6. Basic EventNode
  7. Standalone Usage
  8. With ReactFlow
  9. Node Configuration
  10. Props
  11. EventNodeProps
  12. EventNodeData
  13. Styling
  14. Features

@eventcatalog/visualizer

React components for visualizing EventCatalog nodes, built for ReactFlow.

Installation

npm install @eventcatalog/visualizer
# or
pnpm add @eventcatalog/visualizer

Setup

1. Import the CSS (Required)

The components use Tailwind CSS classes. Import the CSS file in your main CSS file:

/* In your main CSS file (e.g., globals.css, index.css) */
@import '@eventcatalog/visualizer/dist/styles.css';

2. Configure Tailwind (Required for proper styling)

The visualizer components use Tailwind CSS classes. You must configure your build system to include these classes:

For Tailwind CSS v4 (PostCSS):

Add the visualizer package to your postcss.config.js:

export default {
  plugins: {
    "@tailwindcss/postcss": {
      content: [
        // ... your existing paths
        './node_modules/@eventcatalog/visualizer/dist/**/*.{js,mjs}',
        './node_modules/@eventcatalog/visualizer/src/**/*.{js,ts,jsx,tsx}',
      ],
    },
  },
};

For Tailwind CSS v3 (Config file):

Add the visualizer package to your content paths in tailwind.config.js:

module.exports = {
  content: [
    // ... your existing paths
    './node_modules/@eventcatalog/visualizer/dist/**/*.{js,mjs}',
    './node_modules/@eventcatalog/visualizer/src/**/*.{js,ts,jsx,tsx}',
  ],
  // ... rest of config
}

⚠️ Important: Without this configuration, the Tailwind classes used by the visualizer components will be purged from your CSS build, resulting in unstyled components.

Usage

Basic EventNode

import { EventNode } from '@eventcatalog/visualizer';

// Use as standalone component
<EventNode
  id="event-1"
  data={{
    name: "User Registered",
    version: "1.0.0",
    summary: "Fired when a user registers for the first time",
    mode: "full",
    owners: ["team-auth", "team-users"],
    sends: ["user-profile-updated"],
    receives: ["user-registration-request"]
  }}
  selected={false}
/>

Standalone Usage

The EventNode is a pure visual component that can be used anywhere:

import { EventNode } from '@eventcatalog/visualizer';

<EventNode
  id="event-1"
  data={{
    name: "User Registered",
    version: "1.0.0",
    summary: "Fired when a user registers for the first time",
    mode: "full",
  }}
  selected={false}
/>

With ReactFlow

For ReactFlow integration, wrap the EventNode with ReactFlow handles:

import { ReactFlow, Handle, Position } from '@xyflow/react';
import { EventNode } from '@eventcatalog/visualizer';

// Create a ReactFlow node wrapper
function ReactFlowEventNode(props) {
  const { id, data, selected } = props;
  return (
    <>
      <Handle type="target" position={Position.Left} />
      <Handle type="source" position={Position.Right} />
      <EventNode id={id} data={data} selected={selected} />
    </>
  );
}

const nodeTypes = {
  event: ReactFlowEventNode,
};

const nodes = [
  {
    id: '1',
    type: 'event',
    position: { x: 100, y: 100 },
    data: {
      name: 'User Registered',
      version: '1.0.0',
      summary: 'Fired when a user registers',
      mode: 'full',
    },
  },
];

export default function MyFlow() {
  return (
    <ReactFlow
      nodes={nodes}
      nodeTypes={nodeTypes}
    />
  );
}

Node Configuration

The visualizer also exports node configurations:

import { eventConfig } from '@eventcatalog/visualizer';

// Access node metadata
console.log(eventConfig.type); // 'event'
console.log(eventConfig.color); // 'orange'
console.log(eventConfig.icon); // Zap component

Props

EventNodeProps

PropTypeDefaultDescription
idstringrequiredNode ID
dataEventNodeDatarequiredNode data
selectedbooleanfalseWhether node is selected

EventNodeData

PropertyTypeDescription
namestringEvent name
versionstringEvent version
summarystringEvent description
mode'simple' | 'full'Display mode
ownersstring[]Event owners
sendsstring[]Messages this event sends
receivesstring[]Messages this event receives

Styling

Components are styled with Tailwind CSS classes. The package includes:

  • Tailwind Classes: All standard Tailwind utilities used in components
  • Custom CSS: Minimal custom styles exported in dist/styles.css
  • Responsive: Components work across different screen sizes
  • Themeable: Easy to customize with Tailwind's theming system

Features

  • ✅ Pure Visual Component: Clean separation between visual and ReactFlow concerns
  • ✅ Standalone Usage: Works perfectly outside ReactFlow contexts
  • ✅ TypeScript: Full TypeScript support with proper types
  • ✅ Self-Contained Styling: Complete CSS bundle with all required Tailwind classes
  • ✅ Configurable: Support for simple and full display modes
  • ✅ Framework Agnostic: Can be wrapped for any flow library (ReactFlow, etc.)
  • ✅ Zero Dependencies: No ReactFlow dependency, just pure React component

版本与发布记录

@eventcatalog/visualizer 共发布 5 个版本,首次发布于 2025/08/11;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.6latest2025/09/191.2 年前
0.0.52025/08/151.2 年前
0.0.42025/08/121.3 年前
0.0.32025/08/121.3 年前
0.0.22025/08/111.3 年前

关于 @eventcatalog/visualizer 的常见问题

@eventcatalog/visualizer 是什么?

ReactFlow nodes and visualizer components for EventCatalog Visualizer and Studio

如何安装 @eventcatalog/visualizer?

在项目目录运行 npm install @eventcatalog/visualizer,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.0.0)、react-dom(>=18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@eventcatalog/visualizer 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@eventcatalog/visualizer 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@eventcatalog/visualizer 可以商用吗?

@eventcatalog/visualizer 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@eventcatalog/visualizer 的下载量有多少?

根据 npm 官方下载统计,@eventcatalog/visualizer 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,470 次,日均约 82 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eventcatalog/visualizer 还在维护吗?

最新版本 0.0.6 发布于 2025/09/19(1.2 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/08/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。