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

@gzbapp/components

v2.0.0

Published

gzb app components

Readme


name: '@gzbapp/components'

概览

面向 GZB 应用的 UI 组件库,包含移动与桌面端组件、主题与多语言支持,提供按需加载能力。

2.x.x 版本技术栈

正式版起点为 2.0.0,面向 React 18 项目。

React / React DOM ^18.3.1 开发基线,配套 React 18 类型声明;TypeScript ^4.9.5,tsc -b + cpx 构建;依赖 @gzbapp/hooks ^2.0.0、@gzbapp/i18n ^2.0.0、lodash ^4.17.20、rc-tooltip ^5.0.1。React / React DOM peerDependencies 为 >=18.3.1,未限定仅支持 React 18。

安装

yarn add @gzbapp/components

快速开始

import { Button } from '@gzbapp/components'

export default function App() {
  return <Button>确定</Button>
}

主要能力

  • 丰富的基础与业务组件
  • 深色模式与多语言能力
  • 移动端与桌面端适配
  • 支持按需加载样式

特点

  • 组件高度自治, 业务解耦
  • 支持深色模式
  • 适配移动端和桌面端
  • 支持多语言

配置

以 @gdjiami/cli 为例, package.json 配置如下:

{
  // ...
  "jm": {
    "importPlugin": [
      {
        "libraryName": "antd",
        "libraryDirectory": "es",
        "style": "css"
      },
      {
        "libraryName": "@gzbapp/components",
        "libraryDirectory": "es",
        "style": "css"
      }
    ]
  }
}

我们使用了和 antd 一样的源代码组织结构,通过 babel-import-plugin 来实现按需导入代码和样式。

基本用法

初始化多语言

@gzbapp/components 依赖于 @gzbapp/i18n 来实现多语言,所以在入口处,需要进行多语言初始化:

/**
 * App entry
 */
import ready from '@gzbapp/runtime'
import i18n, { initial, addAppBundles, AvailableLanguge } from '@gzbapp/i18n'
import { I18n } from '@gzbapp/components'

import React from 'react'
import ReactDOM from 'react-dom'
import App from '~/containers/App'

ready().then(async () => {
  if (window.GZBSupport) {
    // 初始化 i18n
    await initial({
      supportBackend: true,
      backendName: 'demo',
    })

    // 加载组件库多语言
    await I18n.initial()

    // 本地多语言
    addAppBundles({
      [AvailableLanguge.zh]: {
        hello: '你好',
      },
      [AvailableLanguge.tw]: {
        hello: '你好',
      },
      [AvailableLanguge.en]: {
        hello: 'hello',
      },
    })

    ReactDOM.render(<App />, document.getElementById('root'), () => {
      console.log('首次渲染完成, 耗时 ', performance.now() + ' ms')
    })
  }
})

组件使用

用法和 Antd 一样,具体组件用法见组件 API。

import React from 'react'
import { ScrollView, Button } from '@gzbapp/components'

export default function ButtonDemo() {
  return (
    <ScrollView className="jm-bg-main">
      <div className="jm-btns">
        <Button>hello</Button>
        <Button loading>hello</Button>
        <Button loading danger>
          hello
        </Button>
      </div>
      <Button type="block">hello</Button>
      <Button type="block" danger>
        hello
      </Button>
      <Button type="rounded">hello</Button>
      <Button type="rounded" disabled>
        hello
      </Button>
      <Button type="rounded" danger>
        hello
      </Button>
      <Button type="rounded" danger loading>
        hello
      </Button>
    </ScrollView>
  )
}

因为导入语句会经过 babel-import-plugin 处理, 最终编译结果为:

import ScrollView from '@gzbapp/components/es/scroll-view'
import '@gzbapp/components/es/scroll-view/style/css'
import Button from '@gzbapp/components/es/button'
import '@gzbapp/components/es/button/style/css'

所以说 import-plugin 的配置非常重要,它可以确保按需导入样式和组件。

Typescript 类型

所有组件的 Typescript 类型声明都定义在导出变量 T 中, 例如你可以通过下面的代码导入 Avatar 组件的 AvatarProps

import { T } from '@gzbapp/components'

export interface MyProps extends T.Avatar.AvatarProps {}