react-glide-table 2.3.0 → 2.3.2
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 +27 -0
- package/dist/compound.cjs +219 -105
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +219 -105
- package/dist/core.cjs +219 -107
- package/dist/core.d.cts +3 -2
- package/dist/core.d.ts +3 -2
- package/dist/core.js +219 -107
- package/dist/index.cjs +222 -108
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +222 -108
- package/dist/{types-DdeVn-9s.d.cts → types-hf2ruVdu.d.cts} +25 -1
- package/dist/{types-DdeVn-9s.d.ts → types-hf2ruVdu.d.ts} +25 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,7 @@ export function Products({ data }: { data: Product[] }) {
|
|
|
75
75
|
| `className` / column `className` / `headerClassName` | Extra class hooks |
|
|
76
76
|
| `labels` / `summary` / `toolbar` | Copy and slot nodes |
|
|
77
77
|
| `Column.render` / `ColumnDef.cell` | Cell content custom render (prefer `update` via context) |
|
|
78
|
+
| `Column.copyValue` | Clipboard: `"display"` (default) / `"value"` / `"omit"` / `(ctx) => string` |
|
|
78
79
|
| `Column.kind` / `cellRenderers` | Built-in or custom cell kinds (override / add via registry) |
|
|
79
80
|
|
|
80
81
|
Row/cell **state** is exposed as `data-*` attributes for Tailwind variants:
|
|
@@ -240,6 +241,32 @@ Cell selection ships with clipboard shortcuts. The table parses TSV and emits st
|
|
|
240
241
|
|
|
241
242
|
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`.
|
|
242
243
|
|
|
244
|
+
Per-column `copyValue` controls what lands on the clipboard when a custom `render` / `kind` is present:
|
|
245
|
+
|
|
246
|
+
- (default) / `"display"` — text from the rendered cell (buttons stay empty)
|
|
247
|
+
- `"value"` — raw accessor / field value (e.g. a count behind a button)
|
|
248
|
+
- `"omit"` — drop the column from the TSV entirely (neighbors shift left; same-table paste may misalign)
|
|
249
|
+
- `(ctx) => string` — fully custom clipboard string
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
<ProductTable.Column
|
|
253
|
+
field="partCount"
|
|
254
|
+
copyValue="value"
|
|
255
|
+
render={({ value }) => <button type="button">{value}개 보기</button>}
|
|
256
|
+
>
|
|
257
|
+
Part No
|
|
258
|
+
</ProductTable.Column>
|
|
259
|
+
|
|
260
|
+
<ProductTable.Column
|
|
261
|
+
field="actions"
|
|
262
|
+
virtual
|
|
263
|
+
copyValue="omit"
|
|
264
|
+
render={() => <button type="button">Edit</button>}
|
|
265
|
+
>
|
|
266
|
+
Actions
|
|
267
|
+
</ProductTable.Column>
|
|
268
|
+
```
|
|
269
|
+
|
|
243
270
|
```tsx
|
|
244
271
|
import type { RowsPastePayload } from "react-glide-table/compound";
|
|
245
272
|
|
package/dist/compound.cjs
CHANGED
|
@@ -2658,9 +2658,123 @@ function formatDefaultCellValue(value) {
|
|
|
2658
2658
|
return String(value);
|
|
2659
2659
|
}
|
|
2660
2660
|
|
|
2661
|
+
// src/components/ui/table/features/cell-selection/pasteData.ts
|
|
2662
|
+
function countLeadingEmptyCells(cells) {
|
|
2663
|
+
let depth = 0;
|
|
2664
|
+
while (depth < cells.length && cells[depth] === "") {
|
|
2665
|
+
depth += 1;
|
|
2666
|
+
}
|
|
2667
|
+
return depth;
|
|
2668
|
+
}
|
|
2669
|
+
function looksLikeSubtreeIndentation(leadingEmptyCounts) {
|
|
2670
|
+
if (leadingEmptyCounts.length === 0) return false;
|
|
2671
|
+
const firstDepth = leadingEmptyCounts[0] ?? 0;
|
|
2672
|
+
if (firstDepth !== 0) return false;
|
|
2673
|
+
return leadingEmptyCounts.some((depth) => depth > 0);
|
|
2674
|
+
}
|
|
2675
|
+
function parseClipboardTSVWithDepths(text) {
|
|
2676
|
+
if (!text) return { values: [], depths: [] };
|
|
2677
|
+
const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
2678
|
+
const withoutTrailing = normalized.replace(/\n+$/, "");
|
|
2679
|
+
if (!withoutTrailing) return { values: [], depths: [] };
|
|
2680
|
+
const rows = withoutTrailing.split("\n").map((line) => line.split(" "));
|
|
2681
|
+
const leadingEmptyCounts = rows.map(countLeadingEmptyCells);
|
|
2682
|
+
const treatAsDepth = looksLikeSubtreeIndentation(leadingEmptyCounts);
|
|
2683
|
+
const values = [];
|
|
2684
|
+
const depths = [];
|
|
2685
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
2686
|
+
const cells = rows[index] ?? [];
|
|
2687
|
+
const depth = leadingEmptyCounts[index] ?? 0;
|
|
2688
|
+
if (treatAsDepth) {
|
|
2689
|
+
values.push(cells.slice(depth));
|
|
2690
|
+
depths.push(depth);
|
|
2691
|
+
} else {
|
|
2692
|
+
values.push(cells);
|
|
2693
|
+
depths.push(0);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
return { values, depths };
|
|
2697
|
+
}
|
|
2698
|
+
function resolvePasteColumnIds(rows, startCol, width) {
|
|
2699
|
+
if (width <= 0) return [];
|
|
2700
|
+
const cells = rows[0]?.getVisibleCells() ?? [];
|
|
2701
|
+
const columnIds = [];
|
|
2702
|
+
for (let offset = 0; offset < width; offset += 1) {
|
|
2703
|
+
const cell = cells[startCol + offset];
|
|
2704
|
+
if (!cell) break;
|
|
2705
|
+
columnIds.push(cell.column.id);
|
|
2706
|
+
}
|
|
2707
|
+
return columnIds;
|
|
2708
|
+
}
|
|
2709
|
+
function buildRowsPastePayload(rows, startRow, startCol, text, mode, endRow = startRow) {
|
|
2710
|
+
const { values, depths } = parseClipboardTSVWithDepths(text);
|
|
2711
|
+
if (values.length === 0) return null;
|
|
2712
|
+
const width = Math.max(...values.map((row) => row.length), 0);
|
|
2713
|
+
if (width === 0) return null;
|
|
2714
|
+
const columnIds = resolvePasteColumnIds(rows, startCol, width);
|
|
2715
|
+
if (columnIds.length === 0) return null;
|
|
2716
|
+
const rowIds = [];
|
|
2717
|
+
for (let offset = 0; offset < values.length; offset += 1) {
|
|
2718
|
+
const row = rows[startRow + offset];
|
|
2719
|
+
if (!row) break;
|
|
2720
|
+
rowIds.push(row.id);
|
|
2721
|
+
}
|
|
2722
|
+
const anchorRow = rows[endRow] ?? rows[startRow];
|
|
2723
|
+
return {
|
|
2724
|
+
mode,
|
|
2725
|
+
startRow,
|
|
2726
|
+
startCol,
|
|
2727
|
+
endRow,
|
|
2728
|
+
rowIds,
|
|
2729
|
+
anchorRowId: anchorRow?.id ?? "",
|
|
2730
|
+
columnIds,
|
|
2731
|
+
values,
|
|
2732
|
+
depths
|
|
2733
|
+
};
|
|
2734
|
+
}
|
|
2735
|
+
function isEditablePasteTarget(target) {
|
|
2736
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
2737
|
+
const tag = target.tagName;
|
|
2738
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
|
|
2739
|
+
return Boolean(target.isContentEditable);
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2661
2742
|
// src/components/ui/table/features/cell-selection/useCellSelection.ts
|
|
2662
2743
|
var import_react7 = require("react");
|
|
2663
2744
|
|
|
2745
|
+
// src/components/ui/table/features/cell-selection/activeCellSelectionOwner.ts
|
|
2746
|
+
var activeOwner = null;
|
|
2747
|
+
var clearByOwner = /* @__PURE__ */ new Map();
|
|
2748
|
+
function createCellSelectionOwner() {
|
|
2749
|
+
return /* @__PURE__ */ Symbol("cell-selection-owner");
|
|
2750
|
+
}
|
|
2751
|
+
function registerCellSelectionOwner(owner, clearSelection) {
|
|
2752
|
+
clearByOwner.set(owner, clearSelection);
|
|
2753
|
+
return () => {
|
|
2754
|
+
clearByOwner.delete(owner);
|
|
2755
|
+
if (activeOwner === owner) {
|
|
2756
|
+
activeOwner = null;
|
|
2757
|
+
}
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2760
|
+
function claimCellSelectionOwner(owner) {
|
|
2761
|
+
if (activeOwner === owner) return;
|
|
2762
|
+
activeOwner = owner;
|
|
2763
|
+
for (const [id, clearSelection] of clearByOwner) {
|
|
2764
|
+
if (id !== owner) {
|
|
2765
|
+
clearSelection();
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
function isActiveCellSelectionOwner(owner) {
|
|
2770
|
+
return activeOwner === owner;
|
|
2771
|
+
}
|
|
2772
|
+
function releaseCellSelectionOwner(owner) {
|
|
2773
|
+
if (activeOwner === owner) {
|
|
2774
|
+
activeOwner = null;
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2664
2778
|
// src/components/ui/table/features/cell-selection/copyData.ts
|
|
2665
2779
|
var import_react6 = require("react");
|
|
2666
2780
|
function isReactNodeIterable(node) {
|
|
@@ -2833,19 +2947,31 @@ function extractRenderedCopyText(node, value, cellPosition, root) {
|
|
|
2833
2947
|
function formatCopyCellText(rowData, columnDef, columnId, visibleRow, fallbackIndex, sourceCell, cellPosition, options) {
|
|
2834
2948
|
const meta = columnDef.meta;
|
|
2835
2949
|
const value = sourceCell ? sourceCell.getValue() : readRowColumnValue(rowData, columnDef);
|
|
2950
|
+
const row = visibleRow ?? createCopyRenderRow(rowData, fallbackIndex);
|
|
2951
|
+
const ctx = {
|
|
2952
|
+
value,
|
|
2953
|
+
row,
|
|
2954
|
+
index: row.index,
|
|
2955
|
+
columnId,
|
|
2956
|
+
cellProps: meta?.cellProps,
|
|
2957
|
+
update: () => {
|
|
2958
|
+
}
|
|
2959
|
+
};
|
|
2960
|
+
const copyValue = meta?.copyValue;
|
|
2961
|
+
if (typeof copyValue === "function") {
|
|
2962
|
+
try {
|
|
2963
|
+
return sanitizeClipboardCell(copyValue(ctx));
|
|
2964
|
+
} catch {
|
|
2965
|
+
return formatCellValue(value);
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
if (copyValue === "value") {
|
|
2969
|
+
return formatCellValue(value);
|
|
2970
|
+
}
|
|
2836
2971
|
const cellRender = meta?.cellRender;
|
|
2837
2972
|
if (typeof cellRender === "function") {
|
|
2838
2973
|
try {
|
|
2839
|
-
const
|
|
2840
|
-
const node = cellRender({
|
|
2841
|
-
value,
|
|
2842
|
-
row,
|
|
2843
|
-
index: row.index,
|
|
2844
|
-
columnId,
|
|
2845
|
-
cellProps: meta?.cellProps,
|
|
2846
|
-
update: () => {
|
|
2847
|
-
}
|
|
2848
|
-
});
|
|
2974
|
+
const node = cellRender(ctx);
|
|
2849
2975
|
return extractRenderedCopyText(node, value, cellPosition, options?.root);
|
|
2850
2976
|
} catch {
|
|
2851
2977
|
return formatCellValue(value);
|
|
@@ -2853,16 +2979,6 @@ function formatCopyCellText(rowData, columnDef, columnId, visibleRow, fallbackIn
|
|
|
2853
2979
|
}
|
|
2854
2980
|
if (options?.registry && meta?.kind && isPrimitiveCopyValue(value)) {
|
|
2855
2981
|
try {
|
|
2856
|
-
const row = visibleRow ?? createCopyRenderRow(rowData, fallbackIndex);
|
|
2857
|
-
const ctx = {
|
|
2858
|
-
value,
|
|
2859
|
-
row,
|
|
2860
|
-
index: row.index,
|
|
2861
|
-
columnId,
|
|
2862
|
-
cellProps: meta.cellProps,
|
|
2863
|
-
update: () => {
|
|
2864
|
-
}
|
|
2865
|
-
};
|
|
2866
2982
|
const renderer = resolveCellRenderer(options.registry, meta.kind, ctx);
|
|
2867
2983
|
if (renderer) {
|
|
2868
2984
|
const node = renderer.render(ctx);
|
|
@@ -2969,11 +3085,16 @@ function serializeCopyRowsToTSV(copyRows, visibleRows, bounds, depths, options)
|
|
|
2969
3085
|
const resolvedDepths = depths && depths.length === copyRows.length ? depths : copyRows.map((row) => getRowDepth(row));
|
|
2970
3086
|
const minDepth = Math.min(...resolvedDepths);
|
|
2971
3087
|
const visibleRowByOriginal = buildVisibleRowLookup(visibleRows);
|
|
3088
|
+
const copyableColumns = columnCells.flatMap((templateCell, colOffset) => {
|
|
3089
|
+
const meta = templateCell.column.columnDef.meta;
|
|
3090
|
+
if (meta?.copyValue === "omit") return [];
|
|
3091
|
+
return [{ templateCell, colOffset }];
|
|
3092
|
+
});
|
|
2972
3093
|
return copyRows.map((rowData, index) => {
|
|
2973
3094
|
const relativeDepth = Math.max(0, (resolvedDepths[index] ?? 0) - minDepth);
|
|
2974
3095
|
const visibleRow = visibleRowByOriginal.get(rowData);
|
|
2975
3096
|
const matchingCells = visibleRow?.getVisibleCells().slice(startCol, endCol + 1);
|
|
2976
|
-
const line =
|
|
3097
|
+
const line = copyableColumns.map(({ templateCell, colOffset }) => {
|
|
2977
3098
|
const sourceCell = matchingCells?.[colOffset];
|
|
2978
3099
|
const column = sourceCell?.column ?? templateCell.column;
|
|
2979
3100
|
return formatCopyCellText(
|
|
@@ -3067,87 +3188,6 @@ function hasFillExtension(sourceBounds, fillBounds) {
|
|
|
3067
3188
|
return fillBounds.startRow < sourceBounds.startRow || fillBounds.endRow > sourceBounds.endRow || fillBounds.startCol < sourceBounds.startCol || fillBounds.endCol > sourceBounds.endCol;
|
|
3068
3189
|
}
|
|
3069
3190
|
|
|
3070
|
-
// src/components/ui/table/features/cell-selection/pasteData.ts
|
|
3071
|
-
function countLeadingEmptyCells(cells) {
|
|
3072
|
-
let depth = 0;
|
|
3073
|
-
while (depth < cells.length && cells[depth] === "") {
|
|
3074
|
-
depth += 1;
|
|
3075
|
-
}
|
|
3076
|
-
return depth;
|
|
3077
|
-
}
|
|
3078
|
-
function looksLikeSubtreeIndentation(leadingEmptyCounts) {
|
|
3079
|
-
if (leadingEmptyCounts.length === 0) return false;
|
|
3080
|
-
const firstDepth = leadingEmptyCounts[0] ?? 0;
|
|
3081
|
-
if (firstDepth !== 0) return false;
|
|
3082
|
-
return leadingEmptyCounts.some((depth) => depth > 0);
|
|
3083
|
-
}
|
|
3084
|
-
function parseClipboardTSVWithDepths(text) {
|
|
3085
|
-
if (!text) return { values: [], depths: [] };
|
|
3086
|
-
const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
3087
|
-
const withoutTrailing = normalized.replace(/\n+$/, "");
|
|
3088
|
-
if (!withoutTrailing) return { values: [], depths: [] };
|
|
3089
|
-
const rows = withoutTrailing.split("\n").map((line) => line.split(" "));
|
|
3090
|
-
const leadingEmptyCounts = rows.map(countLeadingEmptyCells);
|
|
3091
|
-
const treatAsDepth = looksLikeSubtreeIndentation(leadingEmptyCounts);
|
|
3092
|
-
const values = [];
|
|
3093
|
-
const depths = [];
|
|
3094
|
-
for (let index = 0; index < rows.length; index += 1) {
|
|
3095
|
-
const cells = rows[index] ?? [];
|
|
3096
|
-
const depth = leadingEmptyCounts[index] ?? 0;
|
|
3097
|
-
if (treatAsDepth) {
|
|
3098
|
-
values.push(cells.slice(depth));
|
|
3099
|
-
depths.push(depth);
|
|
3100
|
-
} else {
|
|
3101
|
-
values.push(cells);
|
|
3102
|
-
depths.push(0);
|
|
3103
|
-
}
|
|
3104
|
-
}
|
|
3105
|
-
return { values, depths };
|
|
3106
|
-
}
|
|
3107
|
-
function resolvePasteColumnIds(rows, startCol, width) {
|
|
3108
|
-
if (width <= 0) return [];
|
|
3109
|
-
const cells = rows[0]?.getVisibleCells() ?? [];
|
|
3110
|
-
const columnIds = [];
|
|
3111
|
-
for (let offset = 0; offset < width; offset += 1) {
|
|
3112
|
-
const cell = cells[startCol + offset];
|
|
3113
|
-
if (!cell) break;
|
|
3114
|
-
columnIds.push(cell.column.id);
|
|
3115
|
-
}
|
|
3116
|
-
return columnIds;
|
|
3117
|
-
}
|
|
3118
|
-
function buildRowsPastePayload(rows, startRow, startCol, text, mode, endRow = startRow) {
|
|
3119
|
-
const { values, depths } = parseClipboardTSVWithDepths(text);
|
|
3120
|
-
if (values.length === 0) return null;
|
|
3121
|
-
const width = Math.max(...values.map((row) => row.length), 0);
|
|
3122
|
-
if (width === 0) return null;
|
|
3123
|
-
const columnIds = resolvePasteColumnIds(rows, startCol, width);
|
|
3124
|
-
if (columnIds.length === 0) return null;
|
|
3125
|
-
const rowIds = [];
|
|
3126
|
-
for (let offset = 0; offset < values.length; offset += 1) {
|
|
3127
|
-
const row = rows[startRow + offset];
|
|
3128
|
-
if (!row) break;
|
|
3129
|
-
rowIds.push(row.id);
|
|
3130
|
-
}
|
|
3131
|
-
const anchorRow = rows[endRow] ?? rows[startRow];
|
|
3132
|
-
return {
|
|
3133
|
-
mode,
|
|
3134
|
-
startRow,
|
|
3135
|
-
startCol,
|
|
3136
|
-
endRow,
|
|
3137
|
-
rowIds,
|
|
3138
|
-
anchorRowId: anchorRow?.id ?? "",
|
|
3139
|
-
columnIds,
|
|
3140
|
-
values,
|
|
3141
|
-
depths
|
|
3142
|
-
};
|
|
3143
|
-
}
|
|
3144
|
-
function isEditablePasteTarget(target) {
|
|
3145
|
-
if (!(target instanceof HTMLElement)) return false;
|
|
3146
|
-
const tag = target.tagName;
|
|
3147
|
-
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
|
|
3148
|
-
return Boolean(target.isContentEditable);
|
|
3149
|
-
}
|
|
3150
|
-
|
|
3151
3191
|
// src/components/ui/table/features/cell-selection/useCellSelection.ts
|
|
3152
3192
|
function useCellSelection({
|
|
3153
3193
|
data,
|
|
@@ -3163,6 +3203,7 @@ function useCellSelection({
|
|
|
3163
3203
|
cellRendererRegistry,
|
|
3164
3204
|
rootRef
|
|
3165
3205
|
}) {
|
|
3206
|
+
const ownerRef = (0, import_react7.useRef)(createCellSelectionOwner());
|
|
3166
3207
|
const [dragState, setDragState] = (0, import_react7.useState)(INITIAL_DRAG_STATE);
|
|
3167
3208
|
const pendingPasteModeRef = (0, import_react7.useRef)(null);
|
|
3168
3209
|
const dragStateRef = (0, import_react7.useRef)(dragState);
|
|
@@ -3174,6 +3215,7 @@ function useCellSelection({
|
|
|
3174
3215
|
const handleCellMouseDown = (0, import_react7.useCallback)(
|
|
3175
3216
|
(rowIndex, colIndex, options) => {
|
|
3176
3217
|
if (!enabled) return;
|
|
3218
|
+
claimCellSelectionOwner(ownerRef.current);
|
|
3177
3219
|
setDragState((prev) => {
|
|
3178
3220
|
if (options?.shiftKey && prev.start) {
|
|
3179
3221
|
return {
|
|
@@ -3215,6 +3257,7 @@ function useCellSelection({
|
|
|
3215
3257
|
const handleFillHandleMouseDown = (0, import_react7.useCallback)(
|
|
3216
3258
|
(rowIndex, colIndex) => {
|
|
3217
3259
|
if (!enabled) return;
|
|
3260
|
+
claimCellSelectionOwner(ownerRef.current);
|
|
3218
3261
|
setDragState((prev) => {
|
|
3219
3262
|
const bounds = getCellSelectionBounds(prev.start, prev.end);
|
|
3220
3263
|
if (!bounds) return prev;
|
|
@@ -3229,14 +3272,27 @@ function useCellSelection({
|
|
|
3229
3272
|
},
|
|
3230
3273
|
[enabled]
|
|
3231
3274
|
);
|
|
3275
|
+
const clearSelection = (0, import_react7.useCallback)(() => {
|
|
3276
|
+
const prev = dragStateRef.current;
|
|
3277
|
+
if (prev.start === null && prev.end === null && !prev.isSelecting && !prev.isFillDragging) {
|
|
3278
|
+
return;
|
|
3279
|
+
}
|
|
3280
|
+
releaseCellSelectionOwner(ownerRef.current);
|
|
3281
|
+
dragStateRef.current = INITIAL_DRAG_STATE;
|
|
3282
|
+
setDragState(INITIAL_DRAG_STATE);
|
|
3283
|
+
}, []);
|
|
3232
3284
|
(0, import_react7.useEffect)(() => {
|
|
3233
3285
|
if (!enabled) {
|
|
3234
|
-
|
|
3286
|
+
clearSelection();
|
|
3235
3287
|
}
|
|
3236
|
-
}, [enabled]);
|
|
3288
|
+
}, [clearSelection, enabled]);
|
|
3289
|
+
(0, import_react7.useEffect)(() => {
|
|
3290
|
+
return registerCellSelectionOwner(ownerRef.current, clearSelection);
|
|
3291
|
+
}, [clearSelection]);
|
|
3237
3292
|
(0, import_react7.useEffect)(() => {
|
|
3238
3293
|
if (!enabled) return;
|
|
3239
3294
|
const handleKeyDown = (e) => {
|
|
3295
|
+
if (!isActiveCellSelectionOwner(ownerRef.current)) return;
|
|
3240
3296
|
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
3241
3297
|
if (isEditablePasteTarget(e.target) || isEditablePasteTarget(document.activeElement)) {
|
|
3242
3298
|
return;
|
|
@@ -3302,6 +3358,7 @@ function useCellSelection({
|
|
|
3302
3358
|
(0, import_react7.useEffect)(() => {
|
|
3303
3359
|
if (!enabled) return;
|
|
3304
3360
|
const handleKeyDown = (e) => {
|
|
3361
|
+
if (!isActiveCellSelectionOwner(ownerRef.current)) return;
|
|
3305
3362
|
if (!activeSelectionBounds) return;
|
|
3306
3363
|
if (!(e.ctrlKey || e.metaKey)) return;
|
|
3307
3364
|
if (isEditablePasteTarget(e.target) || isEditablePasteTarget(document.activeElement)) {
|
|
@@ -3338,6 +3395,7 @@ function useCellSelection({
|
|
|
3338
3395
|
const pasteHandledRef = { current: false };
|
|
3339
3396
|
const ignoreNextPasteRef = { current: false };
|
|
3340
3397
|
const handleKeyDown = (e) => {
|
|
3398
|
+
if (!isActiveCellSelectionOwner(ownerRef.current)) return;
|
|
3341
3399
|
if (!activeSelectionBounds) return;
|
|
3342
3400
|
if (!(e.ctrlKey || e.metaKey)) return;
|
|
3343
3401
|
if (e.key.toLowerCase() !== "v") return;
|
|
@@ -3358,6 +3416,7 @@ function useCellSelection({
|
|
|
3358
3416
|
const text = await navigator.clipboard.readText();
|
|
3359
3417
|
if (pasteHandledRef.current) return;
|
|
3360
3418
|
if (pendingPasteModeRef.current !== mode) return;
|
|
3419
|
+
if (!isActiveCellSelectionOwner(ownerRef.current)) return;
|
|
3361
3420
|
if (!text) return;
|
|
3362
3421
|
pasteHandledRef.current = true;
|
|
3363
3422
|
emitRowsPaste(text, mode);
|
|
@@ -3367,6 +3426,7 @@ function useCellSelection({
|
|
|
3367
3426
|
})();
|
|
3368
3427
|
};
|
|
3369
3428
|
const handlePaste = (e) => {
|
|
3429
|
+
if (!isActiveCellSelectionOwner(ownerRef.current)) return;
|
|
3370
3430
|
if (!activeSelectionBounds) return;
|
|
3371
3431
|
if (isEditablePasteTarget(e.target) || isEditablePasteTarget(document.activeElement)) {
|
|
3372
3432
|
return;
|
|
@@ -3447,10 +3507,30 @@ function useCellSelection({
|
|
|
3447
3507
|
handleCellMouseDown,
|
|
3448
3508
|
handleCellMouseEnter,
|
|
3449
3509
|
handleFillHandleMouseDown,
|
|
3510
|
+
clearSelection,
|
|
3450
3511
|
copySelection
|
|
3451
3512
|
};
|
|
3452
3513
|
}
|
|
3453
3514
|
|
|
3515
|
+
// src/components/ui/table/features/selection-dismiss/isOutsideDismissTarget.ts
|
|
3516
|
+
var OVERLAY_DISMISS_IGNORE_SELECTOR = [
|
|
3517
|
+
'[role="dialog"]',
|
|
3518
|
+
'[role="alertdialog"]',
|
|
3519
|
+
'[role="menu"]',
|
|
3520
|
+
'[role="listbox"]',
|
|
3521
|
+
'[role="tooltip"]',
|
|
3522
|
+
'[aria-modal="true"]',
|
|
3523
|
+
"[data-radix-portal]",
|
|
3524
|
+
"[data-radix-popper-content-wrapper]",
|
|
3525
|
+
"[data-floating-ui-portal]",
|
|
3526
|
+
"[data-table-ignore-outside-dismiss]"
|
|
3527
|
+
].join(",");
|
|
3528
|
+
function isOverlayDismissIgnoreTarget(target) {
|
|
3529
|
+
const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;
|
|
3530
|
+
if (!element) return false;
|
|
3531
|
+
return element.closest(OVERLAY_DISMISS_IGNORE_SELECTOR) !== null;
|
|
3532
|
+
}
|
|
3533
|
+
|
|
3454
3534
|
// src/components/ui/table/features/inline-search/useInlineSearch.ts
|
|
3455
3535
|
var import_react8 = require("react");
|
|
3456
3536
|
var EMPTY_MATCH_KEYS = /* @__PURE__ */ new Set();
|
|
@@ -4038,6 +4118,7 @@ function useGlideTable(options) {
|
|
|
4038
4118
|
handleCellMouseDown,
|
|
4039
4119
|
handleCellMouseEnter,
|
|
4040
4120
|
handleFillHandleMouseDown,
|
|
4121
|
+
clearSelection: clearCellSelection,
|
|
4041
4122
|
copySelection
|
|
4042
4123
|
} = useCellSelection({
|
|
4043
4124
|
data: tableData,
|
|
@@ -4053,6 +4134,37 @@ function useGlideTable(options) {
|
|
|
4053
4134
|
cellRendererRegistry,
|
|
4054
4135
|
rootRef
|
|
4055
4136
|
});
|
|
4137
|
+
const clearRowSelection = (0, import_react9.useCallback)(() => {
|
|
4138
|
+
if (rowSelectionMode === "none") return;
|
|
4139
|
+
const hasSelection = Object.values(rowSelection).some(Boolean);
|
|
4140
|
+
if (!hasSelection) return;
|
|
4141
|
+
if (onRowSelectionChange) {
|
|
4142
|
+
onRowSelectionChange(() => ({}));
|
|
4143
|
+
return;
|
|
4144
|
+
}
|
|
4145
|
+
setInternalRowSelection({});
|
|
4146
|
+
}, [onRowSelectionChange, rowSelection, rowSelectionMode]);
|
|
4147
|
+
(0, import_react9.useEffect)(() => {
|
|
4148
|
+
const clearAllSelections = () => {
|
|
4149
|
+
clearCellSelection();
|
|
4150
|
+
clearRowSelection();
|
|
4151
|
+
};
|
|
4152
|
+
const handleKeyDown = (event) => {
|
|
4153
|
+
if (event.key !== "Escape") return;
|
|
4154
|
+
if (event.defaultPrevented) return;
|
|
4155
|
+
if (isEditablePasteTarget(event.target) || isEditablePasteTarget(document.activeElement)) {
|
|
4156
|
+
return;
|
|
4157
|
+
}
|
|
4158
|
+
if (isOverlayDismissIgnoreTarget(event.target) || isOverlayDismissIgnoreTarget(document.activeElement)) {
|
|
4159
|
+
return;
|
|
4160
|
+
}
|
|
4161
|
+
clearAllSelections();
|
|
4162
|
+
};
|
|
4163
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
4164
|
+
return () => {
|
|
4165
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
4166
|
+
};
|
|
4167
|
+
}, [clearCellSelection, clearRowSelection]);
|
|
4056
4168
|
const {
|
|
4057
4169
|
editingCell,
|
|
4058
4170
|
draftValue,
|
|
@@ -4925,7 +5037,8 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
4925
5037
|
cellProps,
|
|
4926
5038
|
className,
|
|
4927
5039
|
headerClassName,
|
|
4928
|
-
render
|
|
5040
|
+
render,
|
|
5041
|
+
copyValue
|
|
4929
5042
|
} = props;
|
|
4930
5043
|
return {
|
|
4931
5044
|
id: field,
|
|
@@ -4959,6 +5072,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
4959
5072
|
kind,
|
|
4960
5073
|
cellProps,
|
|
4961
5074
|
cellRender: render,
|
|
5075
|
+
copyValue,
|
|
4962
5076
|
frozen,
|
|
4963
5077
|
reorderable,
|
|
4964
5078
|
width,
|
package/dist/compound.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer,
|
|
3
|
+
import { m as DataTableProps, s as TableColumnProps, T as TableColumnGroupProps, t as TableProps } from './types-hf2ruVdu.cjs';
|
|
4
|
+
export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, d as ColumnCopyValue, g as ColumnFreezeMeta, i as ColumnFreezeSide, j as DataTableClassNames, l as DataTableLabels, n as DataTableScrollSlotProps, o as DataTableSlots, P as PasteMode, R as RowSelectionMode, p as RowsPastePayload, q as SearchResultItem } from './types-hf2ruVdu.cjs';
|
|
5
5
|
export { ColumnDef, ColumnOrderState, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/compound.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer,
|
|
3
|
+
import { m as DataTableProps, s as TableColumnProps, T as TableColumnGroupProps, t as TableProps } from './types-hf2ruVdu.js';
|
|
4
|
+
export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, d as ColumnCopyValue, g as ColumnFreezeMeta, i as ColumnFreezeSide, j as DataTableClassNames, l as DataTableLabels, n as DataTableScrollSlotProps, o as DataTableSlots, P as PasteMode, R as RowSelectionMode, p as RowsPastePayload, q as SearchResultItem } from './types-hf2ruVdu.js';
|
|
5
5
|
export { ColumnDef, ColumnOrderState, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
|
|
6
6
|
|
|
7
7
|
/**
|