💡 摘要
一个为增强可用性和自定义而设计的AI友好的React组件库。
🎯 适合人群
🤖 AI 吐槽: “看起来很能打,但别让配置把人劝退。”
风险:Medium。建议检查:是否执行 shell/命令行指令;API Key/Token 的获取、存储与泄露风险;依赖锁定与供应链风险。以最小权限运行,并在生产环境启用前审计代码与依赖。
jobsys-newbie-next
AI-friendly React components built with Ant Design 5.x and Pro Components.
Features
- ✅ AI 友好:完整的 TypeScript 类型定义、详细的 JSDoc 注释、丰富的使用示例
- ✅ 自动化发版:基于 Changesets 的版本管理和 CI/CD 自动化
- ✅ 完整测试:单元测试、集成测试,覆盖率 > 80%
- ✅ Playground:交互式组件展示和文档
Installation
pnpm add jobsys-newbie-next
Quick Start
1. 使用 NewbieProvider
import { NewbieProvider } from 'jobsys-newbie-next' function App() { return ( <NewbieProvider themeMode="system" primaryColor="blue" density="normal" config={{ locale: 'zh_CN', }} > <YourApp /> </NewbieProvider> ) }
2. 使用 NewbieSearch
import { NewbieSearch } from 'jobsys-newbie-next' import type { NewbieProColumn } from 'jobsys-newbie-next' function SearchExample() { const columns: NewbieProColumn[] = [ { title: '姓名', dataIndex: 'name', valueType: 'text' }, { title: '年龄', dataIndex: 'age', valueType: 'digit', sorter: true }, ] return ( <NewbieSearch columns={columns} onSubmit={(query, sort) => { console.log('Search query:', query) console.log('Sort config:', sort) }} /> ) }
Components
NewbieProvider
Global configuration provider that supports default props override for all components.
Features:
- Global configuration management (Theme, Color, Density)
- Component-level default props override
- Deep merge configuration
- Ant Design locale support
- Automatic Ant Design Token translation
Example:
<NewbieProvider themeMode="dark" primaryColor="#00ff00" density="compact" config={{ locale: 'zh_CN', }} > <App /> </NewbieProvider>
NewbieSearch
Advanced search component with condition filtering, sorting, and persistence.
Features:
- Condition filtering system (equal, notEqual, like, between, etc.)
- Expandable search items (tiled selection)
- Multi-field sorting functionality with drag-and-drop
- Custom render support for complex search scenarios
- Search record persistence
- Responsive layout
Props:
| Property | Description | Type | Default |
| --- | --- | --- | --- |
| columns | Search/Table field configurations | NewbieProColumn[] | [] |
| onSubmit | Submit callback | (query: QueryForm, sort: SortForm) => void | - |
| autoQuery | Whether to trigger search automatically on change | boolean | false |
| disableConditions | Global toggle to disable condition selectors | boolean | false |
NewbieProColumn:
Inherits from ProColumns with additional properties:
| Property | Description | Type |
| --- | --- | --- |
| title| Field label | string |
| dataIndex | Unique field identifier | string |
| valueType | Field type | 'text'\|'digit'\|'date'\|'dateTime'\|'select'\|'cascader'\|'textarea' |
| sorter | Enable sorting for this field | boolean |
| fieldProps | Additional props passed to the input component | any |
Example:
<NewbieSearch columns={[ { title: '姓名', dataIndex: 'name', valueType: 'text' }, { title: '分数', dataIndex: 'score', valueType: 'digit', sorter: true }, ]} onSubmit={(query, sort) => { // query format: { name: { value: '...', condition: '...', type: 'input' } } console.log(query, sort) }} />
SlideVerify
High-performance slider verification component with behavior trajectory tracking.
Features:
- High performance: Smooth dragging with optimized rendering.
- Trajectory tracking: Records
(x, y, t)points during sliding for backend security analysis. - Mobile support: Full touch event support.
- Customizable: Adjustable height, handle width, and text labels.
- Reset capability: Programmatic reset support via ref.
Props:
| Property | Description | Type | Default |
| --- | --- | --- | --- |
| active | Whether the slider is active | boolean | true |
| onVerify | Callback after successful verification | (x: number, trail: TrailPoint[]) => void | - |
| height | Track height | number | 48 |
| handleWidth | Slider handle width | number | 40 |
| text | Default hint text | string | '向右滑动完成验证' |
| successText | Success hint text | string | '验证通过' |
| className | Custom container class | string | - |
Example:
import { SlideVerify } from 'jobsys-newbie-next' import type { SlideVerifyRef } from 'jobsys-newbie-next' function App() { const verifyRef = useRef<SlideVerifyRef>(null) return ( <SlideVerify ref={verifyRef} onVerify={(x, trail) => { console.log('Final position:', x) console.log('User behavior trail:', trail) }} /> ) }
Development
# Install dependencies pnpm install # Development (library) pnpm dev # Development (playground) cd playground && pnpm dev # Build pnpm build # Test pnpm test # Test with coverage pnpm test:coverage # Lint pnpm lint # Lint and fix pnpm lint:fix
Project Structure
newbie-next/
├── src/
│ ├── components/ # Components
│ │ ├── provider/ # NewbieProvider
│ │ ├── search/ # NewbieSearch
│ │ ├── form/ # NewbieForm (coming soon)
│ │ └── table/ # NewbieTable (coming soon)
│ ├── hooks/ # Custom Hooks
│ ├── utils/ # Utilities
│ └── types/ # Type definitions
├── playground/ # Playground application
├── .github/workflows/ # CI/CD configuration
└── .changeset/ # Changesets configuration
Testing
The project uses Vitest and @testing-library/react for testing.
# Run tests pnpm test # Run tests with UI pnpm test:ui # Run tests once pnpm test:run # Generate coverage report pnpm test:coverage
AI-Friendly Design
All code follows AI-friendly principles:
- Complete TypeScript types: All APIs have explicit type definitions
- Detailed JSDoc comments: Every function, component, and property has documentation with examples
- Semantic naming: Clear variable and function names
- Clear code structure: Modular, single responsibility
- Rich examples: Multiple usage scenarios
Contributing
See DEVELOPMENT_GUIDE.md for detailed development guidelines.
License
ISC
优点
- 全面的TypeScript支持
- 丰富的文档和示例
- 自动化版本管理
- 高测试覆盖率
缺点
- 仅限于React生态系统
- 复杂用例可能需要额外设置
- 依赖Ant Design
- 新用户可能面临学习曲线
相关技能
免责声明:本内容来源于 GitHub 开源项目,仅供展示和评分分析使用。
版权归原作者所有 jobsys.
