react-glide-table 1.1.4 → 1.1.6
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 +21 -0
- package/README.md +38 -3
- package/dist/compound.cjs +515 -128
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +519 -132
- package/dist/core.cjs +523 -119
- package/dist/core.d.cts +82 -8
- package/dist/core.d.ts +82 -8
- package/dist/core.js +515 -124
- package/dist/index.cjs +565 -130
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +560 -138
- 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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 송찬영
|
|
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
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
|
|