@visactor/vtable-plugins 1.22.4-alpha.1 → 1.22.4-alpha.2
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/auto-fill/rules.js +1 -2
- package/cjs/contextmenu/menu-manager.js +2 -1
- package/cjs/filter/filter-state-manager.d.ts +14 -0
- package/cjs/filter/filter-state-manager.js +35 -1
- package/cjs/filter/filter-state-manager.js.map +1 -1
- package/cjs/filter/filter-toolbar.d.ts +1 -0
- package/cjs/filter/filter-toolbar.js +10 -2
- package/cjs/filter/filter-toolbar.js.map +1 -1
- package/cjs/filter/value-filter.d.ts +2 -0
- package/cjs/filter/value-filter.js +132 -106
- package/cjs/filter/value-filter.js.map +1 -1
- package/dist/vtable-plugins.js +246 -115
- package/dist/vtable-plugins.min.js +1 -1
- package/es/auto-fill/rules.js +1 -2
- package/es/contextmenu/menu-manager.js +2 -1
- package/es/filter/filter-state-manager.d.ts +14 -0
- package/es/filter/filter-state-manager.js +35 -1
- package/es/filter/filter-state-manager.js.map +1 -1
- package/es/filter/filter-toolbar.d.ts +1 -0
- package/es/filter/filter-toolbar.js +10 -2
- package/es/filter/filter-toolbar.js.map +1 -1
- package/es/filter/value-filter.d.ts +2 -0
- package/es/filter/value-filter.js +132 -106
- package/es/filter/value-filter.js.map +1 -1
- package/package.json +7 -7
package/dist/vtable-plugins.js
CHANGED
|
@@ -10075,6 +10075,7 @@ ${recordsStr}
|
|
|
10075
10075
|
engine;
|
|
10076
10076
|
listeners = [];
|
|
10077
10077
|
table;
|
|
10078
|
+
filterMenuStates = new Map();
|
|
10078
10079
|
constructor(table, engine) {
|
|
10079
10080
|
this.state = {
|
|
10080
10081
|
filters: new Map()
|
|
@@ -10160,6 +10161,55 @@ ${recordsStr}
|
|
|
10160
10161
|
];
|
|
10161
10162
|
return shouldApplyActions.includes(action.type) || action.payload.enable;
|
|
10162
10163
|
}
|
|
10164
|
+
initializeFilterMenuState(fieldId, candidateValues, displayToRawMap) {
|
|
10165
|
+
this.filterMenuStates.set(fieldId, {
|
|
10166
|
+
stableCandidateValues: candidateValues,
|
|
10167
|
+
currentSearchKeyword: '',
|
|
10168
|
+
displayToRawMap: displayToRawMap
|
|
10169
|
+
});
|
|
10170
|
+
}
|
|
10171
|
+
getStableCandidateValues(fieldId) {
|
|
10172
|
+
return this.filterMenuStates.get(fieldId)?.stableCandidateValues || [];
|
|
10173
|
+
}
|
|
10174
|
+
updateSearchKeyword(fieldId, keyword) {
|
|
10175
|
+
const menuState = this.filterMenuStates.get(fieldId);
|
|
10176
|
+
if (!menuState) {
|
|
10177
|
+
return;
|
|
10178
|
+
}
|
|
10179
|
+
menuState.currentSearchKeyword = keyword;
|
|
10180
|
+
}
|
|
10181
|
+
getVisibleSelectedValues(fieldId) {
|
|
10182
|
+
const menuState = this.filterMenuStates.get(fieldId);
|
|
10183
|
+
const filter = this.getFilterState(fieldId);
|
|
10184
|
+
if (!menuState || !filter?.values) {
|
|
10185
|
+
return new Set();
|
|
10186
|
+
}
|
|
10187
|
+
const allSelectedValues = new Set(filter.values);
|
|
10188
|
+
const keyword = menuState.currentSearchKeyword;
|
|
10189
|
+
const filterKeywords = keyword
|
|
10190
|
+
.toUpperCase()
|
|
10191
|
+
.split(' ')
|
|
10192
|
+
.filter(s => s);
|
|
10193
|
+
if (filterKeywords.length === 0) {
|
|
10194
|
+
return allSelectedValues;
|
|
10195
|
+
}
|
|
10196
|
+
const visibleSelected = new Set();
|
|
10197
|
+
for (const candidate of menuState.stableCandidateValues) {
|
|
10198
|
+
const displayValue = candidate.value;
|
|
10199
|
+
const txtValue = String(displayValue).toUpperCase();
|
|
10200
|
+
const match = filterKeywords.some(keyword => txtValue.includes(keyword));
|
|
10201
|
+
if (match) {
|
|
10202
|
+
const rawValue = menuState.displayToRawMap ? menuState.displayToRawMap.get(displayValue) : displayValue;
|
|
10203
|
+
if (allSelectedValues.has(rawValue)) {
|
|
10204
|
+
visibleSelected.add(rawValue);
|
|
10205
|
+
}
|
|
10206
|
+
}
|
|
10207
|
+
}
|
|
10208
|
+
return visibleSelected;
|
|
10209
|
+
}
|
|
10210
|
+
getCurrentSearchKeyword(fieldId) {
|
|
10211
|
+
return this.filterMenuStates.get(fieldId)?.currentSearchKeyword || '';
|
|
10212
|
+
}
|
|
10163
10213
|
}
|
|
10164
10214
|
|
|
10165
10215
|
const filterStyles = {
|
|
@@ -10339,9 +10389,9 @@ ${recordsStr}
|
|
|
10339
10389
|
this.collectUniqueColumnValues(fieldId);
|
|
10340
10390
|
}
|
|
10341
10391
|
collectUniqueColumnValues(fieldId) {
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10392
|
+
if (this.uniqueKeys.has(fieldId)) {
|
|
10393
|
+
return;
|
|
10394
|
+
}
|
|
10345
10395
|
const displayToRawMap = new Map();
|
|
10346
10396
|
let targetCol = -1;
|
|
10347
10397
|
for (let col = 0; col < this.table.colCount; col++) {
|
|
@@ -10358,82 +10408,106 @@ ${recordsStr}
|
|
|
10358
10408
|
break;
|
|
10359
10409
|
}
|
|
10360
10410
|
}
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
displayValue = bodyInfo.fieldFormat({ [fieldId]: rawValue });
|
|
10377
|
-
}
|
|
10378
|
-
else {
|
|
10379
|
-
displayValue = rawValue;
|
|
10380
|
-
}
|
|
10381
|
-
}
|
|
10382
|
-
if (rawValue !== undefined && rawValue !== null) {
|
|
10383
|
-
displayValueMap.set(displayValue, (displayValueMap.get(displayValue) || 0) + 1);
|
|
10384
|
-
rawToDisplayMap.set(rawValue, displayValue);
|
|
10385
|
-
displayToRawMap.set(displayValue, rawValue);
|
|
10386
|
-
}
|
|
10387
|
-
}
|
|
10388
|
-
}
|
|
10389
|
-
else {
|
|
10390
|
-
const dataSource = this.table.internalProps.dataSource;
|
|
10391
|
-
const currentLength = dataSource.length;
|
|
10392
|
-
for (let i = 0; i < currentLength; i++) {
|
|
10393
|
-
let rawValue;
|
|
10394
|
-
let displayValue;
|
|
10395
|
-
if (targetCol !== -1) {
|
|
10396
|
-
const row = this.table.columnHeaderLevelCount + i;
|
|
10397
|
-
if (row < this.table.rowCount) {
|
|
10398
|
-
rawValue = this.table.getCellOriginValue(targetCol, row);
|
|
10399
|
-
displayValue = this.table.getCellValue(targetCol, row);
|
|
10400
|
-
}
|
|
10411
|
+
const records = this.table.internalProps.records;
|
|
10412
|
+
const recordsLength = records.length;
|
|
10413
|
+
for (let i = 0; i < recordsLength; i++) {
|
|
10414
|
+
let rawValue;
|
|
10415
|
+
let displayValue;
|
|
10416
|
+
if (targetCol !== -1) {
|
|
10417
|
+
const row = this.table.columnHeaderLevelCount + i;
|
|
10418
|
+
const currentRecord = records[i];
|
|
10419
|
+
rawValue = currentRecord[fieldId];
|
|
10420
|
+
const bodyInfo = this.table.internalProps.layoutMap.getBody(targetCol, row);
|
|
10421
|
+
if (bodyInfo &&
|
|
10422
|
+
'fieldFormat' in bodyInfo &&
|
|
10423
|
+
bodyInfo.fieldFormat &&
|
|
10424
|
+
typeof bodyInfo.fieldFormat === 'function') {
|
|
10425
|
+
displayValue = bodyInfo.fieldFormat({ [fieldId]: rawValue });
|
|
10401
10426
|
}
|
|
10402
10427
|
else {
|
|
10403
|
-
rawValue = this.table.getFieldData(String(fieldId), targetCol !== -1 ? targetCol : 0, this.table.columnHeaderLevelCount + i);
|
|
10404
10428
|
displayValue = rawValue;
|
|
10405
10429
|
}
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10430
|
+
}
|
|
10431
|
+
else {
|
|
10432
|
+
rawValue = records[i][fieldId];
|
|
10433
|
+
displayValue = rawValue;
|
|
10434
|
+
}
|
|
10435
|
+
if (rawValue !== undefined && rawValue !== null && !displayToRawMap.has(displayValue)) {
|
|
10436
|
+
displayToRawMap.set(displayValue, rawValue);
|
|
10411
10437
|
}
|
|
10412
10438
|
}
|
|
10413
10439
|
this.displayToRawValueMap.set(fieldId, displayToRawMap);
|
|
10414
|
-
const uniqueValues = Array.from(
|
|
10440
|
+
const uniqueValues = Array.from(displayToRawMap.entries()).map(([displayValue, rawValue]) => ({
|
|
10415
10441
|
value: displayValue,
|
|
10416
|
-
count,
|
|
10417
|
-
rawValue:
|
|
10442
|
+
count: 0,
|
|
10443
|
+
rawValue: rawValue
|
|
10418
10444
|
}));
|
|
10419
10445
|
this.uniqueKeys.set(fieldId, uniqueValues);
|
|
10420
10446
|
}
|
|
10447
|
+
updateCandidateCounts(fieldId) {
|
|
10448
|
+
const uniqueValues = this.uniqueKeys.get(fieldId);
|
|
10449
|
+
if (!uniqueValues) {
|
|
10450
|
+
return;
|
|
10451
|
+
}
|
|
10452
|
+
const filter = this.filterStateManager.getFilterState(fieldId);
|
|
10453
|
+
const isFiltered = filter?.enable;
|
|
10454
|
+
const dataSource = isFiltered
|
|
10455
|
+
? this.table.internalProps.records
|
|
10456
|
+
: this.table.internalProps.dataSource;
|
|
10457
|
+
let targetCol = -1;
|
|
10458
|
+
for (let col = 0; col < this.table.colCount; col++) {
|
|
10459
|
+
for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) {
|
|
10460
|
+
if (!this.table.internalProps.layoutMap.isHeader(col, row)) {
|
|
10461
|
+
const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);
|
|
10462
|
+
if (bodyInfo && bodyInfo.field === fieldId) {
|
|
10463
|
+
targetCol = col;
|
|
10464
|
+
break;
|
|
10465
|
+
}
|
|
10466
|
+
}
|
|
10467
|
+
}
|
|
10468
|
+
if (targetCol !== -1) {
|
|
10469
|
+
break;
|
|
10470
|
+
}
|
|
10471
|
+
}
|
|
10472
|
+
const dataLength = dataSource.length;
|
|
10473
|
+
const countMap = new Map();
|
|
10474
|
+
for (let i = 0; i < dataLength; i++) {
|
|
10475
|
+
let displayValue;
|
|
10476
|
+
if (targetCol !== -1) {
|
|
10477
|
+
const row = this.table.columnHeaderLevelCount + i;
|
|
10478
|
+
if (row < this.table.rowCount) {
|
|
10479
|
+
displayValue = this.table.getCellValue(targetCol, row);
|
|
10480
|
+
}
|
|
10481
|
+
}
|
|
10482
|
+
else {
|
|
10483
|
+
displayValue = this.table.getFieldData(String(fieldId), targetCol !== -1 ? targetCol : 0, this.table.columnHeaderLevelCount + i);
|
|
10484
|
+
}
|
|
10485
|
+
if (displayValue !== undefined && displayValue !== null) {
|
|
10486
|
+
countMap.set(displayValue, (countMap.get(displayValue) || 0) + 1);
|
|
10487
|
+
}
|
|
10488
|
+
}
|
|
10489
|
+
uniqueValues.forEach(item => {
|
|
10490
|
+
item.count = countMap.get(item.value) || 0;
|
|
10491
|
+
});
|
|
10492
|
+
}
|
|
10421
10493
|
onValueSelect(fieldId, displayValue, selected) {
|
|
10422
10494
|
const displayToRawMap = this.displayToRawValueMap.get(fieldId);
|
|
10423
10495
|
const rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
10424
10496
|
const filter = this.filterStateManager.getFilterState(fieldId);
|
|
10497
|
+
let updatedValues;
|
|
10425
10498
|
if (!filter) {
|
|
10499
|
+
updatedValues = selected ? [rawValue] : [];
|
|
10426
10500
|
this.filterStateManager.dispatch({
|
|
10427
10501
|
type: exports.FilterActionType.ADD_FILTER,
|
|
10428
10502
|
payload: {
|
|
10429
10503
|
field: fieldId,
|
|
10430
10504
|
type: 'byValue',
|
|
10431
|
-
values:
|
|
10505
|
+
values: updatedValues
|
|
10432
10506
|
}
|
|
10433
10507
|
});
|
|
10434
10508
|
}
|
|
10435
10509
|
else {
|
|
10436
|
-
|
|
10510
|
+
updatedValues = selected
|
|
10437
10511
|
? [...(filter.values || []), rawValue]
|
|
10438
10512
|
: (filter.values || []).filter(v => v !== rawValue);
|
|
10439
10513
|
this.filterStateManager.dispatch({
|
|
@@ -10445,22 +10519,45 @@ ${recordsStr}
|
|
|
10445
10519
|
});
|
|
10446
10520
|
}
|
|
10447
10521
|
}
|
|
10522
|
+
isValueVisible(displayValue, keyword) {
|
|
10523
|
+
if (!keyword) {
|
|
10524
|
+
return true;
|
|
10525
|
+
}
|
|
10526
|
+
const filterKeywords = keyword
|
|
10527
|
+
.toUpperCase()
|
|
10528
|
+
.split(' ')
|
|
10529
|
+
.filter(s => s);
|
|
10530
|
+
const txtValue = String(displayValue).toUpperCase();
|
|
10531
|
+
return filterKeywords.some(keyword => txtValue.includes(keyword));
|
|
10532
|
+
}
|
|
10448
10533
|
toggleSelectAll(fieldId, selected) {
|
|
10534
|
+
const currentKeyword = this.filterStateManager.getCurrentSearchKeyword(fieldId);
|
|
10535
|
+
const stableCandidates = this.filterStateManager.getStableCandidateValues(fieldId);
|
|
10536
|
+
const displayToRawMap = this.displayToRawValueMap.get(fieldId);
|
|
10537
|
+
const visibleRawValues = stableCandidates
|
|
10538
|
+
.filter(candidate => this.isValueVisible(candidate.value, currentKeyword))
|
|
10539
|
+
.map(candidate => (displayToRawMap ? displayToRawMap.get(candidate.value) : candidate.value));
|
|
10449
10540
|
const filter = this.filterStateManager.getFilterState(fieldId);
|
|
10450
|
-
const
|
|
10541
|
+
const currentValues = new Set(filter?.values || []);
|
|
10542
|
+
let updatedValues;
|
|
10543
|
+
if (selected) {
|
|
10544
|
+
updatedValues = Array.from(new Set([...currentValues, ...visibleRawValues]));
|
|
10545
|
+
}
|
|
10546
|
+
else {
|
|
10547
|
+
updatedValues = Array.from(currentValues).filter(value => !visibleRawValues.includes(value));
|
|
10548
|
+
}
|
|
10451
10549
|
if (!filter) {
|
|
10452
10550
|
this.filterStateManager.dispatch({
|
|
10453
10551
|
type: exports.FilterActionType.ADD_FILTER,
|
|
10454
10552
|
payload: {
|
|
10455
10553
|
field: fieldId,
|
|
10456
10554
|
type: 'byValue',
|
|
10457
|
-
values:
|
|
10555
|
+
values: updatedValues,
|
|
10458
10556
|
enable: true
|
|
10459
10557
|
}
|
|
10460
10558
|
});
|
|
10461
10559
|
}
|
|
10462
10560
|
else {
|
|
10463
|
-
const updatedValues = selected ? rawValuesToUpdate : [];
|
|
10464
10561
|
this.filterStateManager.dispatch({
|
|
10465
10562
|
type: exports.FilterActionType.UPDATE_FILTER,
|
|
10466
10563
|
payload: {
|
|
@@ -10471,79 +10568,88 @@ ${recordsStr}
|
|
|
10471
10568
|
}
|
|
10472
10569
|
}
|
|
10473
10570
|
onSearch(fieldId, value) {
|
|
10571
|
+
this.filterStateManager.updateSearchKeyword(fieldId, value);
|
|
10572
|
+
const items = this.valueFilterOptionList.get(fieldId);
|
|
10474
10573
|
const filterKeywords = value
|
|
10475
10574
|
.toUpperCase()
|
|
10476
10575
|
.split(' ')
|
|
10477
10576
|
.filter(s => s);
|
|
10478
|
-
const items = this.valueFilterOptionList.get(fieldId);
|
|
10479
10577
|
for (const item of items) {
|
|
10480
10578
|
const txtValue = item.id.toUpperCase() || '';
|
|
10481
10579
|
const match = filterKeywords.some(keyword => txtValue.includes(keyword));
|
|
10482
|
-
|
|
10580
|
+
const isVisible = filterKeywords.length === 0 || match;
|
|
10581
|
+
item.itemContainer.style.display = isVisible ? 'flex' : 'none';
|
|
10483
10582
|
}
|
|
10484
10583
|
}
|
|
10485
10584
|
initFilterStateFromTableData(fieldId) {
|
|
10486
10585
|
const filter = this.filterStateManager.getFilterState(fieldId);
|
|
10487
|
-
const
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
if (
|
|
10495
|
-
|
|
10496
|
-
|
|
10586
|
+
const isEnable = filter?.enable;
|
|
10587
|
+
if (isEnable) {
|
|
10588
|
+
const selectedRawValues = new Set();
|
|
10589
|
+
const displayToRawMap = this.displayToRawValueMap.get(fieldId);
|
|
10590
|
+
let targetCol = -1;
|
|
10591
|
+
for (let col = 0; col < this.table.colCount; col++) {
|
|
10592
|
+
for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) {
|
|
10593
|
+
if (!this.table.internalProps.layoutMap.isHeader(col, row)) {
|
|
10594
|
+
const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);
|
|
10595
|
+
if (bodyInfo && bodyInfo.field === fieldId) {
|
|
10596
|
+
targetCol = col;
|
|
10597
|
+
break;
|
|
10598
|
+
}
|
|
10497
10599
|
}
|
|
10498
10600
|
}
|
|
10601
|
+
if (targetCol !== -1) {
|
|
10602
|
+
break;
|
|
10603
|
+
}
|
|
10499
10604
|
}
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10605
|
+
const dataSource = this.table.internalProps.dataSource;
|
|
10606
|
+
const currentLength = dataSource.length;
|
|
10607
|
+
for (let i = 0; i < currentLength; i++) {
|
|
10608
|
+
let displayValue;
|
|
10609
|
+
let rawValue;
|
|
10610
|
+
if (targetCol !== -1) {
|
|
10611
|
+
const row = this.table.columnHeaderLevelCount + i;
|
|
10612
|
+
if (row < this.table.rowCount) {
|
|
10613
|
+
displayValue = this.table.getCellValue(targetCol, row);
|
|
10614
|
+
rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
10615
|
+
}
|
|
10616
|
+
}
|
|
10617
|
+
else {
|
|
10618
|
+
displayValue = this.table.getFieldData(String(fieldId), targetCol !== -1 ? targetCol : 0, this.table.columnHeaderLevelCount + i);
|
|
10513
10619
|
rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
10514
10620
|
}
|
|
10621
|
+
if (rawValue !== undefined && rawValue !== null) {
|
|
10622
|
+
selectedRawValues.add(rawValue);
|
|
10623
|
+
}
|
|
10515
10624
|
}
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10625
|
+
const hasChanged = !arrayEqual(filter.values, Array.from(selectedRawValues));
|
|
10626
|
+
if (hasChanged) {
|
|
10627
|
+
this.filterStateManager.dispatch({
|
|
10628
|
+
type: exports.FilterActionType.UPDATE_FILTER,
|
|
10629
|
+
payload: {
|
|
10630
|
+
field: fieldId,
|
|
10631
|
+
values: Array.from(selectedRawValues)
|
|
10632
|
+
}
|
|
10633
|
+
});
|
|
10522
10634
|
}
|
|
10523
10635
|
}
|
|
10524
|
-
const hasChanged = !filter || !arrayEqual(filter.values, Array.from(selectedRawValues));
|
|
10525
|
-
if (!hasChanged) {
|
|
10526
|
-
return;
|
|
10527
|
-
}
|
|
10528
|
-
if (filter) {
|
|
10529
|
-
this.filterStateManager.dispatch({
|
|
10530
|
-
type: exports.FilterActionType.UPDATE_FILTER,
|
|
10531
|
-
payload: {
|
|
10532
|
-
field: fieldId,
|
|
10533
|
-
type: 'byValue',
|
|
10534
|
-
values: Array.from(selectedRawValues)
|
|
10535
|
-
}
|
|
10536
|
-
});
|
|
10537
|
-
}
|
|
10538
10636
|
else {
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
10637
|
+
if (!filter) {
|
|
10638
|
+
const availableRawValues = this.uniqueKeys
|
|
10639
|
+
.get(fieldId)
|
|
10640
|
+
?.filter(item => item.count > 0)
|
|
10641
|
+
?.map(item => item.rawValue)
|
|
10642
|
+
.filter(v => v !== undefined && v !== null) || [];
|
|
10643
|
+
this.filterStateManager.dispatch({
|
|
10644
|
+
type: exports.FilterActionType.ADD_FILTER,
|
|
10645
|
+
payload: {
|
|
10646
|
+
field: fieldId,
|
|
10647
|
+
type: 'byValue',
|
|
10648
|
+
values: availableRawValues,
|
|
10649
|
+
enable: false
|
|
10650
|
+
}
|
|
10651
|
+
});
|
|
10652
|
+
}
|
|
10547
10653
|
}
|
|
10548
10654
|
}
|
|
10549
10655
|
syncCheckboxesWithFilterState(filter) {
|
|
@@ -10558,8 +10664,7 @@ ${recordsStr}
|
|
|
10558
10664
|
const rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
10559
10665
|
optionDom.checkbox.checked = selectedRawValues.some(v => v === rawValue);
|
|
10560
10666
|
const count = this.uniqueKeys.get(filter.field)?.find(key => String(key.value) === optionDom.id)?.count || 0;
|
|
10561
|
-
optionDom.
|
|
10562
|
-
optionDom.itemContainer.style.display = count === 0 ? 'none' : 'flex';
|
|
10667
|
+
optionDom.checkbox.disabled = count === 0;
|
|
10563
10668
|
});
|
|
10564
10669
|
}
|
|
10565
10670
|
syncSelectAllWithFilterState(filter) {
|
|
@@ -10587,14 +10692,14 @@ ${recordsStr}
|
|
|
10587
10692
|
}
|
|
10588
10693
|
}
|
|
10589
10694
|
applyFilter(fieldId = this.selectedField) {
|
|
10590
|
-
const
|
|
10591
|
-
if (
|
|
10695
|
+
const visibleSelectedKeys = Array.from(this.filterStateManager.getVisibleSelectedValues(fieldId));
|
|
10696
|
+
if (visibleSelectedKeys.length > 0 && visibleSelectedKeys.length < this.uniqueKeys.get(fieldId)?.length) {
|
|
10592
10697
|
this.filterStateManager.dispatch({
|
|
10593
10698
|
type: exports.FilterActionType.APPLY_FILTERS,
|
|
10594
10699
|
payload: {
|
|
10595
10700
|
field: fieldId,
|
|
10596
10701
|
type: 'byValue',
|
|
10597
|
-
values:
|
|
10702
|
+
values: visibleSelectedKeys,
|
|
10598
10703
|
enable: true
|
|
10599
10704
|
}
|
|
10600
10705
|
});
|
|
@@ -10655,12 +10760,14 @@ ${recordsStr}
|
|
|
10655
10760
|
this.uniqueKeys.get(field)?.forEach(({ value, count, rawValue }) => {
|
|
10656
10761
|
const itemDiv = document.createElement('div');
|
|
10657
10762
|
applyStyles(itemDiv, this.styles.optionItem);
|
|
10763
|
+
itemDiv.style.display = 'flex';
|
|
10658
10764
|
const label = document.createElement('label');
|
|
10659
10765
|
applyStyles(label, this.styles.optionLabel);
|
|
10660
10766
|
const checkbox = document.createElement('input');
|
|
10661
10767
|
checkbox.type = 'checkbox';
|
|
10662
10768
|
checkbox.value = String(value);
|
|
10663
10769
|
checkbox.checked = selectedRawValueSet.has(rawValue);
|
|
10770
|
+
checkbox.disabled = count === 0;
|
|
10664
10771
|
applyStyles(checkbox, this.styles.checkbox);
|
|
10665
10772
|
const countSpan = document.createElement('span');
|
|
10666
10773
|
countSpan.textContent = String(count);
|
|
@@ -10705,7 +10812,17 @@ ${recordsStr}
|
|
|
10705
10812
|
});
|
|
10706
10813
|
}
|
|
10707
10814
|
show() {
|
|
10815
|
+
this.collectUniqueColumnValues(this.selectedField);
|
|
10816
|
+
this.updateCandidateCounts(this.selectedField);
|
|
10708
10817
|
this.initFilterStateFromTableData(this.selectedField);
|
|
10818
|
+
const uniqueValues = this.uniqueKeys.get(this.selectedField);
|
|
10819
|
+
const displayToRawMap = this.displayToRawValueMap.get(this.selectedField);
|
|
10820
|
+
if (uniqueValues && displayToRawMap) {
|
|
10821
|
+
this.filterStateManager.initializeFilterMenuState(this.selectedField, uniqueValues, displayToRawMap);
|
|
10822
|
+
}
|
|
10823
|
+
if (this.filterByValueSearchInput) {
|
|
10824
|
+
this.filterByValueSearchInput.value = '';
|
|
10825
|
+
}
|
|
10709
10826
|
this.renderFilterOptions(this.selectedField);
|
|
10710
10827
|
this.filterByValuePanel.style.display = 'block';
|
|
10711
10828
|
}
|
|
@@ -11047,6 +11164,11 @@ ${recordsStr}
|
|
|
11047
11164
|
this.valueFilter = new ValueFilter(this.table, this.filterStateManager, this.styles);
|
|
11048
11165
|
this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, this.styles);
|
|
11049
11166
|
this.filterMenuWidth = 300;
|
|
11167
|
+
this.filterStateManager.subscribe(state => {
|
|
11168
|
+
if (this.isVisible && this.selectedField !== null) {
|
|
11169
|
+
this.updateClearFilterButtonState(this.selectedField);
|
|
11170
|
+
}
|
|
11171
|
+
});
|
|
11050
11172
|
}
|
|
11051
11173
|
onTabSwitch(tab) {
|
|
11052
11174
|
this.activeTab = tab;
|
|
@@ -11089,6 +11211,14 @@ ${recordsStr}
|
|
|
11089
11211
|
}
|
|
11090
11212
|
this.hide();
|
|
11091
11213
|
}
|
|
11214
|
+
updateClearFilterButtonState(field) {
|
|
11215
|
+
const currentFilter = this.filterStateManager.getFilterState(field);
|
|
11216
|
+
const hasActiveFilter = currentFilter && currentFilter.enable;
|
|
11217
|
+
this.clearFilterOptionLink.style.display = 'inline';
|
|
11218
|
+
this.clearFilterOptionLink.style.opacity = hasActiveFilter ? '1' : '0.5';
|
|
11219
|
+
this.clearFilterOptionLink.style.pointerEvents = hasActiveFilter ? 'auto' : 'none';
|
|
11220
|
+
this.clearFilterOptionLink.style.cursor = hasActiveFilter ? 'pointer' : 'not-allowed';
|
|
11221
|
+
}
|
|
11092
11222
|
render(container) {
|
|
11093
11223
|
this.filterMenu = document.createElement('div');
|
|
11094
11224
|
applyStyles(this.filterMenu, this.styles.filterMenu);
|
|
@@ -11182,6 +11312,7 @@ ${recordsStr}
|
|
|
11182
11312
|
else {
|
|
11183
11313
|
this.onTabSwitch('byValue');
|
|
11184
11314
|
}
|
|
11315
|
+
this.updateClearFilterButtonState(field);
|
|
11185
11316
|
setTimeout(() => {
|
|
11186
11317
|
this.isVisible = true;
|
|
11187
11318
|
}, 0);
|