@quadrats/react 1.1.5 → 1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quadrats/react",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "",
5
5
  "author": "Rytass",
6
6
  "homepage": "https://github.com/Quadrats/quadrats#readme",
@@ -471,6 +471,20 @@ function useTableCellToolbarActions({ element, cellPosition, isHeader, transform
471
471
  }, [tableSelectedOn, setTableSelectedOn, columnCount, element.treatAsTitle, tableElement, moveOrSwapColumn]);
472
472
  // Delete actions
473
473
  const deleteActions = useMemo(() => {
474
+ // 當選中 row 時,檢查是否為最後一行
475
+ if ((tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.region) === 'row' && typeof tableSelectedOn.index === 'number') {
476
+ // 如果只剩一行,不顯示刪除按鈕
477
+ if (isReachMinimumBodyRows && !isHeader) {
478
+ return [];
479
+ }
480
+ }
481
+ // 當選中 column 時,檢查是否為最後一列
482
+ if ((tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.region) === 'column' && typeof tableSelectedOn.index === 'number') {
483
+ // 如果只剩一列(考慮 title columns),不顯示刪除按鈕
484
+ if (columnCount <= 1) {
485
+ return [];
486
+ }
487
+ }
474
488
  return [
475
489
  {
476
490
  icon: Trash,
@@ -487,7 +501,7 @@ function useTableCellToolbarActions({ element, cellPosition, isHeader, transform
487
501
  },
488
502
  },
489
503
  ];
490
- }, [tableSelectedOn, deleteRow, deleteColumn, setTableSelectedOn]);
504
+ }, [tableSelectedOn, deleteRow, deleteColumn, setTableSelectedOn, isReachMinimumBodyRows, isHeader, columnCount]);
491
505
  // Inline toolbar icon groups - 當選中行/列時顯示的完整工具列
492
506
  const inlineToolbarIconGroups = useMemo(() => {
493
507
  return [
@@ -1457,6 +1457,20 @@ function useTableCellToolbarActions({ element, cellPosition, isHeader, transform
1457
1457
  }, [tableSelectedOn, setTableSelectedOn, columnCount, element.treatAsTitle, tableElement, moveOrSwapColumn]);
1458
1458
  // Delete actions
1459
1459
  const deleteActions = React.useMemo(() => {
1460
+ // 當選中 row 時,檢查是否為最後一行
1461
+ if ((tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.region) === 'row' && typeof tableSelectedOn.index === 'number') {
1462
+ // 如果只剩一行,不顯示刪除按鈕
1463
+ if (isReachMinimumBodyRows && !isHeader) {
1464
+ return [];
1465
+ }
1466
+ }
1467
+ // 當選中 column 時,檢查是否為最後一列
1468
+ if ((tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.region) === 'column' && typeof tableSelectedOn.index === 'number') {
1469
+ // 如果只剩一列(考慮 title columns),不顯示刪除按鈕
1470
+ if (columnCount <= 1) {
1471
+ return [];
1472
+ }
1473
+ }
1460
1474
  return [
1461
1475
  {
1462
1476
  icon: icons.Trash,
@@ -1473,7 +1487,7 @@ function useTableCellToolbarActions({ element, cellPosition, isHeader, transform
1473
1487
  },
1474
1488
  },
1475
1489
  ];
1476
- }, [tableSelectedOn, deleteRow, deleteColumn, setTableSelectedOn]);
1490
+ }, [tableSelectedOn, deleteRow, deleteColumn, setTableSelectedOn, isReachMinimumBodyRows, isHeader, columnCount]);
1477
1491
  // Inline toolbar icon groups - 當選中行/列時顯示的完整工具列
1478
1492
  const inlineToolbarIconGroups = React.useMemo(() => {
1479
1493
  return [