@visactor/vtable-sheet 1.22.7-alpha.7 → 1.22.7-alpha.8

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.7-alpha.7";
5
+ export declare const version = "1.22.7-alpha.8";
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.7-alpha.7", (0, style_manager_1.importStyles)();
50
+ exports.version = "1.22.7-alpha.8", (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.7-alpha.7\";\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.7-alpha.8\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
@@ -12,5 +12,4 @@ function isPropertyWritable(obj, prop) {
12
12
  Object.defineProperty(exports, "__esModule", {
13
13
  value: !0
14
14
  }), exports.isPropertyWritable = exports.checkTabTitle = void 0, exports.checkTabTitle = checkTabTitle,
15
- exports.isPropertyWritable = isPropertyWritable;
16
- //# sourceMappingURL=index.js.map
15
+ exports.isPropertyWritable = isPropertyWritable;
@@ -7,4 +7,5 @@ Object.defineProperty(exports, "__esModule", {
7
7
  }), exports.WorkSheetEventType = void 0, function(WorkSheetEventType) {
8
8
  WorkSheetEventType.CELL_CLICK = "cell-click", WorkSheetEventType.CELL_VALUE_CHANGED = "cell-value-changed",
9
9
  WorkSheetEventType.SELECTION_CHANGED = "selection-changed", WorkSheetEventType.SELECTION_END = "selection-end";
10
- }(WorkSheetEventType = exports.WorkSheetEventType || (exports.WorkSheetEventType = {}));
10
+ }(WorkSheetEventType = exports.WorkSheetEventType || (exports.WorkSheetEventType = {}));
11
+ //# sourceMappingURL=event.js.map
@@ -55316,6 +55316,7 @@
55316
55316
  }
55317
55317
  setScrollTop(top, event, triggerEvent = !0) {
55318
55318
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
55319
+ if (!this.table) return;
55319
55320
  const totalHeight = this.table.getAllRowsHeight(),
55320
55321
  sizeTolerance = (null === (_a = this.table.options.customConfig) || void 0 === _a ? void 0 : _a._disableColumnAndRowSizeRound) ? 1 : 0;
55321
55322
  top = Math.max(0, Math.min(top, totalHeight - (null !== (_c = null === (_b = this.table.scenegraph) || void 0 === _b ? void 0 : _b.height) && void 0 !== _c ? _c : 0) - sizeTolerance)), top = Math.ceil(top);
@@ -59755,7 +59756,7 @@
59755
59756
  }
59756
59757
  constructor(container, options = {}) {
59757
59758
  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;
59758
- if (super(), this.showFrozenIcon = !0, this.version = "1.22.7-alpha.7", 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");
59759
+ if (super(), this.showFrozenIcon = !0, this.version = "1.22.7-alpha.8", 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");
59759
59760
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
59760
59761
  options: options,
59761
59762
  container: container
@@ -72768,10 +72769,14 @@
72768
72769
  newFilter = new Map(state.filters);
72769
72770
  switch (type) {
72770
72771
  case FilterActionType.ADD_FILTER:
72771
- newFilter.set(payload.field, payload);
72772
+ payload.shouldKeepUnrelatedState ? newFilter.set(payload.field, Object.assign(Object.assign({}, newFilter.get(payload.field)), payload)) : newFilter.set(payload.field, payload);
72772
72773
  break;
72773
72774
  case FilterActionType.REMOVE_FILTER:
72774
- newFilter.delete(payload.field);
72775
+ payload.shouldKeepUnrelatedState && "byValue" === payload.type ? (delete newFilter.get(payload.field).values, newFilter.set(payload.field, Object.assign(Object.assign({}, newFilter.get(payload.field)), {
72776
+ enable: !1
72777
+ }))) : payload.shouldKeepUnrelatedState && "byCondition" === payload.type ? (delete newFilter.get(payload.field).condition, delete newFilter.get(payload.field).operator, newFilter.set(payload.field, Object.assign(Object.assign({}, newFilter.get(payload.field)), {
72778
+ enable: !1
72779
+ }))) : newFilter.delete(payload.field);
72775
72780
  break;
72776
72781
  case FilterActionType.UPDATE_FILTER:
72777
72782
  newFilter.set(payload.field, Object.assign(Object.assign({}, newFilter.get(payload.field)), payload));
@@ -72978,34 +72983,6 @@
72978
72983
  }
72979
72984
  }), this.candidateKeys.set(fieldId, countMap), this.toUnformattedCache.set(fieldId, toUnformatted);
72980
72985
  }
72981
- syncRulesAndCandidateKeys() {
72982
- const currentRecords = this.table.internalProps.dataSource.records,
72983
- filteredFields = this.filterStateManager.getActiveFilterFields();
72984
- currentRecords.forEach(record => {
72985
- filteredFields.forEach(candidateField => {
72986
- var _a, _b;
72987
- const formatFn = this.getFormatFnCache(candidateField);
72988
- if (isValid$4(record)) {
72989
- const originalValue = record[candidateField],
72990
- formattedValue = formatFn(record);
72991
- !(this.toUnformattedCache.get(candidateField) || new Map()).has(formattedValue) && (null === (_b = null === (_a = this.filterStateManager.getFilterState(candidateField)) || void 0 === _a ? void 0 : _a.values) || void 0 === _b ? void 0 : _b.length) > 0 && (this.filterStateManager.getFilterState(candidateField).values.push(originalValue), this.selectedKeys.get(candidateField).add(originalValue));
72992
- }
72993
- });
72994
- });
72995
- }
72996
- syncSelectedKeys() {
72997
- const currentRecords = this.table.internalProps.dataSource.records,
72998
- filteredFields = this.filterStateManager.getActiveFilterFields();
72999
- currentRecords.forEach(record => {
73000
- filteredFields.forEach(candidateField => {
73001
- var _a;
73002
- if (isValid$4(record)) {
73003
- const originalValue = record[candidateField];
73004
- "byCondition" === (null === (_a = this.filterStateManager.getFilterState(candidateField)) || void 0 === _a ? void 0 : _a.type) && (this.selectedKeys.get(candidateField) || this.selectedKeys.set(candidateField, new Set()), this.selectedKeys.get(candidateField).add(originalValue));
73005
- }
73006
- });
73007
- });
73008
- }
73009
72986
  collectCandidateKeysForFilteredColumn(candidateField) {
73010
72987
  var _a, _b;
73011
72988
  const syncFilterItemsState = null === (_b = null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.syncFilterItemsState) || void 0 === _b || _b,
@@ -73054,8 +73031,8 @@
73054
73031
  const isHasFilteredState = this.filterStateManager.getActiveFilterFields(),
73055
73032
  isValueFilter = "byValue" === (null === (_a = this.filterStateManager.getFilterState(fieldId)) || void 0 === _a ? void 0 : _a.type);
73056
73033
  if (isHasFilteredState && isValueFilter) return;
73057
- let selectedValues = new Set();
73058
- const originalValues = new Set();
73034
+ const selectedValues = new Set(),
73035
+ originalValues = new Set();
73059
73036
  this.table.internalProps.records.forEach(record => {
73060
73037
  isValid$4(record) && originalValues.add(record[fieldId]);
73061
73038
  });
@@ -73063,37 +73040,52 @@
73063
73040
  this.table.internalProps.dataSource.records.forEach(record => {
73064
73041
  isValid$4(record) && selectedValues.add(record[fieldId]);
73065
73042
  });
73043
+ !arrayEqual(Array.from(originalValues), Array.from(selectedValues)) && (this.selectedKeys.set(fieldId, selectedValues), this.filterStateManager.dispatch({
73044
+ type: FilterActionType.ADD_FILTER,
73045
+ payload: {
73046
+ field: fieldId,
73047
+ type: "byValue",
73048
+ values: Array.from(selectedValues),
73049
+ enable: !0
73050
+ }
73051
+ }));
73066
73052
  } else {
73067
- const selectedFromRules = (null === (_d = this.filterStateManager.getFilterState(fieldId)) || void 0 === _d ? void 0 : _d.values) || originalValues;
73068
- selectedValues = new Set(selectedFromRules);
73053
+ const selectedRules = null === (_d = this.filterStateManager.getFilterState(fieldId)) || void 0 === _d ? void 0 : _d.values;
73054
+ if (selectedRules) {
73055
+ !arrayEqual(Array.from(originalValues), selectedRules) && (this.selectedKeys.set(fieldId, new Set(selectedRules)), this.filterStateManager.dispatch({
73056
+ type: FilterActionType.ADD_FILTER,
73057
+ payload: {
73058
+ field: fieldId,
73059
+ type: "byValue",
73060
+ values: selectedRules,
73061
+ enable: !0,
73062
+ shouldKeepUnrelatedState: !0
73063
+ }
73064
+ }));
73065
+ } else this.selectedKeys.set(fieldId, originalValues);
73069
73066
  }
73070
- this.selectedKeys.set(fieldId, selectedValues);
73071
- !arrayEqual(Array.from(originalValues), Array.from(selectedValues)) && this.filterStateManager.dispatch({
73072
- type: FilterActionType.ADD_FILTER,
73073
- payload: {
73074
- field: fieldId,
73075
- type: "byValue",
73076
- values: Array.from(selectedValues),
73077
- enable: !0
73078
- }
73079
- });
73080
73067
  }
73081
73068
  applyFilter(fieldId = this.selectedField) {
73069
+ var _a, _b;
73082
73070
  const options = this.valueFilterOptionList.get(fieldId);
73083
73071
  if (!options || 0 === options.length) return;
73084
73072
  const selections = options.map(option => option.checkbox.checked ? option.originalValue : null).filter(key => null !== key).flat();
73085
- this.selectedKeys.set(fieldId, new Set(selections)), selections.length >= 0 && selections.length < this.valueFilterOptionList.get(fieldId).length ? this.filterStateManager.dispatch({
73073
+ this.selectedKeys.set(fieldId, new Set(selections));
73074
+ const syncFilterItemsState = null === (_b = null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.syncFilterItemsState) || void 0 === _b || _b;
73075
+ selections.length >= 0 && selections.length < this.valueFilterOptionList.get(fieldId).length || !syncFilterItemsState ? this.filterStateManager.dispatch({
73086
73076
  type: FilterActionType.APPLY_FILTERS,
73087
73077
  payload: {
73088
73078
  field: fieldId,
73089
73079
  type: "byValue",
73090
73080
  values: selections,
73091
- enable: !0
73081
+ enable: !0,
73082
+ shouldKeepUnrelatedState: !syncFilterItemsState
73092
73083
  }
73093
73084
  }) : this.filterStateManager.dispatch({
73094
73085
  type: FilterActionType.REMOVE_FILTER,
73095
73086
  payload: {
73096
- field: fieldId
73087
+ field: fieldId,
73088
+ type: "byValue"
73097
73089
  }
73098
73090
  });
73099
73091
  }
@@ -73324,10 +73316,10 @@
73324
73316
  this.categorySelect && (this.currentCategory = this.categorySelect.value, this.updateOperatorOptions(), this.syncUIState());
73325
73317
  }
73326
73318
  loadCurrentFilterState() {
73327
- var _a, _b;
73319
+ var _a, _b, _c, _d;
73328
73320
  const filter = this.filterStateManager.getFilterState(this.selectedField),
73329
73321
  syncFilterItemsState = null === (_b = null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.syncFilterItemsState) || void 0 === _b || _b;
73330
- !filter || "byCondition" !== filter.type && syncFilterItemsState ? this.reset() : (filter.operator && this.operatorSelect && (this.operatorSelect.value = filter.operator), void 0 !== filter.condition && this.valueInput && (Array.isArray(filter.condition) ? (this.valueInput.value = String(filter.condition[0]), this.valueInputMax && (this.valueInputMax.value = String(filter.condition[1]))) : (this.valueInput.value = String(filter.condition), this.valueInputMax && (this.valueInputMax.value = ""))), this.syncUIState());
73322
+ filter && "byCondition" === filter.type || !syncFilterItemsState ? (this.operatorSelect && (this.operatorSelect.value = null !== (_c = null == filter ? void 0 : filter.operator) && void 0 !== _c ? _c : operators[0].value), this.valueInput && (Array.isArray(null == filter ? void 0 : filter.condition) ? (this.valueInput.value = String(filter.condition[0]), this.valueInputMax && (this.valueInputMax.value = String(filter.condition[1]))) : (this.valueInput.value = String(null !== (_d = null == filter ? void 0 : filter.condition) && void 0 !== _d ? _d : ""), this.valueInputMax && (this.valueInputMax.value = ""))), this.syncUIState()) : this.reset();
73331
73323
  }
73332
73324
  reset() {
73333
73325
  this.operatorSelect && (this.operatorSelect.selectedIndex = 0), this.valueInput && (this.valueInput.value = "", this.valueInput.placeholder = "请输入筛选值"), this.valueInputMax && (this.valueInputMax.value = ""), this.currentCategory = FilterOperatorCategory.ALL, this.categorySelect && (this.categorySelect.value = FilterOperatorCategory.ALL), this.updateOperatorOptions(), this.syncUIState();
@@ -73345,32 +73337,34 @@
73345
73337
  return "between" === operator || "notBetween" === operator;
73346
73338
  }
73347
73339
  applyFilter(fieldId = this.selectedField) {
73348
- var _a, _b;
73340
+ var _a, _b, _c, _d;
73349
73341
  if (!this.operatorSelect || !this.valueInput) return;
73350
73342
  const operator = null === (_a = this.operatorSelect) || void 0 === _a ? void 0 : _a.value;
73351
73343
  let conditionValue = null === (_b = this.valueInput) || void 0 === _b ? void 0 : _b.value;
73352
- if (this.currentCategory !== FilterOperatorCategory.NUMBER || (conditionValue = parseFloat(conditionValue), !isNaN(conditionValue))) {
73353
- if (this.isRangeOperator(operator)) {
73354
- const minValue = conditionValue;
73355
- let maxValue = this.valueInputMax.value.trim();
73356
- if (this.currentCategory === FilterOperatorCategory.NUMBER) {
73357
- const numMaxValue = parseFloat(maxValue);
73358
- if (isNaN(numMaxValue)) return;
73359
- maxValue = numMaxValue;
73360
- }
73361
- conditionValue = [minValue, maxValue];
73362
- }
73363
- conditionValue || !1 === conditionValue || 0 === conditionValue || this.isBooleanOperator(operator) ? (this.filterStateManager.dispatch({
73364
- type: FilterActionType.APPLY_FILTERS,
73365
- payload: {
73366
- field: fieldId,
73367
- type: "byCondition",
73368
- operator: operator,
73369
- condition: conditionValue,
73370
- enable: !0
73371
- }
73372
- }), this.hide()) : this.clearFilter(fieldId);
73373
- }
73344
+ if (this.currentCategory === FilterOperatorCategory.NUMBER && (conditionValue = parseFloat(conditionValue), isNaN(conditionValue))) return;
73345
+ if (this.isRangeOperator(operator)) {
73346
+ const minValue = conditionValue;
73347
+ let maxValue = this.valueInputMax.value.trim();
73348
+ if (this.currentCategory === FilterOperatorCategory.NUMBER) {
73349
+ const numMaxValue = parseFloat(maxValue);
73350
+ if (isNaN(numMaxValue)) return;
73351
+ maxValue = numMaxValue;
73352
+ }
73353
+ conditionValue = [minValue, maxValue];
73354
+ }
73355
+ if (!conditionValue && !1 !== conditionValue && 0 !== conditionValue && !this.isBooleanOperator(operator)) return void this.clearFilter(fieldId);
73356
+ const syncFilterItemsState = null === (_d = null === (_c = this.pluginOptions) || void 0 === _c ? void 0 : _c.syncFilterItemsState) || void 0 === _d || _d;
73357
+ this.filterStateManager.dispatch({
73358
+ type: FilterActionType.APPLY_FILTERS,
73359
+ payload: {
73360
+ field: fieldId,
73361
+ type: "byCondition",
73362
+ operator: operator,
73363
+ condition: conditionValue,
73364
+ enable: !0,
73365
+ shouldKeepUnrelatedState: !syncFilterItemsState
73366
+ }
73367
+ }), this.hide();
73374
73368
  }
73375
73369
  clearFilter(fieldId) {
73376
73370
  this.filterStateManager.dispatch({
@@ -91040,7 +91034,7 @@
91040
91034
  importStyle();
91041
91035
  }
91042
91036
 
91043
- const version = "1.22.7-alpha.7";
91037
+ const version = "1.22.7-alpha.8";
91044
91038
  importStyles();
91045
91039
 
91046
91040
  exports.TYPES = index;