@cj-tech-master/excelts 3.0.0-canary.20251228183403.d3eb98d → 3.0.0

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 v3.0.0-canary.20251228183403.d3eb98d
2
+ * @cj-tech-master/excelts v3.0.0
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
@@ -2999,7 +2999,7 @@ function makePivotTable(worksheet, model) {
2999
2999
  validate(worksheet, model, source);
3000
3000
  const { rows, values } = model;
3001
3001
  const columns = model.columns ?? [];
3002
- const cacheFields = makeCacheFields(source, [...rows, ...columns], values);
3002
+ const cacheFields = makeCacheFields(source, [...rows, ...columns]);
3003
3003
  const nameToIndex = cacheFields.reduce((result, cacheField, index) => {
3004
3004
  result[cacheField.name] = index;
3005
3005
  return result;
@@ -3034,10 +3034,9 @@ function validate(_worksheet, model, source) {
3034
3034
  if (model.values.length < 1) throw new Error("Must have at least one value.");
3035
3035
  if (model.values.length > 1 && columns.length > 0) throw new Error("It is currently not possible to have multiple values when columns are specified. Please either supply an empty array for columns or a single value.");
3036
3036
  }
3037
- function makeCacheFields(source, fieldNamesWithSharedItems, valueFieldNames) {
3037
+ function makeCacheFields(source, fieldNamesWithSharedItems) {
3038
3038
  const names = source.getRow(1).values;
3039
3039
  const sharedItemsFields = new Set(fieldNamesWithSharedItems);
3040
- const valueFields = new Set(valueFieldNames);
3041
3040
  const aggregate = (columnIndex) => {
3042
3041
  const columnValues = source.getColumn(columnIndex).values;
3043
3042
  const uniqueValues = /* @__PURE__ */ new Set();
@@ -3072,7 +3071,7 @@ function makeCacheFields(source, fieldNamesWithSharedItems, valueFieldNames) {
3072
3071
  name,
3073
3072
  sharedItems: aggregate(columnIndex)
3074
3073
  });
3075
- else if (valueFields.has(name)) {
3074
+ else {
3076
3075
  const minMax = getMinMax(columnIndex);
3077
3076
  result.push({
3078
3077
  name,
@@ -3080,10 +3079,7 @@ function makeCacheFields(source, fieldNamesWithSharedItems, valueFieldNames) {
3080
3079
  minValue: minMax?.minValue,
3081
3080
  maxValue: minMax?.maxValue
3082
3081
  });
3083
- } else result.push({
3084
- name,
3085
- sharedItems: null
3086
- });
3082
+ }
3087
3083
  }
3088
3084
  return result;
3089
3085
  }
@@ -14684,25 +14680,9 @@ var CacheField = class {
14684
14680
  }
14685
14681
  render() {
14686
14682
  const escapedName = xmlEncode(this.name);
14687
- if (this.sharedItems === null) {
14688
- if (this.minValue === void 0 || this.maxValue === void 0) return `<cacheField name="${escapedName}" numFmtId="0">
14689
- <sharedItems />
14690
- </cacheField>`;
14691
- return `<cacheField name="${escapedName}" numFmtId="0">
14692
- <sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1" containsInteger="1" minValue="${this.minValue}" maxValue="${this.maxValue}" />
14683
+ if (this.sharedItems === null) return `<cacheField name="${escapedName}" numFmtId="0">
14684
+ <sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1" containsInteger="1"${this.minValue !== void 0 && this.maxValue !== void 0 ? ` minValue="${this.minValue}" maxValue="${this.maxValue}"` : ""} />
14693
14685
  </cacheField>`;
14694
- }
14695
- const allNumeric = this.sharedItems.length > 0 && this.sharedItems.every((item) => typeof item === "number" && Number.isFinite(item));
14696
- const allInteger = allNumeric && this.sharedItems.every((item) => Number.isInteger(item));
14697
- if (allNumeric) {
14698
- const minValue = Math.min(...this.sharedItems);
14699
- const maxValue = Math.max(...this.sharedItems);
14700
- return `<cacheField name="${escapedName}" numFmtId="0">
14701
- <sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1"${allInteger ? " containsInteger=\"1\"" : ""} minValue="${minValue}" maxValue="${maxValue}" count="${this.sharedItems.length}">
14702
- ${this.sharedItems.map((item) => `<n v="${item}" />`).join("")}
14703
- </sharedItems>
14704
- </cacheField>`;
14705
- }
14706
14686
  return `<cacheField name="${escapedName}" numFmtId="0">
14707
14687
  <sharedItems count="${this.sharedItems.length}">
14708
14688
  ${this.sharedItems.map((item) => `<s v="${xmlEncode(String(item))}" />`).join("")}
@@ -14756,13 +14736,16 @@ var CacheFieldXform = class extends BaseXform {
14756
14736
  break;
14757
14737
  case "sharedItems":
14758
14738
  this.inSharedItems = true;
14759
- if (this.model) {
14760
- this.model.containsNumber = attributes.containsNumber === "1";
14761
- this.model.containsInteger = attributes.containsInteger === "1";
14762
- if (attributes.minValue !== void 0) this.model.minValue = parseFloat(attributes.minValue);
14763
- if (attributes.maxValue !== void 0) this.model.maxValue = parseFloat(attributes.maxValue);
14739
+ if (attributes.containsNumber === "1" || attributes.containsInteger === "1") {
14740
+ if (this.model) {
14741
+ this.model.containsNumber = attributes.containsNumber === "1";
14742
+ this.model.containsInteger = attributes.containsInteger === "1";
14743
+ if (attributes.minValue !== void 0) this.model.minValue = parseFloat(attributes.minValue);
14744
+ if (attributes.maxValue !== void 0) this.model.maxValue = parseFloat(attributes.maxValue);
14745
+ this.model.sharedItems = null;
14746
+ }
14747
+ } else if (this.model) {
14764
14748
  if (parseInt(attributes.count || "0", 10) > 0) this.model.sharedItems = [];
14765
- else this.model.sharedItems = null;
14766
14749
  }
14767
14750
  break;
14768
14751
  case "s":
@@ -15426,14 +15409,13 @@ function renderPivotFields(pivotTable) {
15426
15409
  const colSet = new Set(pivotTable.columns);
15427
15410
  const valueSet = new Set(pivotTable.values);
15428
15411
  return pivotTable.cacheFields.map((cacheField, fieldIndex) => {
15429
- return renderPivotField(rowSet.has(fieldIndex), colSet.has(fieldIndex), valueSet.has(fieldIndex), cacheField.sharedItems);
15412
+ return renderPivotField(rowSet.has(fieldIndex) ? "row" : colSet.has(fieldIndex) ? "column" : valueSet.has(fieldIndex) ? "value" : null, cacheField.sharedItems);
15430
15413
  }).join("");
15431
15414
  }
15432
- function renderPivotField(isRow, isCol, isValue, sharedItems) {
15433
- if (isRow || isCol) {
15434
- const axis = isRow ? "axisRow" : "axisCol";
15435
- let axisAttributes = "compact=\"0\" outline=\"0\" showAll=\"0\"";
15436
- if (isValue) axisAttributes = `dataField="1" ${axisAttributes}`;
15415
+ function renderPivotField(fieldType, sharedItems) {
15416
+ if (fieldType === "row" || fieldType === "column") {
15417
+ const axis = fieldType === "row" ? "axisRow" : "axisCol";
15418
+ const axisAttributes = "compact=\"0\" outline=\"0\" showAll=\"0\"";
15437
15419
  const itemsXml = [...sharedItems.map((_item, index) => `<item x="${index}" />`), "<item t=\"default\" />"].join("\n ");
15438
15420
  return `
15439
15421
  <pivotField axis="${axis}" ${axisAttributes}>
@@ -15445,7 +15427,7 @@ function renderPivotField(isRow, isCol, isValue, sharedItems) {
15445
15427
  }
15446
15428
  return `
15447
15429
  <pivotField
15448
- ${isValue ? "dataField=\"1\"" : ""}
15430
+ ${fieldType === "value" ? "dataField=\"1\"" : ""}
15449
15431
  compact="0" outline="0" showAll="0" defaultSubtotal="0"
15450
15432
  />
15451
15433
  `;