@ni/nimble-components 18.13.4 → 18.13.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/dist/all-components-bundle.js +316 -79
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +814 -778
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/table/components/group-row/index.js +6 -2
- package/dist/esm/table/components/group-row/index.js.map +1 -1
- package/dist/esm/table/components/group-row/styles.js +18 -1
- package/dist/esm/table/components/group-row/styles.js.map +1 -1
- package/dist/esm/table/components/row/index.js +4 -2
- package/dist/esm/table/components/row/index.js.map +1 -1
- package/dist/esm/table/components/row/template.js +0 -1
- package/dist/esm/table/components/row/template.js.map +1 -1
- package/dist/esm/table/index.d.ts +4 -16
- package/dist/esm/table/index.js +26 -70
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/table/models/interactive-selection-manager.d.ts +17 -0
- package/dist/esm/table/models/interactive-selection-manager.js +51 -0
- package/dist/esm/table/models/interactive-selection-manager.js.map +1 -0
- package/dist/esm/table/models/selection-managers/disabled-selection-manager.d.ts +11 -0
- package/dist/esm/table/models/selection-managers/disabled-selection-manager.js +17 -0
- package/dist/esm/table/models/selection-managers/disabled-selection-manager.js.map +1 -0
- package/dist/esm/table/models/selection-managers/multi-selection-manager.d.ts +20 -0
- package/dist/esm/table/models/selection-managers/multi-selection-manager.js +104 -0
- package/dist/esm/table/models/selection-managers/multi-selection-manager.js.map +1 -0
- package/dist/esm/table/models/selection-managers/selection-manager-base.d.ts +19 -0
- package/dist/esm/table/models/selection-managers/selection-manager-base.js +78 -0
- package/dist/esm/table/models/selection-managers/selection-manager-base.js.map +1 -0
- package/dist/esm/table/models/selection-managers/single-selection-manager.d.ts +11 -0
- package/dist/esm/table/models/selection-managers/single-selection-manager.js +18 -0
- package/dist/esm/table/models/selection-managers/single-selection-manager.js.map +1 -0
- package/dist/esm/table/styles.js +2 -1
- package/dist/esm/table/styles.js.map +1 -1
- package/dist/esm/table/template.js +1 -1
- package/dist/esm/table/template.js.map +1 -1
- package/dist/esm/table/testing/table.pageobject.d.ts +6 -3
- package/dist/esm/table/testing/table.pageobject.js +30 -4
- package/dist/esm/table/testing/table.pageobject.js.map +1 -1
- package/dist/esm/table/types.d.ts +17 -0
- package/dist/esm/table/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -16366,7 +16366,7 @@
|
|
|
16366
16366
|
|
|
16367
16367
|
/**
|
|
16368
16368
|
* Do not edit directly
|
|
16369
|
-
* Generated on
|
|
16369
|
+
* Generated on Thu, 11 May 2023 18:29:12 GMT
|
|
16370
16370
|
*/
|
|
16371
16371
|
const Information100DarkUi = "#a46eff";
|
|
16372
16372
|
const Information100LightUi = "#804ad9";
|
|
@@ -28279,7 +28279,8 @@
|
|
|
28279
28279
|
}
|
|
28280
28280
|
|
|
28281
28281
|
.table-row-container {
|
|
28282
|
-
width:
|
|
28282
|
+
width: fit-content;
|
|
28283
|
+
min-width: 100%;
|
|
28283
28284
|
position: relative;
|
|
28284
28285
|
top: var(--ni-private-table-row-container-top);
|
|
28285
28286
|
background-color: ${tableRowBorderColor};
|
|
@@ -28639,7 +28640,6 @@
|
|
|
28639
28640
|
<span role="gridcell" class="checkbox-container">
|
|
28640
28641
|
<${checkboxTag}
|
|
28641
28642
|
${ref('selectionCheckbox')}
|
|
28642
|
-
role="cell"
|
|
28643
28643
|
class="selection-checkbox"
|
|
28644
28644
|
@change="${(x, c) => x.onSelectionChange(c.event)}"
|
|
28645
28645
|
@click="${(_, c) => c.event.stopPropagation()}"
|
|
@@ -28735,9 +28735,11 @@
|
|
|
28735
28735
|
return;
|
|
28736
28736
|
}
|
|
28737
28737
|
const checkbox = event.target;
|
|
28738
|
+
const checked = checkbox.checked;
|
|
28739
|
+
this.selected = checked;
|
|
28738
28740
|
const detail = {
|
|
28739
|
-
oldState: !
|
|
28740
|
-
newState:
|
|
28741
|
+
oldState: !checked,
|
|
28742
|
+
newState: checked
|
|
28741
28743
|
};
|
|
28742
28744
|
this.$emit('row-selection-toggle', detail);
|
|
28743
28745
|
}
|
|
@@ -28828,13 +28830,29 @@
|
|
|
28828
28830
|
const tableRowTag = DesignSystem.tagFor(TableRow);
|
|
28829
28831
|
|
|
28830
28832
|
const styles$d = css `
|
|
28831
|
-
${display('
|
|
28833
|
+
${display('grid')}
|
|
28832
28834
|
|
|
28833
28835
|
:host {
|
|
28834
28836
|
align-items: center;
|
|
28835
28837
|
height: calc(${controlHeight} + 2 * ${borderWidth});
|
|
28836
28838
|
border-top: calc(2 * ${borderWidth}) solid ${applicationBackgroundColor};
|
|
28837
28839
|
box-sizing: border-box;
|
|
28840
|
+
grid-template-columns:
|
|
28841
|
+
calc(
|
|
28842
|
+
${controlHeight} *
|
|
28843
|
+
(var(--ni-private-table-group-row-indent-level) + 1)
|
|
28844
|
+
)
|
|
28845
|
+
1fr;
|
|
28846
|
+
}
|
|
28847
|
+
|
|
28848
|
+
:host([selectable]) {
|
|
28849
|
+
grid-template-columns:
|
|
28850
|
+
${controlHeight}
|
|
28851
|
+
calc(
|
|
28852
|
+
${controlHeight} *
|
|
28853
|
+
(var(--ni-private-table-group-row-indent-level) + 1)
|
|
28854
|
+
)
|
|
28855
|
+
1fr;
|
|
28838
28856
|
}
|
|
28839
28857
|
|
|
28840
28858
|
:host([expanded]) .animating,
|
|
@@ -28885,6 +28903,7 @@
|
|
|
28885
28903
|
|
|
28886
28904
|
.group-row-child-count {
|
|
28887
28905
|
padding-left: 2px;
|
|
28906
|
+
padding-right: calc(${standardPadding} / 2);
|
|
28888
28907
|
pointer-events: none;
|
|
28889
28908
|
${userSelectNone}
|
|
28890
28909
|
}
|
|
@@ -28997,9 +29016,13 @@
|
|
|
28997
29016
|
return;
|
|
28998
29017
|
}
|
|
28999
29018
|
const checkbox = event.target;
|
|
29019
|
+
const checked = checkbox.checked;
|
|
29020
|
+
this.selectionState = checked
|
|
29021
|
+
? TableRowSelectionState.selected
|
|
29022
|
+
: TableRowSelectionState.notSelected;
|
|
29000
29023
|
const detail = {
|
|
29001
|
-
oldState: !
|
|
29002
|
-
newState:
|
|
29024
|
+
oldState: !checked,
|
|
29025
|
+
newState: checked
|
|
29003
29026
|
};
|
|
29004
29027
|
this.$emit('group-selection-toggle', detail);
|
|
29005
29028
|
}
|
|
@@ -29140,7 +29163,7 @@
|
|
|
29140
29163
|
:dataRecord="${(x, c) => c.parent.tableData[x.index]?.record}"
|
|
29141
29164
|
:columns="${(_, c) => c.parent.columns}"
|
|
29142
29165
|
:nestingLevel="${(x, c) => c.parent.tableData[x.index]?.nestingLevel}"
|
|
29143
|
-
@click="${(x, c) => c.parent.onRowClick(x.index)}"
|
|
29166
|
+
@click="${(x, c) => c.parent.onRowClick(x.index, c.event)}"
|
|
29144
29167
|
@row-selection-toggle="${(x, c) => c.parent.onRowSelectionToggle(x.index, c.event)}"
|
|
29145
29168
|
@row-action-menu-beforetoggle="${(x, c) => c.parent.onRowActionMenuBeforeToggle(x.index, c.event)}"
|
|
29146
29169
|
@row-action-menu-toggle="${(_, c) => c.parent.onRowActionMenuToggle(c.event)}"
|
|
@@ -30091,6 +30114,265 @@
|
|
|
30091
30114
|
}
|
|
30092
30115
|
}
|
|
30093
30116
|
|
|
30117
|
+
/**
|
|
30118
|
+
* Abstract base class for handling behavior associated with interactive row selection of the table.
|
|
30119
|
+
*/
|
|
30120
|
+
class SelectionManagerBase {
|
|
30121
|
+
constructor(tanStackTable) {
|
|
30122
|
+
this.tanStackTable = tanStackTable;
|
|
30123
|
+
}
|
|
30124
|
+
reset() { }
|
|
30125
|
+
toggleIsRowSelected(rowState, isSelecting) {
|
|
30126
|
+
if (rowState.isGrouped
|
|
30127
|
+
&& rowState.selectionState === TableRowSelectionState.selected) {
|
|
30128
|
+
// Work around for https://github.com/TanStack/table/issues/4759
|
|
30129
|
+
// Manually deselect all leaf rows when a fully selected group is being deselected.
|
|
30130
|
+
this.deselectAllLeafRows(rowState.id);
|
|
30131
|
+
}
|
|
30132
|
+
else {
|
|
30133
|
+
this.tanStackTable.getRow(rowState.id).toggleSelected(isSelecting);
|
|
30134
|
+
}
|
|
30135
|
+
}
|
|
30136
|
+
selectSingleRow(rowState) {
|
|
30137
|
+
if (rowState.isGrouped) {
|
|
30138
|
+
throw new Error('function not intended to select grouped rows');
|
|
30139
|
+
}
|
|
30140
|
+
const currentSelection = this.tanStackTable.getState().rowSelection;
|
|
30141
|
+
const selectedRecordIds = [];
|
|
30142
|
+
Object.entries(currentSelection).forEach(([recordId, isSelected]) => {
|
|
30143
|
+
if (isSelected) {
|
|
30144
|
+
selectedRecordIds.push(recordId);
|
|
30145
|
+
}
|
|
30146
|
+
});
|
|
30147
|
+
if (selectedRecordIds.length === 1
|
|
30148
|
+
&& selectedRecordIds[0] === rowState.id) {
|
|
30149
|
+
// The clicked row is already the only selected row. Do nothing.
|
|
30150
|
+
return false;
|
|
30151
|
+
}
|
|
30152
|
+
const newSelectionState = {};
|
|
30153
|
+
newSelectionState[rowState.id] = true;
|
|
30154
|
+
this.tanStackTable.setRowSelection(newSelectionState);
|
|
30155
|
+
return true;
|
|
30156
|
+
}
|
|
30157
|
+
deselectAllLeafRows(rowId) {
|
|
30158
|
+
const groupRow = this.tanStackTable.getRow(rowId);
|
|
30159
|
+
const leafRowIds = this.getAllLeafRowIds(groupRow.id);
|
|
30160
|
+
const selectionState = this.tanStackTable.getState().rowSelection;
|
|
30161
|
+
for (const id of leafRowIds) {
|
|
30162
|
+
delete selectionState[id];
|
|
30163
|
+
}
|
|
30164
|
+
this.tanStackTable.setRowSelection(selectionState);
|
|
30165
|
+
}
|
|
30166
|
+
getAllLeafRowIds(id) {
|
|
30167
|
+
const row = this.tanStackTable
|
|
30168
|
+
.getRowModel()
|
|
30169
|
+
.flatRows.find(x => x.id === id);
|
|
30170
|
+
if (!row?.getIsGrouped()) {
|
|
30171
|
+
return [];
|
|
30172
|
+
}
|
|
30173
|
+
return row
|
|
30174
|
+
.getLeafRows()
|
|
30175
|
+
.filter(leafRow => leafRow.getLeafRows().length === 0)
|
|
30176
|
+
.map(leafRow => leafRow.id);
|
|
30177
|
+
}
|
|
30178
|
+
getAllOrderedRows() {
|
|
30179
|
+
const topLevelRows = this.tanStackTable.getPreExpandedRowModel().rows;
|
|
30180
|
+
return this.getOrderedRows(topLevelRows);
|
|
30181
|
+
}
|
|
30182
|
+
getOrderedRows(topLevelRows) {
|
|
30183
|
+
const allRows = [];
|
|
30184
|
+
for (const row of topLevelRows) {
|
|
30185
|
+
allRows.push(row);
|
|
30186
|
+
if (row.subRows?.length) {
|
|
30187
|
+
allRows.push(...this.getOrderedRows(row.subRows));
|
|
30188
|
+
}
|
|
30189
|
+
}
|
|
30190
|
+
return allRows;
|
|
30191
|
+
}
|
|
30192
|
+
}
|
|
30193
|
+
|
|
30194
|
+
/**
|
|
30195
|
+
* Selection manager for interactive selection when the selection mode of the table is
|
|
30196
|
+
* `TableRowSelectionMode.none`.
|
|
30197
|
+
*/
|
|
30198
|
+
class DisabledSelectionManager extends SelectionManagerBase {
|
|
30199
|
+
handleRowSelectionToggle(_rowState, _isSelecting, _shiftKey) {
|
|
30200
|
+
return false;
|
|
30201
|
+
}
|
|
30202
|
+
handleRowClick(_rowState, _shiftKey, _ctrlKey) {
|
|
30203
|
+
return false;
|
|
30204
|
+
}
|
|
30205
|
+
handleActionMenuOpening(_rowState) {
|
|
30206
|
+
return false;
|
|
30207
|
+
}
|
|
30208
|
+
}
|
|
30209
|
+
|
|
30210
|
+
/**
|
|
30211
|
+
* Selection manager for interactive selection when the selection mode of the table is
|
|
30212
|
+
* `TableRowSelectionMode.multiple`.
|
|
30213
|
+
*/
|
|
30214
|
+
class MultiSelectionManager extends SelectionManagerBase {
|
|
30215
|
+
handleRowSelectionToggle(rowState, isSelecting, shiftKey) {
|
|
30216
|
+
if (shiftKey) {
|
|
30217
|
+
if (this.tryUpdateRangeSelection(rowState.id)) {
|
|
30218
|
+
// Made a range selection
|
|
30219
|
+
return true;
|
|
30220
|
+
}
|
|
30221
|
+
}
|
|
30222
|
+
this.shiftSelectStartRowId = rowState.id;
|
|
30223
|
+
this.previousShiftSelectRowEndId = undefined;
|
|
30224
|
+
this.toggleIsRowSelected(rowState, isSelecting);
|
|
30225
|
+
return true;
|
|
30226
|
+
}
|
|
30227
|
+
handleRowClick(rowState, shiftKey, ctrlKey) {
|
|
30228
|
+
if (ctrlKey) {
|
|
30229
|
+
this.shiftSelectStartRowId = rowState.id;
|
|
30230
|
+
this.previousShiftSelectRowEndId = undefined;
|
|
30231
|
+
this.toggleIsRowSelected(rowState);
|
|
30232
|
+
return true;
|
|
30233
|
+
}
|
|
30234
|
+
if (shiftKey) {
|
|
30235
|
+
if (this.tryUpdateRangeSelection(rowState.id)) {
|
|
30236
|
+
// Made a range selection
|
|
30237
|
+
return true;
|
|
30238
|
+
}
|
|
30239
|
+
}
|
|
30240
|
+
this.shiftSelectStartRowId = rowState.id;
|
|
30241
|
+
this.previousShiftSelectRowEndId = undefined;
|
|
30242
|
+
return this.selectSingleRow(rowState);
|
|
30243
|
+
}
|
|
30244
|
+
handleActionMenuOpening(rowState) {
|
|
30245
|
+
if (rowState.selectionState === TableRowSelectionState.selected) {
|
|
30246
|
+
return false;
|
|
30247
|
+
}
|
|
30248
|
+
return this.selectSingleRow(rowState);
|
|
30249
|
+
}
|
|
30250
|
+
reset() {
|
|
30251
|
+
this.shiftSelectStartRowId = undefined;
|
|
30252
|
+
this.previousShiftSelectRowEndId = undefined;
|
|
30253
|
+
}
|
|
30254
|
+
tryUpdateRangeSelection(rowId) {
|
|
30255
|
+
if (this.shiftSelectStartRowId === undefined) {
|
|
30256
|
+
return false;
|
|
30257
|
+
}
|
|
30258
|
+
const allRows = this.getAllOrderedRows();
|
|
30259
|
+
const selectionStartIndex = this.getRowIndexForId(this.shiftSelectStartRowId, allRows);
|
|
30260
|
+
if (selectionStartIndex === -1) {
|
|
30261
|
+
return false;
|
|
30262
|
+
}
|
|
30263
|
+
const selectionState = this.tanStackTable.getState().rowSelection;
|
|
30264
|
+
this.removePreviousRangeSelection(selectionState, selectionStartIndex, allRows);
|
|
30265
|
+
this.addNewRangeSelection(selectionState, rowId, selectionStartIndex, allRows);
|
|
30266
|
+
this.previousShiftSelectRowEndId = rowId;
|
|
30267
|
+
this.tanStackTable.setRowSelection(selectionState);
|
|
30268
|
+
return true;
|
|
30269
|
+
}
|
|
30270
|
+
removePreviousRangeSelection(selection, shiftSelectStartRowIndex, allRows) {
|
|
30271
|
+
const previousRangeEndIndex = this.getRowIndexForId(this.previousShiftSelectRowEndId, allRows);
|
|
30272
|
+
this.updateSelectionStateForRange(selection, shiftSelectStartRowIndex, previousRangeEndIndex, allRows, false);
|
|
30273
|
+
}
|
|
30274
|
+
addNewRangeSelection(selection, endRangeRowId, shiftSelectStartRowIndex, allRows) {
|
|
30275
|
+
const newRangeEndIndex = this.getRowIndexForId(endRangeRowId, allRows);
|
|
30276
|
+
this.updateSelectionStateForRange(selection, shiftSelectStartRowIndex, newRangeEndIndex, allRows, true);
|
|
30277
|
+
}
|
|
30278
|
+
updateSelectionStateForRange(selection, rangeStartIndex, rangeEndIndex, allRows, isSelecting) {
|
|
30279
|
+
if (rangeStartIndex === -1 || rangeEndIndex === -1) {
|
|
30280
|
+
return;
|
|
30281
|
+
}
|
|
30282
|
+
const firstRowIndex = Math.min(rangeStartIndex, rangeEndIndex);
|
|
30283
|
+
const lastRowIndex = Math.max(rangeStartIndex, rangeEndIndex);
|
|
30284
|
+
for (let i = firstRowIndex; i <= lastRowIndex; i++) {
|
|
30285
|
+
const row = allRows[i];
|
|
30286
|
+
if (row.getIsGrouped()) {
|
|
30287
|
+
continue;
|
|
30288
|
+
}
|
|
30289
|
+
this.updateSelectionStateForRow(selection, row.id, isSelecting);
|
|
30290
|
+
}
|
|
30291
|
+
const endRangeRow = allRows[rangeEndIndex];
|
|
30292
|
+
if (endRangeRow.getIsGrouped()) {
|
|
30293
|
+
this.getAllLeafRowIds(endRangeRow.id).forEach(id => this.updateSelectionStateForRow(selection, id, isSelecting));
|
|
30294
|
+
}
|
|
30295
|
+
}
|
|
30296
|
+
updateSelectionStateForRow(selection, rowId, isSelecting) {
|
|
30297
|
+
if (isSelecting) {
|
|
30298
|
+
selection[rowId] = true;
|
|
30299
|
+
}
|
|
30300
|
+
else {
|
|
30301
|
+
delete selection[rowId];
|
|
30302
|
+
}
|
|
30303
|
+
}
|
|
30304
|
+
getRowIndexForId(id, rows) {
|
|
30305
|
+
if (!id) {
|
|
30306
|
+
return -1;
|
|
30307
|
+
}
|
|
30308
|
+
return rows.findIndex(x => x.id === id);
|
|
30309
|
+
}
|
|
30310
|
+
}
|
|
30311
|
+
|
|
30312
|
+
/**
|
|
30313
|
+
* Selection manager for interactive selection when the selection mode of the table is
|
|
30314
|
+
* `TableRowSelectionMode.single`.
|
|
30315
|
+
*/
|
|
30316
|
+
class SingleSelectionManager extends SelectionManagerBase {
|
|
30317
|
+
handleRowSelectionToggle(rowState, isSelecting, _shiftKey) {
|
|
30318
|
+
this.toggleIsRowSelected(rowState, isSelecting);
|
|
30319
|
+
return true;
|
|
30320
|
+
}
|
|
30321
|
+
handleRowClick(rowState, _shiftKey, _ctrlKey) {
|
|
30322
|
+
return this.selectSingleRow(rowState);
|
|
30323
|
+
}
|
|
30324
|
+
handleActionMenuOpening(rowState) {
|
|
30325
|
+
return this.handleRowClick(rowState, false, false);
|
|
30326
|
+
}
|
|
30327
|
+
}
|
|
30328
|
+
|
|
30329
|
+
/**
|
|
30330
|
+
* Manages the behavior associated with interactive row selection for the table, including
|
|
30331
|
+
* handling when the selection mode of the table is changed.
|
|
30332
|
+
*/
|
|
30333
|
+
class InteractiveSelectionManager {
|
|
30334
|
+
constructor(tanStackTable, selectionMode) {
|
|
30335
|
+
this.tanStackTable = tanStackTable;
|
|
30336
|
+
this.selectionManager = this.createSelectionManager(selectionMode);
|
|
30337
|
+
}
|
|
30338
|
+
handleRowSelectionToggle(rowState, isSelecting, shiftKey) {
|
|
30339
|
+
if (!rowState) {
|
|
30340
|
+
return false;
|
|
30341
|
+
}
|
|
30342
|
+
return this.selectionManager.handleRowSelectionToggle(rowState, isSelecting, shiftKey);
|
|
30343
|
+
}
|
|
30344
|
+
handleRowClick(rowState, shiftKey, ctrlKey) {
|
|
30345
|
+
if (!rowState) {
|
|
30346
|
+
return false;
|
|
30347
|
+
}
|
|
30348
|
+
return this.selectionManager.handleRowClick(rowState, shiftKey, ctrlKey);
|
|
30349
|
+
}
|
|
30350
|
+
handleActionMenuOpening(rowState) {
|
|
30351
|
+
if (!rowState) {
|
|
30352
|
+
return false;
|
|
30353
|
+
}
|
|
30354
|
+
return this.selectionManager.handleActionMenuOpening(rowState);
|
|
30355
|
+
}
|
|
30356
|
+
handleSelectionModeChanged(selectionMode) {
|
|
30357
|
+
this.selectionManager = this.createSelectionManager(selectionMode);
|
|
30358
|
+
}
|
|
30359
|
+
handleSelectionReset() {
|
|
30360
|
+
this.selectionManager.reset();
|
|
30361
|
+
}
|
|
30362
|
+
createSelectionManager(selectionMode) {
|
|
30363
|
+
switch (selectionMode) {
|
|
30364
|
+
case TableRowSelectionMode.multiple:
|
|
30365
|
+
return new MultiSelectionManager(this.tanStackTable);
|
|
30366
|
+
case TableRowSelectionMode.single:
|
|
30367
|
+
return new SingleSelectionManager(this.tanStackTable);
|
|
30368
|
+
case TableRowSelectionMode.none:
|
|
30369
|
+
return new DisabledSelectionManager(this.tanStackTable);
|
|
30370
|
+
default:
|
|
30371
|
+
throw new Error('unknown selection mode found');
|
|
30372
|
+
}
|
|
30373
|
+
}
|
|
30374
|
+
}
|
|
30375
|
+
|
|
30094
30376
|
/**
|
|
30095
30377
|
* A nimble-styled table.
|
|
30096
30378
|
*/
|
|
@@ -30220,6 +30502,7 @@
|
|
|
30220
30502
|
};
|
|
30221
30503
|
this.table = createTable(this.options);
|
|
30222
30504
|
this.virtualizer = new Virtualizer(this, this.table);
|
|
30505
|
+
this.selectionManager = new InteractiveSelectionManager(this.table, this.selectionMode);
|
|
30223
30506
|
}
|
|
30224
30507
|
get validity() {
|
|
30225
30508
|
return this.tableValidator.getValidity();
|
|
@@ -30305,26 +30588,17 @@
|
|
|
30305
30588
|
/** @internal */
|
|
30306
30589
|
onRowSelectionToggle(rowIndex, event) {
|
|
30307
30590
|
event.stopImmediatePropagation();
|
|
30308
|
-
|
|
30309
|
-
|
|
30591
|
+
const selectionChanged = this.selectionManager.handleRowSelectionToggle(this.tableData[rowIndex], event.detail.newState, this.documentShiftKeyDown);
|
|
30592
|
+
if (selectionChanged) {
|
|
30593
|
+
void this.emitSelectionChangeEvent();
|
|
30310
30594
|
}
|
|
30311
|
-
const rowState = this.tableData[rowIndex];
|
|
30312
|
-
if (rowState?.isGrouped
|
|
30313
|
-
&& rowState?.selectionState === TableRowSelectionState.selected) {
|
|
30314
|
-
// Work around for https://github.com/TanStack/table/issues/4759
|
|
30315
|
-
// Manually deselect all leaf rows when a fully selected group is being deselected.
|
|
30316
|
-
this.deselectAllLeafRows(rowIndex);
|
|
30317
|
-
}
|
|
30318
|
-
else {
|
|
30319
|
-
this.table
|
|
30320
|
-
.getRowModel()
|
|
30321
|
-
.rows[rowIndex]?.toggleSelected(event.detail.newState);
|
|
30322
|
-
}
|
|
30323
|
-
void this.emitSelectionChangeEvent();
|
|
30324
30595
|
}
|
|
30325
30596
|
/** @internal */
|
|
30326
|
-
onRowClick(rowIndex) {
|
|
30327
|
-
|
|
30597
|
+
onRowClick(rowIndex, event) {
|
|
30598
|
+
const selectionChanged = this.selectionManager.handleRowClick(this.tableData[rowIndex], event.shiftKey, event.ctrlKey || event.metaKey);
|
|
30599
|
+
if (selectionChanged) {
|
|
30600
|
+
void this.emitSelectionChangeEvent();
|
|
30601
|
+
}
|
|
30328
30602
|
return true;
|
|
30329
30603
|
}
|
|
30330
30604
|
/** @internal */
|
|
@@ -30449,36 +30723,30 @@
|
|
|
30449
30723
|
this.updateTracker.trackColumnInstancesChanged();
|
|
30450
30724
|
}
|
|
30451
30725
|
async handleActionMenuBeforeToggleEvent(rowIndex, event) {
|
|
30452
|
-
|
|
30453
|
-
if (
|
|
30454
|
-
|
|
30455
|
-
if (row && !row.getIsSelected()) {
|
|
30456
|
-
await this.selectSingleRow(rowIndex);
|
|
30457
|
-
}
|
|
30458
|
-
else {
|
|
30459
|
-
recordIds = await this.getSelectedRecordIds();
|
|
30460
|
-
}
|
|
30726
|
+
const selectionChanged = this.selectionManager.handleActionMenuOpening(this.tableData[rowIndex]);
|
|
30727
|
+
if (selectionChanged) {
|
|
30728
|
+
await this.emitSelectionChangeEvent();
|
|
30461
30729
|
}
|
|
30462
30730
|
this.openActionMenuRecordId = event.detail.recordIds[0];
|
|
30463
|
-
const detail =
|
|
30464
|
-
...event.detail,
|
|
30465
|
-
recordIds
|
|
30466
|
-
};
|
|
30731
|
+
const detail = await this.getActionMenuToggleEventDetail(event);
|
|
30467
30732
|
this.$emit('action-menu-beforetoggle', detail);
|
|
30468
30733
|
}
|
|
30469
30734
|
async handleRowActionMenuToggleEvent(event) {
|
|
30470
|
-
const
|
|
30471
|
-
? await this.getSelectedRecordIds()
|
|
30472
|
-
: event.detail.recordIds;
|
|
30473
|
-
const detail = {
|
|
30474
|
-
...event.detail,
|
|
30475
|
-
recordIds
|
|
30476
|
-
};
|
|
30735
|
+
const detail = await this.getActionMenuToggleEventDetail(event);
|
|
30477
30736
|
this.$emit('action-menu-toggle', detail);
|
|
30478
30737
|
if (!event.detail.newState) {
|
|
30479
30738
|
this.openActionMenuRecordId = undefined;
|
|
30480
30739
|
}
|
|
30481
30740
|
}
|
|
30741
|
+
async getActionMenuToggleEventDetail(originalEvent) {
|
|
30742
|
+
const recordIds = this.selectionMode === TableRowSelectionMode.multiple
|
|
30743
|
+
? await this.getSelectedRecordIds()
|
|
30744
|
+
: [this.openActionMenuRecordId];
|
|
30745
|
+
return {
|
|
30746
|
+
...originalEvent.detail,
|
|
30747
|
+
recordIds
|
|
30748
|
+
};
|
|
30749
|
+
}
|
|
30482
30750
|
removeColumnObservers() {
|
|
30483
30751
|
this.columnNotifiers.forEach(notifier => {
|
|
30484
30752
|
notifier.unsubscribe(this);
|
|
@@ -30546,11 +30814,13 @@
|
|
|
30546
30814
|
if (this.updateTracker.updateRowIds) {
|
|
30547
30815
|
updatedOptions.getRowId = this.calculateTanStackRowIdFunction();
|
|
30548
30816
|
updatedOptions.state.rowSelection = {};
|
|
30817
|
+
this.selectionManager.handleSelectionReset();
|
|
30549
30818
|
}
|
|
30550
30819
|
if (this.updateTracker.updateSelectionMode) {
|
|
30551
30820
|
updatedOptions.enableMultiRowSelection = this.selectionMode === TableRowSelectionMode.multiple;
|
|
30552
30821
|
updatedOptions.enableSubRowSelection = this.selectionMode === TableRowSelectionMode.multiple;
|
|
30553
30822
|
updatedOptions.state.rowSelection = {};
|
|
30823
|
+
this.selectionManager.handleSelectionModeChanged(this.selectionMode);
|
|
30554
30824
|
}
|
|
30555
30825
|
if (this.updateTracker.requiresTanStackDataReset) {
|
|
30556
30826
|
// Perform a shallow copy of the data to trigger tanstack to regenerate the row models and columns.
|
|
@@ -30696,39 +30966,6 @@
|
|
|
30696
30966
|
this.table.setOptions(this.options);
|
|
30697
30967
|
this.refreshRows();
|
|
30698
30968
|
}
|
|
30699
|
-
async selectSingleRow(rowIndex) {
|
|
30700
|
-
if (this.selectionMode === TableRowSelectionMode.none) {
|
|
30701
|
-
return;
|
|
30702
|
-
}
|
|
30703
|
-
const row = this.table.getRowModel().rows[rowIndex];
|
|
30704
|
-
if (!row) {
|
|
30705
|
-
return;
|
|
30706
|
-
}
|
|
30707
|
-
const currentSelection = await this.getSelectedRecordIds();
|
|
30708
|
-
if (currentSelection.length === 1 && currentSelection[0] === row.id) {
|
|
30709
|
-
// The clicked row is already the only selected row. Do nothing.
|
|
30710
|
-
return;
|
|
30711
|
-
}
|
|
30712
|
-
this.table.toggleAllRowsSelected(false);
|
|
30713
|
-
row.toggleSelected(true);
|
|
30714
|
-
await this.emitSelectionChangeEvent();
|
|
30715
|
-
}
|
|
30716
|
-
deselectAllLeafRows(rowIndex) {
|
|
30717
|
-
const groupRow = this.table.getRowModel().rows[rowIndex];
|
|
30718
|
-
const leafRowIds = groupRow
|
|
30719
|
-
.getLeafRows()
|
|
30720
|
-
.filter(leafRow => leafRow.getLeafRows().length === 0)
|
|
30721
|
-
.map(leafRow => leafRow.id);
|
|
30722
|
-
const selectionState = this.table.getState().rowSelection;
|
|
30723
|
-
for (const id of leafRowIds) {
|
|
30724
|
-
delete selectionState[id];
|
|
30725
|
-
}
|
|
30726
|
-
this.updateTableOptions({
|
|
30727
|
-
state: {
|
|
30728
|
-
rowSelection: selectionState
|
|
30729
|
-
}
|
|
30730
|
-
});
|
|
30731
|
-
}
|
|
30732
30969
|
toggleGroupExpanded(rowIndex) {
|
|
30733
30970
|
const row = this.table.getRowModel().rows[rowIndex];
|
|
30734
30971
|
const wasExpanded = row.getIsExpanded();
|