@visactor/vtable 1.13.1-alpha.5 → 1.13.1-alpha.7
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/cjs/ListTable.d.ts +1 -1
- package/cjs/ListTable.js +5 -5
- package/cjs/ListTable.js.map +1 -1
- package/cjs/core/BaseTable.js +1 -1
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/state/checkbox/checkbox.js +82 -51
- package/cjs/state/checkbox/checkbox.js.map +1 -1
- package/cjs/state/state.d.ts +1 -1
- package/cjs/state/state.js +4 -4
- package/cjs/state/state.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +134 -88
- package/dist/vtable.min.js +1 -1
- package/es/ListTable.d.ts +1 -1
- package/es/ListTable.js +5 -5
- package/es/ListTable.js.map +1 -1
- package/es/core/BaseTable.js +1 -1
- package/es/core/BaseTable.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/state/checkbox/checkbox.js +82 -52
- package/es/state/checkbox/checkbox.js.map +1 -1
- package/es/state/state.d.ts +1 -1
- package/es/state/state.js +4 -4
- package/es/state/state.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +4 -4
package/dist/vtable.js
CHANGED
|
@@ -50094,13 +50094,14 @@
|
|
|
50094
50094
|
function setCheckedState(col, row, field, checked, state) {
|
|
50095
50095
|
const recordIndex = state.table.getRecordShowIndexByCell(col, row);
|
|
50096
50096
|
if (recordIndex >= 0) {
|
|
50097
|
-
const dataIndex = state.table.dataSource.getIndexKey(recordIndex);
|
|
50098
|
-
if (state.checkedState
|
|
50099
|
-
state.checkedState
|
|
50097
|
+
const dataIndex = state.table.dataSource.getIndexKey(recordIndex).toString();
|
|
50098
|
+
if (state.checkedState.has(dataIndex)) {
|
|
50099
|
+
state.checkedState.get(dataIndex)[field] = checked;
|
|
50100
50100
|
}
|
|
50101
50101
|
else {
|
|
50102
|
-
state.checkedState
|
|
50103
|
-
|
|
50102
|
+
state.checkedState.set(dataIndex, {
|
|
50103
|
+
[field]: checked
|
|
50104
|
+
});
|
|
50104
50105
|
}
|
|
50105
50106
|
}
|
|
50106
50107
|
}
|
|
@@ -50121,7 +50122,7 @@
|
|
|
50121
50122
|
else if (isValid$1(checked)) {
|
|
50122
50123
|
state.headerCheckedState[field] = checked;
|
|
50123
50124
|
}
|
|
50124
|
-
else if (state.checkedState?.
|
|
50125
|
+
else if (state.checkedState?.size > 0) {
|
|
50125
50126
|
const isAllChecked = state.updateHeaderCheckedState(field, col, row);
|
|
50126
50127
|
return isAllChecked;
|
|
50127
50128
|
}
|
|
@@ -50129,22 +50130,23 @@
|
|
|
50129
50130
|
}
|
|
50130
50131
|
const recordIndex = state.table.getRecordShowIndexByCell(col, row);
|
|
50131
50132
|
if (recordIndex >= 0) {
|
|
50132
|
-
const dataIndex = state.table.dataSource.getIndexKey(recordIndex);
|
|
50133
|
-
if (isValid$1(state.checkedState
|
|
50134
|
-
return state.checkedState
|
|
50133
|
+
const dataIndex = state.table.dataSource.getIndexKey(recordIndex).toString();
|
|
50134
|
+
if (isValid$1(state.checkedState.get(dataIndex)?.[field])) {
|
|
50135
|
+
return state.checkedState.get(dataIndex)[field];
|
|
50135
50136
|
}
|
|
50136
|
-
if (state.checkedState
|
|
50137
|
-
state.checkedState
|
|
50137
|
+
if (state.checkedState.has(dataIndex)) {
|
|
50138
|
+
state.checkedState.get(dataIndex)[field] = checked;
|
|
50138
50139
|
}
|
|
50139
50140
|
else {
|
|
50140
|
-
state.checkedState
|
|
50141
|
-
|
|
50141
|
+
state.checkedState.set(dataIndex, {
|
|
50142
|
+
[field]: checked
|
|
50143
|
+
});
|
|
50142
50144
|
}
|
|
50143
50145
|
}
|
|
50144
50146
|
return checked;
|
|
50145
50147
|
}
|
|
50146
50148
|
function initCheckedState(records, state) {
|
|
50147
|
-
state.checkedState
|
|
50149
|
+
state.checkedState.clear();
|
|
50148
50150
|
state.headerCheckedState = {};
|
|
50149
50151
|
state.radioState = {};
|
|
50150
50152
|
let isNeedInitHeaderCheckedStateFromRecord = false;
|
|
@@ -50180,70 +50182,46 @@
|
|
|
50180
50182
|
isNeedInitHeaderCheckedStateFromRecord = true;
|
|
50181
50183
|
}
|
|
50182
50184
|
if (isNeedInitHeaderCheckedStateFromRecord) {
|
|
50183
|
-
|
|
50184
|
-
state._checkboxCellTypeFields.forEach(field => {
|
|
50185
|
-
const value = record[field];
|
|
50186
|
-
let isChecked;
|
|
50187
|
-
if (isObject$4(value)) {
|
|
50188
|
-
isChecked = value.checked;
|
|
50189
|
-
}
|
|
50190
|
-
else if (typeof value === 'boolean') {
|
|
50191
|
-
isChecked = value;
|
|
50192
|
-
}
|
|
50193
|
-
if (isChecked === undefined || isChecked === null) {
|
|
50194
|
-
const headerCheckFunc = state._headerCheckFuncs[field];
|
|
50195
|
-
if (headerCheckFunc) {
|
|
50196
|
-
const cellAddr = state.table.getCellAddrByFieldRecord(field, index);
|
|
50197
|
-
const globalChecked = getOrApply(headerCheckFunc, {
|
|
50198
|
-
col: cellAddr.col,
|
|
50199
|
-
row: cellAddr.row,
|
|
50200
|
-
table: state.table,
|
|
50201
|
-
context: null,
|
|
50202
|
-
value
|
|
50203
|
-
});
|
|
50204
|
-
isChecked = globalChecked;
|
|
50205
|
-
}
|
|
50206
|
-
}
|
|
50207
|
-
if (!state.checkedState[index]) {
|
|
50208
|
-
state.checkedState[index] = {};
|
|
50209
|
-
}
|
|
50210
|
-
state.checkedState[index][field] = isChecked;
|
|
50211
|
-
});
|
|
50212
|
-
});
|
|
50185
|
+
initRecordCheckState(state);
|
|
50213
50186
|
}
|
|
50214
50187
|
}
|
|
50215
50188
|
function updateHeaderCheckedState(field, state, col, row) {
|
|
50216
|
-
|
|
50189
|
+
let allChecked = true;
|
|
50190
|
+
let allUnChecked = true;
|
|
50191
|
+
let hasChecked = false;
|
|
50192
|
+
state.checkedState.forEach((check_state, index) => {
|
|
50193
|
+
if (index.includes(',')) {
|
|
50194
|
+
index = index.split(',').map(item => {
|
|
50195
|
+
return Number(item);
|
|
50196
|
+
});
|
|
50197
|
+
}
|
|
50198
|
+
else {
|
|
50199
|
+
index = Number(index);
|
|
50200
|
+
}
|
|
50217
50201
|
const tableIndex = state.table.getTableIndexByRecordIndex(index);
|
|
50218
50202
|
const mergeCell = state.table.transpose
|
|
50219
50203
|
? state.table.getCustomMerge(tableIndex, row)
|
|
50220
50204
|
: state.table.getCustomMerge(col, tableIndex);
|
|
50221
|
-
|
|
50222
|
-
|
|
50205
|
+
const data = state.table.dataSource.get(index);
|
|
50206
|
+
if (mergeCell || data.vtableMerge) {
|
|
50207
|
+
return;
|
|
50208
|
+
}
|
|
50209
|
+
if (check_state?.[field] !== true) {
|
|
50210
|
+
allChecked = false;
|
|
50211
|
+
}
|
|
50212
|
+
else {
|
|
50213
|
+
allUnChecked = false;
|
|
50214
|
+
hasChecked = true;
|
|
50223
50215
|
}
|
|
50224
|
-
return check_state?.[field] === true;
|
|
50225
50216
|
});
|
|
50226
50217
|
if (allChecked) {
|
|
50227
50218
|
state.headerCheckedState[field] = true;
|
|
50228
50219
|
return allChecked;
|
|
50229
50220
|
}
|
|
50230
|
-
const allUnChecked = state.checkedState.every((check_state, index) => {
|
|
50231
|
-
const tableIndex = state.table.getTableIndexByRecordIndex(index);
|
|
50232
|
-
const mergeCell = state.table.transpose
|
|
50233
|
-
? state.table.getCustomMerge(tableIndex, row)
|
|
50234
|
-
: state.table.getCustomMerge(col, tableIndex);
|
|
50235
|
-
if (mergeCell) {
|
|
50236
|
-
return true;
|
|
50237
|
-
}
|
|
50238
|
-
return check_state?.[field] === false;
|
|
50239
|
-
});
|
|
50240
50221
|
if (allUnChecked) {
|
|
50241
50222
|
state.headerCheckedState[field] = false;
|
|
50242
50223
|
return false;
|
|
50243
50224
|
}
|
|
50244
|
-
const hasChecked = state.checkedState.find((check_state) => {
|
|
50245
|
-
return check_state?.[field] === true;
|
|
50246
|
-
});
|
|
50247
50225
|
if (hasChecked) {
|
|
50248
50226
|
state.headerCheckedState[field] = 'indeterminate';
|
|
50249
50227
|
return 'indeterminate';
|
|
@@ -50251,7 +50229,7 @@
|
|
|
50251
50229
|
return false;
|
|
50252
50230
|
}
|
|
50253
50231
|
function initLeftRecordsCheckState(records, state) {
|
|
50254
|
-
for (let index = state.checkedState.
|
|
50232
|
+
for (let index = state.checkedState.size; index < records.length; index++) {
|
|
50255
50233
|
const record = records[index];
|
|
50256
50234
|
state._checkboxCellTypeFields.forEach(field => {
|
|
50257
50235
|
const value = record[field];
|
|
@@ -50262,10 +50240,11 @@
|
|
|
50262
50240
|
else if (typeof value === 'boolean') {
|
|
50263
50241
|
isChecked = value;
|
|
50264
50242
|
}
|
|
50265
|
-
|
|
50266
|
-
|
|
50243
|
+
const dataIndex = index.toString();
|
|
50244
|
+
if (!state.checkedState.get(dataIndex)) {
|
|
50245
|
+
state.checkedState.set(dataIndex, {});
|
|
50267
50246
|
}
|
|
50268
|
-
state.checkedState[
|
|
50247
|
+
state.checkedState.get(dataIndex)[field] = isChecked;
|
|
50269
50248
|
});
|
|
50270
50249
|
}
|
|
50271
50250
|
}
|
|
@@ -50318,27 +50297,57 @@
|
|
|
50318
50297
|
}
|
|
50319
50298
|
function changeCheckboxOrder(sourceIndex, targetIndex, state) {
|
|
50320
50299
|
const { checkedState, table } = state;
|
|
50300
|
+
let source;
|
|
50301
|
+
let target;
|
|
50321
50302
|
if (table.internalProps.transpose) {
|
|
50322
50303
|
sourceIndex = table.getRecordShowIndexByCell(sourceIndex, 0);
|
|
50323
50304
|
targetIndex = table.getRecordShowIndexByCell(targetIndex, 0);
|
|
50324
50305
|
}
|
|
50325
50306
|
else {
|
|
50326
|
-
|
|
50327
|
-
|
|
50307
|
+
source = table.getRecordIndexByCell(0, sourceIndex);
|
|
50308
|
+
target = table.getRecordIndexByCell(0, targetIndex);
|
|
50328
50309
|
}
|
|
50329
|
-
if (
|
|
50330
|
-
|
|
50331
|
-
|
|
50332
|
-
|
|
50310
|
+
if (isNumber$2(source) && isNumber$2(target)) {
|
|
50311
|
+
if (sourceIndex > targetIndex) {
|
|
50312
|
+
const sourceRecord = checkedState.get(sourceIndex.toString());
|
|
50313
|
+
for (let i = sourceIndex; i > targetIndex; i--) {
|
|
50314
|
+
checkedState.set(i.toString(), checkedState.get((i - 1).toString()));
|
|
50315
|
+
}
|
|
50316
|
+
checkedState.set(targetIndex.toString(), sourceRecord);
|
|
50317
|
+
}
|
|
50318
|
+
else if (sourceIndex < targetIndex) {
|
|
50319
|
+
const sourceRecord = checkedState.get(sourceIndex.toString());
|
|
50320
|
+
for (let i = sourceIndex; i < targetIndex; i++) {
|
|
50321
|
+
checkedState.set(i.toString(), checkedState.get((i + 1).toString()));
|
|
50322
|
+
}
|
|
50323
|
+
checkedState.set(targetIndex.toString(), sourceRecord);
|
|
50333
50324
|
}
|
|
50334
|
-
checkedState[targetIndex] = sourceRecord;
|
|
50335
50325
|
}
|
|
50336
|
-
else if (
|
|
50337
|
-
|
|
50338
|
-
|
|
50339
|
-
|
|
50326
|
+
else if (isArray$1(source) && isArray$1(target)) {
|
|
50327
|
+
sourceIndex = source[source.length - 1];
|
|
50328
|
+
targetIndex = target[target.length - 1];
|
|
50329
|
+
if (sourceIndex > targetIndex) {
|
|
50330
|
+
const sourceRecord = checkedState.get(source.toString());
|
|
50331
|
+
for (let i = sourceIndex; i > targetIndex; i--) {
|
|
50332
|
+
const now = [...source];
|
|
50333
|
+
now[now.length - 1] = i;
|
|
50334
|
+
const last = [...source];
|
|
50335
|
+
last[last.length - 1] = i - 1;
|
|
50336
|
+
checkedState.set(now.toString(), checkedState.get(last.toString()));
|
|
50337
|
+
}
|
|
50338
|
+
checkedState.set(target.toString(), sourceRecord);
|
|
50339
|
+
}
|
|
50340
|
+
else if (sourceIndex < targetIndex) {
|
|
50341
|
+
const sourceRecord = checkedState.get(source.toString());
|
|
50342
|
+
for (let i = sourceIndex; i < targetIndex; i++) {
|
|
50343
|
+
const now = [...source];
|
|
50344
|
+
now[now.length - 1] = i;
|
|
50345
|
+
const next = [...source];
|
|
50346
|
+
next[next.length - 1] = i + 1;
|
|
50347
|
+
checkedState.set(now.toString(), checkedState.get(next.toString()));
|
|
50348
|
+
}
|
|
50349
|
+
checkedState.set(target.toString(), sourceRecord);
|
|
50340
50350
|
}
|
|
50341
|
-
checkedState[targetIndex] = sourceRecord;
|
|
50342
50351
|
}
|
|
50343
50352
|
}
|
|
50344
50353
|
function getGroupCheckboxState(table) {
|
|
@@ -50348,11 +50357,48 @@
|
|
|
50348
50357
|
dataSource.currentIndexedData.forEach((indexArr, index) => {
|
|
50349
50358
|
if (isArray$1(indexArr) && indexArr.length === groupKeyLength) {
|
|
50350
50359
|
const { vtableOriginIndex } = dataSource.getRawRecord(indexArr);
|
|
50351
|
-
result[vtableOriginIndex] = table.stateManager.checkedState
|
|
50360
|
+
result[vtableOriginIndex] = table.stateManager.checkedState.get(indexArr.toString());
|
|
50352
50361
|
}
|
|
50353
50362
|
});
|
|
50354
50363
|
return result;
|
|
50355
50364
|
}
|
|
50365
|
+
function initRecordCheckState(state) {
|
|
50366
|
+
const table = state.table;
|
|
50367
|
+
const start = table.internalProps.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
|
|
50368
|
+
const end = table.internalProps.transpose ? table.colCount : table.rowCount;
|
|
50369
|
+
for (let index = 0; index + start < end; index++) {
|
|
50370
|
+
const record = table.dataSource.get(index);
|
|
50371
|
+
state._checkboxCellTypeFields.forEach(field => {
|
|
50372
|
+
const value = record[field];
|
|
50373
|
+
let isChecked;
|
|
50374
|
+
if (isObject$4(value)) {
|
|
50375
|
+
isChecked = value.checked;
|
|
50376
|
+
}
|
|
50377
|
+
else if (typeof value === 'boolean') {
|
|
50378
|
+
isChecked = value;
|
|
50379
|
+
}
|
|
50380
|
+
if (isChecked === undefined || isChecked === null) {
|
|
50381
|
+
const headerCheckFunc = state._headerCheckFuncs[field];
|
|
50382
|
+
if (headerCheckFunc) {
|
|
50383
|
+
const cellAddr = state.table.getCellAddrByFieldRecord(field, index);
|
|
50384
|
+
const globalChecked = getOrApply(headerCheckFunc, {
|
|
50385
|
+
col: cellAddr.col,
|
|
50386
|
+
row: cellAddr.row,
|
|
50387
|
+
table: state.table,
|
|
50388
|
+
context: null,
|
|
50389
|
+
value
|
|
50390
|
+
});
|
|
50391
|
+
isChecked = globalChecked;
|
|
50392
|
+
}
|
|
50393
|
+
}
|
|
50394
|
+
const dataIndex = state.table.dataSource.getIndexKey(index).toString();
|
|
50395
|
+
if (!state.checkedState.get(dataIndex)) {
|
|
50396
|
+
state.checkedState.set(dataIndex, {});
|
|
50397
|
+
}
|
|
50398
|
+
state.checkedState.get(dataIndex)[field] = isChecked;
|
|
50399
|
+
});
|
|
50400
|
+
}
|
|
50401
|
+
}
|
|
50356
50402
|
|
|
50357
50403
|
function updateResizeRow(xInTable, yInTable, state) {
|
|
50358
50404
|
xInTable = Math.ceil(xInTable);
|
|
@@ -50517,7 +50563,7 @@
|
|
|
50517
50563
|
_clearVerticalScrollBar;
|
|
50518
50564
|
_clearHorizontalScrollBar;
|
|
50519
50565
|
fastScrolling = false;
|
|
50520
|
-
checkedState =
|
|
50566
|
+
checkedState = new Map();
|
|
50521
50567
|
headerCheckedState = {};
|
|
50522
50568
|
_checkboxCellTypeFields = [];
|
|
50523
50569
|
_headerCheckFuncs = {};
|
|
@@ -51553,7 +51599,7 @@
|
|
|
51553
51599
|
return syncRadioState(col, row, field, radioType, indexInCell, isChecked, this);
|
|
51554
51600
|
}
|
|
51555
51601
|
changeCheckboxAndRadioOrder(sourceIndex, targetIndex) {
|
|
51556
|
-
if (this.checkedState.
|
|
51602
|
+
if (this.checkedState.size) {
|
|
51557
51603
|
changeCheckboxOrder(sourceIndex, targetIndex, this);
|
|
51558
51604
|
}
|
|
51559
51605
|
if (this.radioState.length) {
|
|
@@ -58340,7 +58386,7 @@
|
|
|
58340
58386
|
return TABLE_EVENT_TYPE;
|
|
58341
58387
|
}
|
|
58342
58388
|
options;
|
|
58343
|
-
version = "1.13.1-alpha.
|
|
58389
|
+
version = "1.13.1-alpha.7";
|
|
58344
58390
|
pagination;
|
|
58345
58391
|
id = `VTable${Date.now()}`;
|
|
58346
58392
|
headerStyleCache;
|
|
@@ -64992,27 +65038,27 @@
|
|
|
64992
65038
|
this.scenegraph.createSceneGraph();
|
|
64993
65039
|
}
|
|
64994
65040
|
getCheckboxState(field) {
|
|
64995
|
-
if (this.stateManager.checkedState.
|
|
65041
|
+
if (this.stateManager.checkedState.size < this.rowCount - this.columnHeaderLevelCount) {
|
|
64996
65042
|
this.stateManager.initLeftRecordsCheckState(this.records);
|
|
64997
65043
|
}
|
|
64998
65044
|
if (isValid$1(field)) {
|
|
64999
|
-
let stateArr = this.stateManager.checkedState;
|
|
65045
|
+
let stateArr = this.stateManager.checkedState.values();
|
|
65000
65046
|
if (this.options.groupBy) {
|
|
65001
65047
|
stateArr = getGroupCheckboxState(this);
|
|
65002
65048
|
}
|
|
65003
|
-
return stateArr.map(state => {
|
|
65049
|
+
return stateArr.map((state) => {
|
|
65004
65050
|
return state[field];
|
|
65005
65051
|
});
|
|
65006
65052
|
}
|
|
65007
|
-
return this.stateManager.checkedState;
|
|
65053
|
+
return new Array(...this.stateManager.checkedState.values());
|
|
65008
65054
|
}
|
|
65009
65055
|
getCellCheckboxState(col, row) {
|
|
65010
65056
|
const define = this.getBodyColumnDefine(col, row);
|
|
65011
65057
|
const field = define?.field;
|
|
65012
65058
|
const cellType = this.getCellType(col, row);
|
|
65013
65059
|
if (isValid$1(field) && cellType === 'checkbox') {
|
|
65014
|
-
const dataIndex = this.dataSource.getIndexKey(this.getRecordShowIndexByCell(col, row));
|
|
65015
|
-
return this.stateManager.checkedState
|
|
65060
|
+
const dataIndex = this.dataSource.getIndexKey(this.getRecordShowIndexByCell(col, row)).toString();
|
|
65061
|
+
return this.stateManager.checkedState.get(dataIndex)?.[field];
|
|
65016
65062
|
}
|
|
65017
65063
|
return undefined;
|
|
65018
65064
|
}
|
|
@@ -78814,7 +78860,7 @@
|
|
|
78814
78860
|
}
|
|
78815
78861
|
|
|
78816
78862
|
registerForVrender();
|
|
78817
|
-
const version = "1.13.1-alpha.
|
|
78863
|
+
const version = "1.13.1-alpha.7";
|
|
78818
78864
|
function getIcons() {
|
|
78819
78865
|
return get$2();
|
|
78820
78866
|
}
|