@visactor/vtable-sheet 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/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/vtable-sheet.js +187 -111
- package/dist/vtable-sheet.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +4 -4
package/cjs/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import VTableSheet from './components/vtable-sheet';
|
|
|
2
2
|
import type { ISheetDefine, IVTableSheetOptions } from './ts-types';
|
|
3
3
|
import * as TYPES from './ts-types';
|
|
4
4
|
import * as VTable from './vtable';
|
|
5
|
-
export declare const version = "1.22.4-alpha.
|
|
5
|
+
export declare const version = "1.22.4-alpha.2";
|
|
6
6
|
export { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };
|
package/cjs/index.js
CHANGED
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,IAAA,4BAAY,GAAE,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.22.4-alpha.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,IAAA,4BAAY,GAAE,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.22.4-alpha.2\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
|
package/dist/vtable-sheet.js
CHANGED
|
@@ -59310,7 +59310,7 @@
|
|
|
59310
59310
|
}
|
|
59311
59311
|
constructor(container, options = {}) {
|
|
59312
59312
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
59313
|
-
if (super(), this.showFrozenIcon = !0, this.version = "1.22.4-alpha.
|
|
59313
|
+
if (super(), this.showFrozenIcon = !0, this.version = "1.22.4-alpha.2", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env$1.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
|
|
59314
59314
|
this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
|
|
59315
59315
|
options: options,
|
|
59316
59316
|
container: container
|
|
@@ -72268,7 +72268,7 @@
|
|
|
72268
72268
|
|
|
72269
72269
|
class FilterStateManager {
|
|
72270
72270
|
constructor(table, engine) {
|
|
72271
|
-
this.listeners = [], this.state = {
|
|
72271
|
+
this.listeners = [], this.filterMenuStates = new Map(), this.state = {
|
|
72272
72272
|
filters: new Map()
|
|
72273
72273
|
}, this.engine = engine, this.table = table;
|
|
72274
72274
|
}
|
|
@@ -72342,6 +72342,44 @@
|
|
|
72342
72342
|
shouldApplyFilter(action) {
|
|
72343
72343
|
return [FilterActionType.REMOVE_FILTER, FilterActionType.ENABLE_FILTER, FilterActionType.DISABLE_FILTER, FilterActionType.CLEAR_ALL_FILTERS, FilterActionType.APPLY_FILTERS].includes(action.type) || action.payload.enable;
|
|
72344
72344
|
}
|
|
72345
|
+
initializeFilterMenuState(fieldId, candidateValues, displayToRawMap) {
|
|
72346
|
+
this.filterMenuStates.set(fieldId, {
|
|
72347
|
+
stableCandidateValues: candidateValues,
|
|
72348
|
+
currentSearchKeyword: "",
|
|
72349
|
+
displayToRawMap: displayToRawMap
|
|
72350
|
+
});
|
|
72351
|
+
}
|
|
72352
|
+
getStableCandidateValues(fieldId) {
|
|
72353
|
+
var _a;
|
|
72354
|
+
return (null === (_a = this.filterMenuStates.get(fieldId)) || void 0 === _a ? void 0 : _a.stableCandidateValues) || [];
|
|
72355
|
+
}
|
|
72356
|
+
updateSearchKeyword(fieldId, keyword) {
|
|
72357
|
+
const menuState = this.filterMenuStates.get(fieldId);
|
|
72358
|
+
menuState && (menuState.currentSearchKeyword = keyword);
|
|
72359
|
+
}
|
|
72360
|
+
getVisibleSelectedValues(fieldId) {
|
|
72361
|
+
const menuState = this.filterMenuStates.get(fieldId),
|
|
72362
|
+
filter = this.getFilterState(fieldId);
|
|
72363
|
+
if (!menuState || !(null == filter ? void 0 : filter.values)) return new Set();
|
|
72364
|
+
const allSelectedValues = new Set(filter.values),
|
|
72365
|
+
filterKeywords = menuState.currentSearchKeyword.toUpperCase().split(" ").filter(s => s);
|
|
72366
|
+
if (0 === filterKeywords.length) return allSelectedValues;
|
|
72367
|
+
const visibleSelected = new Set();
|
|
72368
|
+
for (const candidate of menuState.stableCandidateValues) {
|
|
72369
|
+
const displayValue = candidate.value,
|
|
72370
|
+
txtValue = String(displayValue).toUpperCase(),
|
|
72371
|
+
match = filterKeywords.some(keyword => txtValue.includes(keyword));
|
|
72372
|
+
if (match) {
|
|
72373
|
+
const rawValue = menuState.displayToRawMap ? menuState.displayToRawMap.get(displayValue) : displayValue;
|
|
72374
|
+
allSelectedValues.has(rawValue) && visibleSelected.add(rawValue);
|
|
72375
|
+
}
|
|
72376
|
+
}
|
|
72377
|
+
return visibleSelected;
|
|
72378
|
+
}
|
|
72379
|
+
getCurrentSearchKeyword(fieldId) {
|
|
72380
|
+
var _a;
|
|
72381
|
+
return (null === (_a = this.filterMenuStates.get(fieldId)) || void 0 === _a ? void 0 : _a.currentSearchKeyword) || "";
|
|
72382
|
+
}
|
|
72345
72383
|
}
|
|
72346
72384
|
|
|
72347
72385
|
const filterStyles = {
|
|
@@ -72496,11 +72534,8 @@
|
|
|
72496
72534
|
this.selectedField = fieldId, this.collectUniqueColumnValues(fieldId);
|
|
72497
72535
|
}
|
|
72498
72536
|
collectUniqueColumnValues(fieldId) {
|
|
72499
|
-
|
|
72500
|
-
const
|
|
72501
|
-
displayValueMap = new Map(),
|
|
72502
|
-
rawToDisplayMap = new Map(),
|
|
72503
|
-
displayToRawMap = new Map();
|
|
72537
|
+
if (this.uniqueKeys.has(fieldId)) return;
|
|
72538
|
+
const displayToRawMap = new Map();
|
|
72504
72539
|
let targetCol = -1;
|
|
72505
72540
|
for (let col = 0; col < this.table.colCount; col++) {
|
|
72506
72541
|
for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) if (!this.table.internalProps.layoutMap.isHeader(col, row)) {
|
|
@@ -72512,133 +72547,164 @@
|
|
|
72512
72547
|
}
|
|
72513
72548
|
if (-1 !== targetCol) break;
|
|
72514
72549
|
}
|
|
72515
|
-
|
|
72516
|
-
|
|
72517
|
-
|
|
72518
|
-
|
|
72519
|
-
|
|
72520
|
-
|
|
72521
|
-
|
|
72522
|
-
|
|
72523
|
-
|
|
72524
|
-
|
|
72525
|
-
|
|
72526
|
-
|
|
72527
|
-
|
|
72528
|
-
null != rawValue && (displayValueMap.set(displayValue, (displayValueMap.get(displayValue) || 0) + 1), rawToDisplayMap.set(rawValue, displayValue), displayToRawMap.set(displayValue, rawValue));
|
|
72529
|
-
}
|
|
72530
|
-
} else {
|
|
72531
|
-
const currentLength = this.table.internalProps.dataSource.length;
|
|
72532
|
-
for (let i = 0; i < currentLength; i++) {
|
|
72533
|
-
let rawValue, displayValue;
|
|
72534
|
-
if (-1 !== targetCol) {
|
|
72535
|
-
const row = this.table.columnHeaderLevelCount + i;
|
|
72536
|
-
row < this.table.rowCount && (rawValue = this.table.getCellOriginValue(targetCol, row), displayValue = this.table.getCellValue(targetCol, row));
|
|
72537
|
-
} else rawValue = this.table.getFieldData(String(fieldId), -1 !== targetCol ? targetCol : 0, this.table.columnHeaderLevelCount + i), displayValue = rawValue;
|
|
72538
|
-
null != rawValue && (displayValueMap.set(displayValue, (displayValueMap.get(displayValue) || 0) + 1), rawToDisplayMap.set(rawValue, displayValue), displayToRawMap.set(displayValue, rawValue));
|
|
72539
|
-
}
|
|
72550
|
+
const records = this.table.internalProps.records,
|
|
72551
|
+
recordsLength = records.length;
|
|
72552
|
+
for (let i = 0; i < recordsLength; i++) {
|
|
72553
|
+
let rawValue, displayValue;
|
|
72554
|
+
if (-1 !== targetCol) {
|
|
72555
|
+
const row = this.table.columnHeaderLevelCount + i;
|
|
72556
|
+
rawValue = records[i][fieldId];
|
|
72557
|
+
const bodyInfo = this.table.internalProps.layoutMap.getBody(targetCol, row);
|
|
72558
|
+
displayValue = bodyInfo && "fieldFormat" in bodyInfo && bodyInfo.fieldFormat && "function" == typeof bodyInfo.fieldFormat ? bodyInfo.fieldFormat({
|
|
72559
|
+
[fieldId]: rawValue
|
|
72560
|
+
}) : rawValue;
|
|
72561
|
+
} else rawValue = records[i][fieldId], displayValue = rawValue;
|
|
72562
|
+
null == rawValue || displayToRawMap.has(displayValue) || displayToRawMap.set(displayValue, rawValue);
|
|
72540
72563
|
}
|
|
72541
72564
|
this.displayToRawValueMap.set(fieldId, displayToRawMap);
|
|
72542
|
-
const uniqueValues = Array.from(
|
|
72565
|
+
const uniqueValues = Array.from(displayToRawMap.entries()).map(([displayValue, rawValue]) => ({
|
|
72543
72566
|
value: displayValue,
|
|
72544
|
-
count:
|
|
72545
|
-
rawValue:
|
|
72567
|
+
count: 0,
|
|
72568
|
+
rawValue: rawValue
|
|
72546
72569
|
}));
|
|
72547
72570
|
this.uniqueKeys.set(fieldId, uniqueValues);
|
|
72548
72571
|
}
|
|
72572
|
+
updateCandidateCounts(fieldId) {
|
|
72573
|
+
const uniqueValues = this.uniqueKeys.get(fieldId);
|
|
72574
|
+
if (!uniqueValues) return;
|
|
72575
|
+
const filter = this.filterStateManager.getFilterState(fieldId),
|
|
72576
|
+
dataSource = (null == filter ? void 0 : filter.enable) ? this.table.internalProps.records : this.table.internalProps.dataSource;
|
|
72577
|
+
let targetCol = -1;
|
|
72578
|
+
for (let col = 0; col < this.table.colCount; col++) {
|
|
72579
|
+
for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) if (!this.table.internalProps.layoutMap.isHeader(col, row)) {
|
|
72580
|
+
const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);
|
|
72581
|
+
if (bodyInfo && bodyInfo.field === fieldId) {
|
|
72582
|
+
targetCol = col;
|
|
72583
|
+
break;
|
|
72584
|
+
}
|
|
72585
|
+
}
|
|
72586
|
+
if (-1 !== targetCol) break;
|
|
72587
|
+
}
|
|
72588
|
+
const dataLength = dataSource.length,
|
|
72589
|
+
countMap = new Map();
|
|
72590
|
+
for (let i = 0; i < dataLength; i++) {
|
|
72591
|
+
let displayValue;
|
|
72592
|
+
if (-1 !== targetCol) {
|
|
72593
|
+
const row = this.table.columnHeaderLevelCount + i;
|
|
72594
|
+
row < this.table.rowCount && (displayValue = this.table.getCellValue(targetCol, row));
|
|
72595
|
+
} else displayValue = this.table.getFieldData(String(fieldId), -1 !== targetCol ? targetCol : 0, this.table.columnHeaderLevelCount + i);
|
|
72596
|
+
null != displayValue && countMap.set(displayValue, (countMap.get(displayValue) || 0) + 1);
|
|
72597
|
+
}
|
|
72598
|
+
uniqueValues.forEach(item => {
|
|
72599
|
+
item.count = countMap.get(item.value) || 0;
|
|
72600
|
+
});
|
|
72601
|
+
}
|
|
72549
72602
|
onValueSelect(fieldId, displayValue, selected) {
|
|
72550
72603
|
const displayToRawMap = this.displayToRawValueMap.get(fieldId),
|
|
72551
72604
|
rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue,
|
|
72552
72605
|
filter = this.filterStateManager.getFilterState(fieldId);
|
|
72553
|
-
|
|
72554
|
-
|
|
72555
|
-
|
|
72556
|
-
|
|
72557
|
-
|
|
72558
|
-
|
|
72559
|
-
|
|
72560
|
-
|
|
72561
|
-
});
|
|
72562
|
-
} else this.filterStateManager.dispatch({
|
|
72606
|
+
let updatedValues;
|
|
72607
|
+
filter ? (updatedValues = selected ? [...(filter.values || []), rawValue] : (filter.values || []).filter(v => v !== rawValue), this.filterStateManager.dispatch({
|
|
72608
|
+
type: FilterActionType.UPDATE_FILTER,
|
|
72609
|
+
payload: {
|
|
72610
|
+
field: fieldId,
|
|
72611
|
+
values: updatedValues
|
|
72612
|
+
}
|
|
72613
|
+
})) : (updatedValues = selected ? [rawValue] : [], this.filterStateManager.dispatch({
|
|
72563
72614
|
type: FilterActionType.ADD_FILTER,
|
|
72564
72615
|
payload: {
|
|
72565
72616
|
field: fieldId,
|
|
72566
72617
|
type: "byValue",
|
|
72567
|
-
values:
|
|
72618
|
+
values: updatedValues
|
|
72568
72619
|
}
|
|
72569
|
-
});
|
|
72620
|
+
}));
|
|
72621
|
+
}
|
|
72622
|
+
isValueVisible(displayValue, keyword) {
|
|
72623
|
+
if (!keyword) return !0;
|
|
72624
|
+
const filterKeywords = keyword.toUpperCase().split(" ").filter(s => s),
|
|
72625
|
+
txtValue = String(displayValue).toUpperCase();
|
|
72626
|
+
return filterKeywords.some(keyword => txtValue.includes(keyword));
|
|
72570
72627
|
}
|
|
72571
72628
|
toggleSelectAll(fieldId, selected) {
|
|
72572
|
-
|
|
72573
|
-
|
|
72574
|
-
|
|
72575
|
-
|
|
72576
|
-
|
|
72577
|
-
|
|
72578
|
-
|
|
72579
|
-
|
|
72580
|
-
|
|
72581
|
-
|
|
72582
|
-
|
|
72583
|
-
|
|
72584
|
-
|
|
72629
|
+
const currentKeyword = this.filterStateManager.getCurrentSearchKeyword(fieldId),
|
|
72630
|
+
stableCandidates = this.filterStateManager.getStableCandidateValues(fieldId),
|
|
72631
|
+
displayToRawMap = this.displayToRawValueMap.get(fieldId),
|
|
72632
|
+
visibleRawValues = stableCandidates.filter(candidate => this.isValueVisible(candidate.value, currentKeyword)).map(candidate => displayToRawMap ? displayToRawMap.get(candidate.value) : candidate.value),
|
|
72633
|
+
filter = this.filterStateManager.getFilterState(fieldId),
|
|
72634
|
+
currentValues = new Set((null == filter ? void 0 : filter.values) || []);
|
|
72635
|
+
let updatedValues;
|
|
72636
|
+
updatedValues = selected ? Array.from(new Set([...currentValues, ...visibleRawValues])) : Array.from(currentValues).filter(value => !visibleRawValues.includes(value)), filter ? this.filterStateManager.dispatch({
|
|
72637
|
+
type: FilterActionType.UPDATE_FILTER,
|
|
72638
|
+
payload: {
|
|
72639
|
+
field: fieldId,
|
|
72640
|
+
values: updatedValues
|
|
72641
|
+
}
|
|
72642
|
+
}) : this.filterStateManager.dispatch({
|
|
72585
72643
|
type: FilterActionType.ADD_FILTER,
|
|
72586
72644
|
payload: {
|
|
72587
72645
|
field: fieldId,
|
|
72588
72646
|
type: "byValue",
|
|
72589
|
-
values:
|
|
72647
|
+
values: updatedValues,
|
|
72590
72648
|
enable: !0
|
|
72591
72649
|
}
|
|
72592
72650
|
});
|
|
72593
72651
|
}
|
|
72594
72652
|
onSearch(fieldId, value) {
|
|
72595
|
-
|
|
72596
|
-
|
|
72653
|
+
this.filterStateManager.updateSearchKeyword(fieldId, value);
|
|
72654
|
+
const items = this.valueFilterOptionList.get(fieldId),
|
|
72655
|
+
filterKeywords = value.toUpperCase().split(" ").filter(s => s);
|
|
72597
72656
|
for (const item of items) {
|
|
72598
72657
|
const txtValue = item.id.toUpperCase() || "",
|
|
72599
|
-
match = filterKeywords.some(keyword => txtValue.includes(keyword))
|
|
72600
|
-
|
|
72658
|
+
match = filterKeywords.some(keyword => txtValue.includes(keyword)),
|
|
72659
|
+
isVisible = 0 === filterKeywords.length || match;
|
|
72660
|
+
item.itemContainer.style.display = isVisible ? "flex" : "none";
|
|
72601
72661
|
}
|
|
72602
72662
|
}
|
|
72603
72663
|
initFilterStateFromTableData(fieldId) {
|
|
72604
|
-
|
|
72605
|
-
|
|
72606
|
-
|
|
72607
|
-
|
|
72608
|
-
|
|
72609
|
-
|
|
72610
|
-
|
|
72611
|
-
|
|
72612
|
-
|
|
72613
|
-
|
|
72664
|
+
var _a, _b;
|
|
72665
|
+
const filter = this.filterStateManager.getFilterState(fieldId);
|
|
72666
|
+
if (null == filter ? void 0 : filter.enable) {
|
|
72667
|
+
const selectedRawValues = new Set(),
|
|
72668
|
+
displayToRawMap = this.displayToRawValueMap.get(fieldId);
|
|
72669
|
+
let targetCol = -1;
|
|
72670
|
+
for (let col = 0; col < this.table.colCount; col++) {
|
|
72671
|
+
for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) if (!this.table.internalProps.layoutMap.isHeader(col, row)) {
|
|
72672
|
+
const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);
|
|
72673
|
+
if (bodyInfo && bodyInfo.field === fieldId) {
|
|
72674
|
+
targetCol = col;
|
|
72675
|
+
break;
|
|
72676
|
+
}
|
|
72614
72677
|
}
|
|
72678
|
+
if (-1 !== targetCol) break;
|
|
72615
72679
|
}
|
|
72616
|
-
|
|
72617
|
-
|
|
72618
|
-
|
|
72619
|
-
|
|
72620
|
-
|
|
72621
|
-
|
|
72622
|
-
|
|
72623
|
-
|
|
72624
|
-
} else displayValue = this.table.getFieldData(String(fieldId), -1 !== targetCol ? targetCol : 0, this.table.columnHeaderLevelCount + i), rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
72625
|
-
null != rawValue && selectedRawValues.add(rawValue);
|
|
72626
|
-
}
|
|
72627
|
-
(!filter || !arrayEqual(filter.values, Array.from(selectedRawValues))) && (filter ? this.filterStateManager.dispatch({
|
|
72628
|
-
type: FilterActionType.UPDATE_FILTER,
|
|
72629
|
-
payload: {
|
|
72630
|
-
field: fieldId,
|
|
72631
|
-
type: "byValue",
|
|
72632
|
-
values: Array.from(selectedRawValues)
|
|
72633
|
-
}
|
|
72634
|
-
}) : this.filterStateManager.dispatch({
|
|
72635
|
-
type: FilterActionType.ADD_FILTER,
|
|
72636
|
-
payload: {
|
|
72637
|
-
field: fieldId,
|
|
72638
|
-
type: "byValue",
|
|
72639
|
-
values: Array.from(selectedRawValues)
|
|
72680
|
+
const currentLength = this.table.internalProps.dataSource.length;
|
|
72681
|
+
for (let i = 0; i < currentLength; i++) {
|
|
72682
|
+
let displayValue, rawValue;
|
|
72683
|
+
if (-1 !== targetCol) {
|
|
72684
|
+
const row = this.table.columnHeaderLevelCount + i;
|
|
72685
|
+
row < this.table.rowCount && (displayValue = this.table.getCellValue(targetCol, row), rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue);
|
|
72686
|
+
} else displayValue = this.table.getFieldData(String(fieldId), -1 !== targetCol ? targetCol : 0, this.table.columnHeaderLevelCount + i), rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
72687
|
+
null != rawValue && selectedRawValues.add(rawValue);
|
|
72640
72688
|
}
|
|
72641
|
-
|
|
72689
|
+
!arrayEqual(filter.values, Array.from(selectedRawValues)) && this.filterStateManager.dispatch({
|
|
72690
|
+
type: FilterActionType.UPDATE_FILTER,
|
|
72691
|
+
payload: {
|
|
72692
|
+
field: fieldId,
|
|
72693
|
+
values: Array.from(selectedRawValues)
|
|
72694
|
+
}
|
|
72695
|
+
});
|
|
72696
|
+
} else if (!filter) {
|
|
72697
|
+
const availableRawValues = (null === (_b = null === (_a = this.uniqueKeys.get(fieldId)) || void 0 === _a ? void 0 : _a.filter(item => item.count > 0)) || void 0 === _b ? void 0 : _b.map(item => item.rawValue).filter(v => null != v)) || [];
|
|
72698
|
+
this.filterStateManager.dispatch({
|
|
72699
|
+
type: FilterActionType.ADD_FILTER,
|
|
72700
|
+
payload: {
|
|
72701
|
+
field: fieldId,
|
|
72702
|
+
type: "byValue",
|
|
72703
|
+
values: availableRawValues,
|
|
72704
|
+
enable: !1
|
|
72705
|
+
}
|
|
72706
|
+
});
|
|
72707
|
+
}
|
|
72642
72708
|
}
|
|
72643
72709
|
syncCheckboxesWithFilterState(filter) {
|
|
72644
72710
|
if (!filter) return;
|
|
@@ -72651,7 +72717,7 @@
|
|
|
72651
72717
|
rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
72652
72718
|
optionDom.checkbox.checked = selectedRawValues.some(v => v === rawValue);
|
|
72653
72719
|
const count = (null === (_b = null === (_a = this.uniqueKeys.get(filter.field)) || void 0 === _a ? void 0 : _a.find(key => String(key.value) === optionDom.id)) || void 0 === _b ? void 0 : _b.count) || 0;
|
|
72654
|
-
optionDom.
|
|
72720
|
+
optionDom.checkbox.disabled = 0 === count;
|
|
72655
72721
|
});
|
|
72656
72722
|
}
|
|
72657
72723
|
syncSelectAllWithFilterState(filter) {
|
|
@@ -72661,14 +72727,14 @@
|
|
|
72661
72727
|
0 === uniqueValuesCount || 0 === filter.values.length ? (this.selectAllCheckbox.checked = !1, this.selectAllCheckbox.indeterminate = !1) : filter.values.length === uniqueValuesCount ? (this.selectAllCheckbox.checked = !0, this.selectAllCheckbox.indeterminate = !1) : (this.selectAllCheckbox.checked = !1, this.selectAllCheckbox.indeterminate = !0);
|
|
72662
72728
|
}
|
|
72663
72729
|
applyFilter(fieldId = this.selectedField) {
|
|
72664
|
-
var _a
|
|
72665
|
-
const
|
|
72666
|
-
|
|
72730
|
+
var _a;
|
|
72731
|
+
const visibleSelectedKeys = Array.from(this.filterStateManager.getVisibleSelectedValues(fieldId));
|
|
72732
|
+
visibleSelectedKeys.length > 0 && visibleSelectedKeys.length < (null === (_a = this.uniqueKeys.get(fieldId)) || void 0 === _a ? void 0 : _a.length) ? this.filterStateManager.dispatch({
|
|
72667
72733
|
type: FilterActionType.APPLY_FILTERS,
|
|
72668
72734
|
payload: {
|
|
72669
72735
|
field: fieldId,
|
|
72670
72736
|
type: "byValue",
|
|
72671
|
-
values:
|
|
72737
|
+
values: visibleSelectedKeys,
|
|
72672
72738
|
enable: !0
|
|
72673
72739
|
}
|
|
72674
72740
|
}) : this.filterStateManager.dispatch({
|
|
@@ -72709,11 +72775,11 @@
|
|
|
72709
72775
|
rawValue: rawValue
|
|
72710
72776
|
}) => {
|
|
72711
72777
|
const itemDiv = document.createElement("div");
|
|
72712
|
-
applyStyles(itemDiv, this.styles.optionItem);
|
|
72778
|
+
applyStyles(itemDiv, this.styles.optionItem), itemDiv.style.display = "flex";
|
|
72713
72779
|
const label = document.createElement("label");
|
|
72714
72780
|
applyStyles(label, this.styles.optionLabel);
|
|
72715
72781
|
const checkbox = document.createElement("input");
|
|
72716
|
-
checkbox.type = "checkbox", checkbox.value = String(value), checkbox.checked = selectedRawValueSet.has(rawValue), applyStyles(checkbox, this.styles.checkbox);
|
|
72782
|
+
checkbox.type = "checkbox", checkbox.value = String(value), checkbox.checked = selectedRawValueSet.has(rawValue), checkbox.disabled = 0 === count, applyStyles(checkbox, this.styles.checkbox);
|
|
72717
72783
|
const countSpan = document.createElement("span");
|
|
72718
72784
|
countSpan.textContent = String(count), applyStyles(countSpan, this.styles.countSpan), label.append(checkbox, ` ${value}`), itemDiv.append(label, countSpan), this.filterItemsContainer.appendChild(itemDiv);
|
|
72719
72785
|
const itemDom = {
|
|
@@ -72745,7 +72811,10 @@
|
|
|
72745
72811
|
});
|
|
72746
72812
|
}
|
|
72747
72813
|
show() {
|
|
72748
|
-
this.
|
|
72814
|
+
this.collectUniqueColumnValues(this.selectedField), this.updateCandidateCounts(this.selectedField), this.initFilterStateFromTableData(this.selectedField);
|
|
72815
|
+
const uniqueValues = this.uniqueKeys.get(this.selectedField),
|
|
72816
|
+
displayToRawMap = this.displayToRawValueMap.get(this.selectedField);
|
|
72817
|
+
uniqueValues && displayToRawMap && this.filterStateManager.initializeFilterMenuState(this.selectedField, uniqueValues, displayToRawMap), this.filterByValueSearchInput && (this.filterByValueSearchInput.value = ""), this.renderFilterOptions(this.selectedField), this.filterByValuePanel.style.display = "block";
|
|
72749
72818
|
}
|
|
72750
72819
|
hide() {
|
|
72751
72820
|
this.filterByValuePanel.style.display = "none";
|
|
@@ -72992,7 +73061,9 @@
|
|
|
72992
73061
|
|
|
72993
73062
|
class FilterToolbar {
|
|
72994
73063
|
constructor(table, filterStateManager, styles) {
|
|
72995
|
-
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue", this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.table = table, this.filterStateManager = filterStateManager, this.styles = styles, this.valueFilter = new ValueFilter(this.table, this.filterStateManager, this.styles), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, this.styles), this.filterMenuWidth = 300
|
|
73064
|
+
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue", this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.table = table, this.filterStateManager = filterStateManager, this.styles = styles, this.valueFilter = new ValueFilter(this.table, this.filterStateManager, this.styles), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, this.styles), this.filterMenuWidth = 300, this.filterStateManager.subscribe(state => {
|
|
73065
|
+
this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
|
|
73066
|
+
});
|
|
72996
73067
|
}
|
|
72997
73068
|
onTabSwitch(tab) {
|
|
72998
73069
|
this.activeTab = tab, "byValue" === tab ? (this.valueFilter.show(), this.conditionFilter.hide()) : (this.conditionFilter.show(), this.valueFilter.hide());
|
|
@@ -73008,6 +73079,11 @@
|
|
|
73008
73079
|
clearFilter(field) {
|
|
73009
73080
|
this.valueFilter && this.valueFilter.clearFilter(field), this.conditionFilter && this.conditionFilter.clearFilter(field), this.hide();
|
|
73010
73081
|
}
|
|
73082
|
+
updateClearFilterButtonState(field) {
|
|
73083
|
+
const currentFilter = this.filterStateManager.getFilterState(field),
|
|
73084
|
+
hasActiveFilter = currentFilter && currentFilter.enable;
|
|
73085
|
+
this.clearFilterOptionLink.style.display = "inline", this.clearFilterOptionLink.style.opacity = hasActiveFilter ? "1" : "0.5", this.clearFilterOptionLink.style.pointerEvents = hasActiveFilter ? "auto" : "none", this.clearFilterOptionLink.style.cursor = hasActiveFilter ? "pointer" : "not-allowed";
|
|
73086
|
+
}
|
|
73011
73087
|
render(container) {
|
|
73012
73088
|
this.filterMenu = document.createElement("div"), applyStyles(this.filterMenu, this.styles.filterMenu), this.filterMenu.style.width = `${this.filterMenuWidth}px`;
|
|
73013
73089
|
const filterTabsContainer = document.createElement("div");
|
|
@@ -73042,7 +73118,7 @@
|
|
|
73042
73118
|
const field = this.table.internalProps.layoutMap.getHeaderField(col, row);
|
|
73043
73119
|
this.updateSelectedField(field);
|
|
73044
73120
|
const currentFilter = this.filterStateManager.getFilterState(field);
|
|
73045
|
-
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"), setTimeout(() => {
|
|
73121
|
+
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"), this.updateClearFilterButtonState(field), setTimeout(() => {
|
|
73046
73122
|
this.isVisible = !0;
|
|
73047
73123
|
}, 0);
|
|
73048
73124
|
}
|
|
@@ -89947,7 +90023,7 @@
|
|
|
89947
90023
|
importStyle();
|
|
89948
90024
|
}
|
|
89949
90025
|
|
|
89950
|
-
const version = "1.22.4-alpha.
|
|
90026
|
+
const version = "1.22.4-alpha.2";
|
|
89951
90027
|
importStyles();
|
|
89952
90028
|
|
|
89953
90029
|
exports.TYPES = index;
|