react-glide-table 1.1.7 → 1.1.9
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/dist/compound.cjs +62 -3
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +62 -3
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/index.cjs +62 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +62 -3
- package/dist/{types-DOLnknDe.d.cts → types-xxzMLUwM.d.cts} +15 -1
- package/dist/{types-DOLnknDe.d.ts → types-xxzMLUwM.d.ts} +15 -1
- package/package.json +1 -1
package/dist/compound.cjs
CHANGED
|
@@ -789,6 +789,19 @@ function cn(...inputs) {
|
|
|
789
789
|
|
|
790
790
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
791
791
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
792
|
+
function isInteractiveMouseTarget(target) {
|
|
793
|
+
if (!(target instanceof Element)) return false;
|
|
794
|
+
const interactiveSelector = [
|
|
795
|
+
"input",
|
|
796
|
+
"textarea",
|
|
797
|
+
"select",
|
|
798
|
+
"button",
|
|
799
|
+
"a[href]",
|
|
800
|
+
"[contenteditable]:not([contenteditable='false'])",
|
|
801
|
+
"[data-table-disable-cell-selection]"
|
|
802
|
+
].join(",");
|
|
803
|
+
return target.closest(interactiveSelector) !== null;
|
|
804
|
+
}
|
|
792
805
|
function resolveExpandCellIndex(cells, toggleField) {
|
|
793
806
|
if (!toggleField) return 0;
|
|
794
807
|
const matchedIndex = cells.findIndex(
|
|
@@ -855,6 +868,33 @@ function DataTableRow({
|
|
|
855
868
|
const isGroupHovered = enableRowSpan && hoveredRowIndex !== null && hoveredRowIndex >= primaryGroupStart && hoveredRowIndex <= primaryGroupStart + primaryGroupSpan - 1;
|
|
856
869
|
const visibleCells = row.getVisibleCells();
|
|
857
870
|
const columnIdsByIndex = visibleCells.map((cell) => cell.column.id);
|
|
871
|
+
row.getIsCellDragSelected = (columnId) => {
|
|
872
|
+
if (!activeSelectionBounds) return false;
|
|
873
|
+
if (columnId) {
|
|
874
|
+
const colIndex = columnIdsByIndex.indexOf(columnId);
|
|
875
|
+
if (colIndex < 0) return false;
|
|
876
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
877
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
878
|
+
rowIndex
|
|
879
|
+
);
|
|
880
|
+
return isCellInSelection(
|
|
881
|
+
startRow,
|
|
882
|
+
colIndex,
|
|
883
|
+
activeSelectionBounds,
|
|
884
|
+
rowSpan2
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
for (let colIndex = 0; colIndex < columnIdsByIndex.length; colIndex += 1) {
|
|
888
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
889
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
890
|
+
rowIndex
|
|
891
|
+
);
|
|
892
|
+
if (isCellInSelection(startRow, colIndex, activeSelectionBounds, rowSpan2)) {
|
|
893
|
+
return true;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
return false;
|
|
897
|
+
};
|
|
858
898
|
const isVisuallySelectedAt = activeSelectionBounds ? (targetRow, targetCol) => {
|
|
859
899
|
if (targetCol < activeSelectionBounds.startCol || targetCol > activeSelectionBounds.endCol) {
|
|
860
900
|
return false;
|
|
@@ -914,6 +954,7 @@ function DataTableRow({
|
|
|
914
954
|
const meta = cell.column.columnDef.meta;
|
|
915
955
|
const align = meta?.align ?? "center";
|
|
916
956
|
const cellClassName = meta?.className;
|
|
957
|
+
const editInputProps = meta?.editInputProps;
|
|
917
958
|
const isRowSpanColumn = Boolean(enableRowSpan && meta?.rowSpan);
|
|
918
959
|
const isExpandCell = cellIndex === expandCellIndex;
|
|
919
960
|
const editable = isColumnEditable(cell.column.columnDef);
|
|
@@ -981,6 +1022,7 @@ function DataTableRow({
|
|
|
981
1022
|
return;
|
|
982
1023
|
}
|
|
983
1024
|
if (!enableCellSelection) return;
|
|
1025
|
+
if (isInteractiveMouseTarget(event.target)) return;
|
|
984
1026
|
event.preventDefault();
|
|
985
1027
|
onCellMouseDown(
|
|
986
1028
|
resolveCellRowIndex(event.clientY, event.currentTarget),
|
|
@@ -1027,18 +1069,31 @@ function DataTableRow({
|
|
|
1027
1069
|
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1028
1070
|
"input",
|
|
1029
1071
|
{
|
|
1072
|
+
...editInputProps,
|
|
1030
1073
|
ref: editInputRef,
|
|
1031
1074
|
type: editType === "number" ? "number" : "text",
|
|
1032
1075
|
defaultValue: draftValue,
|
|
1033
1076
|
className: cn(
|
|
1034
1077
|
"cell-edit-input",
|
|
1035
1078
|
CELL_ALIGN_CLASS[align],
|
|
1079
|
+
editInputProps?.className,
|
|
1036
1080
|
classNames?.cellEditInput
|
|
1037
1081
|
),
|
|
1038
|
-
onChange: (event) =>
|
|
1039
|
-
|
|
1040
|
-
|
|
1082
|
+
onChange: (event) => {
|
|
1083
|
+
editInputProps?.onChange?.(event);
|
|
1084
|
+
onDraftValueChange(event.target.value);
|
|
1085
|
+
},
|
|
1086
|
+
onMouseDown: (event) => {
|
|
1087
|
+
editInputProps?.onMouseDown?.(event);
|
|
1088
|
+
event.stopPropagation();
|
|
1089
|
+
},
|
|
1090
|
+
onClick: (event) => {
|
|
1091
|
+
editInputProps?.onClick?.(event);
|
|
1092
|
+
event.stopPropagation();
|
|
1093
|
+
},
|
|
1041
1094
|
onKeyDown: (event) => {
|
|
1095
|
+
editInputProps?.onKeyDown?.(event);
|
|
1096
|
+
if (event.defaultPrevented) return;
|
|
1042
1097
|
if (event.key === "Enter") {
|
|
1043
1098
|
event.preventDefault();
|
|
1044
1099
|
onCommitEdit(event.currentTarget.value);
|
|
@@ -1049,6 +1104,8 @@ function DataTableRow({
|
|
|
1049
1104
|
}
|
|
1050
1105
|
},
|
|
1051
1106
|
onBlur: (event) => {
|
|
1107
|
+
editInputProps?.onBlur?.(event);
|
|
1108
|
+
if (event.defaultPrevented) return;
|
|
1052
1109
|
onCommitEdit(event.currentTarget.value);
|
|
1053
1110
|
}
|
|
1054
1111
|
}
|
|
@@ -2330,6 +2387,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2330
2387
|
rowSpanKey,
|
|
2331
2388
|
editable,
|
|
2332
2389
|
editType,
|
|
2390
|
+
editInputProps,
|
|
2333
2391
|
className,
|
|
2334
2392
|
headerClassName,
|
|
2335
2393
|
render
|
|
@@ -2356,6 +2414,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2356
2414
|
rowSpanKey,
|
|
2357
2415
|
editable,
|
|
2358
2416
|
editType,
|
|
2417
|
+
editInputProps,
|
|
2359
2418
|
className,
|
|
2360
2419
|
headerClassName
|
|
2361
2420
|
}
|
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 { d as DataTableProps, T as TableColumnProps, g as TableProps } from './types-
|
|
4
|
-
export { a as DataTableClassNames, c as DataTableLabels, e as DataTableSlots, P as PasteMode, R as RowSelectionMode, f as RowsPastePayload } from './types-
|
|
3
|
+
import { d as DataTableProps, T as TableColumnProps, g as TableProps } from './types-xxzMLUwM.cjs';
|
|
4
|
+
export { a as DataTableClassNames, c as DataTableLabels, e as DataTableSlots, P as PasteMode, R as RowSelectionMode, f as RowsPastePayload } from './types-xxzMLUwM.cjs';
|
|
5
5
|
export { ColumnDef, 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 { d as DataTableProps, T as TableColumnProps, g as TableProps } from './types-
|
|
4
|
-
export { a as DataTableClassNames, c as DataTableLabels, e as DataTableSlots, P as PasteMode, R as RowSelectionMode, f as RowsPastePayload } from './types-
|
|
3
|
+
import { d as DataTableProps, T as TableColumnProps, g as TableProps } from './types-xxzMLUwM.js';
|
|
4
|
+
export { a as DataTableClassNames, c as DataTableLabels, e as DataTableSlots, P as PasteMode, R as RowSelectionMode, f as RowsPastePayload } from './types-xxzMLUwM.js';
|
|
5
5
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/compound.js
CHANGED
|
@@ -761,6 +761,19 @@ function cn(...inputs) {
|
|
|
761
761
|
|
|
762
762
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
763
763
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
764
|
+
function isInteractiveMouseTarget(target) {
|
|
765
|
+
if (!(target instanceof Element)) return false;
|
|
766
|
+
const interactiveSelector = [
|
|
767
|
+
"input",
|
|
768
|
+
"textarea",
|
|
769
|
+
"select",
|
|
770
|
+
"button",
|
|
771
|
+
"a[href]",
|
|
772
|
+
"[contenteditable]:not([contenteditable='false'])",
|
|
773
|
+
"[data-table-disable-cell-selection]"
|
|
774
|
+
].join(",");
|
|
775
|
+
return target.closest(interactiveSelector) !== null;
|
|
776
|
+
}
|
|
764
777
|
function resolveExpandCellIndex(cells, toggleField) {
|
|
765
778
|
if (!toggleField) return 0;
|
|
766
779
|
const matchedIndex = cells.findIndex(
|
|
@@ -827,6 +840,33 @@ function DataTableRow({
|
|
|
827
840
|
const isGroupHovered = enableRowSpan && hoveredRowIndex !== null && hoveredRowIndex >= primaryGroupStart && hoveredRowIndex <= primaryGroupStart + primaryGroupSpan - 1;
|
|
828
841
|
const visibleCells = row.getVisibleCells();
|
|
829
842
|
const columnIdsByIndex = visibleCells.map((cell) => cell.column.id);
|
|
843
|
+
row.getIsCellDragSelected = (columnId) => {
|
|
844
|
+
if (!activeSelectionBounds) return false;
|
|
845
|
+
if (columnId) {
|
|
846
|
+
const colIndex = columnIdsByIndex.indexOf(columnId);
|
|
847
|
+
if (colIndex < 0) return false;
|
|
848
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
849
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
850
|
+
rowIndex
|
|
851
|
+
);
|
|
852
|
+
return isCellInSelection(
|
|
853
|
+
startRow,
|
|
854
|
+
colIndex,
|
|
855
|
+
activeSelectionBounds,
|
|
856
|
+
rowSpan2
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
for (let colIndex = 0; colIndex < columnIdsByIndex.length; colIndex += 1) {
|
|
860
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
861
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
862
|
+
rowIndex
|
|
863
|
+
);
|
|
864
|
+
if (isCellInSelection(startRow, colIndex, activeSelectionBounds, rowSpan2)) {
|
|
865
|
+
return true;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
return false;
|
|
869
|
+
};
|
|
830
870
|
const isVisuallySelectedAt = activeSelectionBounds ? (targetRow, targetCol) => {
|
|
831
871
|
if (targetCol < activeSelectionBounds.startCol || targetCol > activeSelectionBounds.endCol) {
|
|
832
872
|
return false;
|
|
@@ -886,6 +926,7 @@ function DataTableRow({
|
|
|
886
926
|
const meta = cell.column.columnDef.meta;
|
|
887
927
|
const align = meta?.align ?? "center";
|
|
888
928
|
const cellClassName = meta?.className;
|
|
929
|
+
const editInputProps = meta?.editInputProps;
|
|
889
930
|
const isRowSpanColumn = Boolean(enableRowSpan && meta?.rowSpan);
|
|
890
931
|
const isExpandCell = cellIndex === expandCellIndex;
|
|
891
932
|
const editable = isColumnEditable(cell.column.columnDef);
|
|
@@ -953,6 +994,7 @@ function DataTableRow({
|
|
|
953
994
|
return;
|
|
954
995
|
}
|
|
955
996
|
if (!enableCellSelection) return;
|
|
997
|
+
if (isInteractiveMouseTarget(event.target)) return;
|
|
956
998
|
event.preventDefault();
|
|
957
999
|
onCellMouseDown(
|
|
958
1000
|
resolveCellRowIndex(event.clientY, event.currentTarget),
|
|
@@ -999,18 +1041,31 @@ function DataTableRow({
|
|
|
999
1041
|
isEditing ? /* @__PURE__ */ jsx3(
|
|
1000
1042
|
"input",
|
|
1001
1043
|
{
|
|
1044
|
+
...editInputProps,
|
|
1002
1045
|
ref: editInputRef,
|
|
1003
1046
|
type: editType === "number" ? "number" : "text",
|
|
1004
1047
|
defaultValue: draftValue,
|
|
1005
1048
|
className: cn(
|
|
1006
1049
|
"cell-edit-input",
|
|
1007
1050
|
CELL_ALIGN_CLASS[align],
|
|
1051
|
+
editInputProps?.className,
|
|
1008
1052
|
classNames?.cellEditInput
|
|
1009
1053
|
),
|
|
1010
|
-
onChange: (event) =>
|
|
1011
|
-
|
|
1012
|
-
|
|
1054
|
+
onChange: (event) => {
|
|
1055
|
+
editInputProps?.onChange?.(event);
|
|
1056
|
+
onDraftValueChange(event.target.value);
|
|
1057
|
+
},
|
|
1058
|
+
onMouseDown: (event) => {
|
|
1059
|
+
editInputProps?.onMouseDown?.(event);
|
|
1060
|
+
event.stopPropagation();
|
|
1061
|
+
},
|
|
1062
|
+
onClick: (event) => {
|
|
1063
|
+
editInputProps?.onClick?.(event);
|
|
1064
|
+
event.stopPropagation();
|
|
1065
|
+
},
|
|
1013
1066
|
onKeyDown: (event) => {
|
|
1067
|
+
editInputProps?.onKeyDown?.(event);
|
|
1068
|
+
if (event.defaultPrevented) return;
|
|
1014
1069
|
if (event.key === "Enter") {
|
|
1015
1070
|
event.preventDefault();
|
|
1016
1071
|
onCommitEdit(event.currentTarget.value);
|
|
@@ -1021,6 +1076,8 @@ function DataTableRow({
|
|
|
1021
1076
|
}
|
|
1022
1077
|
},
|
|
1023
1078
|
onBlur: (event) => {
|
|
1079
|
+
editInputProps?.onBlur?.(event);
|
|
1080
|
+
if (event.defaultPrevented) return;
|
|
1024
1081
|
onCommitEdit(event.currentTarget.value);
|
|
1025
1082
|
}
|
|
1026
1083
|
}
|
|
@@ -2313,6 +2370,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2313
2370
|
rowSpanKey,
|
|
2314
2371
|
editable,
|
|
2315
2372
|
editType,
|
|
2373
|
+
editInputProps,
|
|
2316
2374
|
className,
|
|
2317
2375
|
headerClassName,
|
|
2318
2376
|
render
|
|
@@ -2339,6 +2397,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2339
2397
|
rowSpanKey,
|
|
2340
2398
|
editable,
|
|
2341
2399
|
editType,
|
|
2400
|
+
editInputProps,
|
|
2342
2401
|
className,
|
|
2343
2402
|
headerClassName
|
|
2344
2403
|
}
|
package/dist/core.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CellEditType, a as DataTableClassNames, R as RowSelectionMode, d as DataTableProps, c as DataTableLabels, b as DataTableCopyActions, P as PasteMode, f as RowsPastePayload } from './types-
|
|
2
|
-
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-
|
|
1
|
+
import { C as CellEditType, a as DataTableClassNames, R as RowSelectionMode, d as DataTableProps, c as DataTableLabels, b as DataTableCopyActions, P as PasteMode, f as RowsPastePayload } from './types-xxzMLUwM.cjs';
|
|
2
|
+
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-xxzMLUwM.cjs';
|
|
3
3
|
import { Row, ColumnDef, Table, Updater, RowSelectionState } from '@tanstack/react-table';
|
|
4
4
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
5
5
|
import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CellEditType, a as DataTableClassNames, R as RowSelectionMode, d as DataTableProps, c as DataTableLabels, b as DataTableCopyActions, P as PasteMode, f as RowsPastePayload } from './types-
|
|
2
|
-
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-
|
|
1
|
+
import { C as CellEditType, a as DataTableClassNames, R as RowSelectionMode, d as DataTableProps, c as DataTableLabels, b as DataTableCopyActions, P as PasteMode, f as RowsPastePayload } from './types-xxzMLUwM.js';
|
|
2
|
+
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-xxzMLUwM.js';
|
|
3
3
|
import { Row, ColumnDef, Table, Updater, RowSelectionState } from '@tanstack/react-table';
|
|
4
4
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
5
5
|
import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
|
package/dist/index.cjs
CHANGED
|
@@ -1740,6 +1740,19 @@ function cn(...inputs) {
|
|
|
1740
1740
|
|
|
1741
1741
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
1742
1742
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1743
|
+
function isInteractiveMouseTarget(target) {
|
|
1744
|
+
if (!(target instanceof Element)) return false;
|
|
1745
|
+
const interactiveSelector = [
|
|
1746
|
+
"input",
|
|
1747
|
+
"textarea",
|
|
1748
|
+
"select",
|
|
1749
|
+
"button",
|
|
1750
|
+
"a[href]",
|
|
1751
|
+
"[contenteditable]:not([contenteditable='false'])",
|
|
1752
|
+
"[data-table-disable-cell-selection]"
|
|
1753
|
+
].join(",");
|
|
1754
|
+
return target.closest(interactiveSelector) !== null;
|
|
1755
|
+
}
|
|
1743
1756
|
function resolveExpandCellIndex(cells, toggleField) {
|
|
1744
1757
|
if (!toggleField) return 0;
|
|
1745
1758
|
const matchedIndex = cells.findIndex(
|
|
@@ -1806,6 +1819,33 @@ function DataTableRow({
|
|
|
1806
1819
|
const isGroupHovered = enableRowSpan && hoveredRowIndex !== null && hoveredRowIndex >= primaryGroupStart && hoveredRowIndex <= primaryGroupStart + primaryGroupSpan - 1;
|
|
1807
1820
|
const visibleCells = row.getVisibleCells();
|
|
1808
1821
|
const columnIdsByIndex = visibleCells.map((cell) => cell.column.id);
|
|
1822
|
+
row.getIsCellDragSelected = (columnId) => {
|
|
1823
|
+
if (!activeSelectionBounds) return false;
|
|
1824
|
+
if (columnId) {
|
|
1825
|
+
const colIndex = columnIdsByIndex.indexOf(columnId);
|
|
1826
|
+
if (colIndex < 0) return false;
|
|
1827
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
1828
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
1829
|
+
rowIndex
|
|
1830
|
+
);
|
|
1831
|
+
return isCellInSelection(
|
|
1832
|
+
startRow,
|
|
1833
|
+
colIndex,
|
|
1834
|
+
activeSelectionBounds,
|
|
1835
|
+
rowSpan2
|
|
1836
|
+
);
|
|
1837
|
+
}
|
|
1838
|
+
for (let colIndex = 0; colIndex < columnIdsByIndex.length; colIndex += 1) {
|
|
1839
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
1840
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
1841
|
+
rowIndex
|
|
1842
|
+
);
|
|
1843
|
+
if (isCellInSelection(startRow, colIndex, activeSelectionBounds, rowSpan2)) {
|
|
1844
|
+
return true;
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
return false;
|
|
1848
|
+
};
|
|
1809
1849
|
const isVisuallySelectedAt = activeSelectionBounds ? (targetRow, targetCol) => {
|
|
1810
1850
|
if (targetCol < activeSelectionBounds.startCol || targetCol > activeSelectionBounds.endCol) {
|
|
1811
1851
|
return false;
|
|
@@ -1865,6 +1905,7 @@ function DataTableRow({
|
|
|
1865
1905
|
const meta = cell.column.columnDef.meta;
|
|
1866
1906
|
const align = meta?.align ?? "center";
|
|
1867
1907
|
const cellClassName = meta?.className;
|
|
1908
|
+
const editInputProps = meta?.editInputProps;
|
|
1868
1909
|
const isRowSpanColumn = Boolean(enableRowSpan && meta?.rowSpan);
|
|
1869
1910
|
const isExpandCell = cellIndex === expandCellIndex;
|
|
1870
1911
|
const editable = isColumnEditable(cell.column.columnDef);
|
|
@@ -1932,6 +1973,7 @@ function DataTableRow({
|
|
|
1932
1973
|
return;
|
|
1933
1974
|
}
|
|
1934
1975
|
if (!enableCellSelection) return;
|
|
1976
|
+
if (isInteractiveMouseTarget(event.target)) return;
|
|
1935
1977
|
event.preventDefault();
|
|
1936
1978
|
onCellMouseDown(
|
|
1937
1979
|
resolveCellRowIndex(event.clientY, event.currentTarget),
|
|
@@ -1978,18 +2020,31 @@ function DataTableRow({
|
|
|
1978
2020
|
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1979
2021
|
"input",
|
|
1980
2022
|
{
|
|
2023
|
+
...editInputProps,
|
|
1981
2024
|
ref: editInputRef,
|
|
1982
2025
|
type: editType === "number" ? "number" : "text",
|
|
1983
2026
|
defaultValue: draftValue,
|
|
1984
2027
|
className: cn(
|
|
1985
2028
|
"cell-edit-input",
|
|
1986
2029
|
CELL_ALIGN_CLASS[align],
|
|
2030
|
+
editInputProps?.className,
|
|
1987
2031
|
classNames?.cellEditInput
|
|
1988
2032
|
),
|
|
1989
|
-
onChange: (event) =>
|
|
1990
|
-
|
|
1991
|
-
|
|
2033
|
+
onChange: (event) => {
|
|
2034
|
+
editInputProps?.onChange?.(event);
|
|
2035
|
+
onDraftValueChange(event.target.value);
|
|
2036
|
+
},
|
|
2037
|
+
onMouseDown: (event) => {
|
|
2038
|
+
editInputProps?.onMouseDown?.(event);
|
|
2039
|
+
event.stopPropagation();
|
|
2040
|
+
},
|
|
2041
|
+
onClick: (event) => {
|
|
2042
|
+
editInputProps?.onClick?.(event);
|
|
2043
|
+
event.stopPropagation();
|
|
2044
|
+
},
|
|
1992
2045
|
onKeyDown: (event) => {
|
|
2046
|
+
editInputProps?.onKeyDown?.(event);
|
|
2047
|
+
if (event.defaultPrevented) return;
|
|
1993
2048
|
if (event.key === "Enter") {
|
|
1994
2049
|
event.preventDefault();
|
|
1995
2050
|
onCommitEdit(event.currentTarget.value);
|
|
@@ -2000,6 +2055,8 @@ function DataTableRow({
|
|
|
2000
2055
|
}
|
|
2001
2056
|
},
|
|
2002
2057
|
onBlur: (event) => {
|
|
2058
|
+
editInputProps?.onBlur?.(event);
|
|
2059
|
+
if (event.defaultPrevented) return;
|
|
2003
2060
|
onCommitEdit(event.currentTarget.value);
|
|
2004
2061
|
}
|
|
2005
2062
|
}
|
|
@@ -2394,6 +2451,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2394
2451
|
rowSpanKey,
|
|
2395
2452
|
editable,
|
|
2396
2453
|
editType,
|
|
2454
|
+
editInputProps,
|
|
2397
2455
|
className,
|
|
2398
2456
|
headerClassName,
|
|
2399
2457
|
render
|
|
@@ -2420,6 +2478,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2420
2478
|
rowSpanKey,
|
|
2421
2479
|
editable,
|
|
2422
2480
|
editType,
|
|
2481
|
+
editInputProps,
|
|
2423
2482
|
className,
|
|
2424
2483
|
headerClassName
|
|
2425
2484
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DEFAULT_DATA_TABLE_LABELS, a as DataTableClassNames, b as DataTableCopyActions, c as DataTableLabels, d as DataTableProps, e as DataTableSlots, P as PasteMode, R as RowSelectionMode, f as RowsPastePayload, T as TableColumnProps, g as TableProps, r as resolveDataTableLabels } from './types-
|
|
1
|
+
export { D as DEFAULT_DATA_TABLE_LABELS, a as DataTableClassNames, b as DataTableCopyActions, c as DataTableLabels, d as DataTableProps, e as DataTableSlots, P as PasteMode, R as RowSelectionMode, f as RowsPastePayload, T as TableColumnProps, g as TableProps, r as resolveDataTableLabels } from './types-xxzMLUwM.cjs';
|
|
2
2
|
export { CELL_SELECTION_EDGES_CLASS, CellSelectionBounds, ColumnRowSpanMap, CopyRowEntry, CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DragState, EditingCell, RowSpanInfo, TreeRow, UseConvertTreeDataParams, UseGlideTableOptions, UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, flattenSubtreeRows, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, writeSelectionToClipboard } from './core.cjs';
|
|
3
3
|
export { DataTable, Table, TableCompoundComponent, createTable } from './compound.cjs';
|
|
4
4
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DEFAULT_DATA_TABLE_LABELS, a as DataTableClassNames, b as DataTableCopyActions, c as DataTableLabels, d as DataTableProps, e as DataTableSlots, P as PasteMode, R as RowSelectionMode, f as RowsPastePayload, T as TableColumnProps, g as TableProps, r as resolveDataTableLabels } from './types-
|
|
1
|
+
export { D as DEFAULT_DATA_TABLE_LABELS, a as DataTableClassNames, b as DataTableCopyActions, c as DataTableLabels, d as DataTableProps, e as DataTableSlots, P as PasteMode, R as RowSelectionMode, f as RowsPastePayload, T as TableColumnProps, g as TableProps, r as resolveDataTableLabels } from './types-xxzMLUwM.js';
|
|
2
2
|
export { CELL_SELECTION_EDGES_CLASS, CellSelectionBounds, ColumnRowSpanMap, CopyRowEntry, CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DragState, EditingCell, RowSpanInfo, TreeRow, UseConvertTreeDataParams, UseGlideTableOptions, UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, flattenSubtreeRows, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, writeSelectionToClipboard } from './core.js';
|
|
3
3
|
export { DataTable, Table, TableCompoundComponent, createTable } from './compound.js';
|
|
4
4
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
package/dist/index.js
CHANGED
|
@@ -1681,6 +1681,19 @@ function cn(...inputs) {
|
|
|
1681
1681
|
|
|
1682
1682
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
1683
1683
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1684
|
+
function isInteractiveMouseTarget(target) {
|
|
1685
|
+
if (!(target instanceof Element)) return false;
|
|
1686
|
+
const interactiveSelector = [
|
|
1687
|
+
"input",
|
|
1688
|
+
"textarea",
|
|
1689
|
+
"select",
|
|
1690
|
+
"button",
|
|
1691
|
+
"a[href]",
|
|
1692
|
+
"[contenteditable]:not([contenteditable='false'])",
|
|
1693
|
+
"[data-table-disable-cell-selection]"
|
|
1694
|
+
].join(",");
|
|
1695
|
+
return target.closest(interactiveSelector) !== null;
|
|
1696
|
+
}
|
|
1684
1697
|
function resolveExpandCellIndex(cells, toggleField) {
|
|
1685
1698
|
if (!toggleField) return 0;
|
|
1686
1699
|
const matchedIndex = cells.findIndex(
|
|
@@ -1747,6 +1760,33 @@ function DataTableRow({
|
|
|
1747
1760
|
const isGroupHovered = enableRowSpan && hoveredRowIndex !== null && hoveredRowIndex >= primaryGroupStart && hoveredRowIndex <= primaryGroupStart + primaryGroupSpan - 1;
|
|
1748
1761
|
const visibleCells = row.getVisibleCells();
|
|
1749
1762
|
const columnIdsByIndex = visibleCells.map((cell) => cell.column.id);
|
|
1763
|
+
row.getIsCellDragSelected = (columnId) => {
|
|
1764
|
+
if (!activeSelectionBounds) return false;
|
|
1765
|
+
if (columnId) {
|
|
1766
|
+
const colIndex = columnIdsByIndex.indexOf(columnId);
|
|
1767
|
+
if (colIndex < 0) return false;
|
|
1768
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
1769
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
1770
|
+
rowIndex
|
|
1771
|
+
);
|
|
1772
|
+
return isCellInSelection(
|
|
1773
|
+
startRow,
|
|
1774
|
+
colIndex,
|
|
1775
|
+
activeSelectionBounds,
|
|
1776
|
+
rowSpan2
|
|
1777
|
+
);
|
|
1778
|
+
}
|
|
1779
|
+
for (let colIndex = 0; colIndex < columnIdsByIndex.length; colIndex += 1) {
|
|
1780
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
1781
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
1782
|
+
rowIndex
|
|
1783
|
+
);
|
|
1784
|
+
if (isCellInSelection(startRow, colIndex, activeSelectionBounds, rowSpan2)) {
|
|
1785
|
+
return true;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
return false;
|
|
1789
|
+
};
|
|
1750
1790
|
const isVisuallySelectedAt = activeSelectionBounds ? (targetRow, targetCol) => {
|
|
1751
1791
|
if (targetCol < activeSelectionBounds.startCol || targetCol > activeSelectionBounds.endCol) {
|
|
1752
1792
|
return false;
|
|
@@ -1806,6 +1846,7 @@ function DataTableRow({
|
|
|
1806
1846
|
const meta = cell.column.columnDef.meta;
|
|
1807
1847
|
const align = meta?.align ?? "center";
|
|
1808
1848
|
const cellClassName = meta?.className;
|
|
1849
|
+
const editInputProps = meta?.editInputProps;
|
|
1809
1850
|
const isRowSpanColumn = Boolean(enableRowSpan && meta?.rowSpan);
|
|
1810
1851
|
const isExpandCell = cellIndex === expandCellIndex;
|
|
1811
1852
|
const editable = isColumnEditable(cell.column.columnDef);
|
|
@@ -1873,6 +1914,7 @@ function DataTableRow({
|
|
|
1873
1914
|
return;
|
|
1874
1915
|
}
|
|
1875
1916
|
if (!enableCellSelection) return;
|
|
1917
|
+
if (isInteractiveMouseTarget(event.target)) return;
|
|
1876
1918
|
event.preventDefault();
|
|
1877
1919
|
onCellMouseDown(
|
|
1878
1920
|
resolveCellRowIndex(event.clientY, event.currentTarget),
|
|
@@ -1919,18 +1961,31 @@ function DataTableRow({
|
|
|
1919
1961
|
isEditing ? /* @__PURE__ */ jsx3(
|
|
1920
1962
|
"input",
|
|
1921
1963
|
{
|
|
1964
|
+
...editInputProps,
|
|
1922
1965
|
ref: editInputRef,
|
|
1923
1966
|
type: editType === "number" ? "number" : "text",
|
|
1924
1967
|
defaultValue: draftValue,
|
|
1925
1968
|
className: cn(
|
|
1926
1969
|
"cell-edit-input",
|
|
1927
1970
|
CELL_ALIGN_CLASS[align],
|
|
1971
|
+
editInputProps?.className,
|
|
1928
1972
|
classNames?.cellEditInput
|
|
1929
1973
|
),
|
|
1930
|
-
onChange: (event) =>
|
|
1931
|
-
|
|
1932
|
-
|
|
1974
|
+
onChange: (event) => {
|
|
1975
|
+
editInputProps?.onChange?.(event);
|
|
1976
|
+
onDraftValueChange(event.target.value);
|
|
1977
|
+
},
|
|
1978
|
+
onMouseDown: (event) => {
|
|
1979
|
+
editInputProps?.onMouseDown?.(event);
|
|
1980
|
+
event.stopPropagation();
|
|
1981
|
+
},
|
|
1982
|
+
onClick: (event) => {
|
|
1983
|
+
editInputProps?.onClick?.(event);
|
|
1984
|
+
event.stopPropagation();
|
|
1985
|
+
},
|
|
1933
1986
|
onKeyDown: (event) => {
|
|
1987
|
+
editInputProps?.onKeyDown?.(event);
|
|
1988
|
+
if (event.defaultPrevented) return;
|
|
1934
1989
|
if (event.key === "Enter") {
|
|
1935
1990
|
event.preventDefault();
|
|
1936
1991
|
onCommitEdit(event.currentTarget.value);
|
|
@@ -1941,6 +1996,8 @@ function DataTableRow({
|
|
|
1941
1996
|
}
|
|
1942
1997
|
},
|
|
1943
1998
|
onBlur: (event) => {
|
|
1999
|
+
editInputProps?.onBlur?.(event);
|
|
2000
|
+
if (event.defaultPrevented) return;
|
|
1944
2001
|
onCommitEdit(event.currentTarget.value);
|
|
1945
2002
|
}
|
|
1946
2003
|
}
|
|
@@ -2335,6 +2392,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2335
2392
|
rowSpanKey,
|
|
2336
2393
|
editable,
|
|
2337
2394
|
editType,
|
|
2395
|
+
editInputProps,
|
|
2338
2396
|
className,
|
|
2339
2397
|
headerClassName,
|
|
2340
2398
|
render
|
|
@@ -2361,6 +2419,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2361
2419
|
rowSpanKey,
|
|
2362
2420
|
editable,
|
|
2363
2421
|
editType,
|
|
2422
|
+
editInputProps,
|
|
2364
2423
|
className,
|
|
2365
2424
|
headerClassName
|
|
2366
2425
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnDef, RowSelectionState, Updater, Row } from '@tanstack/react-table';
|
|
2
|
-
import { ReactNode, ComponentType } from 'react';
|
|
2
|
+
import { ReactNode, InputHTMLAttributes, ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
type DataTableLabels = {
|
|
5
5
|
empty: string;
|
|
@@ -14,6 +14,7 @@ declare function resolveDataTableLabels(partial?: Partial<DataTableLabels>): Dat
|
|
|
14
14
|
|
|
15
15
|
type RowSelectionMode = "none" | "single" | "multi";
|
|
16
16
|
type CellEditType = "text" | "number";
|
|
17
|
+
type DataTableEditInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue">;
|
|
17
18
|
|
|
18
19
|
declare module "@tanstack/react-table" {
|
|
19
20
|
interface ColumnMeta<TData, TValue> {
|
|
@@ -28,6 +29,17 @@ declare module "@tanstack/react-table" {
|
|
|
28
29
|
editable?: boolean;
|
|
29
30
|
/** Inline editor input type. Defaults to text */
|
|
30
31
|
editType?: CellEditType;
|
|
32
|
+
/** Inline editor input attribute overrides */
|
|
33
|
+
editInputProps?: DataTableEditInputProps;
|
|
34
|
+
}
|
|
35
|
+
interface Row<TData> {
|
|
36
|
+
/**
|
|
37
|
+
* Returns whether this row's cell is inside the active drag selection.
|
|
38
|
+
* Attached at render time by DataTableRow (optional outside that renderer).
|
|
39
|
+
* - `columnId` omitted: true when any visible cell in the row is selected.
|
|
40
|
+
* - `columnId` provided: checks only that column (row-span aware via merge origin).
|
|
41
|
+
*/
|
|
42
|
+
getIsCellDragSelected?: (columnId?: string) => boolean;
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
type DataTableCopyActions = {
|
|
@@ -260,6 +272,8 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
|
|
|
260
272
|
rowSpanKey?: string;
|
|
261
273
|
editable?: boolean;
|
|
262
274
|
editType?: CellEditType;
|
|
275
|
+
/** Inline editor input attribute overrides */
|
|
276
|
+
editInputProps?: DataTableEditInputProps;
|
|
263
277
|
className?: string;
|
|
264
278
|
headerClassName?: string;
|
|
265
279
|
render?: (value: K extends keyof T ? T[K] : unknown, row: Row<T>, index: number) => ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnDef, RowSelectionState, Updater, Row } from '@tanstack/react-table';
|
|
2
|
-
import { ReactNode, ComponentType } from 'react';
|
|
2
|
+
import { ReactNode, InputHTMLAttributes, ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
type DataTableLabels = {
|
|
5
5
|
empty: string;
|
|
@@ -14,6 +14,7 @@ declare function resolveDataTableLabels(partial?: Partial<DataTableLabels>): Dat
|
|
|
14
14
|
|
|
15
15
|
type RowSelectionMode = "none" | "single" | "multi";
|
|
16
16
|
type CellEditType = "text" | "number";
|
|
17
|
+
type DataTableEditInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue">;
|
|
17
18
|
|
|
18
19
|
declare module "@tanstack/react-table" {
|
|
19
20
|
interface ColumnMeta<TData, TValue> {
|
|
@@ -28,6 +29,17 @@ declare module "@tanstack/react-table" {
|
|
|
28
29
|
editable?: boolean;
|
|
29
30
|
/** Inline editor input type. Defaults to text */
|
|
30
31
|
editType?: CellEditType;
|
|
32
|
+
/** Inline editor input attribute overrides */
|
|
33
|
+
editInputProps?: DataTableEditInputProps;
|
|
34
|
+
}
|
|
35
|
+
interface Row<TData> {
|
|
36
|
+
/**
|
|
37
|
+
* Returns whether this row's cell is inside the active drag selection.
|
|
38
|
+
* Attached at render time by DataTableRow (optional outside that renderer).
|
|
39
|
+
* - `columnId` omitted: true when any visible cell in the row is selected.
|
|
40
|
+
* - `columnId` provided: checks only that column (row-span aware via merge origin).
|
|
41
|
+
*/
|
|
42
|
+
getIsCellDragSelected?: (columnId?: string) => boolean;
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
type DataTableCopyActions = {
|
|
@@ -260,6 +272,8 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
|
|
|
260
272
|
rowSpanKey?: string;
|
|
261
273
|
editable?: boolean;
|
|
262
274
|
editType?: CellEditType;
|
|
275
|
+
/** Inline editor input attribute overrides */
|
|
276
|
+
editInputProps?: DataTableEditInputProps;
|
|
263
277
|
className?: string;
|
|
264
278
|
headerClassName?: string;
|
|
265
279
|
render?: (value: K extends keyof T ? T[K] : unknown, row: Row<T>, index: number) => ReactNode;
|