es-grid-template 1.9.57 → 1.9.59

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,6 +1,6 @@
1
1
  import Space from "rc-master-ui/es/space";
2
2
  import Command from "../components/command/Command";
3
- import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getEditType, getFormat, getNextEditableColumn, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
3
+ import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getDragRightData, getEditType, getFormat, getNextEditableColumn, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
4
4
  import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
5
5
  import classNames from "classnames";
6
6
  import React from "react";
@@ -8,6 +8,7 @@ import { TableContext } from "../useContext";
8
8
  import EditableCell from "./EditableCell";
9
9
  import { nonActionColumn } from "../../grid-component/hooks";
10
10
  import { getValueCellString, renderValueCell, toggleRowSelection } from "../hook/useColumns";
11
+ import { Dropdown } from "rc-master-ui";
11
12
  const renderCellIndex = props => {
12
13
  const {
13
14
  parrents,
@@ -195,6 +196,7 @@ const TableBodyCellEdit = props => {
195
196
  setFocusedCell,
196
197
  setEditingKey,
197
198
  setRangeState,
199
+ rangePasteState,
198
200
  setRangePasteState,
199
201
  endCell,
200
202
  setEndCell,
@@ -238,13 +240,6 @@ const TableBodyCellEdit = props => {
238
240
  const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
239
241
  const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
240
242
  const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
241
-
242
- // const tooltipContent = (isOpenTooltip === false)
243
- // ? ''
244
- // : columnMeta?.tooltipDescription
245
- // ? (typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({ value: cell.getValue(), rowData: record }) : columnMeta.tooltipDescription)
246
- // : cell.getValue()
247
-
248
243
  const canEdit = isEditable(cell.column.columnDef.meta, record) && isRowEditable !== false;
249
244
 
250
245
  // const allRows = table.getRowModel().rows;
@@ -317,7 +312,8 @@ const TableBodyCellEdit = props => {
317
312
  const colPasteds = getColIdsBetween(table, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
318
313
  const rowSelectIds = getRowIdsBetween(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
319
314
  const colSelectIds = getColIdsBetween(table, startCell?.colId ?? '', endCell?.colId ?? '');
320
- const dataSelected = [];
315
+ const dataSelected = []; // data được copy
316
+
321
317
  rowSelectIds.forEach(rowId => {
322
318
  const row = allRows.find(r => r.id === rowId);
323
319
  if (!row) return;
@@ -331,49 +327,104 @@ const TableBodyCellEdit = props => {
331
327
  });
332
328
  const copyRows = flattenData('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
333
329
  let newRange;
334
- if ((startRowIndex ?? 0) < (pasteRangeState.startRowIndex ?? 0)) {
330
+ if (pasteState.type === 'down') {
335
331
  // kéo xuóng
336
332
  setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell));
337
333
  newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length);
338
- } else {
334
+ } else if (pasteState.type === 'up') {
339
335
  // kéo lên
340
336
  setStartCell?.(endCell);
341
337
  setRangeState?.(getSelectedCellMatrix(table, endCell, endPasteCell));
342
338
  newRange = ctrlKey ? addRowsUpWithCtrl(dataSelected, rowPasteIds.length) : addRowsUp(dataSelected, rowPasteIds.length);
339
+ } else if (pasteState.type === 'right') {
340
+ // kéo phải
341
+ setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell));
342
+ // newRange = { addedRows: [], combined: [] }
343
+ // newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length)
344
+ newRange = getDragRightData({
345
+ colPasteds,
346
+ colSelectIds,
347
+ copyRows,
348
+ rowSelectIds
349
+ });
350
+ } else if (pasteState.type === 'left') {
351
+ // kéo trái
352
+ setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell));
353
+ // newRange = { addedRows: [], combined: [] }
354
+ // newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowPasteIds.length) : addRowsDown(dataSelected, rowPasteIds.length)
355
+ newRange = getDragRightData({
356
+ colPasteds,
357
+ colSelectIds,
358
+ copyRows,
359
+ rowSelectIds
360
+ });
343
361
  }
344
362
 
345
363
  // Cập nhật data mới
346
364
  const newData = flattenArray([...dataSource]);
347
365
  const pastedRows = [];
348
- newRange.addedRows.forEach((rowValues, rowIndex1) => {
349
- const targetRow = pasteState.startRowIndex + rowIndex1;
366
+ if (pasteState.type === 'down' || pasteState.type === 'up') {
367
+ newRange.addedRows.forEach((rowValues, rowIndex1) => {
368
+ const targetRow = pasteState.startRowIndex + rowIndex1;
350
369
 
351
- // Nếu vượt quá số dòng hiện có, thêm dòng mới
352
- if (targetRow >= newData.length) {
353
- newData.push({
354
- id: undefined,
355
- rowId: newGuid()
356
- });
357
- }
358
- rowValues.forEach((cellValue, colIndex1) => {
359
- const targetCol = startColIndex + colIndex1;
360
- if (targetCol >= tmpCols.length) {
361
- // Không vượt quá số cột
362
- return;
363
- }
364
- const columnKey = tmpCols[targetCol].id;
365
- const disable = !isEditable(tmpCols[targetCol].columnDef.meta, record);
366
- if (!disable) {
367
- newData[targetRow] = {
368
- ...newData[targetRow],
369
- [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
370
- };
370
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
371
+ if (targetRow >= newData.length) {
372
+ newData.push({
373
+ id: undefined,
374
+ rowId: newGuid()
375
+ });
371
376
  }
377
+ rowValues.forEach((cellValue, colIndex1) => {
378
+ const targetCol = startColIndex + colIndex1;
379
+ if (targetCol >= tmpCols.length) {
380
+ // Không vượt quá số cột
381
+ return;
382
+ }
383
+ const columnKey = tmpCols[targetCol].id;
384
+ const disable = !isEditable(tmpCols[targetCol].columnDef.meta, record);
385
+ if (!disable) {
386
+ newData[targetRow] = {
387
+ ...newData[targetRow],
388
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
389
+ };
390
+ }
391
+ });
392
+
393
+ // Lưu dòng được paste
394
+ pastedRows.push(newData[targetRow]);
372
395
  });
396
+ }
397
+ if (pasteState.type === 'right' || pasteState.type === 'left') {
398
+ newRange.addedCols.forEach((rowValues, rowIndex1) => {
399
+ const targetRow = pasteState.startRowIndex + rowIndex1;
373
400
 
374
- // Lưu dòng được paste
375
- pastedRows.push(newData[targetRow]);
376
- });
401
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
402
+ if (targetRow >= newData.length) {
403
+ newData.push({
404
+ id: undefined,
405
+ rowId: newGuid()
406
+ });
407
+ }
408
+ rowValues.forEach((cellValue, colIndex1) => {
409
+ const targetCol = pasteState.startColIndex + colIndex1;
410
+ if (targetCol >= tmpCols.length) {
411
+ // Không vượt quá số cột
412
+ return;
413
+ }
414
+ const columnKey = tmpCols[targetCol].id;
415
+ const disable = !isEditable(tmpCols[targetCol].columnDef.meta, record);
416
+ if (!disable) {
417
+ newData[targetRow] = {
418
+ ...newData[targetRow],
419
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
420
+ };
421
+ }
422
+ });
423
+
424
+ // Lưu dòng được paste
425
+ pastedRows.push(newData[targetRow]);
426
+ });
427
+ }
377
428
  const rsFilterData = updateOrInsert(flattenArray([...originData]), newData);
378
429
  const rs = unFlattenData(rsFilterData);
379
430
  triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
@@ -454,11 +505,22 @@ const TableBodyCellEdit = props => {
454
505
  });
455
506
  }
456
507
  if (isPasting) {
457
- const absRowIndex = table.getRowModel().flatRows.findIndex(it => it.id === cell.row.id);
458
- if ((startRowIndex ?? 0) > absRowIndex) {
459
- // kéo lên
508
+ const allCols = table.getAllLeafColumns();
509
+ const absRowIndex = table.getRowModel().flatRows.findIndex(it => it.id === rowId); // row cell con chỏ chuột hiện tại
510
+ const absColIndex = allCols.findIndex(it => it.id === colId); // col cell con chỏ chuột hiện tại
460
511
 
461
- const startRowPaste = allRows.find(it => it.index === (startRowIndex ?? 0) - 1);
512
+ // const absColIndex = allCols.findIndex((it) => it.id === endCell?.colId )
513
+
514
+ const endCellColIndex = allCols.findIndex(it => it.id === endCell?.colId); // col cuối cùng vùng được copy
515
+
516
+ const rowGap = absRowIndex - (endRowIndex ?? 0);
517
+ const colGap = absColIndex - (endCellColIndex ?? 0);
518
+ const absRowGap = rangeState?.rowRange.length === 1 ? rowGap : rowGap >= 0 ? rowGap : rowGap + (rangeState?.rowRange.length ?? 0) - 1;
519
+ const absColGap = rangeState?.colRange.length === 1 ? colGap : colGap >= 0 ? colGap : colGap + (rangeState?.colRange.length ?? 0) - 1;
520
+ if (rowGap > 0 && absRowGap > 0 && Math.abs(absRowGap) >= Math.abs(absColGap)) {
521
+ // kéo xuống : cell cuối trùng endCell
522
+ const findIndex = allRows.findIndex(it => it.id === endCell?.rowId);
523
+ const startRowPaste = allRows[findIndex + 1];
462
524
  setStartPasteCell?.({
463
525
  colId: startCell?.colId ?? '',
464
526
  rowId: startRowPaste?.id ?? ''
@@ -473,28 +535,57 @@ const TableBodyCellEdit = props => {
473
535
  }, {
474
536
  colId: endCell?.colId ?? '',
475
537
  rowId
476
- }));
538
+ }, 'down'));
539
+ return;
477
540
  }
478
- if ((startRowIndex ?? 0) < absRowIndex) {
479
- // kéo xuống
480
-
481
- const findIndex = allRows.findIndex(it => it.id === endCell?.rowId);
482
- const startRowPaste = allRows[findIndex + 1];
483
- setStartPasteCell?.({
484
- colId: startCell?.colId ?? '',
485
- rowId: startRowPaste?.id ?? ''
486
- });
487
- setEndPasteCell?.({
488
- colId: endCell?.colId ?? '',
489
- rowId
490
- });
491
- setRangePasteState?.(getSelectedCellMatrix(table, {
541
+ if (rowGap < 0 && absRowGap < 0 && Math.abs(absRowGap) >= Math.abs(absColGap)) {
542
+ // kéo lên
543
+ const startRowPaste = allRows.find(it => it.index === (startRowIndex ?? 0) - 1);
544
+ const startPastCell = {
492
545
  colId: startCell?.colId ?? '',
493
546
  rowId: startRowPaste?.id ?? ''
494
- }, {
547
+ };
548
+ const endPastCell = {
495
549
  colId: endCell?.colId ?? '',
496
550
  rowId
497
- }));
551
+ };
552
+ setStartPasteCell?.(startPastCell);
553
+ setEndPasteCell?.(endPastCell);
554
+ setRangePasteState?.(getSelectedCellMatrix(table, startPastCell, endPastCell, 'up'));
555
+ return;
556
+ }
557
+ if (colGap > 0 && absColGap > 0 && Math.abs(absColGap) > Math.abs(absRowGap)) {
558
+ const startCol = allCols[(rangeState?.endColIndex ?? 0) + 1];
559
+ const startPastCell = {
560
+ colId: startCol?.id ?? '',
561
+ rowId: rangeState?.rowRange[0] ?? ''
562
+ };
563
+ const endPastCell = {
564
+ colId,
565
+ rowId: rangeState?.rowRange[rangeState?.rowRange.length - 1] ?? ''
566
+ };
567
+ setStartPasteCell?.(startPastCell);
568
+ setEndPasteCell?.(endPastCell);
569
+ setRangePasteState?.(getSelectedCellMatrix(table, startPastCell, endPastCell, 'right'));
570
+ return;
571
+ }
572
+ if (colGap < 0 && absColGap < 0 && Math.abs(absColGap) > Math.abs(absRowGap)) {
573
+ const endCol = allCols[(rangeState?.startColIndex ?? 0) - 1];
574
+ const startPastCell = {
575
+ colId: colId ?? '',
576
+ rowId: rangeState?.rowRange[0] ?? ''
577
+ };
578
+ const endPastCell = {
579
+ colId: endCol.id,
580
+ rowId: rangeState?.rowRange[rangeState?.rowRange.length - 1] ?? ''
581
+ };
582
+ setStartPasteCell?.(startPastCell);
583
+ setEndPasteCell?.(endPastCell);
584
+ setRangePasteState?.(getSelectedCellMatrix(table, startPastCell, endPastCell, 'left'));
585
+ return;
586
+ } else {
587
+ setStartPasteCell?.(undefined);
588
+ setEndPasteCell?.(undefined);
498
589
  }
499
590
  }
500
591
  }
@@ -522,14 +613,15 @@ const TableBodyCellEdit = props => {
522
613
  setIsSelecting?.(false);
523
614
  setIsPasting?.(false);
524
615
  const selectState = getSelectedCellMatrix(table, startCell, endCell);
525
- const selectPasteState = getSelectedCellMatrix(table, startPasteCell, endPasteCell);
526
- if (endPasteCell && endCell?.rowId !== endPasteCell?.rowId && isPasting) {
616
+ // const selectPasteState = getSelectedCellMatrix(table, startPasteCell, endPasteCell)
617
+ const selectPasteState = rangePasteState ? {
618
+ ...rangePasteState
619
+ } : {};
620
+
621
+ // if (endPasteCell && endCell?.rowId !== endPasteCell?.rowId && isPasting) {
622
+ if (selectPasteState.type && isPasting) {
527
623
  triggerDragPaste(selectPasteState, e.ctrlKey);
528
624
  } else {
529
- // if ( endCell?.rowId !== rowId || endCell?.colId !== colId) {
530
- // setRangeState?.(selectState)
531
- // }
532
-
533
625
  if (!isObjEqual(rangeState, selectState)) {
534
626
  setRangeState?.(selectState);
535
627
  }
@@ -1175,6 +1267,18 @@ const TableBodyCellEdit = props => {
1175
1267
  const colFormat = typeof columnMeta?.format === 'function' ? columnMeta?.format(record) : columnMeta?.format;
1176
1268
  const cellFormat = getFormat(colFormat, format);
1177
1269
  const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, cellFormat, true);
1270
+ const cellContent = columnMeta?.template ? typeof columnMeta.template === 'function' ? columnMeta.template({
1271
+ field: columnMeta.field,
1272
+ index: cell.row.index,
1273
+ rowData: cell.row.original,
1274
+ value: cell.getValue()
1275
+ }) : columnMeta.template : fomatedValue;
1276
+ const linkContent = columnMeta?.linkTemplate ? typeof columnMeta.linkTemplate === 'function' ? columnMeta.linkTemplate({
1277
+ field: columnMeta.field,
1278
+ index: cell.row.index,
1279
+ rowData: cell.row.original,
1280
+ value: cell.getValue()
1281
+ }) : columnMeta.linkTemplate : cellContent;
1178
1282
  return /*#__PURE__*/React.createElement("div", {
1179
1283
  key: cell.id,
1180
1284
  ref: el => {
@@ -1189,7 +1293,7 @@ const TableBodyCellEdit = props => {
1189
1293
  "data-row-key": cell.row.id,
1190
1294
  "data-tooltip-id": `${id}-tooltip-content`,
1191
1295
  "data-tooltip-delay-show": 500,
1192
- "data-tooltip-content": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : tooltipContent,
1296
+ "data-tooltip-content": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : columnMeta?.type === 'link' ? '' : tooltipContent,
1193
1297
  className: classNames(`${prefix}-grid-cell cell-editable editable `, {
1194
1298
  [`${prefix}-grid-cell-ellipsis`]: true,
1195
1299
  'cell-editing': isEditing,
@@ -1208,7 +1312,8 @@ const TableBodyCellEdit = props => {
1208
1312
  [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
1209
1313
  [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
1210
1314
  [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
1211
- [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
1315
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta?.type === 'number',
1316
+ [`${prefix}-grid-cell-link`]: columnMeta?.type === 'link'
1212
1317
  }),
1213
1318
  style: {
1214
1319
  display: 'flex',
@@ -1308,8 +1413,31 @@ const TableBodyCellEdit = props => {
1308
1413
  record: record,
1309
1414
  visibleColumns: visibleColumns,
1310
1415
  handleNextCell: handleNextCell
1311
- // rowKey={rowKey}
1312
- }) : /*#__PURE__*/React.createElement("div", {
1416
+ }) : columnMeta?.type === 'link' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Dropdown, {
1417
+ trigger: ['hover'],
1418
+ menu: {
1419
+ items: [{
1420
+ key: '1',
1421
+ label: ''
1422
+ }]
1423
+ },
1424
+ dropdownRender: () => /*#__PURE__*/React.createElement("div", {
1425
+ style: {
1426
+ padding: '1rem',
1427
+ backgroundColor: '#ffffff',
1428
+ borderRadius: 6,
1429
+ boxShadow: '0 6px 16px 0 rgba(0, 0, 0, 0.08),0 3px 6px -4px rgba(0, 0, 0, 0.12),0 9px 28px 8px rgba(0, 0, 0, 0.05)'
1430
+ }
1431
+ }, linkContent && typeof linkContent === 'string' ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("a", {
1432
+ href: linkContent,
1433
+ target: "_blank",
1434
+ rel: "noreferrer"
1435
+ }, linkContent)) : linkContent ? linkContent : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("a", {
1436
+ href: typeof cellContent === 'string' ? cellContent : '',
1437
+ target: "_blank",
1438
+ rel: "noreferrer"
1439
+ }, cellContent)))
1440
+ }, /*#__PURE__*/React.createElement("div", {
1313
1441
  className: classNames('ui-rc_cell-content', {
1314
1442
  'select-cell': canEdit && ['select', 'selectTable', 'asyncSelect', 'treeSelect'].includes(getEditType(columnMeta, record))
1315
1443
  })
@@ -1349,17 +1477,57 @@ const TableBodyCellEdit = props => {
1349
1477
  className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
1350
1478
  })) : /*#__PURE__*/React.createElement("span", {
1351
1479
  className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
1352
- }))), columnMeta.template ? typeof columnMeta.template === 'function' ? columnMeta.template({
1353
- field: columnMeta.field,
1354
- index: cell.row.index,
1355
- rowData: cell.row.original,
1356
- value: cell.getValue()
1357
- }) : columnMeta.template : fomatedValue, (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/React.createElement("span", {
1480
+ }))), cellContent, (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/React.createElement("span", {
1481
+ className: 'caret-down',
1482
+ onClick: e => {
1483
+ handleEdit(e);
1484
+ }
1485
+ })))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1486
+ className: classNames('ui-rc_cell-content', {
1487
+ 'select-cell': canEdit && ['select', 'selectTable', 'asyncSelect', 'treeSelect'].includes(getEditType(columnMeta, record))
1488
+ })
1489
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
1490
+ className: "ui-rc-table-row-expand-trigger",
1491
+ style: {
1492
+ paddingLeft: `${cell.row.depth * 25}px`
1493
+ }
1494
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
1495
+ // onClick: row.getToggleExpandedHandler(),
1496
+ onClick: e => {
1497
+ e.stopPropagation();
1498
+ e.preventDefault();
1499
+ setIsExpandClick(true);
1500
+ const keys = Object.keys(expanded);
1501
+ // @ts-ignore
1502
+ const tmp = {
1503
+ ...expanded
1504
+ };
1505
+ if (keys.includes(cell.row.id)) {
1506
+ delete tmp[cell.row.id];
1507
+ setExpanded(tmp);
1508
+ } else {
1509
+ setExpanded(old => ({
1510
+ ...old,
1511
+ [cell.row.id]: true
1512
+ }));
1513
+ }
1514
+ },
1515
+ style: {
1516
+ cursor: "pointer"
1517
+ },
1518
+ className: "ui-rc-table-row-expand"
1519
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
1520
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
1521
+ }) : /*#__PURE__*/React.createElement("span", {
1522
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
1523
+ })) : /*#__PURE__*/React.createElement("span", {
1524
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
1525
+ }))), cellContent, (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/React.createElement("span", {
1358
1526
  className: 'caret-down',
1359
1527
  onClick: e => {
1360
1528
  handleEdit(e);
1361
1529
  }
1362
- })), !isSelecting && !isEditing && rowRange &&
1530
+ }))), !isSelecting && !isEditing && rowRange &&
1363
1531
  // rowNumber === rangeState?.endRowIndex &&
1364
1532
  cell.row.id === rowRange[rowRange?.length - 1] && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/React.createElement("div", {
1365
1533
  className: 'dragging-point',
@@ -96,7 +96,7 @@ export declare const genPresets: (presets?: import("@ant-design/colors").Palette
96
96
  export declare const getEditType: <T>(column: ColumnTable<T>, rowData?: any) => EditType;
97
97
  export declare const getDefaultValue: (defaultValue: any) => AnyObject;
98
98
  export declare const flattenData: <RecordType extends AnyObject = AnyObject>(childrenColumnName: string, data?: RecordType[]) => RecordType[];
99
- export declare const getSelectedCellMatrix: (table: Table<any>, startCell: IPositionCell | undefined, endCell: IPositionCell | undefined) => RangeState;
99
+ export declare const getSelectedCellMatrix: (table: Table<any>, startCell: IPositionCell | undefined, endCell: IPositionCell | undefined, type?: string) => RangeState;
100
100
  export declare function addRowsDownWithCtrl(arr: any, n: number): {
101
101
  combined: any;
102
102
  addedRows: any[];
@@ -125,6 +125,16 @@ export declare function addRowsUp(array: any, n: number): {
125
125
  combined: any[];
126
126
  addedRows: any[];
127
127
  };
128
+ interface DragCopyParams {
129
+ rowSelectIds: string[];
130
+ colSelectIds: string[];
131
+ colPasteds: string[];
132
+ copyRows: any[];
133
+ }
134
+ export declare const getDragRightData: ({ rowSelectIds, colSelectIds, colPasteds, copyRows, }: DragCopyParams) => {
135
+ combined: any[][];
136
+ addedCols: any[][];
137
+ };
128
138
  export declare const convertFilters: (filters: any[]) => any[];
129
139
  export declare const revertConvertFilters: (clauses: any[]) => FilterState[];
130
140
  export declare function getInvisibleColumns(columns: ColumnTable[]): Record<string, boolean>;
@@ -170,3 +180,4 @@ export declare function sumNumberFields(columns: ColumnTable[], data: any[], chi
170
180
  export declare const getTreeDepth: (rows: any[]) => number;
171
181
  export type FormatToken = 'YYYY' | 'MM' | 'DD' | 'HH' | 'mm' | 'ss';
172
182
  export declare const isDateChanged: (oldDate: string | Date, newDate: string | Date, format: string) => FormatToken | null;
183
+ export {};
@@ -1355,7 +1355,7 @@ export const flattenData = (childrenColumnName, data) => {
1355
1355
  });
1356
1356
  return list;
1357
1357
  };
1358
- export const getSelectedCellMatrix = (table, startCell, endCell) => {
1358
+ export const getSelectedCellMatrix = (table, startCell, endCell, type) => {
1359
1359
  if (!startCell || !endCell) return {
1360
1360
  rowIds: [],
1361
1361
  colIds: [],
@@ -1364,7 +1364,8 @@ export const getSelectedCellMatrix = (table, startCell, endCell) => {
1364
1364
  startColIndex: undefined,
1365
1365
  endColIndex: undefined,
1366
1366
  colRange: [],
1367
- rowRange: []
1367
+ rowRange: [],
1368
+ type
1368
1369
  };
1369
1370
 
1370
1371
  // const rowIds = table.getRowModel().rows.map(r => r.id);
@@ -1386,7 +1387,8 @@ export const getSelectedCellMatrix = (table, startCell, endCell) => {
1386
1387
  startColIndex,
1387
1388
  endColIndex,
1388
1389
  rowIds,
1389
- colIds
1390
+ colIds,
1391
+ type
1390
1392
  };
1391
1393
  };
1392
1394
  export function addRowsDownWithCtrl(arr, n) {
@@ -1935,6 +1937,30 @@ export function addRowsUp(array, n) {
1935
1937
  addedRows
1936
1938
  };
1937
1939
  }
1940
+ export const getDragRightData = ({
1941
+ rowSelectIds,
1942
+ colSelectIds,
1943
+ colPasteds,
1944
+ copyRows
1945
+ }) => {
1946
+ const selectedRows = copyRows.filter(row => rowSelectIds.includes(String(row.rowId ?? row.id)));
1947
+ const addedCols = selectedRows.map(row => {
1948
+ return colPasteds.map((_, index) => {
1949
+ const sourceCol = colSelectIds[index % colSelectIds.length];
1950
+ return row[sourceCol] ?? '';
1951
+ });
1952
+ });
1953
+ const combined = selectedRows.map((row, rowIndex) => {
1954
+ const sourceValues = colSelectIds.map(col => {
1955
+ return row[col] ?? '';
1956
+ });
1957
+ return [...sourceValues, ...addedCols[rowIndex]];
1958
+ });
1959
+ return {
1960
+ combined,
1961
+ addedCols
1962
+ };
1963
+ };
1938
1964
  export const convertFilters = filters => {
1939
1965
  const result = [];
1940
1966
  filters.forEach(({
@@ -48,4 +48,4 @@ const colorDark = '#e6e4f3e6 ';
48
48
  export const GridStyle = styled.div.withConfig({
49
49
  displayName: "GridStyle",
50
50
  componentId: "es-grid-template__sc-hdqm5k-0"
51
- })(["&.", "-grid{color:", ";font-size:", ";background-color:", ";font-family:", ";&.", "-grid-editable{.", "-grid-container{.", "-grid-tbody{.", "-grid-row{background-color:", ";color:", ";&.", "-grid-row-parent{background-color:#ffffff;font-weight:500;}}}}}table{table-layout:fixed;border-collapse:separate;border-spacing:0;}.", "-grid-container{border:1px solid ", ";border-right:0;&::after{position:absolute;top:0px;right:0;z-index:1;height:100%;border-right:1px solid ", ";content:'';pointer-events:none;}.", "-grid-cell{padding:5px 8px;&.", "-grid-cell-text-center{text-align:center;justify-content:center;}&.", "-grid-cell-text-right{justify-content:flex-end;text-align:right;}&.editable{.ui-rc_cell-content{height:100%}}&.", "-grid-cell-ellipsis{.ui-rc_cell-content{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;&.select-cell{padding-right:18px;position:relative;}.caret-down{float:right;position:absolute;right:0;&::before{content:'';display:inline-block;margin-left:4px;vertical-align:middle;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #6f7777;}}}}&.", "-grid-cell-wrap{white-space:normal;text-overflow:ellipsis;word-break:break-word;}.", "-grid-header-text-wrap{white-space:normal;overflow:hidden;text-overflow:ellipsis;word-break:break-word;}}.", "-grid-thead{background-color:", ";font-weight:", ";.", "-grid-cell{font-weight:inherit;color:", ";background-color:inherit;border-inline-end:1px solid ", ";border-bottom:1px solid ", ";&.ui-rc-grid-cell-ellipsis{.ui-rc-table-column-title,.", "-grid-cell-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}}&.ui-rc-grid-cell-wrap{.ui-rc-table-column-title,.", "-grid-cell-text-wrap{white-space:normal;word-break:break-word;overflow:hidden;}}&:hover{.ui-rc-header-trigger{.ui-rc-table-column-sorter-cancel{opacity:1;}}}.", "-grid-filter-column{display:flex;justify-content:space-between;width:100%;align-items:center;position:relative;z-index:3;}.ui-rc-header-trigger{padding-left:6px;display:flex;align-items:center;.ui-rc-table-column-sorter-cancel{opacity:0;}}.resizer{cursor:col-resize;height:100%;position:absolute;right:0;top:0;z-index:3;touch-action:none;user-select:none;width:5px;}.resizer.isResizing{opacity:1;}}}.", "-grid-tbody{.", "-grid-row{font-weight:", ";background-color:", ";color:", ";&.", "-grid-row-odd{background-color:#f9f8fd;}&.", "-grid-row-even{}&.", "-grid-row-parent{background-color:#f5f5f5;font-weight:500;}}}.", "-grid-tfoot{.", "-grid-footer-row{border-bottom-width:1px;border-bottom-color:", ";border-bottom-style:solid;border-top-width:1px;border-top-color:", ";border-top-style:solid;background-color:#fafafa;}.", "-grid-cell{background-color:inherit;border-inline-end:1px solid ", ";}}}&.", "-grid-dark{background-color:", ";color:", ";.", "-grid-container{border-color:", ";&::after{border-right-color:", ";}}}.ui-rc-toolbar-bottom{border-right:1px solid #e0e0e0;border-left:1px solid #e0e0e0;.be-toolbar-item{.ui-rc-btn{font-size:12px;line-height:1.5}.toolbar-dropdown-button{font-size:12px;.ui-rc-btn.ui-rc-btn-default.ui-rc-btn-variant-outlined.ui-rc-btn-compact-item.ui-rc-btn-compact-first-item{border-color:#28c76f;}.ui-rc-btn.ui-rc-btn-default.ui-rc-btn-variant-outlined.ui-rc-btn-compact-item.ui-rc-btn-compact-last-item{border-color:#28c76f;.ui-rc-btn-icon{color:#28c76f;}}}}}.ui-rc-toolbar-bottom_border-bottom{border-bottom:1px solid #e0e0e0;}.ui-rc-toolbar-bottom{position:relative;padding:.15rem 0.5rem;background-color:#ffffff;.toolbar-button{border-radius:3px;}.ui-rc-btn{border-radius:3px;height:28px;&.ui-rc-btn-compact-item.ui-rc-btn-compact-last-item{border-start-start-radius:0;border-end-start-radius:0;}&.ui-rc-btn-compact-item.ui-rc-btn-compact-first-item{border-start-end-radius:0;border-end-end-radius:0;}}}}"], props => props.$prefix, color, fontSize, BgColor, fontFamily, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, props => `${props.$theme.color ? props.$theme.color : color}`, props => props.$prefix, props => props.$prefix, tableBorderColor, tableBorderColor, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, fwHeader, props => props.$prefix, props => `${props.$theme.color ? props.$theme.color : color}`, tableBorderColor, tableBorderColor, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, fwBody, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, props => `${props.$theme.color ? props.$theme.color : color}`, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, tableBorderColor, tableBorderColor, props => props.$prefix, tableBorderColor, props => props.$prefix, BgColorDark, colorDark, props => props.$prefix, tableBorderColorDark, tableBorderColorDark);
51
+ })(["&.", "-grid{color:", ";font-size:", ";background-color:", ";font-family:", ";&.", "-grid-editable{.", "-grid-container{.", "-grid-tbody{.", "-grid-row{background-color:", ";color:", ";&.", "-grid-row-parent{background-color:#ffffff;font-weight:500;}}}}}table{table-layout:fixed;border-collapse:separate;border-spacing:0;}.", "-grid-container{border:1px solid ", ";border-right:0;&::after{position:absolute;top:0px;right:0;z-index:1;height:100%;border-right:1px solid ", ";content:'';pointer-events:none;}.", "-grid-cell{padding:5px 8px;&.", "-grid-cell-text-center{text-align:center;justify-content:center;}&.", "-grid-cell-text-right{justify-content:flex-end;text-align:right;}&.", "-grid-cell-link{text-decoration:underline;color:#336cc9;&:has(textarea){text-decoration:none;}}&.editable{.ui-rc_cell-content{height:100%}}&.", "-grid-cell-ellipsis{.ui-rc_cell-content{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;&.select-cell{padding-right:18px;position:relative;}.caret-down{float:right;position:absolute;right:0;&::before{content:'';display:inline-block;margin-left:4px;vertical-align:middle;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #6f7777;}}}}&.", "-grid-cell-wrap{white-space:normal;text-overflow:ellipsis;word-break:break-word;}.", "-grid-header-text-wrap{white-space:normal;overflow:hidden;text-overflow:ellipsis;word-break:break-word;}}.", "-grid-thead{background-color:", ";font-weight:", ";.", "-grid-cell{font-weight:inherit;color:", ";background-color:inherit;border-inline-end:1px solid ", ";border-bottom:1px solid ", ";&.ui-rc-grid-cell-ellipsis{.ui-rc-table-column-title,.", "-grid-cell-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}}&.ui-rc-grid-cell-wrap{.ui-rc-table-column-title,.", "-grid-cell-text-wrap{white-space:normal;word-break:break-word;overflow:hidden;}}&:hover{.ui-rc-header-trigger{.ui-rc-table-column-sorter-cancel{opacity:1;}}}.", "-grid-filter-column{display:flex;justify-content:space-between;width:100%;align-items:center;position:relative;z-index:3;}.ui-rc-header-trigger{padding-left:6px;display:flex;align-items:center;.ui-rc-table-column-sorter-cancel{opacity:0;}}.resizer{cursor:col-resize;height:100%;position:absolute;right:0;top:0;z-index:3;touch-action:none;user-select:none;width:5px;}.resizer.isResizing{opacity:1;}}}.", "-grid-tbody{.", "-grid-row{font-weight:", ";background-color:", ";color:", ";&.", "-grid-row-odd{background-color:#f9f8fd;}&.", "-grid-row-even{}&.", "-grid-row-parent{background-color:#f5f5f5;font-weight:500;}}}.", "-grid-tfoot{.", "-grid-footer-row{border-bottom-width:1px;border-bottom-color:", ";border-bottom-style:solid;border-top-width:1px;border-top-color:", ";border-top-style:solid;background-color:#fafafa;}.", "-grid-cell{background-color:inherit;border-inline-end:1px solid ", ";}}}&.", "-grid-dark{background-color:", ";color:", ";.", "-grid-container{border-color:", ";&::after{border-right-color:", ";}}}.ui-rc-toolbar-bottom{border-right:1px solid #e0e0e0;border-left:1px solid #e0e0e0;.be-toolbar-item{.ui-rc-btn{font-size:12px;line-height:1.5}.toolbar-dropdown-button{font-size:12px;.ui-rc-btn.ui-rc-btn-default.ui-rc-btn-variant-outlined.ui-rc-btn-compact-item.ui-rc-btn-compact-first-item{border-color:#28c76f;}.ui-rc-btn.ui-rc-btn-default.ui-rc-btn-variant-outlined.ui-rc-btn-compact-item.ui-rc-btn-compact-last-item{border-color:#28c76f;.ui-rc-btn-icon{color:#28c76f;}}}}}.ui-rc-toolbar-bottom_border-bottom{border-bottom:1px solid #e0e0e0;}.ui-rc-toolbar-bottom{position:relative;padding:.15rem 0.5rem;background-color:#ffffff;.toolbar-button{border-radius:3px;}.ui-rc-btn{border-radius:3px;height:28px;&.ui-rc-btn-compact-item.ui-rc-btn-compact-last-item{border-start-start-radius:0;border-end-start-radius:0;}&.ui-rc-btn-compact-item.ui-rc-btn-compact-first-item{border-start-end-radius:0;border-end-end-radius:0;}}}}"], props => props.$prefix, color, fontSize, BgColor, fontFamily, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, props => `${props.$theme.color ? props.$theme.color : color}`, props => props.$prefix, props => props.$prefix, tableBorderColor, tableBorderColor, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, fwHeader, props => props.$prefix, props => `${props.$theme.color ? props.$theme.color : color}`, tableBorderColor, tableBorderColor, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, fwBody, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, props => `${props.$theme.color ? props.$theme.color : color}`, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, tableBorderColor, tableBorderColor, props => props.$prefix, tableBorderColor, props => props.$prefix, BgColorDark, colorDark, props => props.$prefix, tableBorderColorDark, tableBorderColorDark);
@@ -1,9 +1,9 @@
1
1
  import type * as React from "react";
2
2
  import dayjs from "dayjs";
3
- import type { EditType, IColumnType, TypeFilter } from "rc-master-ui";
3
+ import type { TypeFilter } from "rc-master-ui";
4
4
  import type { Key } from "react";
5
5
  import type { ColumnsTable } from "./../index";
6
- import type { AnyObject, ColumnTable, GetRowKey, IFormat } from "../type";
6
+ import type { AnyObject, ColumnTable, EditType, GetRowKey, IColumnType, IFormat } from "../type";
7
7
  export declare const newGuid: () => any;
8
8
  export declare const sumDataByField: (data: any[], field: string) => any;
9
9
  export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
@@ -48,19 +48,9 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
48
48
  var _moment = _interopRequireDefault(require("moment/moment"));
49
49
  var _uuid = require("uuid");
50
50
  var _colors = require("@ant-design/colors");
51
- // import type {ColumnTable, GetRowKey, IFormat, Presets} from "./../ type"
52
-
53
- // import type {SelectionSettings} from "../type"
54
- // import type {AnyObject} from "../type"
55
-
56
- // import {Table} from "rc-master-ui"
57
- // import {flatColumns2} from "./columns"
58
- // import {SELECTION_COLUMN} from "./useColumns"
59
-
60
51
  const newGuid = () => {
61
52
  for (let i = 0; i < 20; i++) {
62
53
  // @ts-ignore
63
- // const id = crypto.randomUUID()
64
54
  return (0, _uuid.v4)();
65
55
  }
66
56
  };
@@ -94,10 +94,10 @@ export type IFormat = {
94
94
  yearFormat?: string;
95
95
  };
96
96
  export type RowSelectMethod = 'all' | 'none' | 'invert' | 'single' | 'multiple';
97
- export type EditType = 'text' | 'numeric' | 'asyncSelect' | 'date' | 'datetime' | 'time' | 'week' | 'month' | 'quarter' | 'year' | 'select' | 'checkbox' | 'currency' | 'image' | 'selectTable' | 'customSelect' | 'form' | 'color' | 'treeSelect' | 'file';
97
+ export type EditType = 'text' | 'numeric' | 'asyncSelect' | 'date' | 'datetime' | 'time' | 'week' | 'month' | 'quarter' | 'year' | 'select' | 'checkbox' | 'currency' | 'image' | 'selectTable' | 'customSelect' | 'form' | 'color' | 'link' | 'treeSelect' | 'file';
98
98
  export type ITextAlign = 'center' | 'left' | 'right';
99
99
  export type TypeFilter = 'Text' | 'Date' | 'Time' | 'Datetime' | 'DateRange' | 'Month' | 'Quarter' | 'Year' | 'Week' | 'Number' | 'NumberRange' | 'Dropdown' | 'DropTree' | 'Checkbox' | 'CheckboxTree' | 'CheckboxDropdown';
100
- export type IColumnType = 'number' | 'time' | 'date' | 'week' | 'month' | 'file' | 'quarter' | 'year' | 'datetime' | 'string' | 'boolean' | 'checkbox' | 'color' | null | undefined;
100
+ export type IColumnType = 'number' | 'time' | 'date' | 'week' | 'month' | 'file' | 'quarter' | 'year' | 'datetime' | 'string' | 'boolean' | 'checkbox' | 'color' | 'link' | null | undefined;
101
101
  export type FilterOperator = 'equal' | 'notequal' | 'greaterthan' | 'greaterthanorequal' | 'lessthan' | 'lessthanorequal' | 'startswith' | 'endswith' | 'contains';
102
102
  export type FixedType = 'left' | 'right' | boolean;
103
103
  export type SelectMode = 'checkbox' | 'radio' | undefined;
@@ -241,6 +241,7 @@ export type ColumnTable<RecordType = AnyObject> = {
241
241
  textAlign?: ITextAlign;
242
242
  /** Template custom render cell */
243
243
  template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
244
+ linkTemplate?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
244
245
  /** Hiển thị tooltip cell */
245
246
  showTooltip?: boolean;
246
247
  /** Nội dung tooltip của cell */
@@ -811,6 +812,7 @@ export type RangeState = {
811
812
  endColIndex: number | undefined;
812
813
  rowIds: string[];
813
814
  colIds: string[];
815
+ type?: any;
814
816
  };
815
817
  export type Sorter = {
816
818
  columnKey: string;
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import type { EditType } from "rc-master-ui";
3
- import type { ColumnTable, IFormat } from "../../grid-component/type";
2
+ import type { ColumnTable, EditType, IFormat } from "../../grid-component/type";
4
3
  interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
5
4
  t?: any;
6
5
  dataIndex: string;
@@ -189,6 +189,7 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
189
189
  align?: import("./../../grid-component/type").ITextAlign;
190
190
  textAlign?: import("./../../grid-component/type").ITextAlign;
191
191
  template?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
192
+ linkTemplate?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
192
193
  showTooltip?: boolean;
193
194
  tooltipDescription?: string | ((args: {
194
195
  value: any;
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import type { EditType } from "rc-master-ui";
3
- import type { ColumnTable, IFormat } from "../../grid-component/type";
2
+ import type { ColumnTable, EditType, IFormat } from "../../grid-component/type";
4
3
  import type { Column } from "@tanstack/react-table";
5
4
  interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
6
5
  t?: any;