@zvndev/yable-react 0.0.0-canary-20260629011348

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present ZVN DEV
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # @zvndev/yable-react
2
+
3
+ React bindings for the Yable data table engine.
4
+
5
+ `@zvndev/yable-react` provides the `useTable` hook, a component tree for rendering tables, form controls for in-cell editing, and convenience components for pagination and filtering. It re-exports `@zvndev/yable-core` utilities so you only need one import for most use cases.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @zvndev/yable-core @zvndev/yable-react
11
+ ```
12
+
13
+ **Peer dependencies:** React 18+ (also works with React 19).
14
+
15
+ ## Quick Start
16
+
17
+ ```tsx
18
+ import { createColumnHelper, useTable, Table, Pagination } from '@zvndev/yable-react'
19
+ import '@zvndev/yable-themes'
20
+
21
+ interface Task {
22
+ title: string
23
+ status: 'todo' | 'in-progress' | 'done'
24
+ priority: number
25
+ }
26
+
27
+ const columnHelper = createColumnHelper<Task>()
28
+
29
+ const columns = [
30
+ columnHelper.accessor('title', { header: 'Title' }),
31
+ columnHelper.accessor('status', { header: 'Status' }),
32
+ columnHelper.accessor('priority', { header: 'Priority', enableSorting: true }),
33
+ ]
34
+
35
+ const data: Task[] = [
36
+ { title: 'Build table', status: 'done', priority: 1 },
37
+ { title: 'Write docs', status: 'in-progress', priority: 2 },
38
+ { title: 'Ship it', status: 'todo', priority: 3 },
39
+ ]
40
+
41
+ function TaskTable() {
42
+ const table = useTable({ data, columns })
43
+
44
+ return (
45
+ <Table table={table} striped>
46
+ <Pagination table={table} />
47
+ </Table>
48
+ )
49
+ }
50
+ ```
51
+
52
+ ## Hook
53
+
54
+ ### `useTable<TData>(options: TableOptions<TData>): Table<TData>`
55
+
56
+ The primary hook. Accepts the same options as `@zvndev/yable-core`'s `createTable()` but manages React state internally. Supports both uncontrolled (default) and controlled state patterns.
57
+
58
+ ```tsx
59
+ // Uncontrolled -- useTable manages all state
60
+ const table = useTable({ data, columns })
61
+
62
+ // Controlled -- you manage specific state slices
63
+ const [sorting, setSorting] = useState<SortingState>([])
64
+ const table = useTable({
65
+ data,
66
+ columns,
67
+ state: { sorting },
68
+ onSortingChange: setSorting,
69
+ })
70
+ ```
71
+
72
+ ## Components
73
+
74
+ ### Layout Components
75
+
76
+ | Component | Description |
77
+ |---|---|
78
+ | `Table` | Root container -- wraps everything in a `<div>` with a `<table>` inside. Accepts `table`, `striped`, `bordered`, `compact`, `stickyHeader`, `theme`, `loading`, `emptyMessage`, `footer`, and `children` props. |
79
+ | `TableHeader` | Renders `<thead>` with header groups and sort indicators. |
80
+ | `TableBody` | Renders `<tbody>` with rows and cells. |
81
+ | `TableCell` | Renders a single `<td>` with editing support. |
82
+ | `TableFooter` | Renders `<tfoot>` with footer content. |
83
+
84
+ ### Interactive Components
85
+
86
+ | Component | Description |
87
+ |---|---|
88
+ | `Pagination` | Page navigation with first/last/prev/next buttons, page numbers, and page size selector. Props: `table`, `showPageSize`, `pageSizes`, `showInfo`, `showFirstLast`. |
89
+ | `GlobalFilter` | Debounced search input for the global filter. Props: `table`, `placeholder`, `debounce`, `className`. |
90
+ | `SortIndicator` | Sort direction arrow icon. Props: `direction`, `index` (for multi-sort badge). |
91
+
92
+ ### Form Components (In-Cell Editing)
93
+
94
+ | Component | Description |
95
+ |---|---|
96
+ | `CellInput` | Text/number input for cell editing. Props: `context`, `type`, `placeholder`, `inline`, `autoFocus`. |
97
+ | `CellSelect` | Dropdown select for cell editing. |
98
+ | `CellCheckbox` | Checkbox for boolean cell values. |
99
+ | `CellToggle` | Toggle switch for boolean cell values. |
100
+ | `CellDatePicker` | Date input for cell editing. |
101
+
102
+ ### Context
103
+
104
+ | Export | Description |
105
+ |---|---|
106
+ | `TableProvider` | React context provider for the table instance. |
107
+ | `useTableContext()` | Hook to access the table instance from any child component. |
108
+
109
+ ## Re-exports from @zvndev/yable-core
110
+
111
+ For convenience, `@zvndev/yable-react` re-exports commonly used utilities so you don't need to import from `@zvndev/yable-core` directly:
112
+
113
+ - `createColumnHelper`
114
+ - `sortingFns`
115
+ - `filterFns`
116
+ - `aggregationFns`
117
+ - `functionalUpdate`
118
+ - All core types (`TableOptions`, `SortingState`, `ColumnDef`, etc.)
119
+
120
+ ## Table Props
121
+
122
+ The `<Table>` component accepts these props:
123
+
124
+ ```typescript
125
+ interface TableProps<TData> {
126
+ table: Table<TData> // Required -- the table instance from useTable
127
+ stickyHeader?: boolean // Pin header to top on scroll
128
+ striped?: boolean // Alternate row backgrounds
129
+ bordered?: boolean // Add cell borders
130
+ compact?: boolean // Reduce padding
131
+ theme?: string // Theme variant name
132
+ clickableRows?: boolean // Add pointer cursor + hover to rows
133
+ footer?: boolean // Show table footer
134
+ loading?: boolean // Show loading overlay
135
+ emptyMessage?: string // Text when no rows (default: "No data")
136
+ renderEmpty?: () => ReactNode // Custom empty state
137
+ renderLoading?: () => ReactNode // Custom loading state
138
+ children?: ReactNode // Extra content (e.g. Pagination)
139
+ className?: string // Additional CSS class
140
+ }
141
+ ```
142
+
143
+ ## License
144
+
145
+ MIT