@canvas-components/list-table 0.3.31 → 0.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +58 -12
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +58 -12
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -30790,7 +30790,7 @@ var ListTableEventController = class {
|
|
|
30790
30790
|
this.host.updateTooltip(result);
|
|
30791
30791
|
return;
|
|
30792
30792
|
}
|
|
30793
|
-
if ((event.shiftKey || toggleColumn) && (result.area === "body" || result.area === "body-content") && typeof result.rowIndex === "number" && result.columnKey && !isSystemColumnKey(result.columnKey)) {
|
|
30793
|
+
if ((event.shiftKey || toggleColumn) && (result.area === "body" || result.area === "body-content") && !(event.shiftKey && !toggleColumn && this.host.options.rowSelection?.selectRowByClick && this.host.options.rowSelection.type !== "radio") && typeof result.rowIndex === "number" && result.columnKey && !isSystemColumnKey(result.columnKey)) {
|
|
30794
30794
|
const columnIndex = this.host.leafColumns.findIndex(
|
|
30795
30795
|
(column) => column.key === result.columnKey
|
|
30796
30796
|
);
|
|
@@ -30936,7 +30936,7 @@ var ListTableEventController = class {
|
|
|
30936
30936
|
if ((result.area === "body-control" || result.area === "body") && result.columnKey === ROW_SELECTION_COLUMN_KEY && typeof result.rowIndex === "number") {
|
|
30937
30937
|
const record = this.resolveBodyRecord(result.rowIndex);
|
|
30938
30938
|
if (record) {
|
|
30939
|
-
this.host.toggleRowSelection(record, result.rowIndex);
|
|
30939
|
+
this.host.toggleRowSelection(record, result.rowIndex, event.shiftKey);
|
|
30940
30940
|
}
|
|
30941
30941
|
return;
|
|
30942
30942
|
}
|
|
@@ -30957,9 +30957,13 @@ var ListTableEventController = class {
|
|
|
30957
30957
|
}
|
|
30958
30958
|
);
|
|
30959
30959
|
if (canOpenEditorByDoubleClick && event.detail === 1) {
|
|
30960
|
-
this.scheduleEditableCellRowSelection(
|
|
30960
|
+
this.scheduleEditableCellRowSelection(
|
|
30961
|
+
record,
|
|
30962
|
+
result.rowIndex,
|
|
30963
|
+
event.shiftKey
|
|
30964
|
+
);
|
|
30961
30965
|
} else if (!canOpenEditorByDoubleClick || event.detail !== 2) {
|
|
30962
|
-
this.host.toggleRowSelection(record, result.rowIndex);
|
|
30966
|
+
this.host.toggleRowSelection(record, result.rowIndex, event.shiftKey);
|
|
30963
30967
|
}
|
|
30964
30968
|
}
|
|
30965
30969
|
}
|
|
@@ -31538,11 +31542,11 @@ var ListTableEventController = class {
|
|
|
31538
31542
|
event.preventDefault();
|
|
31539
31543
|
this.host.editingController.open(rowIndex, columnKey, event.key);
|
|
31540
31544
|
}
|
|
31541
|
-
scheduleEditableCellRowSelection(record, rowIndex) {
|
|
31545
|
+
scheduleEditableCellRowSelection(record, rowIndex, shiftKey) {
|
|
31542
31546
|
this.cancelPendingEditableCellRowSelection();
|
|
31543
31547
|
this.pendingEditableCellRowSelectionTimer = globalThis.setTimeout(() => {
|
|
31544
31548
|
this.pendingEditableCellRowSelectionTimer = null;
|
|
31545
|
-
this.host.toggleRowSelection(record, rowIndex);
|
|
31549
|
+
this.host.toggleRowSelection(record, rowIndex, shiftKey);
|
|
31546
31550
|
}, EDITABLE_CELL_ROW_SELECTION_DELAY);
|
|
31547
31551
|
}
|
|
31548
31552
|
cancelPendingEditableCellRowSelection() {
|
|
@@ -33088,7 +33092,10 @@ function createListTableEventHost(core) {
|
|
|
33088
33092
|
clearBodySelection: () => core.selectionController.clearBodySelection(),
|
|
33089
33093
|
clearSelectedHeader: () => core.selectionController.clearSelectedHeader(),
|
|
33090
33094
|
selectHeader: (columnKey, rect) => core.selectionController.selectHeader(columnKey, rect),
|
|
33091
|
-
resetRangeHighlightForHeaderSelection: (shiftKey, ctrlKey) => core.selectionController.resetRangeHighlightForHeaderSelection(
|
|
33095
|
+
resetRangeHighlightForHeaderSelection: (shiftKey, ctrlKey) => core.selectionController.resetRangeHighlightForHeaderSelection(
|
|
33096
|
+
shiftKey,
|
|
33097
|
+
ctrlKey
|
|
33098
|
+
),
|
|
33092
33099
|
updateRangeHighlightForBodyInteraction: (params) => core.selectionController.updateRangeHighlightForBodyInteraction(params),
|
|
33093
33100
|
updateRangeHighlightForHeaderClick: (columnKey, shiftKey, ctrlKey) => core.selectionController.updateRangeHighlightForHeaderClick(
|
|
33094
33101
|
columnKey,
|
|
@@ -33107,7 +33114,7 @@ function createListTableEventHost(core) {
|
|
|
33107
33114
|
showCellContentPreview: (content) => core.contentActionController.showCellContentPreview(content),
|
|
33108
33115
|
showDangerConfirmRequest: (request) => core.overlayController.showDangerConfirm(request),
|
|
33109
33116
|
toggleSelectAllVisibleRows: () => core.rowActionController.toggleSelectAllVisibleRows(),
|
|
33110
|
-
toggleRowSelection: (record, rowIndex) => core.rowActionController.toggleRowSelection(record, rowIndex),
|
|
33117
|
+
toggleRowSelection: (record, rowIndex, shiftKey) => core.rowActionController.toggleRowSelection(record, rowIndex, shiftKey),
|
|
33111
33118
|
toggleRowExpand: (rowIndex) => core.rowActionController.toggleRowExpand(rowIndex),
|
|
33112
33119
|
expandCollapsedRange: (contentKey) => core.rowActionController.expandCollapsedRange(contentKey),
|
|
33113
33120
|
expandCollapsedColumnRange: (contentKey) => core.rowActionController.expandCollapsedColumnRange(contentKey),
|
|
@@ -35589,7 +35596,35 @@ function emitSelectionChange(params) {
|
|
|
35589
35596
|
|
|
35590
35597
|
// src/services/selection-action-service.ts
|
|
35591
35598
|
function resolveToggleSingleSelectionAction(params) {
|
|
35592
|
-
|
|
35599
|
+
const single = toggleSingleRowSelection(params);
|
|
35600
|
+
const { options, anchorKey, displayData } = params;
|
|
35601
|
+
if (!single || options.rowSelection?.type === "radio" || anchorKey == null || !displayData) {
|
|
35602
|
+
return single;
|
|
35603
|
+
}
|
|
35604
|
+
const targetKey = getRowKey(options, params.record, params.rowIndex);
|
|
35605
|
+
const anchorIndex = displayData.findIndex(
|
|
35606
|
+
(record, index) => getRowKey(options, record, index) === anchorKey
|
|
35607
|
+
);
|
|
35608
|
+
const targetIndex = displayData.findIndex(
|
|
35609
|
+
(record, index) => getRowKey(options, record, index) === targetKey
|
|
35610
|
+
);
|
|
35611
|
+
if (anchorIndex < 0 || targetIndex < 0 || anchorIndex === targetIndex)
|
|
35612
|
+
return single;
|
|
35613
|
+
const keys = new Set(params.selectedRowKeys);
|
|
35614
|
+
for (let index = Math.min(anchorIndex, targetIndex); index <= Math.max(anchorIndex, targetIndex); index += 1) {
|
|
35615
|
+
const record = displayData[index];
|
|
35616
|
+
if (options.rowSelection?.getCheckboxProps?.(record)?.disabled) continue;
|
|
35617
|
+
const key = getRowKey(options, record, index);
|
|
35618
|
+
if (single.selected) keys.delete(key);
|
|
35619
|
+
else keys.add(key);
|
|
35620
|
+
}
|
|
35621
|
+
const nextKeys = [...keys];
|
|
35622
|
+
return {
|
|
35623
|
+
...single,
|
|
35624
|
+
nextKeys,
|
|
35625
|
+
selectedRows: getSelectedRows(options, nextKeys),
|
|
35626
|
+
multiple: true
|
|
35627
|
+
};
|
|
35593
35628
|
}
|
|
35594
35629
|
function resolveToggleAllVisibleSelectionAction(params) {
|
|
35595
35630
|
return toggleAllVisibleRowSelection(params);
|
|
@@ -35649,6 +35684,7 @@ function fromBoundaryRightX(columnKey, positions, widths) {
|
|
|
35649
35684
|
var ListTableRowActionController = class {
|
|
35650
35685
|
constructor(options) {
|
|
35651
35686
|
__publicField(this, "options");
|
|
35687
|
+
__publicField(this, "selectionAnchorKey");
|
|
35652
35688
|
this.options = options;
|
|
35653
35689
|
}
|
|
35654
35690
|
freezeRow(rowIndex, position) {
|
|
@@ -35864,17 +35900,27 @@ var ListTableRowActionController = class {
|
|
|
35864
35900
|
this.options.requestRender();
|
|
35865
35901
|
return true;
|
|
35866
35902
|
}
|
|
35867
|
-
toggleRowSelection(record, rowIndex) {
|
|
35903
|
+
toggleRowSelection(record, rowIndex, shiftKey = false) {
|
|
35868
35904
|
const resolved = resolveToggleSingleSelectionAction({
|
|
35869
35905
|
options: this.options.getOptions(),
|
|
35870
35906
|
selectedRowKeys: this.options.getSelectedRowKeys(),
|
|
35871
35907
|
record,
|
|
35872
|
-
rowIndex
|
|
35908
|
+
rowIndex,
|
|
35909
|
+
anchorKey: shiftKey ? this.selectionAnchorKey : void 0,
|
|
35910
|
+
displayData: shiftKey ? this.options.getDisplayData() : void 0
|
|
35873
35911
|
});
|
|
35874
35912
|
if (!resolved) {
|
|
35875
35913
|
return;
|
|
35876
35914
|
}
|
|
35877
|
-
this.
|
|
35915
|
+
this.selectionAnchorKey = getRowKey(
|
|
35916
|
+
this.options.getOptions(),
|
|
35917
|
+
record,
|
|
35918
|
+
rowIndex
|
|
35919
|
+
);
|
|
35920
|
+
this.updateSelectedRowKeys(
|
|
35921
|
+
resolved.nextKeys,
|
|
35922
|
+
"multiple" in resolved ? "multiple" : "single"
|
|
35923
|
+
);
|
|
35878
35924
|
this.options.getOptions().rowSelection?.onSelect?.(
|
|
35879
35925
|
record,
|
|
35880
35926
|
!resolved.selected,
|
package/dist/index.d.cts
CHANGED
|
@@ -1987,7 +1987,7 @@ interface ListTableRowSelectionChangeInfo {
|
|
|
1987
1987
|
type: "single" | "all" | "invert" | "none" | "multiple";
|
|
1988
1988
|
}
|
|
1989
1989
|
/**
|
|
1990
|
-
* 行选择配置。
|
|
1990
|
+
* 行选择配置。checkbox 模式支持 Shift 点击,按当前显示顺序批量切换两次点击之间的行。
|
|
1991
1991
|
*/
|
|
1992
1992
|
interface ListTableRowSelectionOptions<RecordType> {
|
|
1993
1993
|
type?: "checkbox" | "radio";
|
package/dist/index.d.ts
CHANGED
|
@@ -1987,7 +1987,7 @@ interface ListTableRowSelectionChangeInfo {
|
|
|
1987
1987
|
type: "single" | "all" | "invert" | "none" | "multiple";
|
|
1988
1988
|
}
|
|
1989
1989
|
/**
|
|
1990
|
-
* 行选择配置。
|
|
1990
|
+
* 行选择配置。checkbox 模式支持 Shift 点击,按当前显示顺序批量切换两次点击之间的行。
|
|
1991
1991
|
*/
|
|
1992
1992
|
interface ListTableRowSelectionOptions<RecordType> {
|
|
1993
1993
|
type?: "checkbox" | "radio";
|
package/dist/index.js
CHANGED
|
@@ -30768,7 +30768,7 @@ var ListTableEventController = class {
|
|
|
30768
30768
|
this.host.updateTooltip(result);
|
|
30769
30769
|
return;
|
|
30770
30770
|
}
|
|
30771
|
-
if ((event.shiftKey || toggleColumn) && (result.area === "body" || result.area === "body-content") && typeof result.rowIndex === "number" && result.columnKey && !isSystemColumnKey(result.columnKey)) {
|
|
30771
|
+
if ((event.shiftKey || toggleColumn) && (result.area === "body" || result.area === "body-content") && !(event.shiftKey && !toggleColumn && this.host.options.rowSelection?.selectRowByClick && this.host.options.rowSelection.type !== "radio") && typeof result.rowIndex === "number" && result.columnKey && !isSystemColumnKey(result.columnKey)) {
|
|
30772
30772
|
const columnIndex = this.host.leafColumns.findIndex(
|
|
30773
30773
|
(column) => column.key === result.columnKey
|
|
30774
30774
|
);
|
|
@@ -30914,7 +30914,7 @@ var ListTableEventController = class {
|
|
|
30914
30914
|
if ((result.area === "body-control" || result.area === "body") && result.columnKey === ROW_SELECTION_COLUMN_KEY && typeof result.rowIndex === "number") {
|
|
30915
30915
|
const record = this.resolveBodyRecord(result.rowIndex);
|
|
30916
30916
|
if (record) {
|
|
30917
|
-
this.host.toggleRowSelection(record, result.rowIndex);
|
|
30917
|
+
this.host.toggleRowSelection(record, result.rowIndex, event.shiftKey);
|
|
30918
30918
|
}
|
|
30919
30919
|
return;
|
|
30920
30920
|
}
|
|
@@ -30935,9 +30935,13 @@ var ListTableEventController = class {
|
|
|
30935
30935
|
}
|
|
30936
30936
|
);
|
|
30937
30937
|
if (canOpenEditorByDoubleClick && event.detail === 1) {
|
|
30938
|
-
this.scheduleEditableCellRowSelection(
|
|
30938
|
+
this.scheduleEditableCellRowSelection(
|
|
30939
|
+
record,
|
|
30940
|
+
result.rowIndex,
|
|
30941
|
+
event.shiftKey
|
|
30942
|
+
);
|
|
30939
30943
|
} else if (!canOpenEditorByDoubleClick || event.detail !== 2) {
|
|
30940
|
-
this.host.toggleRowSelection(record, result.rowIndex);
|
|
30944
|
+
this.host.toggleRowSelection(record, result.rowIndex, event.shiftKey);
|
|
30941
30945
|
}
|
|
30942
30946
|
}
|
|
30943
30947
|
}
|
|
@@ -31516,11 +31520,11 @@ var ListTableEventController = class {
|
|
|
31516
31520
|
event.preventDefault();
|
|
31517
31521
|
this.host.editingController.open(rowIndex, columnKey, event.key);
|
|
31518
31522
|
}
|
|
31519
|
-
scheduleEditableCellRowSelection(record, rowIndex) {
|
|
31523
|
+
scheduleEditableCellRowSelection(record, rowIndex, shiftKey) {
|
|
31520
31524
|
this.cancelPendingEditableCellRowSelection();
|
|
31521
31525
|
this.pendingEditableCellRowSelectionTimer = globalThis.setTimeout(() => {
|
|
31522
31526
|
this.pendingEditableCellRowSelectionTimer = null;
|
|
31523
|
-
this.host.toggleRowSelection(record, rowIndex);
|
|
31527
|
+
this.host.toggleRowSelection(record, rowIndex, shiftKey);
|
|
31524
31528
|
}, EDITABLE_CELL_ROW_SELECTION_DELAY);
|
|
31525
31529
|
}
|
|
31526
31530
|
cancelPendingEditableCellRowSelection() {
|
|
@@ -33066,7 +33070,10 @@ function createListTableEventHost(core) {
|
|
|
33066
33070
|
clearBodySelection: () => core.selectionController.clearBodySelection(),
|
|
33067
33071
|
clearSelectedHeader: () => core.selectionController.clearSelectedHeader(),
|
|
33068
33072
|
selectHeader: (columnKey, rect) => core.selectionController.selectHeader(columnKey, rect),
|
|
33069
|
-
resetRangeHighlightForHeaderSelection: (shiftKey, ctrlKey) => core.selectionController.resetRangeHighlightForHeaderSelection(
|
|
33073
|
+
resetRangeHighlightForHeaderSelection: (shiftKey, ctrlKey) => core.selectionController.resetRangeHighlightForHeaderSelection(
|
|
33074
|
+
shiftKey,
|
|
33075
|
+
ctrlKey
|
|
33076
|
+
),
|
|
33070
33077
|
updateRangeHighlightForBodyInteraction: (params) => core.selectionController.updateRangeHighlightForBodyInteraction(params),
|
|
33071
33078
|
updateRangeHighlightForHeaderClick: (columnKey, shiftKey, ctrlKey) => core.selectionController.updateRangeHighlightForHeaderClick(
|
|
33072
33079
|
columnKey,
|
|
@@ -33085,7 +33092,7 @@ function createListTableEventHost(core) {
|
|
|
33085
33092
|
showCellContentPreview: (content) => core.contentActionController.showCellContentPreview(content),
|
|
33086
33093
|
showDangerConfirmRequest: (request) => core.overlayController.showDangerConfirm(request),
|
|
33087
33094
|
toggleSelectAllVisibleRows: () => core.rowActionController.toggleSelectAllVisibleRows(),
|
|
33088
|
-
toggleRowSelection: (record, rowIndex) => core.rowActionController.toggleRowSelection(record, rowIndex),
|
|
33095
|
+
toggleRowSelection: (record, rowIndex, shiftKey) => core.rowActionController.toggleRowSelection(record, rowIndex, shiftKey),
|
|
33089
33096
|
toggleRowExpand: (rowIndex) => core.rowActionController.toggleRowExpand(rowIndex),
|
|
33090
33097
|
expandCollapsedRange: (contentKey) => core.rowActionController.expandCollapsedRange(contentKey),
|
|
33091
33098
|
expandCollapsedColumnRange: (contentKey) => core.rowActionController.expandCollapsedColumnRange(contentKey),
|
|
@@ -35567,7 +35574,35 @@ function emitSelectionChange(params) {
|
|
|
35567
35574
|
|
|
35568
35575
|
// src/services/selection-action-service.ts
|
|
35569
35576
|
function resolveToggleSingleSelectionAction(params) {
|
|
35570
|
-
|
|
35577
|
+
const single = toggleSingleRowSelection(params);
|
|
35578
|
+
const { options, anchorKey, displayData } = params;
|
|
35579
|
+
if (!single || options.rowSelection?.type === "radio" || anchorKey == null || !displayData) {
|
|
35580
|
+
return single;
|
|
35581
|
+
}
|
|
35582
|
+
const targetKey = getRowKey(options, params.record, params.rowIndex);
|
|
35583
|
+
const anchorIndex = displayData.findIndex(
|
|
35584
|
+
(record, index) => getRowKey(options, record, index) === anchorKey
|
|
35585
|
+
);
|
|
35586
|
+
const targetIndex = displayData.findIndex(
|
|
35587
|
+
(record, index) => getRowKey(options, record, index) === targetKey
|
|
35588
|
+
);
|
|
35589
|
+
if (anchorIndex < 0 || targetIndex < 0 || anchorIndex === targetIndex)
|
|
35590
|
+
return single;
|
|
35591
|
+
const keys = new Set(params.selectedRowKeys);
|
|
35592
|
+
for (let index = Math.min(anchorIndex, targetIndex); index <= Math.max(anchorIndex, targetIndex); index += 1) {
|
|
35593
|
+
const record = displayData[index];
|
|
35594
|
+
if (options.rowSelection?.getCheckboxProps?.(record)?.disabled) continue;
|
|
35595
|
+
const key = getRowKey(options, record, index);
|
|
35596
|
+
if (single.selected) keys.delete(key);
|
|
35597
|
+
else keys.add(key);
|
|
35598
|
+
}
|
|
35599
|
+
const nextKeys = [...keys];
|
|
35600
|
+
return {
|
|
35601
|
+
...single,
|
|
35602
|
+
nextKeys,
|
|
35603
|
+
selectedRows: getSelectedRows(options, nextKeys),
|
|
35604
|
+
multiple: true
|
|
35605
|
+
};
|
|
35571
35606
|
}
|
|
35572
35607
|
function resolveToggleAllVisibleSelectionAction(params) {
|
|
35573
35608
|
return toggleAllVisibleRowSelection(params);
|
|
@@ -35627,6 +35662,7 @@ function fromBoundaryRightX(columnKey, positions, widths) {
|
|
|
35627
35662
|
var ListTableRowActionController = class {
|
|
35628
35663
|
constructor(options) {
|
|
35629
35664
|
__publicField(this, "options");
|
|
35665
|
+
__publicField(this, "selectionAnchorKey");
|
|
35630
35666
|
this.options = options;
|
|
35631
35667
|
}
|
|
35632
35668
|
freezeRow(rowIndex, position) {
|
|
@@ -35842,17 +35878,27 @@ var ListTableRowActionController = class {
|
|
|
35842
35878
|
this.options.requestRender();
|
|
35843
35879
|
return true;
|
|
35844
35880
|
}
|
|
35845
|
-
toggleRowSelection(record, rowIndex) {
|
|
35881
|
+
toggleRowSelection(record, rowIndex, shiftKey = false) {
|
|
35846
35882
|
const resolved = resolveToggleSingleSelectionAction({
|
|
35847
35883
|
options: this.options.getOptions(),
|
|
35848
35884
|
selectedRowKeys: this.options.getSelectedRowKeys(),
|
|
35849
35885
|
record,
|
|
35850
|
-
rowIndex
|
|
35886
|
+
rowIndex,
|
|
35887
|
+
anchorKey: shiftKey ? this.selectionAnchorKey : void 0,
|
|
35888
|
+
displayData: shiftKey ? this.options.getDisplayData() : void 0
|
|
35851
35889
|
});
|
|
35852
35890
|
if (!resolved) {
|
|
35853
35891
|
return;
|
|
35854
35892
|
}
|
|
35855
|
-
this.
|
|
35893
|
+
this.selectionAnchorKey = getRowKey(
|
|
35894
|
+
this.options.getOptions(),
|
|
35895
|
+
record,
|
|
35896
|
+
rowIndex
|
|
35897
|
+
);
|
|
35898
|
+
this.updateSelectedRowKeys(
|
|
35899
|
+
resolved.nextKeys,
|
|
35900
|
+
"multiple" in resolved ? "multiple" : "single"
|
|
35901
|
+
);
|
|
35856
35902
|
this.options.getOptions().rowSelection?.onSelect?.(
|
|
35857
35903
|
record,
|
|
35858
35904
|
!resolved.selected,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canvas-components/list-table",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"description": "Framework-agnostic list table core engine.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ant-design/icons-svg": "4.6.0",
|
|
30
30
|
"@canvas-components/barcode": "0.2.2",
|
|
31
|
-
"@canvas-components/stats": "0.1.4",
|
|
32
|
-
"@canvas-components/utils": "0.2.8",
|
|
33
31
|
"@canvas-components/chart": "0.3.7",
|
|
34
|
-
"@canvas-components/
|
|
32
|
+
"@canvas-components/stats": "0.1.4",
|
|
33
|
+
"@canvas-components/qrcode": "0.2.2",
|
|
34
|
+
"@canvas-components/utils": "0.2.8"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsup --config tsup.config.ts"
|