@visactor/vtable-sheet 1.22.4-alpha.2 → 1.22.4-alpha.3

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.2";
5
+ export declare const version = "1.22.4-alpha.3";
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.2", (0, style_manager_1.importStyles)();
50
+ exports.version = "1.22.4-alpha.3", (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.2\";\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.3\";\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.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");
59313
+ if (super(), this.showFrozenIcon = !0, this.version = "1.22.4-alpha.3", 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
@@ -73108,13 +73108,20 @@
73108
73108
  e.stopPropagation();
73109
73109
  });
73110
73110
  }
73111
- show(col, row, filterModes) {
73112
- this.filterModes = filterModes, this.filterModes.includes("byValue") ? this.filterModes.includes("byCondition") || (this.filterTabByCondition.style.display = "none", setTimeout(() => this.onTabSwitch("byValue"), 0)) : (this.filterTabByValue.style.display = "none", setTimeout(() => this.onTabSwitch("byCondition"), 0));
73111
+ adjustMenuPosition(col, row, providedLeft, providedTop) {
73112
+ if ("number" == typeof providedLeft && "number" == typeof providedTop) return this.filterMenu.style.display = this.isVisible ? "block" : "none", this.filterMenu.style.left = `${providedLeft}px`, void (this.filterMenu.style.top = `${providedTop}px`);
73113
+ const effectiveCol = "number" == typeof col ? col : this.currentCol,
73114
+ effectiveRow = "number" == typeof row ? row : this.currentRow;
73115
+ if ("number" != typeof effectiveCol || "number" != typeof effectiveRow) return;
73116
+ this.currentCol = effectiveCol, this.currentRow = effectiveRow;
73113
73117
  let left = 0,
73114
73118
  top = 0;
73115
73119
  const canvasBounds = this.table.canvas.getBoundingClientRect(),
73116
- cell = this.table.getMergeCellRect(col, row);
73117
- cell.right < this.filterMenuWidth ? (left = cell.left + canvasBounds.left, top = cell.bottom + canvasBounds.top) : (left = cell.right + canvasBounds.left - this.filterMenuWidth, top = cell.bottom + canvasBounds.top), this.filterMenu.style.display = "block", this.filterMenu.style.left = `${left}px`, this.filterMenu.style.top = `${top}px`;
73120
+ cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow);
73121
+ cell.right < this.filterMenuWidth ? (left = cell.left + canvasBounds.left, top = cell.bottom + canvasBounds.top) : (left = cell.right + canvasBounds.left - this.filterMenuWidth, top = cell.bottom + canvasBounds.top), this.filterMenu.style.display = this.isVisible ? "block" : "none", this.filterMenu.style.left = `${left}px`, this.filterMenu.style.top = `${top}px`;
73122
+ }
73123
+ show(col, row, filterModes) {
73124
+ this.filterModes = filterModes, this.filterModes.includes("byValue") ? this.filterModes.includes("byCondition") || (this.filterTabByCondition.style.display = "none", this.onTabSwitch("byValue")) : (this.filterTabByValue.style.display = "none", this.onTabSwitch("byCondition")), this.adjustMenuPosition(col, row), this.filterMenu.style.display = "block";
73118
73125
  const field = this.table.internalProps.layoutMap.getHeaderField(col, row);
73119
73126
  this.updateSelectedField(field);
73120
73127
  const currentFilter = this.filterStateManager.getFilterState(field);
@@ -82596,7 +82603,7 @@
82596
82603
  class FilterPlugin {
82597
82604
  constructor(pluginOptions) {
82598
82605
  var _a, _b, _c;
82599
- this.id = "filter", this.name = "Filter", this.runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, TABLE_EVENT_TYPE.ICON_CLICK], this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = pluginOptions, this.pluginOptions.filterIcon = null !== (_b = pluginOptions.filterIcon) && void 0 !== _b ? _b : {
82606
+ this.id = "filter", this.name = "Filter", this.runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, TABLE_EVENT_TYPE.ICON_CLICK, TABLE_EVENT_TYPE.SCROLL], this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = pluginOptions, this.pluginOptions.filterIcon = null !== (_b = pluginOptions.filterIcon) && void 0 !== _b ? _b : {
82600
82607
  name: "filter-icon",
82601
82608
  type: "svg",
82602
82609
  width: 12,
@@ -82619,23 +82626,23 @@
82619
82626
  const eventArgs = args[0],
82620
82627
  runtime = args[1],
82621
82628
  table = args[2];
82622
- if (this.table = table, runtime === TABLE_EVENT_TYPE.BEFORE_INIT) this.filterEngine = new FilterEngine(), this.filterStateManager = new FilterStateManager(this.table, this.filterEngine), this.filterToolbar = new FilterToolbar(this.table, this.filterStateManager, this.pluginOptions.styles), this.filterToolbar.render(document.body), this.updateFilterIcons(eventArgs.options), this.filterStateManager.subscribe(() => {
82623
- this.updateFilterIcons(eventArgs.options), this.table.updateColumns(eventArgs.options.columns, {
82629
+ if (this.table = table, runtime === TABLE_EVENT_TYPE.BEFORE_INIT) this.filterEngine = new FilterEngine(), this.filterStateManager = new FilterStateManager(this.table, this.filterEngine), this.filterToolbar = new FilterToolbar(this.table, this.filterStateManager, this.pluginOptions.styles), this.columns = eventArgs.options.columns, this.filterToolbar.render(document.body), this.updateFilterIcons(this.columns), this.filterStateManager.subscribe(() => {
82630
+ this.updateFilterIcons(this.columns), this.table.updateColumns(this.columns, {
82624
82631
  clearRowHeightCache: !1
82625
82632
  });
82626
- });else if (runtime === TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION) this.pluginOptions = Object.assign(Object.assign({}, this.pluginOptions), eventArgs.options.plugins.find(plugin => plugin.id === this.id).pluginOptions), this.handleOptionUpdate(eventArgs.options);else if (runtime === TABLE_EVENT_TYPE.ICON_CLICK && "filter-icon" === eventArgs.name || "filtering-icon" === eventArgs.name) {
82633
+ });else if (runtime === TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION) this.pluginOptions = Object.assign(Object.assign({}, this.pluginOptions), eventArgs.options.plugins.find(plugin => plugin.id === this.id).pluginOptions), this.columns = eventArgs.options.columns, this.handleOptionUpdate(eventArgs.options);else if (runtime === TABLE_EVENT_TYPE.ICON_CLICK && "filter-icon" === eventArgs.name || "filtering-icon" === eventArgs.name) {
82627
82634
  if (3 === (null === (_a = eventArgs.event) || void 0 === _a ? void 0 : _a.which) || 2 === (null === (_b = eventArgs.event) || void 0 === _b ? void 0 : _b.button) || 2 == (2 & (null === (_c = eventArgs.event) || void 0 === _c ? void 0 : _c.buttons))) return;
82628
82635
  const col = eventArgs.col,
82629
82636
  row = eventArgs.row;
82630
82637
  this.filterToolbar.isVisible ? this.filterToolbar.hide() : this.filterToolbar.show(col, row, this.pluginOptions.filterModes);
82631
- }
82638
+ } else runtime === TABLE_EVENT_TYPE.SCROLL && "horizontal" === eventArgs.scrollDirection && this.filterToolbar.adjustMenuPosition();
82632
82639
  }
82633
82640
  update() {
82634
82641
  this.filterStateManager && this.reapplyActiveFilters();
82635
82642
  }
82636
82643
  handleOptionUpdate(options) {
82637
82644
  const currentActiveFields = this.filterStateManager ? this.filterStateManager.getActiveFilterFields() : [];
82638
- this.filterStateManager && currentActiveFields.length > 0 && this.validateFilterStatesAfterUpdate(options, currentActiveFields), this.updateFilterIcons(options);
82645
+ this.filterStateManager && currentActiveFields.length > 0 && this.validateFilterStatesAfterUpdate(options, currentActiveFields), this.updateFilterIcons(options.columns);
82639
82646
  }
82640
82647
  reapplyActiveFilters() {
82641
82648
  this.filterStateManager.reapplyCurrentFilters();
@@ -82655,11 +82662,11 @@
82655
82662
  });
82656
82663
  });
82657
82664
  }
82658
- updateFilterIcons(options) {
82665
+ updateFilterIcons(columns = []) {
82659
82666
  const filterIcon = this.pluginOptions.filterIcon,
82660
82667
  filteringIcon = this.pluginOptions.filteringIcon,
82661
82668
  isIconEqual = (a, b) => a === b || a && b && "object" == typeof a && "object" == typeof b && a.name === b.name;
82662
- options.columns.forEach(column => {
82669
+ columns.forEach(column => {
82663
82670
  var _a;
82664
82671
  const shouldShow = this.shouldEnableFilterForColumn(column.field, column),
82665
82672
  isFiltering = !!(null === (_a = this.filterStateManager.getFilterState(column.field)) || void 0 === _a ? void 0 : _a.enable);
@@ -82691,13 +82698,10 @@
82691
82698
  };
82692
82699
  }
82693
82700
  setFilterState(filterState) {
82694
- if (!this.filterStateManager || !filterState || !filterState.filters) return;
82695
- this.filterStateManager.dispatch({
82701
+ this.filterStateManager && (this.filterStateManager.dispatch({
82696
82702
  type: FilterActionType.CLEAR_ALL_FILTERS,
82697
82703
  payload: {}
82698
- });
82699
- this.table.columns;
82700
- Object.entries(filterState.filters).forEach(([, config]) => {
82704
+ }), filterState && filterState.filters && Object.entries(filterState.filters).forEach(([, config]) => {
82701
82705
  config.enable && this.filterStateManager.dispatch({
82702
82706
  type: FilterActionType.ADD_FILTER,
82703
82707
  payload: {
@@ -82709,7 +82713,7 @@
82709
82713
  enable: !0
82710
82714
  }
82711
82715
  });
82712
- });
82716
+ }));
82713
82717
  }
82714
82718
  release() {
82715
82719
  this.table = null, this.filterEngine = null, this.filterStateManager = null, this.filterToolbar = null;
@@ -90023,7 +90027,7 @@
90023
90027
  importStyle();
90024
90028
  }
90025
90029
 
90026
- const version = "1.22.4-alpha.2";
90030
+ const version = "1.22.4-alpha.3";
90027
90031
  importStyles();
90028
90032
 
90029
90033
  exports.TYPES = index;