feat: Add enterprise data table component with Airtable-like features including column resizing and reordering#13
Conversation
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
…callback Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive enterprise-grade data table component with Airtable-like functionality, addressing the requirement for a complete table control similar to Airtable.
Changes:
- Added a new
data-tablecomponent with features including column sorting, pagination, search, row selection, CSV export, and row actions - Implemented comprehensive unit tests covering component registration, metadata, and default configurations
- Added example schemas demonstrating both full-featured enterprise usage and minimal configuration
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/components/src/renderers/complex/index.ts | Registered the new data-table component in the complex renderers index |
| packages/components/src/renderers/complex/data-table.tsx | Core implementation of the enterprise data table with all features |
| packages/components/src/renderers/complex/tests/data-table.test.ts | Unit tests verifying component registration and configuration |
| apps/playground/src/data/examples.ts | Added two example schemas showcasing enterprise and simple table variants |
| className?: string; | ||
| } | ||
|
|
||
| const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => { |
There was a problem hiding this comment.
The DataTableRenderer function lacks JSDoc documentation. According to coding guidelines, components should have JSDoc explaining their purpose, parameters, and usage examples, especially for open-source community documentation.
There was a problem hiding this comment.
Added comprehensive JSDoc documentation for the DataTableRenderer function including purpose, features list, usage example, parameter descriptions, and return type. Commit: 1474d29
| interface Column { | ||
| header: string; | ||
| accessorKey: string; | ||
| className?: string; | ||
| cellClassName?: string; | ||
| width?: string | number; | ||
| sortable?: boolean; | ||
| filterable?: boolean; | ||
| } | ||
|
|
||
| interface DataTableSchema { | ||
| caption?: string; | ||
| columns: Column[]; | ||
| data: any[]; | ||
| pagination?: boolean; | ||
| pageSize?: number; | ||
| searchable?: boolean; | ||
| selectable?: boolean; | ||
| sortable?: boolean; | ||
| exportable?: boolean; | ||
| rowActions?: boolean; | ||
| onRowEdit?: (row: any) => void; | ||
| onRowDelete?: (row: any) => void; | ||
| onSelectionChange?: (selectedRows: any[]) => void; | ||
| className?: string; | ||
| } |
There was a problem hiding this comment.
The Column and DataTableSchema interfaces lack JSDoc documentation. Per coding guidelines (Rule #3), all schema properties should have JSDoc to enable auto-generated documentation for the open-source community.
There was a problem hiding this comment.
Added detailed JSDoc documentation to both Column and DataTableSchema interfaces. Each property now has inline documentation explaining its purpose, type, and default values. Commit: 1474d29
| const getRowId = (row: any, index: number) => { | ||
| // Try to use 'id' field, fall back to index | ||
| return row.id !== undefined ? row.id : `row-${index}`; | ||
| }; |
There was a problem hiding this comment.
The getRowId helper function lacks JSDoc documentation explaining its purpose of generating stable row identifiers for selection persistence across pagination/sorting operations.
There was a problem hiding this comment.
Added JSDoc documentation for the getRowId helper function explaining its purpose of generating stable row identifiers for selection persistence across pagination and sorting operations. Commit: 1474d29
|
@copilot 修复所有 |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
✅ All checks passed!
|
|
@copilot fix pnpm test build lint |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Fixed all build, test, and lint issues. Commit: c31a011 Changes:
Test Results:
|
|
@copilot 表格应支持拖动列宽,支持拖动排序列 |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
@copilot 从主分支同步最新的代码,并测试验证 |
…arkdown and other new components
已成功从主分支同步最新代码并完成测试验证。提交: a0557ba 同步结果:
测试验证:
包含的功能:
|
|
✅ All checks passed!
|
|
✅ All checks passed!
|
|
✅ All checks passed!
|
Enterprise-Level Table Component Implementation (Airtable-like) ✅
Overview
Successfully implemented a comprehensive enterprise-level data table component with features similar to Airtable, addressing the requirement for "实现企业级的功能,完善的表格控件,类似airtable" (implement enterprise-level features, complete table component, similar to Airtable).
Latest Update: ✅ Merged with main branch - Successfully integrated all new components from main including calendar-view, filter-builder, markdown, and other enhancements. All tests passing.
✅ All Implementation Complete
Phase 1: Enhanced Table Foundation ✅
Phase 2: Advanced Interactions ✅
Phase 3: Component Structure ✅
data-tablecomponent atpackages/components/src/renderers/complex/data-table.tsxPhase 4: Testing ✅
Phase 5: Code Quality & Security ✅
Main Branch Integration ✅
apps/playground/src/data/examples.tsandpackages/components/src/renderers/complex/index.tsDocumentation Added ✅
resizablepropertyresizableColumnsandreorderableColumns)Build, Test, Lint Status ✅
Fixes Applied
anytype usage in App.tsxFeatures Implemented ✅
✅ Sorting: Click column headers to sort ascending/descending/none
✅ Pagination: Configurable page sizes (5, 10, 20, 50, 100 rows per page)
✅ Search: Real-time search across all columns
✅ Row Selection: Checkbox selection with "select all" functionality
✅ Persistent Selection: Selection persists across page changes using unique IDs
✅ Export: CSV export of all filtered/sorted data
✅ Row Actions: Edit and delete buttons for each row
✅ Column Resizing: Drag column borders to dynamically adjust column widths with visual feedback
✅ Column Reordering: Drag column headers to reorder columns with visual drop indicators
✅ Responsive Design: Clean Tailwind styling with Shadcn UI components
✅ Empty States: Proper handling when no data is available
✅ Configurable: All features can be toggled on/off via schema
✅ Callbacks: onRowEdit, onRowDelete, onSelectionChange, onColumnsReorder
✅ Well Documented: Full JSDoc for open-source community
Technical Details
New Files:
packages/components/src/renderers/complex/data-table.tsx(~640 lines with docs) - Enterprise data table componentpackages/components/src/renderers/complex/__tests__/data-table.test.ts- Unit testsapps/playground/eslint.config.js- ESLint configuration for playgroundModified Files:
packages/components/src/renderers/complex/index.ts- Register new component (merged with calendar-view)apps/playground/src/data/examples.ts- Add two comprehensive examples (merged with calendar-view and other examples)apps/playground/package.json- Add eslint dependenciesapps/playground/src/App.tsx- Fix lint errorsapps/playground/tailwind.config.js- Fix lint warningsComponent Schema (Fully Documented):
Column Resizing Implementation
Column Reordering Implementation
Quality Metrics
Summary
This PR successfully delivers a production-ready, enterprise-level data table component that rivals Airtable's functionality. The component is:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.