react-glide-table 1.1.5 → 1.1.7
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/README.md +38 -3
- package/dist/compound.cjs +378 -82
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +381 -85
- package/dist/core.cjs +401 -76
- package/dist/core.d.cts +59 -6
- package/dist/core.d.ts +59 -6
- package/dist/core.js +395 -81
- package/dist/index.cjs +424 -84
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +420 -91
- package/dist/{types-BfthylVR.d.cts → types-DOLnknDe.d.cts} +52 -1
- package/dist/{types-BfthylVR.d.ts → types-DOLnknDe.d.ts} +52 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,6 +141,39 @@ export function ProductTable({ data }: { data: Product[] }) {
|
|
|
141
141
|
|
|
142
142
|
Wire `rowContextValue` into your own row/cell components for edit, selection, expand, and row-span behavior.
|
|
143
143
|
|
|
144
|
+
## Clipboard copy & paste
|
|
145
|
+
|
|
146
|
+
Cell selection ships with clipboard shortcuts. The table parses TSV and emits structured payloads; **your app applies domain conversion and updates data**.
|
|
147
|
+
|
|
148
|
+
| Shortcut | Behavior |
|
|
149
|
+
| --- | --- |
|
|
150
|
+
| Ctrl/Cmd+C | Copy the active selection (visible rows) |
|
|
151
|
+
| Ctrl/Cmd+Shift+C | Copy including collapsed tree descendants (`enableSubtreeCopy`) |
|
|
152
|
+
| Ctrl/Cmd+V | Paste **overwrite** into the selection (`onRowsPaste`, `mode: "overwrite"`) |
|
|
153
|
+
| Ctrl/Cmd+Shift+V | Paste **insert** rows after the selection (`mode: "insert"`, when `enableInsertPaste`) |
|
|
154
|
+
|
|
155
|
+
Subtree copy encodes relative tree depth as leading tabs in the TSV so paste can rebuild parent/child nesting via `payload.depths`. Depth is only inferred when the clipboard looks like subtree indentation (first row unindented, at least one later row indented). Otherwise leading empty cells are kept as real values (e.g. Excel/Sheets blank first column) and `depths` stay `0`.
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import type { RowsPastePayload } from "react-glide-table/compound"
|
|
159
|
+
|
|
160
|
+
<ProductTable
|
|
161
|
+
data={data}
|
|
162
|
+
getRowId={(row) => row.id}
|
|
163
|
+
enableCellSelection
|
|
164
|
+
onRowsPaste={(payload: RowsPastePayload) => {
|
|
165
|
+
// overwrite: update cells from startRow using payload.values / columnIds
|
|
166
|
+
// insert: create rows after payload.endRow (or payload.anchorRowId for trees)
|
|
167
|
+
setData((prev) => applyMyPaste(prev, payload))
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
{/* columns… */}
|
|
171
|
+
</ProductTable>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Related props: `onRowsPaste`, `enableInsertPaste`, `enableSubtreeCopy`, `onCopyActionsReady`.
|
|
175
|
+
Helpers (`/core`): `buildRowsPastePayload`, `parseClipboardTSV`, `parseClipboardTSVWithDepths`, `serializeSelectionToTSV`, …
|
|
176
|
+
|
|
144
177
|
## Public API
|
|
145
178
|
|
|
146
179
|
| Export | Path | Role |
|
|
@@ -149,15 +182,17 @@ Wire `rowContextValue` into your own row/cell components for edit, selection, ex
|
|
|
149
182
|
| `DataTable` | `/compound` | Unstyled default renderer (semantic HTML + slots/props) |
|
|
150
183
|
| `useGlideTable` | `/core` | Headless engine escape hatch |
|
|
151
184
|
| `useCellEdit` / `useCellSelection` / `useConvertTreeData` | `/core` | Feature hooks |
|
|
152
|
-
| `applyCellEdit`, `applyFillData`, `buildColumnRowSpanMap`, … | `/core` | Pure helpers |
|
|
185
|
+
| `applyCellEdit`, `applyFillData`, `buildRowsPastePayload`, `buildColumnRowSpanMap`, … | `/core` | Pure helpers |
|
|
153
186
|
| `DEFAULT_DATA_TABLE_LABELS` / `resolveDataTableLabels` | `/core` | Optional English UI copy helpers |
|
|
154
187
|
| Tree field defaults | `/core` | `id` / `parentId` / `children` / `qty` |
|
|
155
188
|
|
|
156
|
-
Root `react-glide-table` re-exports both surfaces. Related types: `TableProps`, `TableColumnProps`, `DataTableProps`, `DataTableSlots`, `TableCompoundComponent`, `ColumnDef`, …
|
|
189
|
+
Root `react-glide-table` re-exports both surfaces. Related types: `TableProps`, `TableColumnProps`, `DataTableProps`, `DataTableSlots`, `TableCompoundComponent`, `ColumnDef`, `RowsPastePayload`, `PasteMode`, …
|
|
157
190
|
|
|
158
191
|
## Notable constraints
|
|
159
192
|
|
|
160
193
|
- **Row span + virtualization**: when `enableRowSpan` is on, virtualization is forced off (HTML `<table>` + `rowspan` cannot safely share a virtual window).
|
|
194
|
+
- **Paste is app-owned**: the library does not mutate `data` on paste — handle `onRowsPaste` (coerce types, ids, tree shape, row-span keys).
|
|
195
|
+
- **Flat tree parent order**: `useConvertTreeData` attaches each child to the nearest *preceding* row whose toggle key matches `parentId` (duplicate keys after paste resolve this way). Flat inputs must list parents before their children; a child whose parent appears later becomes a root. Nested `children` arrays are flattened parent-before-child automatically.
|
|
161
196
|
- **No shipped CSS**: the default renderer emits class hooks only. Bring your own styles (see playground for a CSS-skinned example).
|
|
162
197
|
|
|
163
198
|
## Local playground
|
|
@@ -167,7 +202,7 @@ pnpm install
|
|
|
167
202
|
pnpm dev
|
|
168
203
|
```
|
|
169
204
|
|
|
170
|
-
The playground uses `createTable` with a local CSS skin (`src/styles/index.css`) to exercise the compound API and headless core.
|
|
205
|
+
The playground uses `createTable` with a local CSS skin (`src/styles/index.css`) to exercise the compound API and headless core — including cell copy/paste (overwrite + insert) on flat and tree (BOM) tables.
|
|
171
206
|
|
|
172
207
|
## License
|
|
173
208
|
|