@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 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.1";
5
+ export declare const version = "1.22.4-alpha.2";
6
6
  export { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };
package/cjs/index.js CHANGED
@@ -47,4 +47,4 @@ exports.VTable = VTable;
47
47
 
48
48
  const style_manager_1 = require("./styles/style-manager");
49
49
 
50
- exports.version = "1.22.4-alpha.1", (0, style_manager_1.importStyles)();
50
+ exports.version = "1.22.4-alpha.2", (0, style_manager_1.importStyles)();
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\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
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"]}
@@ -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.1", 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");
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
- var _a;
72500
- const isEnable = null === (_a = this.filterStateManager.getFilterState(fieldId)) || void 0 === _a ? void 0 : _a.enable,
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
- if (isEnable) {
72516
- const records = this.table.internalProps.records,
72517
- recordsLength = records.length;
72518
- for (let i = 0; i < recordsLength; i++) {
72519
- let rawValue, displayValue;
72520
- if (-1 !== targetCol) {
72521
- const row = this.table.columnHeaderLevelCount + i;
72522
- rawValue = records[i][fieldId];
72523
- const bodyInfo = this.table.internalProps.layoutMap.getBody(targetCol, row);
72524
- displayValue = bodyInfo && "fieldFormat" in bodyInfo && bodyInfo.fieldFormat && "function" == typeof bodyInfo.fieldFormat ? bodyInfo.fieldFormat({
72525
- [fieldId]: rawValue
72526
- }) : rawValue;
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(displayValueMap.entries()).map(([displayValue, count]) => ({
72565
+ const uniqueValues = Array.from(displayToRawMap.entries()).map(([displayValue, rawValue]) => ({
72543
72566
  value: displayValue,
72544
- count: count,
72545
- rawValue: displayToRawMap.get(displayValue)
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
- if (filter) {
72554
- const updatedValues = selected ? [...(filter.values || []), rawValue] : (filter.values || []).filter(v => v !== rawValue);
72555
- this.filterStateManager.dispatch({
72556
- type: FilterActionType.UPDATE_FILTER,
72557
- payload: {
72558
- field: fieldId,
72559
- values: updatedValues
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: [rawValue]
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
- var _a;
72573
- const filter = this.filterStateManager.getFilterState(fieldId),
72574
- rawValuesToUpdate = selected && (null === (_a = this.uniqueKeys.get(fieldId)) || void 0 === _a ? void 0 : _a.map(item => item.rawValue)) || [];
72575
- if (filter) {
72576
- const updatedValues = selected ? rawValuesToUpdate : [];
72577
- this.filterStateManager.dispatch({
72578
- type: FilterActionType.UPDATE_FILTER,
72579
- payload: {
72580
- field: fieldId,
72581
- values: updatedValues
72582
- }
72583
- });
72584
- } else this.filterStateManager.dispatch({
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: rawValuesToUpdate,
72647
+ values: updatedValues,
72590
72648
  enable: !0
72591
72649
  }
72592
72650
  });
72593
72651
  }
72594
72652
  onSearch(fieldId, value) {
72595
- const filterKeywords = value.toUpperCase().split(" ").filter(s => s),
72596
- items = this.valueFilterOptionList.get(fieldId);
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
- item.itemContainer.style.display = 0 === filterKeywords.length || match ? "flex" : "none";
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
- const filter = this.filterStateManager.getFilterState(fieldId),
72605
- selectedRawValues = new Set(),
72606
- displayToRawMap = this.displayToRawValueMap.get(fieldId);
72607
- let targetCol = -1;
72608
- for (let col = 0; col < this.table.colCount; col++) {
72609
- for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) if (!this.table.internalProps.layoutMap.isHeader(col, row)) {
72610
- const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);
72611
- if (bodyInfo && bodyInfo.field === fieldId) {
72612
- targetCol = col;
72613
- break;
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
- if (-1 !== targetCol) break;
72617
- }
72618
- const currentLength = this.table.internalProps.dataSource.length;
72619
- for (let i = 0; i < currentLength; i++) {
72620
- let displayValue, rawValue;
72621
- if (-1 !== targetCol) {
72622
- const row = this.table.columnHeaderLevelCount + i;
72623
- row < this.table.rowCount && (displayValue = this.table.getCellValue(targetCol, row), rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue);
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.countSpan.textContent = String(count), optionDom.itemContainer.style.display = 0 === count ? "none" : "flex";
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, _b;
72665
- const selectedKeys = (null === (_a = this.filterStateManager.getFilterState(fieldId)) || void 0 === _a ? void 0 : _a.values) || [];
72666
- selectedKeys.length > 0 && selectedKeys.length < (null === (_b = this.uniqueKeys.get(fieldId)) || void 0 === _b ? void 0 : _b.length) ? this.filterStateManager.dispatch({
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: selectedKeys,
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.initFilterStateFromTableData(this.selectedField), this.renderFilterOptions(this.selectedField), this.filterByValuePanel.style.display = "block";
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.1";
90026
+ const version = "1.22.4-alpha.2";
89951
90027
  importStyles();
89952
90028
 
89953
90029
  exports.TYPES = index;