@cj-tech-master/excelts 1.4.0 → 1.4.1

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v1.4.0
2
+ * @cj-tech-master/excelts v1.4.1
3
3
  * TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
4
4
  * (c) 2025 cjnoname
5
5
  * Released under the MIT License
@@ -2508,7 +2508,20 @@ var ExcelTS = (function(exports) {
2508
2508
  return this.model[address] = validation$2;
2509
2509
  }
2510
2510
  find(address) {
2511
- return this.model[address];
2511
+ const direct = this.model[address];
2512
+ if (direct !== void 0) return direct;
2513
+ const rangeKeys = Object.keys(this.model).filter((k) => k.startsWith("range:"));
2514
+ if (rangeKeys.length === 0) return;
2515
+ const decoded = colCache.decodeAddress(address);
2516
+ for (const key$1 of rangeKeys) {
2517
+ const rangeStr = key$1.slice(6);
2518
+ const rangeDecoded = colCache.decodeEx(rangeStr);
2519
+ if (rangeDecoded.dimensions) {
2520
+ const tl = rangeDecoded.tl;
2521
+ const br = rangeDecoded.br;
2522
+ if (decoded.row >= tl.row && decoded.row <= br.row && decoded.col >= tl.col && decoded.col <= br.col) return this.model[key$1];
2523
+ }
2524
+ }
2512
2525
  }
2513
2526
  remove(address) {
2514
2527
  this.model[address] = void 0;
@@ -34635,7 +34648,21 @@ ${XMLNS_NAMESPACE}.`);
34635
34648
  }
34636
34649
  function optimiseDataValidations(model) {
34637
34650
  if (!model) return [];
34638
- const dvList = Object.entries(model).map(([address, dataValidation]) => ({
34651
+ const rangeValidations = [];
34652
+ const regularModel = {};
34653
+ for (const [key$1, value] of Object.entries(model)) {
34654
+ if (value === void 0 || value === null) continue;
34655
+ if (key$1.startsWith("range:")) {
34656
+ const rangeStr = key$1.slice(6);
34657
+ const { sqref: _sqref, ...rest } = value;
34658
+ rangeValidations.push({
34659
+ ...rest,
34660
+ sqref: rangeStr
34661
+ });
34662
+ } else regularModel[key$1] = value;
34663
+ }
34664
+ if (Object.keys(regularModel).length === 0) return rangeValidations;
34665
+ const dvList = Object.entries(regularModel).map(([address, dataValidation]) => ({
34639
34666
  address,
34640
34667
  dataValidation,
34641
34668
  marked: false
@@ -34644,11 +34671,11 @@ ${XMLNS_NAMESPACE}.`);
34644
34671
  const matchCol = (addr, height, col) => {
34645
34672
  for (let i$2 = 0; i$2 < height; i$2++) {
34646
34673
  const otherAddress = colCache.encodeAddress(addr.row + i$2, col);
34647
- if (!model[otherAddress] || !isEqual(model[addr.address], model[otherAddress])) return false;
34674
+ if (!regularModel[otherAddress] || !isEqual(regularModel[addr.address], regularModel[otherAddress])) return false;
34648
34675
  }
34649
34676
  return true;
34650
34677
  };
34651
- return dvList.map((dv) => {
34678
+ const optimized = dvList.map((dv) => {
34652
34679
  if (!dv.marked) {
34653
34680
  const addr = colCache.decodeEx(dv.address);
34654
34681
  if (addr.dimensions) {
@@ -34660,7 +34687,7 @@ ${XMLNS_NAMESPACE}.`);
34660
34687
  }
34661
34688
  let height = 1;
34662
34689
  let otherAddress = colCache.encodeAddress(addr.row + height, addr.col);
34663
- while (model[otherAddress] && isEqual(dv.dataValidation, model[otherAddress])) {
34690
+ while (regularModel[otherAddress] && isEqual(dv.dataValidation, regularModel[otherAddress])) {
34664
34691
  height++;
34665
34692
  otherAddress = colCache.encodeAddress(addr.row + height, addr.col);
34666
34693
  }
@@ -34685,6 +34712,7 @@ ${XMLNS_NAMESPACE}.`);
34685
34712
  }
34686
34713
  return null;
34687
34714
  }).filter(Boolean);
34715
+ return [...rangeValidations, ...optimized];
34688
34716
  }
34689
34717
  var DataValidationsXform = class extends BaseXform {
34690
34718
  get tag() {
@@ -34769,10 +34797,13 @@ ${XMLNS_NAMESPACE}.`);
34769
34797
  delete this._dataValidation.operator;
34770
34798
  }
34771
34799
  (this._address.split(/\s+/g) || []).forEach((addr) => {
34772
- if (addr.includes(":")) new Range(addr).forEachAddress((address) => {
34773
- this.model[address] = this._dataValidation;
34774
- });
34775
- else this.model[addr] = this._dataValidation;
34800
+ if (addr.includes(":")) {
34801
+ const range$1 = new Range(addr);
34802
+ if ((range$1.bottom - range$1.top + 1) * (range$1.right - range$1.left + 1) <= 1e3) range$1.forEachAddress((address) => {
34803
+ this.model[address] = this._dataValidation;
34804
+ });
34805
+ else this.model[`range:${addr}`] = this._dataValidation;
34806
+ } else this.model[addr] = this._dataValidation;
34776
34807
  });
34777
34808
  return true;
34778
34809
  case "formula1":