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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gmfe/business

v2.14.31

Published

`@gmfe/business` 是 gmfe 组件库的业务组件包,提供分页管理相关的业务组件,封装了常见的分页数据请求模式,简化分页列表页面的开发。

Readme

@gmfe/business

简介

@gmfe/business 是 gmfe 组件库的业务组件包,提供分页管理相关的业务组件,封装了常见的分页数据请求模式,简化分页列表页面的开发。

安装

npm install @gmfe/business

使用

ManagePaginationV2

import React from 'react'
import { ManagePaginationV2 } from '@gmfe/business'
import { Table } from '@gmfe/table'

function UserList() {
  return (
    <ManagePaginationV2
      id="user-list"
      onRequest={async ({ offset, limit }) => {
        const res = await fetch(`/api/users?offset=${offset}&limit=${limit}`)
        const data = await res.json()
        return { data: data.list, count: data.total }
      }}
    >
      {({ data, loading }) => (
        <Table
          data={data || []}
          columns={columns}
          loading={loading}
        />
      )}
    </ManagePaginationV2>
  )
}

API

ManagePagination

分页管理组件(基础版本),自动管理分页请求和加载状态。

| 属性 | 说明 | 类型 | 默认值 | 必填 | |------|------|------|--------|------| | id | 唯一标识,用于记住每页条数 | string | - | 否 | | onRequest | 分页请求函数,接收 { offset, limit } 参数,返回 Promise<{ data: array, count: number }> | function | - | 是 | | children | 子内容,可以是元素或函数(接收 { data, loading } 参数) | ReactElement \| function | - | 是 | | defaultLimit | 默认每页条数 | number | 10 | 否 |

ManagePaginationV2

分页管理组件 V2,支持禁用分页和自定义样式。

| 属性 | 说明 | 类型 | 默认值 | 必填 | |------|------|------|--------|------| | id | 唯一标识,用于记住每页条数 | string | - | 否 | | onRequest | 分页请求函数,接收 { offset, limit } 参数,返回 Promise<{ data: array, count: number }> | function | - | 是 | | children | 子内容,可以是元素或函数(接收 { data, loading } 参数) | ReactElement \| function | - | 是 | | defaultLimit | 默认每页条数 | number | 10 | 否 | | disablePage | 是否禁用分页控制 | boolean | false | 否 | | className | 自定义类名 | string | - | 否 | | style | 自定义样式 | object | - | 否 |

示例

使用元素作为 children

import React from 'react'
import { ManagePaginationV2 } from '@gmfe/business'
import { Table } from '@gmfe/table'

function OrderList() {
  const [data, setData] = React.useState([])
  const [loading, setLoading] = React.useState(false)

  return (
    <ManagePaginationV2
      id="order-list"
      defaultLimit={20}
      onRequest={async ({ offset, limit }) => {
        setLoading(true)
        const res = await fetch(`/api/orders?offset=${offset}&limit=${limit}`)
        const json = await res.json()
        setData(json.list)
        setLoading(false)
        return { data: json.list, count: json.total }
      }}
    >
      <Table data={data} columns={columns} loading={loading} />
    </ManagePaginationV2>
  )
}

禁用分页

<ManagePaginationV2
  id="simple-list"
  disablePage
  onRequest={async ({ limit }) => {
    const res = await fetch(`/api/items?limit=${limit}`)
    const json = await res.json()
    return { data: json.list, count: json.list.length }
  }}
>
  {({ data }) => <List data={data} />}
</ManagePaginationV2>

注意事项

  • onRequest 必须返回包含 data(数组)和 count(总数)的对象。
  • children 为函数时,会接收 { data, loading } 参数,data 在首次请求前为 undefined
  • id 用于在 localStorage 中记住用户选择的每页条数,相同 id 的组件会共享设置。
  • 推荐使用 ManagePaginationV2 替代 ManagePagination