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

@newnpmjs/form-controls

v0.1.2

Published

13种表单控件集合 — ControlMain 独立包,支持 shadcn/ui 主题

Downloads

408

Readme

@newnpmjs/form-controls

13 种表单控件集合 — ControlMain 独立包,支持 shadcn/ui 主题。

@newnpmjs/dynamic-form-plugin 独立拆分的核心控件层。

安装

pnpm add @newnpmjs/form-controls

需要 peer 依赖 react@^18react-dom@^18

用法

import { ControlMain } from '@newnpmjs/form-controls'
import type { ControlMainProps } from '@newnpmjs/form-controls'

function Demo() {
  const [val, setVal] = useState('')

  return (
    <ControlMain
      type={1}
      name="uknom"
      value={val}
      onChange={setVal}
    />
  )
}

控件类型

| type | 控件 | 说明 | |------|------|------| | 0 | 只读文本 | 纯展示 value | | 1 | 文本/数字输入框 | 支持 isnum / maxlen / disabled | | 2 | 下拉选择 | options[] 定义选项 | | 3 | 复选框 | 搭配 extendcontrol | | 4 | 单选组 | 互斥选项 | | 5 | 日期选择 | 原生 date picker | | 6 | 日期时间 | date + time | | 7 | 开关 | 值归一化为 0 / 1 | | 8 | 菜单 + 跳转按钮 | menus[] 定义菜单项 | | 9 | 颜色选择器 | 色块 + 编号 | | 10 | 线型选择器 | SVG 预览 | | 11 | 线宽选择器 | SVG 预览 | | 12 | 垂直数字输入 | ▲▼ 按钮 + 数字 | | 13 | 日期区间 | start / end | | 999 | 自定义渲染 | custom ReactNode |

Props

继承 FieldConfig,主要属性:

| 属性 | 类型 | 说明 | |------|------|------| | type | number | 控件类型 (0-13, 999) | | value | any | 当前值 | | onChange | (val: any) => void | 值变化回调 | | onBlur | (e: any) => void | 失焦回调 | | onClick | (e: any) => void | 点击回调 | | disabled | number | 禁用状态 | | isnum | number | 是否数值模式 | | maxlen / minlen | number | 最大/最小长度/值 | | label | string | 标签文本 | | placeholder | string | 占位符 | | options | {value, name, disabled?, className?}[] | 选项列表 | | menus | {name, action}[] | 菜单项 | | custom | ReactNode | 自定义渲染 (type=999) | | extendcontrol | ReactNode | 额外内容 | | controlclass | string | 控件自定义 class | | colors | Record<string, string> | 颜色表覆盖 (type=9) |

样式

控件依赖 Tailwind CSS class 原子类,需在项目中配置 Tailwind 并引入 shadcn/ui 主题变量。不提供独立 CSS 文件。

License

MIT