@arim-aisdc/public-components 2.3.82 → 2.3.84

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.
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ThemeType } from "../../../dist/components/ThemeProvider";
2
+ import { ThemeType } from "../../../node_modules/@arim-aisdc/public-components";
3
3
  import type { VariablesJsonType } from './type';
4
4
  import { Locale } from '../../locales';
5
5
  export interface ConfigConsumerProps {
@@ -81,6 +81,9 @@ var VirtualRow = function VirtualRow(_ref) {
81
81
  var timerRef = useRef();
82
82
  var clickCountRef = useRef(0);
83
83
 
84
+ // 拖拽时的鼠标位置跟踪
85
+ var dragStartPosRef = useRef(null);
86
+
84
87
  // 优化:使用useMemo缓存计算结果
85
88
  var dropPreviewLineClassName = useMemo(function () {
86
89
  if (hoverRowIndex === row.index) {
@@ -114,7 +117,7 @@ var VirtualRow = function VirtualRow(_ref) {
114
117
  return row.getVisibleCells();
115
118
  }, [row, table.getState().columnVisibility]);
116
119
 
117
- // 拖拽相关逻辑保持不变
120
+ // 拖拽相关逻辑
118
121
  var _useDrop = useDrop({
119
122
  accept: 'TABLE_ROW',
120
123
  drop: function drop(formDatas) {
@@ -125,7 +128,9 @@ var VirtualRow = function VirtualRow(_ref) {
125
128
  });
126
129
  },
127
130
  hover: function hover(item, monitor) {
128
- if (monitor.isOver() && monitor.canDrop()) {
131
+ var clientOffset = monitor.getClientOffset();
132
+ if (clientOffset && monitor.isOver() && monitor.canDrop()) {
133
+ // 在hover时传递鼠标位置,触发滚动
129
134
  changeHoverRow({
130
135
  target: row,
131
136
  origin: item
@@ -149,14 +154,30 @@ var VirtualRow = function VirtualRow(_ref) {
149
154
  return row.index;
150
155
  });
151
156
  var isMultipleDrag = selectedRowsNumber > 1 && selectedRowsIndexList.includes(row.index);
157
+
158
+ // 记录拖拽开始时的位置
159
+ dragStartPosRef.current = {
160
+ x: 0,
161
+ y: 0
162
+ };
152
163
  return {
153
164
  draggedRow: row,
154
165
  isMultipleDrag: isMultipleDrag,
155
166
  draggedRows: isMultipleDrag ? selectedRows : [row],
156
- sourceTableId: tableId
167
+ sourceTableId: tableId,
168
+ dragStartTime: Date.now()
157
169
  };
158
170
  },
159
- type: 'TABLE_ROW'
171
+ type: 'TABLE_ROW',
172
+ end: function end(item, monitor) {
173
+ // 拖拽结束时的清理
174
+ dragStartPosRef.current = null;
175
+ var didDrop = monitor.didDrop();
176
+ if (!didDrop) {
177
+ // 拖拽取消时的处理
178
+ console.log('Drag cancelled');
179
+ }
180
+ }
160
181
  }),
161
182
  _useDrag2 = _slicedToArray(_useDrag, 3),
162
183
  isDragging = _useDrag2[0].isDragging,
@@ -168,17 +189,17 @@ var VirtualRow = function VirtualRow(_ref) {
168
189
  captureDraggingState: true
169
190
  });
170
191
  }
171
- }, [canRowDrag]);
192
+ }, [canRowDrag, preview]);
172
193
  useEffect(function () {
173
194
  if (setSelectedRowDragging && row.getIsSelected()) {
174
195
  setSelectedRowDragging(isDragging);
175
196
  }
176
- }, [isDragging, row.getIsSelected()]);
197
+ }, [isDragging, row.getIsSelected(), setSelectedRowDragging]);
177
198
  useUpdateEffect(function () {
178
199
  if (!isDragging) {
179
200
  clearHoverRowIndex();
180
201
  }
181
- }, [isDragging]);
202
+ }, [isDragging, clearHoverRowIndex]);
182
203
  var handleCellRightClick = useCallback(function (e, cell) {
183
204
  onCellContextMenu(e, cell);
184
205
  }, [onCellContextMenu]);
@@ -203,7 +224,7 @@ var VirtualRow = function VirtualRow(_ref) {
203
224
  return baseStyle;
204
225
  }, [isDragging, selectedRowDragging, row.getIsSelected(), canRowDrag, editting, disableDragRowIds, row.id, rowStyle, virtualRowStart]);
205
226
 
206
- // 点击事件处理逻辑保持不变
227
+ // 点击事件处理逻辑
207
228
  var handleRowClick = useCallback(function (evt) {
208
229
  clickCountRef.current++;
209
230
  if (clickCountRef.current === 1) {
@@ -225,7 +246,7 @@ var VirtualRow = function VirtualRow(_ref) {
225
246
  timerRef.current = undefined;
226
247
  }
227
248
  }
228
- }, [row, table, canSelection, selectionWithoutChecked, setRowHighLightId, setRowSelectedId, selectedRowChange, onSelectChange, selectRowWhenClick, editting, onRowMouseClick, onRowMouseDoubleClick, canEditRowWhenDClick, handleEditRowWhenDClick, table.getState().columnSizing]);
249
+ }, [row, table, canSelection, selectionWithoutChecked, setRowHighLightId, setRowSelectedId, selectedRowChange, onSelectChange, selectRowWhenClick, editting, onRowMouseClick, onRowMouseDoubleClick, canEditRowWhenDClick, handleEditRowWhenDClick]);
229
250
  var handleSingleClick = useCallback(function (evt) {
230
251
  onRowMouseClick === null || onRowMouseClick === void 0 || onRowMouseClick(row);
231
252
  if (!row.getCanSelect()) {
@@ -240,7 +261,7 @@ var VirtualRow = function VirtualRow(_ref) {
240
261
  } else {
241
262
  handleSingleSelection(evt);
242
263
  }
243
- }, [row, canSelection, selectRowWhenClick, setRowHighLightId]);
264
+ }, [row, canSelection, selectRowWhenClick, setRowHighLightId, onRowMouseClick]);
244
265
  var handleDoubleClick = useCallback(function (evt) {
245
266
  onRowMouseDoubleClick === null || onRowMouseDoubleClick === void 0 || onRowMouseDoubleClick(row);
246
267
  if (canEditRowWhenDClick) {
@@ -248,10 +269,70 @@ var VirtualRow = function VirtualRow(_ref) {
248
269
  }
249
270
  }, [row, onRowMouseDoubleClick, canEditRowWhenDClick, handleEditRowWhenDClick]);
250
271
 
251
- // 其他事件处理函数保持不变...
272
+ // 选择点击处理
252
273
  var handleSelectionClick = useCallback(function (evt) {
253
- // ... 选择逻辑保持不变
274
+ if (selectionWithoutChecked) {
275
+ if (evt.ctrlKey) {
276
+ handleCtrlSelection();
277
+ } else if (evt.shiftKey) {
278
+ handleShiftSelection();
279
+ } else {
280
+ handleSingleRowSelection();
281
+ }
282
+ } else {
283
+ if (evt.shiftKey) {
284
+ handleShiftSelectionWithCheckbox();
285
+ } else {
286
+ handleToggleSelection();
287
+ }
288
+ }
254
289
  }, [row, table, selectionWithoutChecked]);
290
+ var handleCtrlSelection = useCallback(function () {
291
+ var selectionConfig = _objectSpread({}, table.getState().rowSelection);
292
+ if (!row.getIsSelected()) {
293
+ selectionConfig[row.id] = true;
294
+ } else if (Object.keys(selectionConfig).length > 1) {
295
+ delete selectionConfig[row.id];
296
+ }
297
+ // setRowSelection({ ...selectionConfig });
298
+ }, [row, table]);
299
+ var handleShiftSelection = useCallback(function () {
300
+ var min = Math.min(initselectedIndex || 0, row.index);
301
+ var max = Math.max(initselectedIndex || 0, row.index);
302
+ var selectionConfig = {};
303
+ table.getRowModel().rows.filter(function (row) {
304
+ return row.index >= min && row.index <= max;
305
+ }).forEach(function (row) {
306
+ selectionConfig[row.id] = true;
307
+ });
308
+
309
+ // setRowSelection(selectionConfig);
310
+ }, [row, table]);
311
+ var handleSingleRowSelection = useCallback(function () {
312
+ initselectedIndex = row.index;
313
+ // setRowSelection({ [row?.id]: true });
314
+ }, [row, table]);
315
+ var handleShiftSelectionWithCheckbox = useCallback(function () {
316
+ var selectionConfig = _objectSpread({}, table.getState().rowSelection);
317
+ var min = Math.min(initselectedIndex || 0, row.index);
318
+ var max = Math.max(initselectedIndex || 0, row.index);
319
+ table.getRowModel().rows.filter(function (row) {
320
+ return row.index >= min && row.index <= max;
321
+ }).forEach(function (row) {
322
+ selectionConfig[row.id] = true;
323
+ });
324
+
325
+ // setRowSelection(selectionConfig);
326
+ }, [row, table]);
327
+ var handleToggleSelection = useCallback(function () {
328
+ if (!row.getIsSelected()) {
329
+ initselectedIndex = row.index;
330
+ }
331
+ var selectionConfig = _objectSpread(_objectSpread({}, table.getState().rowSelection), {}, _defineProperty({}, row.id, !row.getIsSelected()));
332
+ if (row.getCanSelect()) {
333
+ // setRowSelection(selectionConfig);
334
+ }
335
+ }, [row, table]);
255
336
  var handleSingleSelection = useCallback(function (evt) {
256
337
  setRowSelectedId === null || setRowSelectedId === void 0 || setRowSelectedId(row === null || row === void 0 ? void 0 : row.id);
257
338
  selectedRowChange === null || selectedRowChange === void 0 || selectedRowChange(row);
@@ -371,9 +452,7 @@ var VirtualRow = function VirtualRow(_ref) {
371
452
  console.error('Error rendering row:', error);
372
453
  return null;
373
454
  }
374
- }, [
375
- // 依赖项保持不变
376
- row, row.id, rowEditing, tableId, editting, canRowDrag, disableDragRowIds, isDragging, selectedRowDragging, rowStyle, handleRowClick, rowMouseEnter, rowMouseLeave, rowClassNames, cellClassName, theme, table, handleCellRightClick, getCellProps, tableTooltip, onEditValueChange, dateFormat, row.getVisibleCells(), row.getIsSelected(), rowStyles, table.getState().columnSizing, row.getIsExpanded(), table.getExpandedRowModel()]);
455
+ }, [row, row.id, rowEditing, tableId, editting, canRowDrag, disableDragRowIds, isDragging, selectedRowDragging, rowStyle, handleRowClick, rowMouseEnter, rowMouseLeave, rowClassNames, cellClassName, theme, table, handleCellRightClick, getCellProps, tableTooltip, onEditValueChange, dateFormat, rowStyles]);
377
456
  var rowCom = function rowCom() {
378
457
  var renderCell = function renderCell(cell) {
379
458
  var _cellClassName2;
@@ -0,0 +1,62 @@
1
+ import { DropSide, OnSelectChangeType } from "../type";
2
+ import { Table } from '@tanstack/react-table';
3
+ import React, { Dispatch, ReactNode, SetStateAction } from 'react';
4
+ import './index.less';
5
+ type IRowProps = {
6
+ table: Table<any>;
7
+ tableId: string;
8
+ row: any;
9
+ rowSelectedId?: string;
10
+ setRowSelectedId?: Dispatch<SetStateAction<string | undefined>>;
11
+ rowHighLightId: string;
12
+ setRowHighLightId?: Dispatch<SetStateAction<string | undefined>>;
13
+ selectedRowChange?: (row: any) => void;
14
+ onSelectChange?: OnSelectChangeType;
15
+ tableBodyRef: any;
16
+ canSelection?: boolean;
17
+ selectionWithoutChecked?: boolean;
18
+ reorderRow?: (targetRowIndex: any, draggedRowIndex: any) => void;
19
+ canRowDrag?: boolean;
20
+ rowClassName?: (row: any) => string[];
21
+ cellClassName?: (cell: any) => string[];
22
+ rowStyle?: object;
23
+ getCellProps?: (ctx: any) => object;
24
+ editting?: boolean;
25
+ rowEditing?: boolean;
26
+ renderSubComponent?: (value: {
27
+ row: any;
28
+ }) => ReactNode;
29
+ selectedRowDragging?: boolean;
30
+ setSelectedRowDragging?: Dispatch<SetStateAction<boolean>>;
31
+ onRowMouseEnter?: (row: any) => void;
32
+ onRowMouseLeave?: (row: any) => void;
33
+ onRowMouseClick?: (row: any) => void;
34
+ onRowMouseDoubleClick?: (row: any) => void;
35
+ disableDragRowIds?: any[];
36
+ selectRowWhenClick: boolean;
37
+ handleEditRowWhenDClick: (row: any) => void;
38
+ canEditRowWhenDClick: boolean;
39
+ theme: string;
40
+ dragBeforeStart?: (datas: any) => boolean;
41
+ rowKey?: string;
42
+ onCellContextMenu: (e: React.MouseEvent, cell: any) => void;
43
+ /**获取行hover时的tip信息 */
44
+ getRowHoverTipConfig?: (row: any) => {
45
+ title: string;
46
+ color: string;
47
+ };
48
+ tableTooltip: boolean;
49
+ changeHoverRow: (params: {
50
+ target?: any;
51
+ origin?: any;
52
+ }) => void;
53
+ clearHoverRowIndex: () => void;
54
+ hoverRowIndex: number;
55
+ dropSide: DropSide;
56
+ onEditValueChange?: (field: string, value: any, extra?: any) => void;
57
+ setRowSelection?: Function;
58
+ openMemo?: boolean;
59
+ virtualRowStart?: number;
60
+ };
61
+ declare const VirtualRow: ({ tableBodyRef, table, tableId, row, rowSelectedId, setRowSelectedId, rowHighLightId, setRowHighLightId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, reorderRow, canRowDrag, rowClassName, cellClassName, rowStyle, getCellProps, editting, rowEditing, renderSubComponent, selectedRowDragging, setSelectedRowDragging, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, disableDragRowIds, selectRowWhenClick, handleEditRowWhenDClick, canEditRowWhenDClick, theme, dragBeforeStart, onCellContextMenu, getRowHoverTipConfig, tableTooltip, changeHoverRow, clearHoverRowIndex, hoverRowIndex, dropSide, onEditValueChange, setRowSelection, openMemo, virtualRowStart, }: IRowProps) => import("react/jsx-runtime").JSX.Element;
62
+ export { VirtualRow };