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

@gavin9527/tl-components

v1.0.1

Published

Vue 3 + TypeScript 动态表单和表格组件库,基于 Hook API

Downloads

167

Readme

TL Components

Vue 3 + TypeScript 组件库,提供基于 Hook 的动态表单和表格组件。

npm version license

🚀 快速开始

安装

npm install tl-components

开发

# 安装依赖
npm install

# 启动开发服务器(自动打开 playground)
npm run dev

# 或者显式启动 playground
npm run dev:playground

访问 http://localhost:5173/playground/ 查看示例。

构建

# 构建组件库
npm run build

# 或使用别名
npm run build:lib

构建产物在 dist/ 目录:

  • dist/index.js - UMD 格式的组件库(包含 CSS)

预览

# 预览构建后的 playground
npm run preview

📁 项目结构

form-components/
├── form/                     # 表单模块
│   ├── hook.ts              # useForm hook
│   ├── index.vue            # DynamicForm 组件
│   ├── types.ts             # TypeScript 类型定义
│   ├── componentMap.ts      # 组件注册表
│   └── index.ts             # 模块导出
├── grid/                    # 表格模块
│   ├── hook.ts              # useVxeGrid hook
│   ├── index.vue            # BasicGrid 组件
│   ├── types.ts             # TypeScript 类型定义
│   └── index.ts             # 模块导出
├── playground/              # 开发测试环境
│   ├── pages/               # 示例页面
│   │   ├── Home.vue         # 首页
│   │   ├── FormBasic.vue    # 基础表单示例
│   │   ├── FormAdvanced.vue # 动态表单示例
│   │   ├── GridBasic.vue    # 基础表格示例
│   │   └── GridAdvanced.vue # 高级表格示例
│   ├── components/          # 布局组件
│   │   └── Layout.vue       # 主布局(含导航)
│   ├── router/              # 路由配置
│   │   └── index.ts         # 路由定义
│   ├── App.vue              # 根组件
│   ├── main.ts              # 入口文件
│   └── index.html           # HTML 模板
├── dist/                    # 构建输出
├── index.ts                 # 主入口(库导出)
├── vite.config.ts           # Vite 配置
├── tsconfig.json            # TypeScript 配置
└── package.json             # 项目配置

🛠️ 技术栈

  • Vue 3.4+ - 渐进式 JavaScript 框架
  • TypeScript 5.4+ - 类型安全
  • Vite 5.3+ - 构建工具
  • Vue Router 4 - 官方路由管理器
  • Element Plus 2.8+ - UI 组件库
  • VXE Table 4.17+ - 表格组件
  • @tanstack/vue-query - 数据请求管理

🎮 Playground 功能

Playground 提供了一个完整的路由系统,包含多个功能演示页面:

页面导航

  • 首页 (/home) - 项目介绍和快速开始
  • 表单组件
    • 基础表单 (/form/basic) - 展示各种表单控件的基本用法
    • 动态表单 (/form/advanced) - 展示动态渲染、条件显示等高级功能
  • 表格组件
    • 基础表格 (/grid/basic) - 展示表格的基本功能(过滤、选择等)
    • 高级表格 (/grid/advanced) - 展示动态列、条件显示等高级功能

添加新的 Demo 页面

  1. playground/pages/ 创建新的 Vue 组件
  2. playground/router/index.ts 添加路由配置
  3. 重启开发服务器,新页面会自动出现在导航菜单中
// playground/router/index.ts
{
  path: '/your-feature',
  name: 'YourFeature',
  component: () => import('../pages/YourFeature.vue'),
  meta: {
    title: '你的功能',
    icon: '🎯',
  },
}

📦 使用方式

安装

npm install tl-components

使用 useForm

import { useForm } from 'tl-components';

const [Form, { validate, setFieldsValue, setProps }] = useForm({
  gridCols: 2,
  schemas: [
    {
      fieldName: 'name',
      label: '姓名',
      component: 'Input',
      rules: 'required'
    }
  ]
});

// 初始 schemas 必填,component 必填
// setProps 支持 schema patch(component 可省略)
setProps({
  schemas: [
    {
      fieldName: 'name',
      label: '姓名(全名)'
    },
    {
      fieldName: 'age',
      label: '年龄',
      component: 'InputNumber'
    }
  ]
});

使用 useVxeGrid

import { useVxeGrid } from 'tl-components';
import { VxeGrid } from 'vxe-table';

const [Grid, { reload, getCheckboxRecords }] = useVxeGrid({
  columns: [
    { field: 'name', title: '姓名' },
    { field: 'age', title: '年龄' }
  ],
  data: tableData
}, VxeGrid);

📖 文档

🔧 配置说明

Vite 配置

开发模式和生产构建使用不同配置:

  • 开发模式 (npm run dev):使用 playground/ 作为开发环境
  • 生产构建 (npm run build):构建 UMD 格式的组件库到 dist/

TypeScript 配置

项目使用 TypeScript strict 模式,包含以下模块:

  • form/**/*.ts, form/**/*.vue
  • grid/**/*.ts, grid/**/*.vue
  • playground/**/*.ts, playground/**/*.vue

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT