@easyv/biz-components 2.1.5 → 2.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.
Files changed (84) hide show
  1. package/dist/lib/components/ai-components/mobile-voice-input/icon-button.es.js +1 -1
  2. package/dist/lib/components/ai-components/mobile-voice-input/mobile-voice-input.es.js +5 -5
  3. package/dist/lib/components/code-mirror-editor/code-mirror-editor.es.js +9 -9
  4. package/dist/lib/components/code-mirror-editor/code-mirror-editor.es.js.map +1 -1
  5. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-context-menu.es.js +84 -0
  6. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-context-menu.es.js.map +1 -0
  7. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-editable-cell.es.js +58 -0
  8. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-editable-cell.es.js.map +1 -0
  9. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-selection.hook.es.js +97 -0
  10. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-selection.hook.es.js.map +1 -0
  11. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus.es.js +1063 -0
  12. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus.es.js.map +1 -0
  13. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid.module.less.es.js +7 -0
  14. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid.module.less.es.js.map +1 -0
  15. package/dist/lib/components/easyv-reactgrid-plus/utils.es.js +93 -0
  16. package/dist/lib/components/easyv-reactgrid-plus/utils.es.js.map +1 -0
  17. package/dist/lib/easyv-biz-components/src/components/code-mirror-editor/code-mirror-editor.d.ts +2 -2
  18. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus-context-menu.d.ts +14 -0
  19. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus-editable-cell.d.ts +11 -0
  20. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus-selection.hook.d.ts +16 -0
  21. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus.d.ts +16 -0
  22. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus.types.d.ts +18 -0
  23. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/index.d.ts +1 -0
  24. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/test/easyv-react-grid-plus.cy.d.ts +1 -0
  25. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/utils.d.ts +6 -0
  26. package/dist/lib/easyv-biz-components/src/components/index.d.ts +1 -0
  27. package/dist/lib/easyv-biz-components/src/utils/ai-agent-message-manager/constants.d.ts +3 -1
  28. package/dist/lib/easyv-biz-components/src/utils/ai-agent-message-manager/types.d.ts +1 -0
  29. package/dist/lib/easyv-biz-components/src/utils/ai-agent-message-manager/utils.d.ts +1 -0
  30. package/dist/lib/easyv-biz-components/src/utils/easy-fetch/easy-fetch.d.ts +13 -0
  31. package/dist/lib/easyv-biz-components/src/utils/easy-fetch/index.d.ts +1 -0
  32. package/dist/lib/easyv-biz-components/src/utils/easy-fetch/test/easy-fetch.cy.d.ts +1 -0
  33. package/dist/lib/easyv-biz-components/src/utils/easy-fetch/types.d.ts +6 -0
  34. package/dist/lib/easyv-biz-components/src/utils/easyv-gui-helper/component-dimension.d.ts +2 -0
  35. package/dist/lib/easyv-biz-components/src/utils/easyv-gui-helper/easyv-gui-helper.d.ts +3 -0
  36. package/dist/lib/easyv-biz-components/src/utils/easyv-gui-helper/types.d.ts +3 -0
  37. package/dist/lib/easyv-biz-components/src/utils/index.d.ts +2 -0
  38. package/dist/lib/easyv-biz-components/src/utils/twin/index.d.ts +1 -0
  39. package/dist/lib/easyv-biz-components/src/utils/twin/utils.d.ts +5 -0
  40. package/dist/lib/hooks/use-tencent-sentence-recognition/use-tencent-sentence-recognition.es.js +2 -2
  41. package/dist/lib/index.es.js +8 -1
  42. package/dist/lib/index.es.js.map +1 -1
  43. package/dist/lib/node_modules/.pnpm/@tanstack_react-table@8.21.3_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-table/build/lib/index.es.js +103 -0
  44. package/dist/lib/node_modules/.pnpm/@tanstack_react-table@8.21.3_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-table/build/lib/index.es.js.map +1 -0
  45. package/dist/lib/node_modules/.pnpm/@tanstack_react-virtual@3.13.23_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-virtual/dist/esm/index.es.js +53 -0
  46. package/dist/lib/node_modules/.pnpm/@tanstack_react-virtual@3.13.23_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-virtual/dist/esm/index.es.js.map +1 -0
  47. package/dist/lib/node_modules/.pnpm/@tanstack_table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.es.js +2672 -0
  48. package/dist/lib/node_modules/.pnpm/@tanstack_table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.es.js.map +1 -0
  49. package/dist/lib/node_modules/.pnpm/@tanstack_virtual-core@3.13.23/node_modules/@tanstack/virtual-core/dist/esm/index.es.js +871 -0
  50. package/dist/lib/node_modules/.pnpm/@tanstack_virtual-core@3.13.23/node_modules/@tanstack/virtual-core/dist/esm/index.es.js.map +1 -0
  51. package/dist/lib/node_modules/.pnpm/@tanstack_virtual-core@3.13.23/node_modules/@tanstack/virtual-core/dist/esm/utils.es.js +73 -0
  52. package/dist/lib/node_modules/.pnpm/@tanstack_virtual-core@3.13.23/node_modules/@tanstack/virtual-core/dist/esm/utils.es.js.map +1 -0
  53. package/dist/lib/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.es.js +11 -0
  54. package/dist/lib/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.es.js.map +1 -0
  55. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{button-Dip6wfc7.es.es.js → button-VOE5PncW.es.es.js} +2 -2
  56. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{button-Dip6wfc7.es.es.js.map → button-VOE5PncW.es.es.js.map} +1 -1
  57. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{index-EAFzPBke.es.es.js → index-6AIVHTQ0.es.es.js} +11 -11
  58. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{index-EAFzPBke.es.es.js.map → index-6AIVHTQ0.es.es.js.map} +1 -1
  59. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{index-zvVd1BJp.es.es.js → index-DttpqRHH.es.es.js} +596 -605
  60. package/dist/lib/packages/easyv-arco/dist/lib/chunks/index-DttpqRHH.es.es.js.map +1 -0
  61. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{input-Dhdn9e9Z.es.es.js → input-CqQJPvav.es.es.js} +54 -54
  62. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{input-Dhdn9e9Z.es.es.js.map → input-CqQJPvav.es.es.js.map} +1 -1
  63. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{keycode-DOHuQiUY.es.es.js → keycode-cVKDBtW_.es.es.js} +4 -4
  64. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{keycode-DOHuQiUY.es.es.js.map → keycode-cVKDBtW_.es.es.js.map} +1 -1
  65. package/dist/lib/packages/easyv-arco/dist/lib/index.es.es.js.map +1 -1
  66. package/dist/lib/stats.html +1 -1
  67. package/dist/lib/style.pkg.css +1 -1
  68. package/dist/lib/utils/ai-agent-message-manager/ai-agent-message-manager.es.js +9 -1
  69. package/dist/lib/utils/ai-agent-message-manager/ai-agent-message-manager.es.js.map +1 -1
  70. package/dist/lib/utils/ai-agent-message-manager/constants.es.js +4 -2
  71. package/dist/lib/utils/ai-agent-message-manager/constants.es.js.map +1 -1
  72. package/dist/lib/utils/ai-agent-message-manager/types.es.js.map +1 -1
  73. package/dist/lib/utils/ai-agent-message-manager/utils.es.js +10 -0
  74. package/dist/lib/utils/ai-agent-message-manager/utils.es.js.map +1 -0
  75. package/dist/lib/utils/easy-fetch/easy-fetch.es.js +88 -0
  76. package/dist/lib/utils/easy-fetch/easy-fetch.es.js.map +1 -0
  77. package/dist/lib/utils/easyv-gui-helper/easyv-gui-helper.es.js +13 -4
  78. package/dist/lib/utils/easyv-gui-helper/easyv-gui-helper.es.js.map +1 -1
  79. package/dist/lib/utils/show-modal/show-modal.es.js +5 -5
  80. package/dist/lib/utils/twin/utils.es.js +30 -0
  81. package/dist/lib/utils/twin/utils.es.js.map +1 -0
  82. package/dist/tailwindcss.pkg.css +113 -0
  83. package/package.json +13 -7
  84. package/dist/lib/packages/easyv-arco/dist/lib/chunks/index-zvVd1BJp.es.es.js.map +0 -1
@@ -0,0 +1,1063 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.es.js";
2
+ import { useRef, useState, useCallback, useMemo, useEffect } from "react";
3
+ import { useReactTable, flexRender } from "../../node_modules/.pnpm/@tanstack_react-table@8.21.3_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-table/build/lib/index.es.js";
4
+ import { useVirtualizer } from "../../node_modules/.pnpm/@tanstack_react-virtual@3.13.23_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-virtual/dist/esm/index.es.js";
5
+ import classNames from "../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js";
6
+ import { produce } from "../../node_modules/.pnpm/immer@10.1.1/node_modules/immer/dist/immer.es.js";
7
+ import { EasyvReactGridPlusContextMenu } from "./easyv-react-grid-plus-context-menu.es.js";
8
+ import { EasyvReactGridPlusEditableCell } from "./easyv-react-grid-plus-editable-cell.es.js";
9
+ import { useGridSelectionAutoScroll } from "./easyv-react-grid-plus-selection.hook.es.js";
10
+ import styles from "./easyv-react-grid.module.less.es.js";
11
+ import { getColumnLabel, calculateFillPreviewRange, parseClipboardText } from "./utils.es.js";
12
+ import { getCoreRowModel } from "../../node_modules/.pnpm/@tanstack_table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.es.js";
13
+ const EasyvReactGridPlus = (props) => {
14
+ var _a, _b, _c, _d, _e;
15
+ const {
16
+ wrapClassName = "",
17
+ wrapStyle,
18
+ data = [],
19
+ onDataChange,
20
+ expandMinGrid = true,
21
+ minRows = 50,
22
+ minCols = 26,
23
+ stickyTopRow = true,
24
+ stickyLeftColumn = true,
25
+ defaultRowHeight = 32
26
+ } = props;
27
+ const parentRef = useRef(null);
28
+ const skipSelectionClickRef = useRef(false);
29
+ const [columnWidths, setColumnWidths] = useState({});
30
+ const [rowHeights, setRowHeights] = useState({});
31
+ const [editingCellKey, setEditingCellKey] = useState(null);
32
+ const [selectedCellKeys, setSelectedCellKeys] = useState(/* @__PURE__ */ new Set());
33
+ const [selectedRowIndexes, setSelectedRowIndexes] = useState(/* @__PURE__ */ new Set());
34
+ const [selectedColIndexes, setSelectedColIndexes] = useState(/* @__PURE__ */ new Set());
35
+ const [isSelectingRange, setIsSelectingRange] = useState(false);
36
+ const [selectionStart, setSelectionStart] = useState(null);
37
+ const [isFillDragging, setIsFillDragging] = useState(false);
38
+ const [fillSourceRange, setFillSourceRange] = useState(null);
39
+ const [fillPreviewRange, setFillPreviewRange] = useState(null);
40
+ const [resizingColumn, setResizingColumn] = useState(null);
41
+ const [resizingRow, setResizingRow] = useState(null);
42
+ const [contextMenuState, setContextMenuState] = useState({
43
+ visible: false,
44
+ x: 0,
45
+ y: 0,
46
+ target: null
47
+ });
48
+ const [clipboardCache, setClipboardCache] = useState("");
49
+ const [insertRowCount, setInsertRowCount] = useState(1);
50
+ const [insertColCount, setInsertColCount] = useState(1);
51
+ const [isGridActive, setIsGridActive] = useState(false);
52
+ const [editingInputSeed, setEditingInputSeed] = useState(
53
+ null
54
+ );
55
+ const handleCopyRef = useRef(() => {
56
+ });
57
+ const handlePasteRef = useRef(() => {
58
+ });
59
+ const colsCount = ((_a = data[0]) == null ? void 0 : _a.length) || 0;
60
+ const rowsCount = data.length;
61
+ const displayRowsCount = expandMinGrid ? Math.max(rowsCount, minRows) : rowsCount;
62
+ const displayColsCount = expandMinGrid ? Math.max(colsCount, minCols) : colsCount;
63
+ const getCellKey = useCallback((row, col) => `${row}:${col}`, []);
64
+ const selectSingleCell = (row, col) => {
65
+ setSelectedCellKeys(/* @__PURE__ */ new Set([getCellKey(row, col)]));
66
+ setSelectedRowIndexes(/* @__PURE__ */ new Set());
67
+ setSelectedColIndexes(/* @__PURE__ */ new Set());
68
+ };
69
+ const selectRangeCells = useCallback(
70
+ (startRow, startCol, endRow, endCol) => {
71
+ const rowMin = Math.min(startRow, endRow);
72
+ const rowMax = Math.max(startRow, endRow);
73
+ const colMin = Math.min(startCol, endCol);
74
+ const colMax = Math.max(startCol, endCol);
75
+ const next = /* @__PURE__ */ new Set();
76
+ for (let r = rowMin; r <= rowMax; r++) {
77
+ for (let c = colMin; c <= colMax; c++) {
78
+ next.add(getCellKey(r, c));
79
+ }
80
+ }
81
+ setSelectedCellKeys(next);
82
+ setSelectedRowIndexes(/* @__PURE__ */ new Set());
83
+ setSelectedColIndexes(/* @__PURE__ */ new Set());
84
+ },
85
+ [getCellKey]
86
+ );
87
+ const setSelectionByRange = useCallback(
88
+ (range) => {
89
+ const next = /* @__PURE__ */ new Set();
90
+ for (let r = range.minRow; r <= range.maxRow; r++) {
91
+ for (let c = range.minCol; c <= range.maxCol; c++) {
92
+ next.add(getCellKey(r, c));
93
+ }
94
+ }
95
+ setSelectedCellKeys(next);
96
+ setSelectedRowIndexes(/* @__PURE__ */ new Set());
97
+ setSelectedColIndexes(/* @__PURE__ */ new Set());
98
+ },
99
+ [getCellKey]
100
+ );
101
+ const { setSelectionPointer } = useGridSelectionAutoScroll({
102
+ parentRef,
103
+ isSelectingRange,
104
+ selectionStart,
105
+ selectRangeCells,
106
+ stopSelectingRange: () => {
107
+ setIsSelectingRange(false);
108
+ setSelectionStart(null);
109
+ }
110
+ });
111
+ const selectRow = (rowIndex) => {
112
+ setSelectedRowIndexes(/* @__PURE__ */ new Set([rowIndex]));
113
+ setSelectedColIndexes(/* @__PURE__ */ new Set());
114
+ setSelectedCellKeys(/* @__PURE__ */ new Set());
115
+ };
116
+ const selectColumn = (colIndex) => {
117
+ setSelectedColIndexes(/* @__PURE__ */ new Set([colIndex]));
118
+ setSelectedRowIndexes(/* @__PURE__ */ new Set());
119
+ setSelectedCellKeys(/* @__PURE__ */ new Set());
120
+ };
121
+ const closeContextMenu = () => {
122
+ setContextMenuState((prev) => ({ ...prev, visible: false }));
123
+ };
124
+ const openContextMenu = (event, target) => {
125
+ const menuWidth = 180;
126
+ const menuHeight = 260;
127
+ const adjustedX = event.clientX + menuWidth > window.innerWidth ? window.innerWidth - menuWidth - 8 : event.clientX;
128
+ const adjustedY = event.clientY + menuHeight > window.innerHeight ? window.innerHeight - menuHeight - 8 : event.clientY;
129
+ setContextMenuState({
130
+ visible: true,
131
+ x: Math.max(8, adjustedX),
132
+ y: Math.max(8, adjustedY),
133
+ target
134
+ });
135
+ setInsertRowCount(1);
136
+ setInsertColCount(1);
137
+ };
138
+ const tableData = useMemo(() => {
139
+ return Array.from({ length: displayRowsCount }).map((_, rowIndex) => {
140
+ const row = data[rowIndex] || [];
141
+ const rowData = { id: rowIndex };
142
+ for (let colIndex = 0; colIndex < displayColsCount; colIndex++) {
143
+ rowData[String(colIndex)] = row[colIndex] ?? "";
144
+ }
145
+ return rowData;
146
+ });
147
+ }, [data, displayColsCount, displayRowsCount]);
148
+ const columns = useMemo(() => {
149
+ const cols = [
150
+ {
151
+ id: "header-col",
152
+ header: "",
153
+ accessorKey: "id",
154
+ cell: (info) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "biz-text-[#c9cbd3] biz-w-full biz-h-full biz-flex biz-items-center biz-justify-center", children: Number(info.getValue()) + 1 }),
155
+ size: columnWidths["header-col"] ?? 75
156
+ }
157
+ ];
158
+ for (let i = 0; i < displayColsCount; i++) {
159
+ cols.push({
160
+ id: String(i),
161
+ header: getColumnLabel(i),
162
+ accessorKey: String(i),
163
+ cell: (info) => {
164
+ const cellKey = `${info.row.id}:${String(i)}`;
165
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
166
+ EasyvReactGridPlusEditableCell,
167
+ {
168
+ value: editingCellKey === cellKey && (editingInputSeed == null ? void 0 : editingInputSeed.key) === cellKey ? editingInputSeed.value : info.getValue(),
169
+ row: info.row.index,
170
+ column: i,
171
+ isEditing: editingCellKey === cellKey,
172
+ onRequestEdit: () => {
173
+ setEditingInputSeed(null);
174
+ setEditingCellKey(cellKey);
175
+ },
176
+ onFinishEdit: () => {
177
+ setEditingInputSeed(null);
178
+ setEditingCellKey((prev) => prev === cellKey ? null : prev);
179
+ },
180
+ updateData: (row, col, value) => {
181
+ if (!onDataChange) return;
182
+ const newData = produce(data, (draft) => {
183
+ while (draft.length <= row) {
184
+ draft.push(new Array(displayColsCount).fill(""));
185
+ }
186
+ while (draft[row].length <= col) {
187
+ draft[row].push("");
188
+ }
189
+ draft[row][col] = value;
190
+ });
191
+ onDataChange(newData);
192
+ }
193
+ }
194
+ );
195
+ },
196
+ size: columnWidths[String(i)] ?? 100
197
+ });
198
+ }
199
+ return cols;
200
+ }, [columnWidths, data, displayColsCount, editingCellKey, editingInputSeed, onDataChange]);
201
+ const table = useReactTable({
202
+ data: tableData,
203
+ columns,
204
+ getCoreRowModel: getCoreRowModel()
205
+ });
206
+ const { rows } = table.getRowModel();
207
+ const rowVirtualizer = useVirtualizer({
208
+ count: rows.length,
209
+ getScrollElement: () => parentRef.current,
210
+ estimateSize: (index) => {
211
+ var _a2;
212
+ return rowHeights[((_a2 = rows[index]) == null ? void 0 : _a2.id) ?? ""] ?? defaultRowHeight;
213
+ },
214
+ overscan: 10,
215
+ getItemKey: (index) => {
216
+ var _a2;
217
+ return ((_a2 = rows[index]) == null ? void 0 : _a2.id) ?? index;
218
+ },
219
+ measureElement: (element) => element.getBoundingClientRect().height
220
+ });
221
+ useEffect(() => {
222
+ rowVirtualizer.measure();
223
+ }, [rowHeights, rowVirtualizer]);
224
+ useEffect(() => {
225
+ if (!resizingColumn) return;
226
+ const onMouseMove = (event) => {
227
+ const delta = event.clientX - resizingColumn.startX;
228
+ const nextWidth = Math.max(60, resizingColumn.startWidth + delta);
229
+ setColumnWidths((prev) => ({
230
+ ...prev,
231
+ [resizingColumn.columnId]: nextWidth
232
+ }));
233
+ };
234
+ const onMouseUp = () => {
235
+ setResizingColumn(null);
236
+ };
237
+ window.addEventListener("mousemove", onMouseMove);
238
+ window.addEventListener("mouseup", onMouseUp);
239
+ return () => {
240
+ window.removeEventListener("mousemove", onMouseMove);
241
+ window.removeEventListener("mouseup", onMouseUp);
242
+ };
243
+ }, [resizingColumn]);
244
+ useEffect(() => {
245
+ if (!resizingRow) return;
246
+ const onMouseMove = (event) => {
247
+ const delta = event.clientY - resizingRow.startY;
248
+ const nextHeight = Math.max(24, resizingRow.startHeight + delta);
249
+ setRowHeights((prev) => ({
250
+ ...prev,
251
+ [resizingRow.rowId]: nextHeight
252
+ }));
253
+ };
254
+ const onMouseUp = () => {
255
+ setResizingRow(null);
256
+ };
257
+ window.addEventListener("mousemove", onMouseMove);
258
+ window.addEventListener("mouseup", onMouseUp);
259
+ return () => {
260
+ window.removeEventListener("mousemove", onMouseMove);
261
+ window.removeEventListener("mouseup", onMouseUp);
262
+ };
263
+ }, [resizingRow]);
264
+ useEffect(() => {
265
+ if (!contextMenuState.visible) return;
266
+ const onPointerDown = () => {
267
+ closeContextMenu();
268
+ };
269
+ window.addEventListener("mousedown", onPointerDown);
270
+ window.addEventListener("scroll", onPointerDown, true);
271
+ return () => {
272
+ window.removeEventListener("mousedown", onPointerDown);
273
+ window.removeEventListener("scroll", onPointerDown, true);
274
+ };
275
+ }, [contextMenuState.visible]);
276
+ useEffect(() => {
277
+ const onPointerDown = (event) => {
278
+ if (!parentRef.current) return;
279
+ setIsGridActive(parentRef.current.contains(event.target));
280
+ };
281
+ window.addEventListener("mousedown", onPointerDown);
282
+ return () => {
283
+ window.removeEventListener("mousedown", onPointerDown);
284
+ };
285
+ }, []);
286
+ useEffect(() => {
287
+ if (!isFillDragging || !fillSourceRange || !fillPreviewRange) return;
288
+ const onMouseUp = () => {
289
+ if (onDataChange) {
290
+ const sourceHeight = fillSourceRange.maxRow - fillSourceRange.minRow + 1;
291
+ const sourceWidth = fillSourceRange.maxCol - fillSourceRange.minCol + 1;
292
+ const newData = produce(data, (draft) => {
293
+ var _a2;
294
+ for (let r = fillPreviewRange.minRow; r <= fillPreviewRange.maxRow; r++) {
295
+ for (let c = fillPreviewRange.minCol; c <= fillPreviewRange.maxCol; c++) {
296
+ const isInSource = r >= fillSourceRange.minRow && r <= fillSourceRange.maxRow && c >= fillSourceRange.minCol && c <= fillSourceRange.maxCol;
297
+ if (isInSource) continue;
298
+ const sourceRow = fillSourceRange.minRow + ((r - fillSourceRange.minRow) % sourceHeight + sourceHeight) % sourceHeight;
299
+ const sourceCol = fillSourceRange.minCol + ((c - fillSourceRange.minCol) % sourceWidth + sourceWidth) % sourceWidth;
300
+ while (draft.length <= r) {
301
+ draft.push(new Array(displayColsCount).fill(""));
302
+ }
303
+ while (draft[r].length <= c) {
304
+ draft[r].push("");
305
+ }
306
+ draft[r][c] = ((_a2 = draft[sourceRow]) == null ? void 0 : _a2[sourceCol]) ?? "";
307
+ }
308
+ }
309
+ });
310
+ onDataChange(newData);
311
+ }
312
+ setSelectionByRange(fillPreviewRange);
313
+ setIsFillDragging(false);
314
+ setFillSourceRange(null);
315
+ setFillPreviewRange(null);
316
+ };
317
+ window.addEventListener("mouseup", onMouseUp);
318
+ return () => {
319
+ window.removeEventListener("mouseup", onMouseUp);
320
+ };
321
+ }, [
322
+ data,
323
+ displayColsCount,
324
+ fillPreviewRange,
325
+ fillSourceRange,
326
+ isFillDragging,
327
+ onDataChange,
328
+ setSelectionByRange
329
+ ]);
330
+ const virtualRows = rowVirtualizer.getVirtualItems();
331
+ const totalSize = rowVirtualizer.getTotalSize();
332
+ const tableWidth = useMemo(() => {
333
+ let width = columnWidths["header-col"] ?? 75;
334
+ for (let i = 0; i < displayColsCount; i++) {
335
+ width += columnWidths[String(i)] ?? 100;
336
+ }
337
+ return width;
338
+ }, [columnWidths, displayColsCount]);
339
+ const paddingTop = virtualRows.length > 0 ? ((_b = virtualRows[0]) == null ? void 0 : _b.start) || 0 : 0;
340
+ const paddingBottom = virtualRows.length > 0 ? totalSize - (((_c = virtualRows[virtualRows.length - 1]) == null ? void 0 : _c.end) || 0) : 0;
341
+ const selectedCellRange = useMemo(() => {
342
+ if (selectedCellKeys.size <= 1) return null;
343
+ let minRow = Number.POSITIVE_INFINITY;
344
+ let maxRow = Number.NEGATIVE_INFINITY;
345
+ let minCol = Number.POSITIVE_INFINITY;
346
+ let maxCol = Number.NEGATIVE_INFINITY;
347
+ selectedCellKeys.forEach((key) => {
348
+ const [rowText, colText] = key.split(":");
349
+ const row = Number(rowText);
350
+ const col = Number(colText);
351
+ if (Number.isNaN(row) || Number.isNaN(col)) return;
352
+ minRow = Math.min(minRow, row);
353
+ maxRow = Math.max(maxRow, row);
354
+ minCol = Math.min(minCol, col);
355
+ maxCol = Math.max(maxCol, col);
356
+ });
357
+ if (minRow === Number.POSITIVE_INFINITY || maxRow === Number.NEGATIVE_INFINITY || minCol === Number.POSITIVE_INFINITY || maxCol === Number.NEGATIVE_INFINITY) {
358
+ return null;
359
+ }
360
+ return { minRow, maxRow, minCol, maxCol };
361
+ }, [selectedCellKeys]);
362
+ const singleSelectedCellRange = useMemo(() => {
363
+ if (selectedCellKeys.size !== 1) return null;
364
+ const [firstKey] = Array.from(selectedCellKeys);
365
+ if (!firstKey) return null;
366
+ const [rowText, colText] = firstKey.split(":");
367
+ const row = Number(rowText);
368
+ const col = Number(colText);
369
+ if (Number.isNaN(row) || Number.isNaN(col)) return null;
370
+ return {
371
+ minRow: row,
372
+ maxRow: row,
373
+ minCol: col,
374
+ maxCol: col
375
+ };
376
+ }, [selectedCellKeys]);
377
+ const selectedRowRange = useMemo(() => {
378
+ if (selectedRowIndexes.size === 0) return null;
379
+ const rowsArray = Array.from(selectedRowIndexes);
380
+ return {
381
+ minRow: Math.min(...rowsArray),
382
+ maxRow: Math.max(...rowsArray),
383
+ minCol: 0,
384
+ maxCol: Math.max(displayColsCount - 1, 0)
385
+ };
386
+ }, [displayColsCount, selectedRowIndexes]);
387
+ const selectedColRange = useMemo(() => {
388
+ if (selectedColIndexes.size === 0) return null;
389
+ const colsArray = Array.from(selectedColIndexes);
390
+ return {
391
+ minRow: 0,
392
+ maxRow: Math.max(displayRowsCount - 1, 0),
393
+ minCol: Math.min(...colsArray),
394
+ maxCol: Math.max(...colsArray)
395
+ };
396
+ }, [displayRowsCount, selectedColIndexes]);
397
+ const fillSourceCandidateRange = selectedCellRange || singleSelectedCellRange;
398
+ const selectionRange = selectedCellRange || singleSelectedCellRange || selectedRowRange || selectedColRange;
399
+ const calculateOverlayStyle = useCallback(
400
+ (range) => {
401
+ if (!range) return null;
402
+ let left = columnWidths["header-col"] ?? 75;
403
+ for (let col = 0; col < range.minCol; col++) {
404
+ left += columnWidths[String(col)] ?? 100;
405
+ }
406
+ let top = rowHeights["header-row"] ?? defaultRowHeight;
407
+ for (let row = 0; row < range.minRow; row++) {
408
+ top += rowHeights[String(row)] ?? defaultRowHeight;
409
+ }
410
+ let width = 0;
411
+ for (let col = range.minCol; col <= range.maxCol; col++) {
412
+ width += columnWidths[String(col)] ?? 100;
413
+ }
414
+ let height = 0;
415
+ for (let row = range.minRow; row <= range.maxRow; row++) {
416
+ height += rowHeights[String(row)] ?? defaultRowHeight;
417
+ }
418
+ return { left, top, width, height };
419
+ },
420
+ [columnWidths, defaultRowHeight, rowHeights]
421
+ );
422
+ const getOverlayStyleFromDom = useCallback((range) => {
423
+ if (!range || !parentRef.current) return null;
424
+ const startCell = parentRef.current.querySelector(
425
+ `[data-grid-row="${range.minRow}"][data-grid-col="${range.minCol}"]`
426
+ );
427
+ const endCell = parentRef.current.querySelector(
428
+ `[data-grid-row="${range.maxRow}"][data-grid-col="${range.maxCol}"]`
429
+ );
430
+ if (!startCell || !endCell) return null;
431
+ const containerRect = parentRef.current.getBoundingClientRect();
432
+ const startRect = startCell.getBoundingClientRect();
433
+ const endRect = endCell.getBoundingClientRect();
434
+ const left = startRect.left - containerRect.left + parentRef.current.scrollLeft;
435
+ const top = startRect.top - containerRect.top + parentRef.current.scrollTop;
436
+ const width = endRect.right - startRect.left;
437
+ const height = endRect.bottom - startRect.top;
438
+ return { left, top, width, height };
439
+ }, []);
440
+ const selectionOverlayStyle = useMemo(() => {
441
+ return getOverlayStyleFromDom(selectionRange) || calculateOverlayStyle(selectionRange);
442
+ }, [selectionRange, calculateOverlayStyle, getOverlayStyleFromDom]);
443
+ const fillPreviewOverlayStyle = useMemo(() => {
444
+ if (!isFillDragging) return null;
445
+ return getOverlayStyleFromDom(fillPreviewRange) || calculateOverlayStyle(fillPreviewRange);
446
+ }, [fillPreviewRange, isFillDragging, calculateOverlayStyle, getOverlayStyleFromDom]);
447
+ const selectedRows = useMemo(
448
+ () => Array.from(selectedRowIndexes).sort((a, b) => a - b),
449
+ [selectedRowIndexes]
450
+ );
451
+ const selectedCols = useMemo(
452
+ () => Array.from(selectedColIndexes).sort((a, b) => a - b),
453
+ [selectedColIndexes]
454
+ );
455
+ const getClipboardRange = () => {
456
+ if (selectionRange) return selectionRange;
457
+ if (!contextMenuState.target) return null;
458
+ if (contextMenuState.target.kind === "cell") {
459
+ return {
460
+ minRow: contextMenuState.target.rowIndex,
461
+ maxRow: contextMenuState.target.rowIndex,
462
+ minCol: contextMenuState.target.colIndex,
463
+ maxCol: contextMenuState.target.colIndex
464
+ };
465
+ }
466
+ if (contextMenuState.target.kind === "rowHeader") {
467
+ return {
468
+ minRow: contextMenuState.target.rowIndex,
469
+ maxRow: contextMenuState.target.rowIndex,
470
+ minCol: 0,
471
+ maxCol: Math.max(displayColsCount - 1, 0)
472
+ };
473
+ }
474
+ return {
475
+ minRow: 0,
476
+ maxRow: Math.max(displayRowsCount - 1, 0),
477
+ minCol: contextMenuState.target.colIndex,
478
+ maxCol: contextMenuState.target.colIndex
479
+ };
480
+ };
481
+ const toClipboardText = (range) => {
482
+ var _a2;
483
+ const lines = [];
484
+ for (let r = range.minRow; r <= range.maxRow; r++) {
485
+ const cells = [];
486
+ for (let c = range.minCol; c <= range.maxCol; c++) {
487
+ cells.push(String(((_a2 = data[r]) == null ? void 0 : _a2[c]) ?? ""));
488
+ }
489
+ lines.push(cells.join(" "));
490
+ }
491
+ return lines.join("\n");
492
+ };
493
+ const ensureSize = (draft, targetRow, targetCol) => {
494
+ var _a2;
495
+ const widthBase = Math.max(targetCol + 1, ((_a2 = draft[0]) == null ? void 0 : _a2.length) || displayColsCount || 1);
496
+ while (draft.length <= targetRow) {
497
+ draft.push(new Array(widthBase).fill(""));
498
+ }
499
+ while (draft[targetRow].length <= targetCol) {
500
+ draft[targetRow].push("");
501
+ }
502
+ };
503
+ const handleCopy = async (isCut) => {
504
+ var _a2;
505
+ const range = getClipboardRange();
506
+ if (!range) return;
507
+ const text = toClipboardText(range);
508
+ setClipboardCache(text);
509
+ if ((_a2 = navigator.clipboard) == null ? void 0 : _a2.writeText) {
510
+ try {
511
+ await navigator.clipboard.writeText(text);
512
+ } catch {
513
+ setClipboardCache(text);
514
+ }
515
+ }
516
+ if (isCut && onDataChange) {
517
+ const next = produce(data, (draft) => {
518
+ var _a3;
519
+ for (let r = range.minRow; r <= range.maxRow; r++) {
520
+ for (let c = range.minCol; c <= range.maxCol; c++) {
521
+ if (((_a3 = draft[r]) == null ? void 0 : _a3[c]) !== void 0) {
522
+ draft[r][c] = "";
523
+ }
524
+ }
525
+ }
526
+ });
527
+ onDataChange(next);
528
+ }
529
+ };
530
+ const handlePaste = async () => {
531
+ var _a2, _b2, _c2;
532
+ let text = clipboardCache;
533
+ if ((_a2 = navigator.clipboard) == null ? void 0 : _a2.readText) {
534
+ try {
535
+ const fromClipboard = await navigator.clipboard.readText();
536
+ if (fromClipboard) text = fromClipboard;
537
+ } catch {
538
+ text = clipboardCache;
539
+ }
540
+ }
541
+ if (!text || !onDataChange) return;
542
+ const matrix = parseClipboardText(text);
543
+ if (matrix.length === 0) return;
544
+ const range = getClipboardRange();
545
+ const anchorRow = (range == null ? void 0 : range.minRow) ?? ((_b2 = contextMenuState.target) == null ? void 0 : _b2.rowIndex) ?? 0;
546
+ const anchorCol = (range == null ? void 0 : range.minCol) ?? ((_c2 = contextMenuState.target) == null ? void 0 : _c2.colIndex) ?? 0;
547
+ const next = produce(data, (draft) => {
548
+ for (let r = 0; r < matrix.length; r++) {
549
+ for (let c = 0; c < matrix[r].length; c++) {
550
+ const targetRow = anchorRow + r;
551
+ const targetCol = anchorCol + c;
552
+ ensureSize(draft, targetRow, targetCol);
553
+ draft[targetRow][targetCol] = matrix[r][c];
554
+ }
555
+ }
556
+ });
557
+ onDataChange(next);
558
+ const endRow = anchorRow + matrix.length - 1;
559
+ const endCol = anchorCol + matrix[0].length - 1;
560
+ setSelectionByRange({
561
+ minRow: anchorRow,
562
+ maxRow: endRow,
563
+ minCol: anchorCol,
564
+ maxCol: endCol
565
+ });
566
+ };
567
+ const handleInsertRows = (position, countInput) => {
568
+ var _a2, _b2;
569
+ if (!onDataChange) return;
570
+ const count = Math.max(1, Math.floor(countInput || 1));
571
+ const fallback = ((_a2 = contextMenuState.target) == null ? void 0 : _a2.rowIndex) ?? 0;
572
+ const rangeBasedRows = selectionRange && selectedRows.length === 0 && selectedCols.length === 0 ? [selectionRange.minRow, selectionRange.maxRow] : null;
573
+ const baseIndex = selectedRows.length > 0 ? position === "above" ? selectedRows[0] : selectedRows[selectedRows.length - 1] : rangeBasedRows ? position === "above" ? rangeBasedRows[0] : rangeBasedRows[1] : fallback;
574
+ const insertAt = position === "above" ? baseIndex : baseIndex + 1;
575
+ const width = Math.max(displayColsCount, ((_b2 = data[0]) == null ? void 0 : _b2.length) || 0, 1);
576
+ const next = produce(data, (draft) => {
577
+ for (let i = 0; i < count; i++) {
578
+ draft.splice(insertAt + i, 0, new Array(width).fill(""));
579
+ }
580
+ });
581
+ onDataChange(next);
582
+ };
583
+ const handleInsertCols = (position, countInput) => {
584
+ var _a2;
585
+ if (!onDataChange) return;
586
+ const count = Math.max(1, Math.floor(countInput || 1));
587
+ const fallback = ((_a2 = contextMenuState.target) == null ? void 0 : _a2.colIndex) ?? 0;
588
+ const rangeBasedCols = selectionRange && selectedRows.length === 0 && selectedCols.length === 0 ? [selectionRange.minCol, selectionRange.maxCol] : null;
589
+ const baseIndex = selectedCols.length > 0 ? position === "left" ? selectedCols[0] : selectedCols[selectedCols.length - 1] : rangeBasedCols ? position === "left" ? rangeBasedCols[0] : rangeBasedCols[1] : fallback;
590
+ const insertAt = position === "left" ? baseIndex : baseIndex + 1;
591
+ const next = produce(data, (draft) => {
592
+ const rowCount = Math.max(draft.length, displayRowsCount);
593
+ while (draft.length < rowCount) {
594
+ draft.push(new Array(Math.max(displayColsCount, 1)).fill(""));
595
+ }
596
+ for (let r = 0; r < draft.length; r++) {
597
+ for (let i = 0; i < count; i++) {
598
+ draft[r].splice(insertAt + i, 0, "");
599
+ }
600
+ }
601
+ });
602
+ onDataChange(next);
603
+ };
604
+ const handleDeleteRows = () => {
605
+ if (!onDataChange) return;
606
+ const rangeRows = selectionRange && selectedRows.length === 0 && selectedCols.length === 0 ? Array.from(
607
+ { length: selectionRange.maxRow - selectionRange.minRow + 1 },
608
+ (_, i) => selectionRange.minRow + i
609
+ ) : [];
610
+ const rowsToDelete = selectedRows.length > 0 ? selectedRows : rangeRows.length > 0 ? rangeRows : contextMenuState.target ? [contextMenuState.target.rowIndex] : [];
611
+ if (rowsToDelete.length === 0) return;
612
+ const next = produce(data, (draft) => {
613
+ [...rowsToDelete].sort((a, b) => b - a).forEach((rowIndex) => {
614
+ if (rowIndex >= 0 && rowIndex < draft.length) {
615
+ draft.splice(rowIndex, 1);
616
+ }
617
+ });
618
+ });
619
+ onDataChange(next);
620
+ };
621
+ const handleDeleteCols = () => {
622
+ if (!onDataChange) return;
623
+ const rangeCols = selectionRange && selectedRows.length === 0 && selectedCols.length === 0 ? Array.from(
624
+ { length: selectionRange.maxCol - selectionRange.minCol + 1 },
625
+ (_, i) => selectionRange.minCol + i
626
+ ) : [];
627
+ const colsToDelete = selectedCols.length > 0 ? selectedCols : rangeCols.length > 0 ? rangeCols : contextMenuState.target ? [contextMenuState.target.colIndex] : [];
628
+ if (colsToDelete.length === 0) return;
629
+ const next = produce(data, (draft) => {
630
+ [...colsToDelete].sort((a, b) => b - a).forEach((colIndex) => {
631
+ draft.forEach((row) => {
632
+ if (colIndex >= 0 && colIndex < row.length) {
633
+ row.splice(colIndex, 1);
634
+ }
635
+ });
636
+ });
637
+ });
638
+ onDataChange(next);
639
+ };
640
+ const runMenuAction = async (action) => {
641
+ if (action === "copy") await handleCopy(false);
642
+ if (action === "cut") await handleCopy(true);
643
+ if (action === "paste") await handlePaste();
644
+ if (action === "insertRowAbove") handleInsertRows("above", insertRowCount);
645
+ if (action === "insertRowBelow") handleInsertRows("below", insertRowCount);
646
+ if (action === "insertColLeft") handleInsertCols("left", insertColCount);
647
+ if (action === "insertColRight") handleInsertCols("right", insertColCount);
648
+ if (action === "deleteRows") handleDeleteRows();
649
+ if (action === "deleteCols") handleDeleteCols();
650
+ closeContextMenu();
651
+ };
652
+ const isRowHeaderMenu = ((_d = contextMenuState.target) == null ? void 0 : _d.kind) === "rowHeader";
653
+ const isColHeaderMenu = ((_e = contextMenuState.target) == null ? void 0 : _e.kind) === "colHeader";
654
+ handleCopyRef.current = handleCopy;
655
+ handlePasteRef.current = handlePaste;
656
+ useEffect(() => {
657
+ const onKeyDown = (event) => {
658
+ var _a2;
659
+ if (!isGridActive) return;
660
+ const target = event.target;
661
+ const tagName = (_a2 = target == null ? void 0 : target.tagName) == null ? void 0 : _a2.toLowerCase();
662
+ if (tagName === "input" || tagName === "textarea" || (target == null ? void 0 : target.isContentEditable)) {
663
+ return;
664
+ }
665
+ const hasCommandKey = event.metaKey || event.ctrlKey;
666
+ const key = event.key.toLowerCase();
667
+ if (hasCommandKey) {
668
+ if (key === "c") {
669
+ event.preventDefault();
670
+ void handleCopyRef.current(false);
671
+ }
672
+ if (key === "x") {
673
+ event.preventDefault();
674
+ void handleCopyRef.current(true);
675
+ }
676
+ if (key === "v") {
677
+ event.preventDefault();
678
+ void handlePasteRef.current();
679
+ }
680
+ return;
681
+ }
682
+ if (event.altKey) return;
683
+ if (selectedCellKeys.size !== 1) return;
684
+ const [cellKey] = Array.from(selectedCellKeys);
685
+ if (!cellKey) return;
686
+ const nativeEvent = event;
687
+ if (nativeEvent.isComposing || nativeEvent.keyCode === 229 || key === "process") {
688
+ event.preventDefault();
689
+ setEditingInputSeed(null);
690
+ setEditingCellKey(cellKey);
691
+ return;
692
+ }
693
+ if (event.key.length === 1) {
694
+ event.preventDefault();
695
+ setEditingInputSeed({ key: cellKey, value: event.key });
696
+ setEditingCellKey(cellKey);
697
+ }
698
+ };
699
+ window.addEventListener("keydown", onKeyDown);
700
+ return () => {
701
+ window.removeEventListener("keydown", onKeyDown);
702
+ };
703
+ }, [isGridActive, selectedCellKeys]);
704
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
705
+ "div",
706
+ {
707
+ ref: parentRef,
708
+ className: classNames(
709
+ styles["easyv-react-grid"],
710
+ "easyv-react-grid-plus",
711
+ "biz-w-full biz-h-full biz-overflow-auto",
712
+ wrapClassName
713
+ ),
714
+ style: {
715
+ ...wrapStyle,
716
+ position: "relative"
717
+ },
718
+ children: [
719
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
720
+ "table",
721
+ {
722
+ className: "biz-w-full biz-table-fixed",
723
+ style: {
724
+ width: tableWidth,
725
+ borderCollapse: "separate",
726
+ borderSpacing: 0,
727
+ border: "1px solid #2f3338"
728
+ },
729
+ children: [
730
+ /* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: headerGroup.headers.map((header) => {
731
+ const isFirstCol = header.column.id === "header-col";
732
+ const isStickyLeft = isFirstCol && stickyLeftColumn;
733
+ const headerColIndex = Number(header.column.id);
734
+ const isColSelected = !isFirstCol && selectedColIndexes.has(headerColIndex);
735
+ const headerHeight = rowHeights["header-row"] ?? defaultRowHeight;
736
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
737
+ "th",
738
+ {
739
+ onContextMenu: (event) => {
740
+ event.preventDefault();
741
+ event.stopPropagation();
742
+ if (isFirstCol || Number.isNaN(headerColIndex)) return;
743
+ selectColumn(headerColIndex);
744
+ openContextMenu(event, {
745
+ kind: "colHeader",
746
+ rowIndex: 0,
747
+ colIndex: headerColIndex
748
+ });
749
+ },
750
+ onClick: () => {
751
+ if (skipSelectionClickRef.current) {
752
+ skipSelectionClickRef.current = false;
753
+ return;
754
+ }
755
+ if (!isFirstCol && !Number.isNaN(headerColIndex)) {
756
+ selectColumn(headerColIndex);
757
+ }
758
+ },
759
+ className: classNames("biz-bg-[#252830] biz-relative biz-text-center"),
760
+ style: {
761
+ width: header.getSize(),
762
+ height: headerHeight,
763
+ position: stickyTopRow || isStickyLeft ? "sticky" : "relative",
764
+ top: stickyTopRow ? 0 : void 0,
765
+ left: isStickyLeft ? 0 : void 0,
766
+ zIndex: stickyTopRow && isStickyLeft ? 40 : stickyTopRow ? 30 : isStickyLeft ? 20 : 1,
767
+ border: "1px solid #2f3338",
768
+ borderRightColor: isFirstCol ? "#50535e" : "#2f3338",
769
+ borderTopLeftRadius: isFirstCol ? 8 : void 0,
770
+ color: "#b4b7c1",
771
+ fontSize: 12,
772
+ fontWeight: 400,
773
+ backgroundColor: isColSelected ? "#353843" : "#252830"
774
+ },
775
+ children: [
776
+ header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()),
777
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
778
+ "div",
779
+ {
780
+ onClick: (event) => {
781
+ event.preventDefault();
782
+ event.stopPropagation();
783
+ },
784
+ onMouseDown: (event) => {
785
+ event.preventDefault();
786
+ event.stopPropagation();
787
+ skipSelectionClickRef.current = true;
788
+ setResizingColumn({
789
+ columnId: String(header.column.id),
790
+ startX: event.clientX,
791
+ startWidth: header.getSize()
792
+ });
793
+ },
794
+ className: classNames(
795
+ "biz-absolute biz-right-[-2px] biz-top-0 biz-h-full biz-w-[6px] biz-cursor-col-resize hover:biz-bg-[#337efe] biz-z-20",
796
+ (resizingColumn == null ? void 0 : resizingColumn.columnId) === String(header.column.id) && "biz-bg-[#337efe]"
797
+ )
798
+ }
799
+ ),
800
+ isFirstCol && /* @__PURE__ */ jsxRuntimeExports.jsx(
801
+ "div",
802
+ {
803
+ onClick: (event) => {
804
+ event.preventDefault();
805
+ event.stopPropagation();
806
+ },
807
+ onMouseDown: (event) => {
808
+ event.preventDefault();
809
+ event.stopPropagation();
810
+ skipSelectionClickRef.current = true;
811
+ setResizingRow({
812
+ rowId: "header-row",
813
+ startY: event.clientY,
814
+ startHeight: headerHeight
815
+ });
816
+ },
817
+ className: "biz-absolute biz-left-0 biz-bottom-0 biz-h-[6px] biz-w-full biz-cursor-row-resize hover:biz-bg-[#337efe] biz-z-20"
818
+ }
819
+ )
820
+ ]
821
+ },
822
+ header.id
823
+ );
824
+ }) }, headerGroup.id)) }),
825
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("tbody", { children: [
826
+ paddingTop > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
827
+ "td",
828
+ {
829
+ colSpan: table.getAllLeafColumns().length,
830
+ style: { height: `${paddingTop}px` }
831
+ }
832
+ ) }),
833
+ virtualRows.map((virtualRow) => {
834
+ const row = rows[virtualRow.index];
835
+ const rowHeight = rowHeights[row.id] ?? defaultRowHeight;
836
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
837
+ "tr",
838
+ {
839
+ "data-index": virtualRow.index,
840
+ ref: rowVirtualizer.measureElement,
841
+ style: { height: rowHeight },
842
+ children: row.getVisibleCells().map((cell) => {
843
+ const isFirstCol = cell.column.id === "header-col";
844
+ const isStickyLeft = isFirstCol && stickyLeftColumn;
845
+ const rowIndex = row.index;
846
+ const colIndex = Number(cell.column.id);
847
+ const isDataCell = !isFirstCol && !Number.isNaN(colIndex);
848
+ const isSelectedByCell = isDataCell && selectedCellKeys.has(getCellKey(rowIndex, colIndex));
849
+ const isSingleCellSelected = isSelectedByCell && selectedCellKeys.size <= 1;
850
+ const isRowHeaderSelected = isFirstCol && selectedRowIndexes.has(rowIndex);
851
+ const shouldHighlightCellByDefault = isRowHeaderSelected || isSingleCellSelected;
852
+ const baseBorderColor = "#2f3338";
853
+ const selectedBorderColor = "#337efe";
854
+ const borderTopColor = shouldHighlightCellByDefault ? selectedBorderColor : baseBorderColor;
855
+ const borderBottomColor = shouldHighlightCellByDefault ? selectedBorderColor : baseBorderColor;
856
+ const borderLeftColor = shouldHighlightCellByDefault ? selectedBorderColor : baseBorderColor;
857
+ const borderRightColor = isFirstCol ? "#50535e" : shouldHighlightCellByDefault ? selectedBorderColor : baseBorderColor;
858
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
859
+ "td",
860
+ {
861
+ "data-grid-row": isDataCell ? rowIndex : void 0,
862
+ "data-grid-col": isDataCell ? colIndex : void 0,
863
+ onContextMenu: (event) => {
864
+ event.preventDefault();
865
+ event.stopPropagation();
866
+ if (isFirstCol) {
867
+ selectRow(rowIndex);
868
+ openContextMenu(event, {
869
+ kind: "rowHeader",
870
+ rowIndex,
871
+ colIndex: 0
872
+ });
873
+ return;
874
+ }
875
+ if (isDataCell) {
876
+ if (!selectedCellKeys.has(getCellKey(rowIndex, colIndex))) {
877
+ selectSingleCell(rowIndex, colIndex);
878
+ }
879
+ openContextMenu(event, {
880
+ kind: "cell",
881
+ rowIndex,
882
+ colIndex
883
+ });
884
+ }
885
+ },
886
+ onMouseDown: (event) => {
887
+ if (event.button !== 0) return;
888
+ if (isDataCell) {
889
+ setSelectionPointer(event.clientX, event.clientY);
890
+ setIsSelectingRange(true);
891
+ setSelectionStart({ row: rowIndex, col: colIndex });
892
+ selectSingleCell(rowIndex, colIndex);
893
+ }
894
+ },
895
+ onMouseEnter: (event) => {
896
+ setSelectionPointer(event.clientX, event.clientY);
897
+ if (isDataCell && isFillDragging && fillSourceRange) {
898
+ setFillPreviewRange(
899
+ calculateFillPreviewRange(fillSourceRange, rowIndex, colIndex)
900
+ );
901
+ return;
902
+ }
903
+ if (isDataCell && isSelectingRange && selectionStart) {
904
+ selectRangeCells(
905
+ selectionStart.row,
906
+ selectionStart.col,
907
+ rowIndex,
908
+ colIndex
909
+ );
910
+ }
911
+ },
912
+ onClick: () => {
913
+ if (skipSelectionClickRef.current) {
914
+ skipSelectionClickRef.current = false;
915
+ return;
916
+ }
917
+ if (isFirstCol) {
918
+ selectRow(rowIndex);
919
+ } else if (isDataCell) {
920
+ selectSingleCell(rowIndex, colIndex);
921
+ }
922
+ },
923
+ onDoubleClick: () => {
924
+ if (!isFirstCol) {
925
+ setEditingCellKey(`${row.id}:${String(cell.column.id)}`);
926
+ }
927
+ },
928
+ style: {
929
+ width: cell.column.getSize(),
930
+ position: isStickyLeft ? "sticky" : "relative",
931
+ left: isStickyLeft ? 0 : void 0,
932
+ zIndex: isStickyLeft ? 20 : 1,
933
+ border: "1px solid #2f3338",
934
+ borderTopColor,
935
+ borderBottomColor,
936
+ borderLeftColor,
937
+ borderRightColor,
938
+ fontSize: 12,
939
+ color: "white",
940
+ textAlign: "center",
941
+ backgroundColor: shouldHighlightCellByDefault ? isFirstCol ? "#353843" : "#1c2338" : isFirstCol ? "#252830" : "#13171d",
942
+ userSelect: "none"
943
+ },
944
+ children: [
945
+ flexRender(cell.column.columnDef.cell, cell.getContext()),
946
+ isFirstCol && /* @__PURE__ */ jsxRuntimeExports.jsx(
947
+ "div",
948
+ {
949
+ onClick: (event) => {
950
+ event.preventDefault();
951
+ event.stopPropagation();
952
+ },
953
+ onMouseDown: (event) => {
954
+ event.preventDefault();
955
+ event.stopPropagation();
956
+ skipSelectionClickRef.current = true;
957
+ setResizingRow({
958
+ rowId: row.id,
959
+ startY: event.clientY,
960
+ startHeight: rowHeight
961
+ });
962
+ },
963
+ className: "biz-absolute biz-left-0 biz-bottom-0 biz-h-[6px] biz-w-full biz-cursor-row-resize hover:biz-bg-[#337efe] biz-z-20"
964
+ }
965
+ )
966
+ ]
967
+ },
968
+ cell.id
969
+ );
970
+ })
971
+ },
972
+ row.id
973
+ );
974
+ }),
975
+ paddingBottom > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
976
+ "td",
977
+ {
978
+ colSpan: table.getAllLeafColumns().length,
979
+ style: { height: `${paddingBottom}px` }
980
+ }
981
+ ) })
982
+ ] })
983
+ ]
984
+ }
985
+ ),
986
+ selectionOverlayStyle && /* @__PURE__ */ jsxRuntimeExports.jsx(
987
+ "div",
988
+ {
989
+ style: {
990
+ position: "absolute",
991
+ pointerEvents: "none",
992
+ left: selectionOverlayStyle.left,
993
+ top: selectionOverlayStyle.top,
994
+ width: selectionOverlayStyle.width,
995
+ height: selectionOverlayStyle.height,
996
+ backgroundColor: "rgba(58, 137, 254, 0.18)",
997
+ border: "1px solid #337efe",
998
+ zIndex: 15
999
+ }
1000
+ }
1001
+ ),
1002
+ fillPreviewOverlayStyle && /* @__PURE__ */ jsxRuntimeExports.jsx(
1003
+ "div",
1004
+ {
1005
+ style: {
1006
+ position: "absolute",
1007
+ pointerEvents: "none",
1008
+ left: fillPreviewOverlayStyle.left,
1009
+ top: fillPreviewOverlayStyle.top,
1010
+ width: fillPreviewOverlayStyle.width,
1011
+ height: fillPreviewOverlayStyle.height,
1012
+ border: "1px dashed #337efe",
1013
+ zIndex: 16
1014
+ }
1015
+ }
1016
+ ),
1017
+ selectionOverlayStyle && fillSourceCandidateRange && /* @__PURE__ */ jsxRuntimeExports.jsx(
1018
+ "div",
1019
+ {
1020
+ onMouseDown: (event) => {
1021
+ event.preventDefault();
1022
+ event.stopPropagation();
1023
+ setEditingCellKey(null);
1024
+ setIsFillDragging(true);
1025
+ setFillSourceRange(fillSourceCandidateRange);
1026
+ setFillPreviewRange(fillSourceCandidateRange);
1027
+ },
1028
+ style: {
1029
+ position: "absolute",
1030
+ left: selectionOverlayStyle.left + selectionOverlayStyle.width - 4,
1031
+ top: selectionOverlayStyle.top + selectionOverlayStyle.height - 4,
1032
+ width: 8,
1033
+ height: 8,
1034
+ backgroundColor: "#337efe",
1035
+ border: "1px solid #ffffff",
1036
+ cursor: "crosshair",
1037
+ zIndex: 17
1038
+ }
1039
+ }
1040
+ ),
1041
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1042
+ EasyvReactGridPlusContextMenu,
1043
+ {
1044
+ visible: contextMenuState.visible,
1045
+ x: contextMenuState.x,
1046
+ y: contextMenuState.y,
1047
+ isRowHeaderMenu,
1048
+ isColHeaderMenu,
1049
+ insertRowCount,
1050
+ insertColCount,
1051
+ setInsertRowCount,
1052
+ setInsertColCount,
1053
+ runMenuAction
1054
+ }
1055
+ )
1056
+ ]
1057
+ }
1058
+ );
1059
+ };
1060
+ export {
1061
+ EasyvReactGridPlus
1062
+ };
1063
+ //# sourceMappingURL=easyv-react-grid-plus.es.js.map