@visactor/vtable-sheet 1.22.4-alpha.11 → 1.22.4-alpha.13

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.11";
5
+ export declare const version = "1.22.4-alpha.13";
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.11", (0, style_manager_1.importStyles)();
50
+ exports.version = "1.22.4-alpha.13", (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,iBAAiB,CAAC;AAEzC,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.11\";\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,iBAAiB,CAAC;AAEzC,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.13\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
@@ -59319,7 +59319,7 @@
59319
59319
  }
59320
59320
  constructor(container, options = {}) {
59321
59321
  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;
59322
- if (super(), this.showFrozenIcon = !0, this.version = "1.22.4-alpha.11", 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");
59322
+ if (super(), this.showFrozenIcon = !0, this.version = "1.22.4-alpha.13", 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");
59323
59323
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
59324
59324
  options: options,
59325
59325
  container: container
@@ -72532,8 +72532,8 @@
72532
72532
  }
72533
72533
 
72534
72534
  class ValueFilter {
72535
- constructor(table, filterStateManager, styles) {
72536
- this.uniqueKeys = new Map(), this.displayToRawValueMap = new Map(), this.valueFilterOptionList = new Map(), this.table = table, this.filterStateManager = filterStateManager, this.styles = styles, this.filterStateManager.subscribe(state => {
72535
+ constructor(table, filterStateManager, pluginOptions) {
72536
+ this.uniqueKeys = new Map(), this.displayToRawValueMap = new Map(), this.valueFilterOptionList = new Map(), this.table = table, this.filterStateManager = filterStateManager, this.pluginOptions = pluginOptions, this.styles = pluginOptions.styles, this.filterStateManager.subscribe(state => {
72537
72537
  const filterState = state.filters.get(this.selectedField);
72538
72538
  filterState && "byValue" === filterState.type && this.updateUI(filterState);
72539
72539
  });
@@ -72564,8 +72564,10 @@
72564
72564
  for (let i = 0; i < recordsLength; i++) {
72565
72565
  let rawValue, displayValue;
72566
72566
  if (-1 !== targetCol) {
72567
- const row = this.table.columnHeaderLevelCount + i;
72568
- rawValue = records[i][fieldId];
72567
+ const row = this.table.columnHeaderLevelCount + i,
72568
+ currentRecord = records[i];
72569
+ if (null == currentRecord) continue;
72570
+ rawValue = currentRecord[fieldId];
72569
72571
  const bodyInfo = this.table.internalProps.layoutMap.getBody(targetCol, row);
72570
72572
  displayValue = bodyInfo && "fieldFormat" in bodyInfo && bodyInfo.fieldFormat && "function" == typeof bodyInfo.fieldFormat ? bodyInfo.fieldFormat({
72571
72573
  [fieldId]: rawValue
@@ -72673,9 +72675,11 @@
72673
72675
  }
72674
72676
  }
72675
72677
  initFilterStateFromTableData(fieldId) {
72676
- var _a, _b;
72677
- const filter = this.filterStateManager.getFilterState(fieldId);
72678
- if (null == filter ? void 0 : filter.enable) {
72678
+ var _a, _b, _c, _d;
72679
+ const filter = this.filterStateManager.getFilterState(fieldId),
72680
+ isEnable = null == filter ? void 0 : filter.enable,
72681
+ syncCheckboxCheckedState = null === (_b = null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.syncCheckboxCheckedState) || void 0 === _b || _b;
72682
+ if (isEnable) {
72679
72683
  const selectedRawValues = new Set(),
72680
72684
  displayToRawMap = this.displayToRawValueMap.get(fieldId);
72681
72685
  let targetCol = -1;
@@ -72698,7 +72702,7 @@
72698
72702
  } else displayValue = this.table.getFieldData(String(fieldId), -1 !== targetCol ? targetCol : 0, this.table.columnHeaderLevelCount + i), rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
72699
72703
  null != rawValue && selectedRawValues.add(rawValue);
72700
72704
  }
72701
- !arrayEqual(filter.values, Array.from(selectedRawValues)) && this.filterStateManager.dispatch({
72705
+ !arrayEqual(filter.values, Array.from(selectedRawValues)) && syncCheckboxCheckedState && this.filterStateManager.dispatch({
72702
72706
  type: FilterActionType.UPDATE_FILTER,
72703
72707
  payload: {
72704
72708
  field: fieldId,
@@ -72706,7 +72710,7 @@
72706
72710
  }
72707
72711
  });
72708
72712
  } else {
72709
- 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)) || [];
72713
+ const availableRawValues = (null === (_d = null === (_c = this.uniqueKeys.get(fieldId)) || void 0 === _c ? void 0 : _c.filter(item => !syncCheckboxCheckedState || item.count > 0)) || void 0 === _d ? void 0 : _d.map(item => item.rawValue).filter(v => null != v)) || [];
72710
72714
  this.filterStateManager.dispatch({
72711
72715
  type: FilterActionType.ADD_FILTER,
72712
72716
  payload: {
@@ -72724,12 +72728,9 @@
72724
72728
  displayToRawMap = this.displayToRawValueMap.get(filter.field),
72725
72729
  optionDomList = this.valueFilterOptionList.get(filter.field);
72726
72730
  null == optionDomList || optionDomList.forEach(optionDom => {
72727
- var _a, _b;
72728
72731
  const displayValue = optionDom.originalValue,
72729
72732
  rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
72730
72733
  optionDom.checkbox.checked = selectedRawValues.some(v => v === rawValue);
72731
- 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;
72732
- optionDom.checkbox.disabled = 0 === count;
72733
72734
  });
72734
72735
  }
72735
72736
  syncSelectAllWithFilterState(filter) {
@@ -72768,6 +72769,9 @@
72768
72769
  var _a;
72769
72770
  this.filterByValuePanel = document.createElement("div"), applyStyles(this.filterByValuePanel, this.styles.filterPanel), this.searchContainer = document.createElement("div"), applyStyles(this.searchContainer, this.styles.searchContainer), this.filterByValueSearchInput = document.createElement("input"), this.filterByValueSearchInput.type = "text", this.filterByValueSearchInput.placeholder = (null === (_a = this.styles.searchInput) || void 0 === _a ? void 0 : _a.placeholder) || "可使用空格分隔多个关键词", applyStyles(this.filterByValueSearchInput, this.styles.searchInput), this.searchContainer.appendChild(this.filterByValueSearchInput), this.optionsContainer = document.createElement("div"), applyStyles(this.optionsContainer, this.styles.optionsContainer), this.selectAllItemDiv = document.createElement("div"), applyStyles(this.selectAllItemDiv, this.styles.optionItem), this.selectAllLabel = document.createElement("label"), applyStyles(this.selectAllLabel, this.styles.optionLabel), this.selectAllCheckbox = document.createElement("input"), this.selectAllCheckbox.type = "checkbox", this.selectAllCheckbox.checked = !0, applyStyles(this.selectAllCheckbox, this.styles.checkbox), this.selectAllLabel.append(this.selectAllCheckbox, " 全选"), this.selectAllItemDiv.appendChild(this.selectAllLabel), this.filterItemsContainer = document.createElement("div"), this.optionsContainer.append(this.selectAllItemDiv, this.filterItemsContainer), this.filterByValuePanel.append(this.searchContainer, this.optionsContainer), container.appendChild(this.filterByValuePanel), this.bindEventForFilterByValue();
72770
72771
  }
72772
+ updatePluginOptions(pluginOptions) {
72773
+ this.pluginOptions = pluginOptions, this.styles = pluginOptions.styles, this.updateStyles(pluginOptions.styles);
72774
+ }
72771
72775
  updateStyles(styles) {
72772
72776
  var _a;
72773
72777
  applyStyles(this.filterByValuePanel, styles.filterPanel), applyStyles(this.searchContainer, styles.searchContainer), this.filterByValueSearchInput.placeholder = (null === (_a = styles.searchInput) || void 0 === _a ? void 0 : _a.placeholder) || "可使用空格分隔多个关键词", applyStyles(this.filterByValueSearchInput, styles.searchInput), applyStyles(this.optionsContainer, styles.optionsContainer), applyStyles(this.selectAllItemDiv, styles.optionItem), applyStyles(this.selectAllLabel, styles.optionLabel), applyStyles(this.selectAllCheckbox, styles.checkbox);
@@ -72788,7 +72792,7 @@
72788
72792
  const label = document.createElement("label");
72789
72793
  applyStyles(label, this.styles.optionLabel);
72790
72794
  const checkbox = document.createElement("input");
72791
- checkbox.type = "checkbox", checkbox.value = String(value), checkbox.checked = selectedRawValueSet.has(rawValue), checkbox.disabled = 0 === count, applyStyles(checkbox, this.styles.checkbox);
72795
+ checkbox.type = "checkbox", checkbox.value = String(value), checkbox.checked = selectedRawValueSet.has(rawValue), applyStyles(checkbox, this.styles.checkbox);
72792
72796
  const countSpan = document.createElement("span");
72793
72797
  countSpan.textContent = String(count), applyStyles(countSpan, this.styles.countSpan), label.append(checkbox, ` ${rawValue}`), itemDiv.append(label, countSpan), this.filterItemsContainer.appendChild(itemDiv);
72794
72798
  const itemDom = {
@@ -72965,8 +72969,8 @@
72965
72969
  }];
72966
72970
 
72967
72971
  class ConditionFilter {
72968
- constructor(table, filterStateManager, styles, conditionCategories) {
72969
- this.currentCategory = FilterOperatorCategory.ALL, this.categories = [], this.operators = [], this.table = table, this.styles = styles, this.filterStateManager = filterStateManager, this.categories = conditionCategories, this.operators = operators;
72972
+ constructor(table, filterStateManager, pluginOptions) {
72973
+ this.currentCategory = FilterOperatorCategory.ALL, this.categories = [], this.operators = [], this.table = table, this.styles = pluginOptions.styles, this.filterStateManager = filterStateManager, this.categories = pluginOptions.conditionCategories, this.operators = operators;
72970
72974
  }
72971
72975
  setSelectedField(fieldId) {
72972
72976
  this.selectedField = fieldId, this.updateOperatorOptions(), this.loadCurrentFilterState();
@@ -73055,6 +73059,9 @@
73055
73059
  placeholder: "最大值"
73056
73060
  }), applyStyles(this.valueInputMax, this.styles.searchInput), this.valueInputMax.style.display = "none", this.rangeInputContainer.appendChild(this.valueInput), this.rangeInputContainer.appendChild(this.andLabel), this.rangeInputContainer.appendChild(this.valueInputMax), this.conditionContainer.appendChild(this.categoryLabel), this.conditionContainer.appendChild(this.categorySelect), this.conditionContainer.appendChild(this.operatorLabel), this.conditionContainer.appendChild(this.operatorSelect), this.conditionContainer.appendChild(this.valueLabel), this.conditionContainer.appendChild(this.rangeInputContainer), this.filterByConditionPanel.appendChild(this.conditionContainer), container.appendChild(this.filterByConditionPanel), this.hide(), this.updateOperatorOptions(), this.bindEvents();
73057
73061
  }
73062
+ updatePluginOptions(filterOptions) {
73063
+ this.styles = filterOptions.styles, this.categories = filterOptions.conditionCategories, this.updateStyles(filterOptions.styles);
73064
+ }
73058
73065
  updateStyles(styles) {
73059
73066
  applyStyles(this.filterByConditionPanel, styles.filterPanel), applyStyles(this.conditionContainer, styles.conditionContainer), applyStyles(this.categoryLabel, styles.formLabel), applyStyles(this.categorySelect, styles.operatorSelect), applyStyles(this.operatorLabel, styles.formLabel), applyStyles(this.operatorSelect, styles.operatorSelect), applyStyles(this.valueLabel, styles.formLabel), applyStyles(this.rangeInputContainer, styles.rangeInputContainer), applyStyles(this.valueInput, styles.searchInput), applyStyles(this.andLabel, styles.addLabel), applyStyles(this.valueInputMax, styles.searchInput);
73060
73067
  }
@@ -73080,11 +73087,14 @@
73080
73087
  }
73081
73088
 
73082
73089
  class FilterToolbar {
73083
- constructor(table, filterStateManager, styles, conditionCategories) {
73084
- 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, conditionCategories), this.filterMenuWidth = 300, this.filterStateManager.subscribe(state => {
73090
+ constructor(table, filterStateManager, pluginOptions) {
73091
+ 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 = pluginOptions.styles, this.valueFilter = new ValueFilter(this.table, this.filterStateManager, pluginOptions), this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, pluginOptions), this.filterMenuWidth = 300, this.filterStateManager.subscribe(state => {
73085
73092
  this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
73086
73093
  });
73087
73094
  }
73095
+ updatePluginOptions(pluginOptions) {
73096
+ this.valueFilter.updatePluginOptions(pluginOptions), this.conditionFilter.updatePluginOptions(pluginOptions);
73097
+ }
73088
73098
  onTabSwitch(tab) {
73089
73099
  this.activeTab = tab, "byValue" === tab ? (this.valueFilter.show(), this.conditionFilter.hide()) : (this.conditionFilter.show(), this.valueFilter.hide());
73090
73100
  const isValueTab = "byValue" === tab;
@@ -82648,7 +82658,7 @@
82648
82658
  }, this.pluginOptions.filterModes && this.pluginOptions.filterModes.length || (this.pluginOptions.filterModes = ["byValue", "byCondition"]), this.pluginOptions.styles = lodashExports.merge({}, filterStyles, pluginOptions.styles), this.pluginOptions.conditionCategories = null !== (_d = pluginOptions.conditionCategories) && void 0 !== _d ? _d : categories;
82649
82659
  }
82650
82660
  initFilterPlugin(eventArgs) {
82651
- this.filterEngine = new FilterEngine(), this.filterStateManager = new FilterStateManager(this.table, this.filterEngine), this.filterToolbar = new FilterToolbar(this.table, this.filterStateManager, this.pluginOptions.styles, this.pluginOptions.conditionCategories), this.columns = eventArgs.options.columns, this.filterToolbar.render(document.body), this.updateFilterIcons(this.columns), this.filterStateManager.subscribe((_, action) => {
82661
+ this.filterEngine = new FilterEngine(), this.filterStateManager = new FilterStateManager(this.table, this.filterEngine), this.filterToolbar = new FilterToolbar(this.table, this.filterStateManager, this.pluginOptions), this.columns = eventArgs.options.columns, this.filterToolbar.render(document.body), this.updateFilterIcons(this.columns), this.filterStateManager.subscribe((_, action) => {
82652
82662
  (null == action ? void 0 : action.type) !== FilterActionType.ADD_FILTER && (this.updateFilterIcons(this.columns), this.table.updateColumns(this.columns, {
82653
82663
  clearRowHeightCache: !1
82654
82664
  }));
@@ -82667,10 +82677,10 @@
82667
82677
  } else runtime === TABLE_EVENT_TYPE.SCROLL && "horizontal" === eventArgs.scrollDirection && this.filterToolbar.adjustMenuPosition();
82668
82678
  }
82669
82679
  updatePluginOptions(pluginOptions) {
82670
- this.pluginOptions = lodashExports.merge(this.pluginOptions, pluginOptions);
82680
+ this.pluginOptions = lodashExports.merge(this.pluginOptions, pluginOptions), this.filterToolbar.updatePluginOptions(this.pluginOptions);
82671
82681
  }
82672
82682
  update() {
82673
- if (this.filterToolbar.updateStyles(this.pluginOptions.styles), this.filterToolbar.valueFilter) {
82683
+ if (this.filterToolbar.valueFilter) {
82674
82684
  const allFields = this.table.columns.map(col => col.field),
82675
82685
  valueFilter = this.filterToolbar.valueFilter;
82676
82686
  allFields.forEach(field => {
@@ -90068,7 +90078,7 @@
90068
90078
  importStyle();
90069
90079
  }
90070
90080
 
90071
- const version = "1.22.4-alpha.11";
90081
+ const version = "1.22.4-alpha.13";
90072
90082
  importStyles();
90073
90083
 
90074
90084
  exports.TYPES = index;