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

@gingkoo/pandora-metrics

v0.0.9

Published

`Metrics` 组件是一个功能强大的 React 组件,用于管理指标、公式及相关数据。它提供了一个结构化的接口,用于处理加载状态、树形结构、公式操作以及用户交互。

Readme

Metrics 组件

Metrics 组件是一个功能强大的 React 组件,用于管理指标、公式及相关数据。它提供了一个结构化的接口,用于处理加载状态、树形结构、公式操作以及用户交互。

Props

Metrics 组件支持以下属性:

| 属性名 | 类型 | 描述 | | ------------------ | --------------------------------------------------- | ----------------------------------------------------------------------------------------- | | loading | boolean(可选) | 表示组件是否处于加载状态。 | | saveLoading | boolean (可选) | 表示保存操作是否正在进行中。 | | value | FormulaItem[] | 公式项的默认值。 | | treeTitle | string (可选) | 指标树左侧标题。 | | resultStatus | ResultStatus (可选) | 结果状态,由 ResultStatus 枚举定义。 | | treeStatus | TreeStatus (可选) | 指标树的状态,由 TreeStatus 枚举定义。 | | formulaData | FormulaGroup[] (可选) | 可供选择或操作的公式列表。 | | calcData | any[] (可选) | 试运算结果数据。 | | treeData | object[] (可选) | 表示指标树结构的数据。 | | showCalc | boolean (可选) | 是否显示试运算部分。 | | onReloadTreeData | () => void (可选) | 刷新指标树数据的回调函数。 | | onSave | (data?: any) => void (可选) | 保存数据时触发的回调函数。 | | onCalc | (data?: any) => void (可选) | 执行试运算时触发的回调函数。 | | onChange | (data?: FormulaItem[]) => void (可选) | 公式项变化时触发的回调函数。 | | toolbar | Array<'save' \| 'del' \| 'formula'>\|false (可选) | 工具栏配置,支持传入一个数组,定义需要显示的操作按钮(如 ['save', 'del', 'formula'])。 | | expandedAll | boolean (可选) | 是否展开全部 | | expandedKeys | string[] (可选) | 展开对应树id |


枚举

ResultStatus

ResultStatus 枚举定义了结果的可能状态:

| 值 | 描述 | | ------------ | -------------------- | | FIRST_OPEN | 表示组件首次打开。 | | LOADING | 表示结果正在加载中。 | | NO_DATA | 表示没有可用数据。 | | SUCCESS | 表示操作成功。 | | ERROR | 表示发生错误。 |

TreeStatus

TreeStatus 枚举定义了指标树的可能状态:

| 值 | 描述 | | ----------- | ---------------------- | | LOADING | 表示树数据正在加载中。 | | NO_DATA | 表示没有树数据可用。 | | NO_SEARCH | 表示未找到搜索结果。 | | SUCCESS | 表示树数据加载成功。 |


接口

FormulaItem

FormulaItem 接口表示单个公式项:

| 属性名 | 类型 | 描述 | | ------------- | ----------------- | ---------------------------------------------------------- | | type | FormulaItemType | 公式项的类型。 | | text | string | 公式项的文本内容。 | | id | string (可选) | id | | placeholder | string (可选) | 占位符文本(仅当 type = FormulaItemType.INDEX 时存在)。 |

FormulaGroup

{
	type:string,//公式类型
	data:[]	//公式数据
}

FormulaGroup.data 公式数据

| 属性名 | 类型 | 描述 | | ------------- | ----------------- | ---------------------------- | | type | FormulaItemType | 公式项的类型。 | | label | string | 公式项的文本内容。 | | formula | string[] (可选) | 公式数组,公式由多个符号组成 | | desc | string (可选) | 公式描述 | | placeholder | string[] (可选) | 公式占位符对应formula中Input |


通过以上文档,您可以快速了解 Metrics 组件的功能及其使用方法。