@evotecit/officeimo 0.1.9 → 0.1.21

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.
Files changed (43) hide show
  1. package/README.md +6 -3
  2. package/bundles/officeimo-canopyx-adapter.js +123 -61
  3. package/bundles/officeimo-canopyx-adapter.min.js +1 -1
  4. package/bundles/officeimo-canopyx-adapter.min.mjs +1 -1
  5. package/bundles/officeimo-canopyx-adapter.mjs +109 -48
  6. package/bundles/officeimo-canopyx.js +179 -102
  7. package/bundles/officeimo-canopyx.min.js +1 -1
  8. package/bundles/officeimo-canopyx.min.mjs +1 -1
  9. package/bundles/officeimo-canopyx.mjs +145 -69
  10. package/bundles/officeimo-datatables-adapter.js +7 -7
  11. package/bundles/officeimo-datatables-adapter.min.js +1 -1
  12. package/bundles/officeimo-datatables-adapter.min.mjs +1 -1
  13. package/bundles/officeimo-datatables-adapter.mjs +3 -3
  14. package/bundles/officeimo-datatables.js +63 -48
  15. package/bundles/officeimo-datatables.min.js +1 -1
  16. package/bundles/officeimo-datatables.min.mjs +1 -1
  17. package/bundles/officeimo-datatables.mjs +39 -24
  18. package/bundles/officeimo-xlsx.js +59 -44
  19. package/bundles/officeimo-xlsx.min.js +1 -1
  20. package/bundles/officeimo-xlsx.min.mjs +1 -1
  21. package/bundles/officeimo-xlsx.mjs +39 -24
  22. package/bundles/officeimo.js +61 -46
  23. package/bundles/officeimo.min.js +1 -1
  24. package/bundles/officeimo.min.mjs +1 -1
  25. package/bundles/officeimo.mjs +40 -25
  26. package/dist/integrations/canopyx/index.js +4 -2
  27. package/dist/integrations/canopyx/metadata.js +1 -1
  28. package/dist/integrations/canopyx/pdf-number.js +9 -6
  29. package/dist/integrations/canopyx/rule-predicates.d.ts +1 -1
  30. package/dist/integrations/canopyx/rule-predicates.js +2 -1
  31. package/dist/integrations/canopyx/rules.d.ts +1 -1
  32. package/dist/integrations/canopyx/rules.js +11 -13
  33. package/dist/integrations/canopyx/source.js +44 -7
  34. package/dist/integrations/canopyx/tones.d.ts +10 -0
  35. package/dist/integrations/canopyx/tones.js +12 -0
  36. package/dist/integrations/canopyx/types.d.ts +10 -2
  37. package/dist/xlsx/options.js +1 -1
  38. package/dist/xlsx/portable.js +1 -1
  39. package/dist/xlsx/styles.js +28 -18
  40. package/dist/xlsx/types.d.ts +5 -1
  41. package/dist/xlsx/workbook.js +3 -1
  42. package/dist/xlsx/worksheet.js +5 -2
  43. package/package.json +1 -1
@@ -1389,7 +1389,7 @@ const { captureFields } = _m10;
1389
1389
  /** @internal The workbook owner captures these settings before validation or adapter merging. */
1390
1390
  const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "creator", "title", "subject", "description", "created", "modified"];
1391
1391
  /** @internal Worksheet settings also used by the portable sheet owner. */
1392
- const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
1392
+ const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerBorder", "headerWrap", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
1393
1393
  /** @internal Includes inherited format-specific ceilings before a wrapper combines stream settings. */
1394
1394
  const workbookLimitFields = ["maxRows", "maxCells", "maxTextCharacters", "maxOutputBytes", "maxStyles", "maxSheets", "maxOverflowCharacters", "maxHyperlinks", "maxImageBytes", "maxBufferedCells", "maxBufferedCharacters", "maxMergedRanges", "maxConditionalFormats", "maxDifferentialStyles", "maxCharts", "maxChartPoints", "maxChartTextCharacters", "maxFormulaCharacters", "maxDataValidations", "maxValidationTextCharacters"];
1395
1395
  /** @internal Capture the workbook's known ceilings without dropping supported prototype fields. */
@@ -2409,6 +2409,24 @@ const { DifferentialStyles } = _m34;
2409
2409
 
2410
2410
 
2411
2411
  const spreadsheetNamespace = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
2412
+ const borderStyles = ["thin", "medium", "dashed", "dotted", "thick", "double", "hair", "dashDot", "dashDotDot", "slantDashDot", "mediumDashed", "mediumDashDot", "mediumDashDotDot"];
2413
+ /** @internal Validate and normalize border edges without registering a workbook style. */
2414
+ function normalizeBorder(border) {
2415
+ if (!border || typeof border !== "object")
2416
+ throw new TypeError("A border must be an object of edges.");
2417
+ const result = {};
2418
+ for (const side of ["left", "right", "top", "bottom"]) {
2419
+ const edge = border[side];
2420
+ if (edge) {
2421
+ // Read each property once, so the validated edge is the one that is stored.
2422
+ const { style, color } = edge;
2423
+ if (!borderStyles.includes(style))
2424
+ throw new TypeError("Invalid border style.");
2425
+ result[side] = { style, ...(color ? { color: colorArgb(color) } : {}) };
2426
+ }
2427
+ }
2428
+ return result;
2429
+ }
2412
2430
  const NumberFormats = { General: "General", Integer: "0", Decimal: "0.00", Percent: "0.00%", Date: "yyyy-mm-dd", DateTime: "yyyy-mm-dd hh:mm:ss" };
2413
2431
  function index(value, count, kind) {
2414
2432
  if (!Number.isInteger(value) || value < 0 || value >= count)
@@ -2481,32 +2499,24 @@ class StyleRegistry {
2481
2499
  /** @internal */
2482
2500
  addDifferentials(styles) { this.checkDifferentials(styles); return this.differential.add(styles); }
2483
2501
  addFont(font) {
2484
- if (font.name !== undefined && typeof font.name !== "string")
2502
+ const { name: requested, size: requestedSize, bold, italic, underline, strike, color } = font;
2503
+ if (requested !== undefined && typeof requested !== "string")
2485
2504
  throw new TypeError("Font name must be a string.");
2486
- const name = cleanXml(font.name ?? "Calibri", this.policy), size = font.size ?? 11;
2505
+ const name = cleanXml(requested ?? "Calibri", this.policy), size = requestedSize ?? 11;
2487
2506
  if (typeof name !== "string" || !name || name.length > 31)
2488
2507
  throw new TypeError("Font name must contain 1 through 31 characters.");
2489
2508
  if (!Number.isFinite(size) || size <= 0 || size > 409)
2490
2509
  throw new RangeError("Font size must be positive and at most 409.");
2491
- return deduplicate(this.fonts, this.fontIndexes, { name, size, bold: !!font.bold, italic: !!font.italic, underline: !!font.underline, strike: !!font.strike, color: font.color ? colorArgb(font.color) : "" }, this.maximum);
2510
+ return deduplicate(this.fonts, this.fontIndexes, { name, size, bold: !!bold, italic: !!italic, underline: !!underline, strike: !!strike, color: color ? colorArgb(color) : "" }, this.maximum);
2492
2511
  }
2493
2512
  addFill(fill) {
2494
- const pattern = fill.pattern ?? (fill.color ? "solid" : "none");
2495
- if (!["none", "gray125", "solid"].includes(pattern) || (pattern === "solid" && !fill.color) || (pattern !== "solid" && fill.color))
2513
+ const { color } = fill, pattern = fill.pattern ?? (color ? "solid" : "none");
2514
+ if (!["none", "gray125", "solid"].includes(pattern) || (pattern === "solid" && !color) || (pattern !== "solid" && color))
2496
2515
  throw new TypeError("A solid fill requires a color; none and gray125 have no color.");
2497
- return deduplicate(this.fills, this.fillIndexes, { pattern, color: fill.color ? colorArgb(fill.color) : "" }, this.maximum + 1);
2516
+ return deduplicate(this.fills, this.fillIndexes, { pattern, color: color ? colorArgb(color) : "" }, this.maximum + 1);
2498
2517
  }
2499
2518
  addBorder(border) {
2500
- const result = {};
2501
- for (const side of ["left", "right", "top", "bottom"]) {
2502
- const edge = border[side];
2503
- if (edge) {
2504
- if (!["thin", "medium", "dashed", "dotted", "thick", "double", "hair", "dashDot", "dashDotDot", "slantDashDot", "mediumDashed", "mediumDashDot", "mediumDashDotDot"].includes(edge.style))
2505
- throw new TypeError("Invalid border style.");
2506
- result[side] = { style: edge.style, ...(edge.color ? { color: colorArgb(edge.color) } : {}) };
2507
- }
2508
- }
2509
- return deduplicate(this.borders, this.borderIndexes, result, this.maximum);
2519
+ return deduplicate(this.borders, this.borderIndexes, normalizeBorder(border), this.maximum);
2510
2520
  }
2511
2521
  addNumberFormat(format) {
2512
2522
  if (typeof format !== "string" || !format || format.length > 255)
@@ -2572,7 +2582,7 @@ class StyleRegistry {
2572
2582
  return this.compose(base, { numberFormat: this.styles[this.validateStyle(dateStyle)].numberFormat });
2573
2583
  }
2574
2584
  /** @internal Column shorthand and header style composition. */
2575
- forColumn(column, header = false, fill, date = false) {
2585
+ forColumn(column, header = false, fill, date = false, border) {
2576
2586
  const base = !header && column.style !== undefined ? this.styles[this.validateStyle(column.style)] : undefined;
2577
2587
  const format = column.format !== undefined ? column.format || NumberFormats.General : base?.numberFormat || (column.type === "date" || date ? NumberFormats.DateTime : NumberFormats.General);
2578
2588
  return this.add({
@@ -2581,7 +2591,7 @@ class StyleRegistry {
2581
2591
  wrapText: column.wrapText ?? base?.wrapText ?? false,
2582
2592
  ...(column.alignment ? { alignment: column.alignment } : base?.alignment ? { alignment: base.alignment } : {}),
2583
2593
  ...(base?.verticalAlignment ? { verticalAlignment: base.verticalAlignment } : {}),
2584
- ...(header ? { font: { bold: true } } : {}), ...(fill ? { fill: { color: fill } } : {})
2594
+ ...(header ? { font: { bold: true } } : {}), ...(fill ? { fill: { color: fill } } : {}), ...(border ? { border } : {})
2585
2595
  });
2586
2596
  }
2587
2597
  toXml() {
@@ -2606,7 +2616,7 @@ class StyleRegistry {
2606
2616
  }).join("") + '</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>' + this.differential.toXml() + '</styleSheet>';
2607
2617
  }
2608
2618
  }
2609
- const _exports = Object.freeze({ colorArgb: _m33.colorArgb, spreadsheetNamespace: spreadsheetNamespace, NumberFormats: NumberFormats, validateStylePatch: validateStylePatch, copyStylePatch: copyStylePatch, StyleRegistry: StyleRegistry });
2619
+ const _exports = Object.freeze({ colorArgb: _m33.colorArgb, spreadsheetNamespace: spreadsheetNamespace, normalizeBorder: normalizeBorder, NumberFormats: NumberFormats, validateStylePatch: validateStylePatch, copyStylePatch: copyStylePatch, StyleRegistry: StyleRegistry });
2610
2620
  return _exports;
2611
2621
  })();
2612
2622
 
@@ -3859,8 +3869,9 @@ class Worksheet {
3859
3869
  book.checkLinks(this.links.length);
3860
3870
  this.declared = this.columns.map((column, i) => ({ column, letter: columnName(i + 1),
3861
3871
  style: book.styles.forColumn(column), dateStyle: book.styles.forColumn(column, false, undefined, true),
3862
- headerStyle: this.headerRows ? options.headerStyle ?? book.styles.forColumn({ header: column.header, ...(column.wrapText === undefined ? {} : { wrapText: column.wrapText }),
3863
- ...(column.alignment === undefined ? {} : { alignment: column.alignment }) }, options.boldHeader !== false, options.headerFill) : 0
3872
+ headerStyle: this.headerRows ? options.headerStyle ?? book.styles.forColumn({ header: column.header,
3873
+ ...((options.headerWrap ?? column.wrapText) === undefined ? {} : { wrapText: options.headerWrap ?? column.wrapText }),
3874
+ ...(column.alignment === undefined ? {} : { alignment: column.alignment }) }, options.boldHeader !== false, options.headerFill, false, options.headerBorder) : 0
3864
3875
  }));
3865
3876
  // Register conditional styles only after worksheet construction can no longer reject its options.
3866
3877
  this.conditional = new ConditionalFormats(conditional, book.styles);
@@ -3912,6 +3923,8 @@ class Worksheet {
3912
3923
  throw new TypeError("A frozen header or autofilter requires a header row.");
3913
3924
  if (options.headerFill !== undefined)
3914
3925
  colorArgb(options.headerFill);
3926
+ if (options.headerWrap !== undefined && typeof options.headerWrap !== "boolean")
3927
+ throw new TypeError("headerWrap must be boolean.");
3915
3928
  if (options.headerStyle !== undefined)
3916
3929
  book.styles.validateStyle(options.headerStyle);
3917
3930
  if (options.alternatingRowStyle !== undefined)
@@ -4912,7 +4925,7 @@ const { OpcPackage, officeRelationshipsNamespace, relationshipTypes, corePropert
4912
4925
 
4913
4926
  const { escapeOoxmlAttribute, cleanXml, xmlDeclaration } = _m28;
4914
4927
 
4915
- const { StyleRegistry, spreadsheetNamespace } = _m32;
4928
+ const { StyleRegistry, spreadsheetNamespace, normalizeBorder } = _m32;
4916
4929
 
4917
4930
  const { sheetName, assertXlsxValue, copyValue } = _m35;
4918
4931
 
@@ -4953,6 +4966,8 @@ function captureSheet(options, policy) {
4953
4966
  return { ...captured, columns,
4954
4967
  ...(captured.columnOutlines === undefined ? {} : { columnOutlines: captureColumnOutlines(captured.columnOutlines, columns.length) }),
4955
4968
  ...(captured.headerRows === undefined ? {} : { headerRows: captureTableSpans(captured.headerRows, columns.length) }),
4969
+ // Preflight and every header style read this one snapshot of the edges.
4970
+ ...(captured.headerBorder === undefined ? {} : { headerBorder: normalizeBorder(captured.headerBorder) }),
4956
4971
  ...(footer ? { footer: { ...footer,
4957
4972
  ...(footer.rows === undefined ? {} : { rows: captureTableSpans(footer.rows, columns.length) }),
4958
4973
  ...(footer.values === undefined ? {} : { values: footer.values.map(copyValue) }) } } : {}),
@@ -5403,7 +5418,7 @@ function value(result) {
5403
5418
  function portableSheet(options = {}) {
5404
5419
  options = captureFields(options, sheetOptionFields);
5405
5420
  if (options.headerStyle !== undefined)
5406
- throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader and headerFill.");
5421
+ throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader, headerFill, headerBorder and headerWrap.");
5407
5422
  style(options.alternatingRowStyle);
5408
5423
  style(options.title?.style);
5409
5424
  style(options.footer?.style);
@@ -11757,6 +11772,23 @@ const _exports = Object.freeze({ canopyXlsxWidth: canopyXlsxWidth, canopyNumberF
11757
11772
  return _exports;
11758
11773
  })();
11759
11774
 
11775
+ const _m100 = (() => {
11776
+ /** Stable document palette for CanopyX's standard tones. Browser CSS variables and resolved cell.format are never interpreted.
11777
+ * Each foreground keeps at least a 4.5:1 contrast ratio on its background. */
11778
+ const canopyTonePalette = Object.freeze({
11779
+ info: Object.freeze({ color: "4472C4", background: "DDEBF7", foreground: "1F4E78" }),
11780
+ success: Object.freeze({ color: "70AD47", background: "E2F0D9", foreground: "375623" }),
11781
+ warning: Object.freeze({ color: "FFC000", background: "FFF2CC", foreground: "7F5000" }),
11782
+ danger: Object.freeze({ color: "C00000", background: "FFC7CE", foreground: "9C0006" }),
11783
+ // Muted tones dim the text rather than painting the cell.
11784
+ muted: Object.freeze({ color: "A6A6A6", foreground: "595959" })
11785
+ });
11786
+ /** Default cell presentation for a standard tone; `neutral` and unknown tones have none. */
11787
+ const canopyDefaultTones = new Map(Object.entries(canopyTonePalette).map(([name, tone]) => [name, Object.freeze({ ...(tone.background === undefined ? {} : { background: tone.background }), color: tone.foreground })]));
11788
+ const _exports = Object.freeze({ canopyTonePalette: canopyTonePalette, canopyDefaultTones: canopyDefaultTones });
11789
+ return _exports;
11790
+ })();
11791
+
11760
11792
  const _m96 = (() => {
11761
11793
  const { ExportCell, checkAbort, inputRows } = _m1;
11762
11794
 
@@ -11774,8 +11806,21 @@ const { canopyDiagnostics } = _m95;
11774
11806
 
11775
11807
  const { canopyNumberFormat, canopyXlsxWidth } = _m99;
11776
11808
 
11809
+ const { canopyDefaultTones } = _m100;
11810
+
11777
11811
  const columnFields = ["width", "format", "wrapText", "alignment", "rowHeader", "groups"];
11812
+ // Captured presentations whose cell text already carries the readable content (badge labels are appended below).
11813
+ // Their visual loss is reported, never treated as an unsupported export.
11814
+ const textFallbacks = new Set(["relative-link", "history-series", "badges", "custom-class", "custom-renderer"]);
11815
+ const badgeSeparator = " \u00b7 ";
11778
11816
  const rawIdentities = new WeakMap();
11817
+ // Appended badge labels, kept apart so later passes that re-render a cell's text (PDF numbers) can carry them over.
11818
+ const badgeSuffixes = new WeakMap();
11819
+ /** @internal The text a later pass may re-render, and the badge suffix it must append back unchanged. */
11820
+ function canopyBadgeSplit(cell) {
11821
+ const suffix = badgeSuffixes.get(cell), text = cell.text ?? "";
11822
+ return suffix !== undefined && text.endsWith(suffix) ? { text: text.slice(0, text.length - suffix.length), suffix } : { text, suffix: "" };
11823
+ }
11779
11824
  /** @internal Grouping uses captured identity even when a detail cell displays a relative-link label. */
11780
11825
  function canopyIdentityValue(value) {
11781
11826
  if (!(value instanceof ExportCell))
@@ -11783,6 +11828,20 @@ function canopyIdentityValue(value) {
11783
11828
  const original = rawIdentities.get(value);
11784
11829
  return original === undefined ? value.value : original;
11785
11830
  }
11831
+ function badgeText(input) {
11832
+ if (!Array.isArray(input) || input.length > 64)
11833
+ throw new TypeError("Canopy cell badges must be a bounded array of { text, tone?, title? }.");
11834
+ const labels = [];
11835
+ for (const badge of input) {
11836
+ const text = typeof badge === "string" ? badge : badge && typeof badge === "object" ? badge.text : undefined;
11837
+ if (typeof text !== "string")
11838
+ throw new TypeError("Canopy cell badges must be a bounded array of { text, tone?, title? }.");
11839
+ const label = text.trim();
11840
+ if (label)
11841
+ labels.push(label);
11842
+ }
11843
+ return labels.length ? labels.join(badgeSeparator) : undefined;
11844
+ }
11786
11845
  /** Map an immutable CanopyX record capture to a writer without querying the grid or retaining its body. */
11787
11846
  function createCanopyExport(capture, format, options = {}) {
11788
11847
  return prepareCanopyExport(capture, format, options).source;
@@ -11816,7 +11875,7 @@ function prepareCanopyExport(capture, format, options = {}) {
11816
11875
  throw new TypeError("Canopy presentation diagnostics must be strings.");
11817
11876
  for (const code of items) {
11818
11877
  const diagnostic = { code, ...(rowId === undefined ? {} : { rowId }), ...(columnId === undefined ? {} : { columnId }) };
11819
- (code === "relative-link" || code === "history-series" ? fallback : report)(diagnostic);
11878
+ (textFallbacks.has(code) ? fallback : report)(diagnostic);
11820
11879
  }
11821
11880
  };
11822
11881
  if (request.presentation !== "text" && request.presentation !== "semantic")
@@ -11831,11 +11890,13 @@ function prepareCanopyExport(capture, format, options = {}) {
11831
11890
  return undefined;
11832
11891
  if (typeof name !== "string")
11833
11892
  throw new TypeError("Canopy tones must be strings.");
11834
- const style = tones.get(name);
11893
+ const style = tones.get(name) ?? canopyDefaultTones.get(name);
11835
11894
  if (!style && name !== "neutral")
11836
11895
  fallback({ code: "UNMAPPED_TONE:" + name, rowId, ...(columnId === undefined ? {} : { columnId }) });
11837
11896
  return style;
11838
11897
  };
11898
+ // The full writer fills this with columns read by the native rules it emits, before any row is enumerated.
11899
+ const ruleOperands = new Set();
11839
11900
  const ids = new Set();
11840
11901
  const specs = (pivot?.columns ?? request.columns).map(input => {
11841
11902
  const fields = captureFields(input, ["id", "title", "kind", "width", "pinned", "format", "wrap", "alignment", "diagnostics"]);
@@ -11894,8 +11955,14 @@ function prepareCanopyExport(capture, format, options = {}) {
11894
11955
  diagnostics(cell.diagnostics, row.id, spec.id);
11895
11956
  // A relative destination is navigation metadata, not the visible label.
11896
11957
  // History captures already carry their frozen latest scalar (or null).
11897
- const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link");
11898
- let value = values === "display" || relativeLabel ? cell.text : cell.value;
11958
+ // Columns read by an emitted native rule keep the raw scalar the rule compares, so the label goes to the text only.
11959
+ const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link") && !ruleOperands.has(spec.id);
11960
+ const badges = cell.badges === undefined ? undefined : badgeText(cell.badges);
11961
+ const text = badges ? cell.text ? cell.text + badgeSeparator + badges : badges : cell.text;
11962
+ // Badges belong to the visible label, so a badged text cell exports that composed label rather than a raw/label hybrid.
11963
+ // Typed columns keep their scalar, and native rule operands keep the raw value the rule compares; both carry badges in the text only.
11964
+ const badgedValue = !!badges && values === "raw" && !relativeLabel && spec.kind === "text" && !ruleOperands.has(spec.id);
11965
+ let value = values === "display" || relativeLabel || badgedValue ? text : cell.value;
11899
11966
  if (format === "xlsx" && values === "raw" && spec.kind === "datetime" && typeof value === "string")
11900
11967
  value = datetime(value, dateMode, clock);
11901
11968
  const capturedFormat = pivot && spec.kind === "number" && cell.value !== null ? pivotNumberFormat(cell) : undefined;
@@ -11910,9 +11977,12 @@ function prepareCanopyExport(capture, format, options = {}) {
11910
11977
  if (format === "csv")
11911
11978
  result.push(value);
11912
11979
  else {
11913
- const exported = new ExportCell(value, { text: cell.text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) });
11914
- if (relativeLabel)
11980
+ const exported = new ExportCell(value, { text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) });
11981
+ if (relativeLabel || badgedValue)
11915
11982
  rawIdentities.set(exported, cell.value);
11983
+ // A badge-only label is all suffix: later passes then see the captured label as empty.
11984
+ if (badges)
11985
+ badgeSuffixes.set(exported, cell.text ? badgeSeparator + badges : badges);
11916
11986
  result.push(exported);
11917
11987
  }
11918
11988
  }
@@ -11924,13 +11994,13 @@ function prepareCanopyExport(capture, format, options = {}) {
11924
11994
  if (rowCount !== null && count !== rowCount)
11925
11995
  throw new TypeError("Canopy capture did not produce its declared recordCount.");
11926
11996
  } });
11927
- return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot });
11997
+ return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot, ruleOperands });
11928
11998
  }
11929
- const _exports = Object.freeze({ canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
11999
+ const _exports = Object.freeze({ canopyBadgeSplit: canopyBadgeSplit, canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
11930
12000
  return _exports;
11931
12001
  })();
11932
12002
 
11933
- const _m101 = (() => {
12003
+ const _m102 = (() => {
11934
12004
  const { columnName, excelDate } = _m35;
11935
12005
 
11936
12006
  const { captureFields } = _m10;
@@ -11938,7 +12008,7 @@ const { captureFields } = _m10;
11938
12008
  const { datetime } = _m98;
11939
12009
 
11940
12010
  /** Compile only comparisons whose raw types and native encodings have a faithful bounded mapping. */
11941
- function canopyPredicate(request, grouped, options, root, unsupported, cellTypes) {
12011
+ function canopyPredicate(request, grouped, options, root, unsupported, cellTypes, operands) {
11942
12012
  let nodes = 0;
11943
12013
  const operations = { eq: "=", ne: "<>", gt: ">", ge: ">=", lt: "<", le: "<=" };
11944
12014
  const numeric = (value) => {
@@ -11985,6 +12055,7 @@ function canopyPredicate(request, grouped, options, root, unsupported, cellTypes
11985
12055
  const index = request.columns.findIndex(column => column.id === filter.column);
11986
12056
  if (index < 0)
11987
12057
  return unsupported("RULE_COLUMN_NOT_EXPORTED:" + filter.column);
12058
+ operands?.add(filter.column);
11988
12059
  const column = request.columns[index], letter = columnName(index + 1 + (grouped ? 1 : 0));
11989
12060
  const reference = "INDEX($" + letter + ":$" + letter + ",ROW())", present = "NOT(ISBLANK(" + reference + "))";
11990
12061
  if (column.kind === "number")
@@ -12048,24 +12119,19 @@ const _exports = Object.freeze({ canopyPredicate: canopyPredicate });
12048
12119
  return _exports;
12049
12120
  })();
12050
12121
 
12051
- const _m100 = (() => {
12122
+ const _m101 = (() => {
12052
12123
  const { captureFields } = _m10;
12053
12124
 
12054
- const { canopyPredicate } = _m101;
12125
+ const { canopyPredicate } = _m102;
12126
+
12127
+ const { canopyDefaultTones, canopyTonePalette: palette } = _m100;
12055
12128
 
12056
- // Stable document palette. Browser CSS variables and resolved cell.format are never interpreted.
12057
- const palette = {
12058
- info: { color: "4472C4", background: "DDEBF7", foreground: "1F4E78" },
12059
- success: { color: "70AD47", background: "E2F0D9", foreground: "375623" },
12060
- warning: { color: "FFC000", background: "FFF2CC", foreground: "9C6500" },
12061
- danger: { color: "C00000", background: "FFC7CE", foreground: "9C0006" }
12062
- };
12063
12129
  class UnsupportedRule extends Error {
12064
12130
  }
12065
12131
  const unsupported = (message) => { throw new UnsupportedRule(message); };
12066
12132
  /** Compile declarations in source order, then emit native target/aspect priorities.
12067
12133
  * Data-column selectors let grouped writers exclude generated headings, subtotals and grand totals. */
12068
- function canopyRules(request, format, grouped, tones, report, options = {}, cellTypes) {
12134
+ function canopyRules(request, format, grouped, tones, report, options = {}, cellTypes, operands) {
12069
12135
  if (request.formatRules === undefined || format === "csv")
12070
12136
  return [];
12071
12137
  if (!Array.isArray(request.formatRules) || request.formatRules.length > 1000)
@@ -12104,7 +12170,7 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
12104
12170
  }
12105
12171
  const priorStops = [];
12106
12172
  const priorRows = [], priorCells = new Map();
12107
- const requiredCells = new Map();
12173
+ const requiredCells = new Map(), emittedOperands = new Set();
12108
12174
  const column = (id) => {
12109
12175
  const index = columns.findIndex(column => column.id === id);
12110
12176
  if (index < 0)
@@ -12122,8 +12188,7 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
12122
12188
  return value;
12123
12189
  };
12124
12190
  const style = (name) => {
12125
- const defaults = palette[name];
12126
- const mapping = tones.get(name) ?? (defaults ? { background: defaults.background, color: defaults.foreground } : undefined);
12191
+ const mapping = tones.get(name) ?? canopyDefaultTones.get(name);
12127
12192
  if (!mapping)
12128
12193
  return unsupported("UNMAPPED_RULE_TONE:" + name);
12129
12194
  if ("alignment" in mapping || "wrapText" in mapping)
@@ -12196,8 +12261,8 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
12196
12261
  const range = rule.target === "row" ? { column: columns[0].id, through: columns.at(-1).id } : { column: rule.column };
12197
12262
  if (rule.column !== undefined)
12198
12263
  column(rule.column);
12199
- const ruleCells = new Map();
12200
- const ownPredicate = canopyPredicate(request, grouped, options, rule.when, unsupported, ruleCells);
12264
+ const ruleCells = new Map(), ruleOperands = new Set();
12265
+ const ownPredicate = canopyPredicate(request, grouped, options, rule.when, unsupported, ruleCells, ruleOperands);
12201
12266
  const reachable = priorStops.length ? "AND(" + ownPredicate + ",NOT(OR(" + priorStops.join(",") + ")))" : ownPredicate;
12202
12267
  const previous = rule.target === "row" ? priorRows : priorCells.get(rule.column) ?? [];
12203
12268
  const formula = previous.length ? "AND(" + reachable + ",NOT(OR(" + previous.join(",") + ")))" : reachable;
@@ -12209,6 +12274,8 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
12209
12274
  priorCells.set(rule.column, previous);
12210
12275
  for (const [column, type] of ruleCells)
12211
12276
  requiredCells.set(column, type);
12277
+ for (const id of ruleOperands)
12278
+ emittedOperands.add(id);
12212
12279
  // A matched declaration still stops the row when an earlier tone on that target already won.
12213
12280
  if (rule.stopIfTrue)
12214
12281
  priorStops.push(ownPredicate);
@@ -12224,6 +12291,9 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
12224
12291
  }
12225
12292
  for (const [column, type] of requiredCells)
12226
12293
  cellTypes?.set(column, type);
12294
+ // Only emitted rules read raw cells; a rejected comparison leaves its column free to carry badge labels.
12295
+ for (const id of emittedOperands)
12296
+ operands?.add(id);
12227
12297
  // Canopy paints cell visuals/tones over the row tint. Build masks before changing native priority order.
12228
12298
  return Object.freeze([...visuals, ...cells, ...rows]);
12229
12299
  }
@@ -12231,7 +12301,7 @@ const _exports = Object.freeze({ canopyRules: canopyRules });
12231
12301
  return _exports;
12232
12302
  })();
12233
12303
 
12234
- const _m102 = (() => {
12304
+ const _m103 = (() => {
12235
12305
  const { createGroupedReport } = _m8;
12236
12306
 
12237
12307
  const { checkAbort } = _m4;
@@ -12440,7 +12510,7 @@ const _exports = Object.freeze({ canopyGrouped: canopyGrouped });
12440
12510
  return _exports;
12441
12511
  })();
12442
12512
 
12443
- const _m103 = (() => {
12513
+ const _m104 = (() => {
12444
12514
  const { cellText } = _m35;
12445
12515
 
12446
12516
  const { cleanXml } = _m28;
@@ -12449,7 +12519,7 @@ const { cleanXml } = _m28;
12449
12519
  function canopyAbout(request, options) {
12450
12520
  const result = [["revision", request.revision], ["recordCount", request.recordCount === null ? "unknown" : request.recordCount]];
12451
12521
  if (request.scope !== undefined) {
12452
- if (!["filtered", "selected", "all"].includes(request.scope))
12522
+ if (!["filtered", "visible", "selected", "all"].includes(request.scope))
12453
12523
  throw new TypeError("Invalid Canopy export scope.");
12454
12524
  result.push(["scope", request.scope]);
12455
12525
  }
@@ -12498,7 +12568,7 @@ const _exports = Object.freeze({ canopyAbout: canopyAbout });
12498
12568
  return _exports;
12499
12569
  })();
12500
12570
 
12501
- const _m104 = (() => {
12571
+ const _m105 = (() => {
12502
12572
  const { Workbook, addGroupedXlsx } = _m23;
12503
12573
 
12504
12574
  const { portableWorkbook } = _m53;
@@ -12558,9 +12628,11 @@ const _exports = Object.freeze({ writeCanopyWorkbook: writeCanopyWorkbook });
12558
12628
  return _exports;
12559
12629
  })();
12560
12630
 
12561
- const _m106 = (() => {
12631
+ const _m107 = (() => {
12562
12632
  const { ExportCell } = _m1;
12563
12633
 
12634
+ const { canopyBadgeSplit } = _m96;
12635
+
12564
12636
  /** Fixed numeric formats affect PDF text, not the frozen numeric value used by other writers. */
12565
12637
  function numericProfile(format) {
12566
12638
  // No declared precision: whole values (including counts) stay whole.
@@ -12608,11 +12680,11 @@ function documentDecimal(sample, columns) {
12608
12680
  const profile = numericProfile(cell.presentation?.numberFormat ?? column.format);
12609
12681
  if (!profile)
12610
12682
  continue;
12611
- const captured = capturedNumber(cell.text ?? "", profile);
12683
+ const label = canopyBadgeSplit(cell).text, captured = capturedNumber(label, profile);
12612
12684
  if (!captured)
12613
12685
  continue;
12614
12686
  // A literal percent label is a culture signal without requesting numeric scaling.
12615
- const percentageSignal = profile.percent || profile.prefix.includes("%") || profile.suffix.includes("%") || (cell.text ?? "").includes("%");
12687
+ const percentageSignal = profile.percent || profile.prefix.includes("%") || profile.suffix.includes("%") || label.includes("%");
12616
12688
  if (percentageSignal !== percent)
12617
12689
  continue;
12618
12690
  const match = /([.,])(\d+)$/.exec(captured.number.trimEnd());
@@ -12639,10 +12711,12 @@ function canopyPdfNumbers(sample, columns) {
12639
12711
  return value;
12640
12712
  const format = value.presentation?.numberFormat ?? columns[index].format;
12641
12713
  let profile = numericProfile(format);
12642
- if (!profile || value.text === "")
12714
+ // Badge labels are not part of the number: format the captured label alone, then append them unchanged.
12715
+ const { text: label, suffix: badges } = canopyBadgeSplit(value);
12716
+ if (!profile || label === "")
12643
12717
  return value;
12644
- const captured = capturedNumber(value.text ?? "", profile);
12645
- if (value.text && !captured)
12718
+ const captured = capturedNumber(label, profile);
12719
+ if (label && !captured)
12646
12720
  return value;
12647
12721
  // Undeclared formats normalize only plain numeric labels; a decoration
12648
12722
  // alone does not declare how the raw value was transformed for display.
@@ -12674,7 +12748,7 @@ function canopyPdfNumbers(sample, columns) {
12674
12748
  let suffix = captured?.suffix || profile.suffix;
12675
12749
  if (profile.percent && !profile.suffix)
12676
12750
  suffix = suffix.replace(/%/g, "");
12677
- return new ExportCell(value.value, { text: leadingSign + prefix + formatted + (profile.percent ? "%" : "") + suffix,
12751
+ return new ExportCell(value.value, { text: leadingSign + prefix + formatted + (profile.percent ? "%" : "") + suffix + badges,
12678
12752
  ...(value.presentation ? { presentation: value.presentation } : {}), ...(value.link ? { link: value.link } : {}) });
12679
12753
  });
12680
12754
  }
@@ -12682,7 +12756,7 @@ const _exports = Object.freeze({ canopyPdfNumbers: canopyPdfNumbers });
12682
12756
  return _exports;
12683
12757
  })();
12684
12758
 
12685
- const _m105 = (() => {
12759
+ const _m106 = (() => {
12686
12760
  const { ExportCell, NotSupportedError, OfficeIMOError } = _m1;
12687
12761
 
12688
12762
  const { inputRows, checkAbort, pause, taskYieldDue } = _m4;
@@ -12693,7 +12767,7 @@ const { resolveScalar, selectFont, validateFonts } = _m68;
12693
12767
 
12694
12768
  const { settings } = _m17;
12695
12769
 
12696
- const { canopyPdfNumbers } = _m106;
12770
+ const { canopyPdfNumbers } = _m107;
12697
12771
 
12698
12772
  /** A bounded lookahead is replayed once; no second capture, full-dataset copy or smaller font is needed. */
12699
12773
  async function withCanopyPdfLayout(source, captured, options, write) {
@@ -12811,15 +12885,15 @@ const { prepareCanopyExport } = _m96;
12811
12885
 
12812
12886
  const { canopyPins } = _m99;
12813
12887
 
12814
- const { canopyRules } = _m100;
12888
+ const { canopyRules } = _m101;
12815
12889
 
12816
- const { canopyGrouped } = _m102;
12890
+ const { canopyGrouped } = _m103;
12817
12891
 
12818
- const { canopyAbout } = _m103;
12892
+ const { canopyAbout } = _m104;
12819
12893
 
12820
- const { writeCanopyWorkbook } = _m104;
12894
+ const { writeCanopyWorkbook } = _m105;
12821
12895
 
12822
- const { withCanopyPdfLayout } = _m105;
12896
+ const { withCanopyPdfLayout } = _m106;
12823
12897
 
12824
12898
 
12825
12899
 
@@ -12827,6 +12901,7 @@ const { withCanopyPdfLayout } = _m105;
12827
12901
 
12828
12902
 
12829
12903
 
12904
+ const canopyHeaderFill = "E7EDF5", canopyHeaderBorder = Object.freeze({ bottom: Object.freeze({ style: "thin", color: "A6B4C8" }) });
12830
12905
  /** Write a captured CanopyX grid to a caller-owned destination; partial bytes remain caller-owned on failure. */
12831
12906
  async function writeCanopyTo(capture, format, destination, options = {}) {
12832
12907
  const selected = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "csv", "pdf", "signal", "onDiagnostic", "limits", "onProgress", "grouped", "about"]);
@@ -12866,13 +12941,14 @@ async function writeCanopyTo(capture, format, destination, options = {}) {
12866
12941
  const stream = { ...(signal ? { signal } : {}), ...progress };
12867
12942
  if (format === "xlsx") {
12868
12943
  const formatLimits = mergeAdapterLimits(xlsx.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, { ...selected, xlsx }, formatLimits, report, format);
12869
- const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes);
12944
+ const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes, prepared.ruleOperands);
12870
12945
  if (pivot && (xlsx.sheet?.rowOutline !== undefined || xlsx.sheet?.columnOutlines !== undefined || xlsx.sheet?.maxOutlineLevel !== undefined ||
12871
12946
  xlsx.sheet?.outlineSummaryBelow !== undefined || xlsx.sheet?.outlineSummaryRight !== undefined || xlsx.sheet?.table !== undefined || xlsx.sheet?.footer !== undefined))
12872
12947
  throw new TypeError("Captured pivot metadata owns outlines and totals; worksheet overrides cannot regroup or recalculate it.");
12873
12948
  if (pivot && xlsx.cellValueWriters !== undefined)
12874
12949
  throw new TypeError("Captured pivot exports use frozen values rather than custom cellValueWriters.");
12875
- const sheet = { ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
12950
+ // The header matches the PDF table heading: shaded, bold, wrapped and ruled off from the data.
12951
+ const sheet = { headerFill: canopyHeaderFill, headerBorder: canopyHeaderBorder, headerWrap: true, ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
12876
12952
  freezeHeader: xlsx.sheet?.freezeHeader ?? (xlsx.sheet?.includeHeader !== false),
12877
12953
  freezeColumns: xlsx.sheet?.freezeColumns ?? (pinned ? pinned + (grouped ? 1 : 0) : 0),
12878
12954
  conditionalFormats: [...rules, ...(xlsx.sheet?.conditionalFormats ?? [])] };
@@ -8,9 +8,9 @@ const _core = key => { const value = _modules && _modules.get(key); if (!value)
8
8
  const _c0 = _core("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00");
9
9
  const _c1 = _core("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f");
10
10
  const _c2 = _core("b48bcab805d4c75294dd8d8e8dc57f96d9db3f5af31a8f0ddc6562f010f566e4");
11
- const _c3 = _core("d6587a933b36ccfdba9a2a252389924ac8461f672b3a500082cceb5e53c8b0b6");
11
+ const _c3 = _core("e5310c591178a3de9292f150e2e6f1477b94b895ef0c90840c72adef00f75974");
12
12
  const _c4 = _core("027aafa08408056b10d7d717d63d1f7c0ee20ecfc68213aa66feacc75ec525fe");
13
- const _c5 = _core("a10003e971cd5ec2cee127bc9b029a0aa06fe3d50112838929d7a04a55e177c0");
13
+ const _c5 = _core("62ff1bcbf8ca07e8ab92cd1f6afbd54049346193e18160ab0afec48e03950bba");
14
14
  const _c6 = _core("732224f6995c2478cf33a6ed01f3e3d3dcccb159a731d6db9280104bd5040fc5");
15
15
  const _c7 = _core("d56b24243cff6f3552a2f7b45521af4491494375ec76117e9ac1ebb047ce02da");
16
16
  const _c8 = _core("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3");
@@ -19,7 +19,7 @@ const _c10 = _core("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5
19
19
  const _c11 = _core("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc");
20
20
  const _c12 = _core("f0627ba89e5c8fcb376ebe3ce72dcc8d68c34952981f8703e36b8bb1a9894208");
21
21
  const _c13 = _core("4a089607f7cbe50e13d4382d1cc4e5f6ce32c5773bbec2df84178710f54d9a38");
22
- const _c14 = _core("477ff98f49343b8ec4213008254b57a60dd42d07cb9843b3791d5e5f8e295865");
22
+ const _c14 = _core("8f13b484030aa6b921e616d803614fd061f718241692003633375fab4c36045e");
23
23
  const _c15 = _core("d9c1509dff0538488752433e47cd0927ece5f93c559ad0e32dc56602dfd44596");
24
24
  const _m7 = _modules.get("e37eb5f0298d8bc9492db790f163f4a1d6d8b4293981cfdacfcd9d9810ec9b7f") ?? (() => {
25
25
  /** @internal Runtime-checked calls across the optional third-party API boundary. */
@@ -391,7 +391,7 @@ _modules.set("8edb7b3b19d6555ea24a92d771d532dc0448ad18101fdf663217b4c518b5a31b",
391
391
  return _exports;
392
392
  })();
393
393
 
394
- const _m16 = _modules.get("7b12a415e92cc9ef7212fb3a88007cb6dc37f9f30077165d4897cfa8052f9a3c") ?? (() => {
394
+ const _m16 = _modules.get("bbf637a660bc4dc3fa6fc932009b7b8fb557ad6403af8b5479a1cc857cc020a4") ?? (() => {
395
395
  const { captureFields } = _c10;
396
396
 
397
397
  const { ExportBudget } = _c9;
@@ -432,11 +432,11 @@ function capturePdfOptions(input = {}) {
432
432
  return { ...options, ...(options.limits === undefined ? {} : { limits: capturePdfLimits(options.limits) }) };
433
433
  }
434
434
  const _exports = Object.freeze({ captureCommonLimits: captureCommonLimits, mergeAdapterLimits: mergeAdapterLimits, captureXlsxOptions: captureXlsxOptions, captureCsvOptions: captureCsvOptions, capturePdfOptions: capturePdfOptions });
435
- _modules.set("7b12a415e92cc9ef7212fb3a88007cb6dc37f9f30077165d4897cfa8052f9a3c", _exports);
435
+ _modules.set("bbf637a660bc4dc3fa6fc932009b7b8fb557ad6403af8b5479a1cc857cc020a4", _exports);
436
436
  return _exports;
437
437
  })();
438
438
 
439
- const _m0 = _modules.get("f5f1435b6f22ab08d91f4a58bb66e975d4427bcaf5697011e28bfa9e74b2a2ca") ?? (() => {
439
+ const _m0 = _modules.get("b37d12c21a5952285ca726c58ce4ecc454fef6f97e4d880e5537fe48cba67ebf") ?? (() => {
440
440
  const { BlobByteSink, checkAbort, saveBlob } = _c0;
441
441
 
442
442
  const { notifyProgress } = _c1;
@@ -619,7 +619,7 @@ function registerDataTablesButtons(host, options = {}) {
619
619
  }
620
620
  }
621
621
  const _exports = Object.freeze({ createDataTablesExport: _m11.createDataTablesExport, ExportCell: _c6.ExportCell, PdfFont: _c15.PdfFont, writeDataTableTo: writeDataTableTo, exportDataTable: exportDataTable, registerDataTablesButtons: registerDataTablesButtons });
622
- _modules.set("f5f1435b6f22ab08d91f4a58bb66e975d4427bcaf5697011e28bfa9e74b2a2ca", _exports);
622
+ _modules.set("b37d12c21a5952285ca726c58ce4ecc454fef6f97e4d880e5537fe48cba67ebf", _exports);
623
623
  return _exports;
624
624
  })();
625
625
  Object.assign(officeimo, _m0);