npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wsc-tech/guanshi-report-editor

v0.0.5

Published

您可以将此库作为 npm 包安装并在您的 React 项目中使用。

Readme

📦 集成到第三方项目

您可以将此库作为 npm 包安装并在您的 React 项目中使用。

安装

npm install @wsc-tech/guanshi-report-editor

关键:使用 LanguageProvider 包裹应用

注意ReportDesignerReportViewer 组件依赖于国际化上下文 LanguageProvider。因此,在引入这些组件时,必须在它们的外层(或者应用的根节点)包裹 <LanguageProvider>,否则组件将无法正常运行并报错。

示例代码

以下是一个完整的集成示例,展示了如何正确地初始化和使用设计器组件:

import React, { useState } from 'react';
import { 
  LanguageProvider, 
  ReportDesigner, 
  printReport,
  ReportSchema 
} from '@wsc-tech/guanshi-report-editor';
// import '@wsc-tech/guanshi-report-editor/dist/style.css'; // 如有样式文件导出请引入

const ReportDesignerPage = () => {
  // 模拟的业务数据,用于打印预览
  const [reportData] = useState({
    "vol_arch_code": "2023-ARCH-001",
    "tableData": [
      { "NO": "1", "Title": "示例文件1", "Date": "2023-01-15" },
      { "NO": "2", "Title": "示例文件2", "Date": "2023-02-15" }
    ]
  });

  // 处理打印事件
  const handlePrint = (currentReport: ReportSchema) => {
    // 调用内置的打印工具函数,传入当前的报表设计和业务数据
    printReport(currentReport, reportData);
  };

  return (
    <div style={{ height: '100vh', display: 'flex', flexDirection: 'column' }}>
      <ReportDesigner 
        onPrint={handlePrint} 
        className="h-full w-full"
      />
    </div>
  );
};

// 导出时确保包裹 LanguageProvider
const App = () => {
  return (
    <LanguageProvider>
      <ReportDesignerPage />
    </LanguageProvider>
  );
};

export default App;

组件 API 说明

<ReportDesigner />

报表设计器组件。

  • onPrint: (report: ReportSchema) => void
    • 当用户点击工具栏上的“打印”按钮时触发的回调。您可以在此处调用 printReport 函数。
  • onSave: (report: ReportSchema) => void
    • 当用户点击“保存”按钮时触发。
  • initialReport: ReportSchema (可选)
    • 用于加载初始的报表模板数据。

printReport(report, data)

手动触发打印预览的工具函数。

  • report: ReportSchema - 报表结构定义。
  • data: any - 填充到报表中的数据对象。

<ReportViewer />

纯预览组件,用于只读展示报表。

import { ReportViewer } from '@wsc-tech/guanshi-report-editor';

<ReportViewer 
  report={myReportSchema} 
  data={myData} 
/>