@evotecit/officeimo 0.1.19 → 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 (42) hide show
  1. package/README.md +6 -3
  2. package/bundles/officeimo-canopyx-adapter.js +121 -59
  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 +108 -47
  6. package/bundles/officeimo-canopyx.js +177 -100
  7. package/bundles/officeimo-canopyx.min.js +1 -1
  8. package/bundles/officeimo-canopyx.min.mjs +1 -1
  9. package/bundles/officeimo-canopyx.mjs +144 -68
  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/pdf-number.js +9 -6
  28. package/dist/integrations/canopyx/rule-predicates.d.ts +1 -1
  29. package/dist/integrations/canopyx/rule-predicates.js +2 -1
  30. package/dist/integrations/canopyx/rules.d.ts +1 -1
  31. package/dist/integrations/canopyx/rules.js +11 -13
  32. package/dist/integrations/canopyx/source.js +44 -7
  33. package/dist/integrations/canopyx/tones.d.ts +10 -0
  34. package/dist/integrations/canopyx/tones.js +12 -0
  35. package/dist/integrations/canopyx/types.d.ts +8 -1
  36. package/dist/xlsx/options.js +1 -1
  37. package/dist/xlsx/portable.js +1 -1
  38. package/dist/xlsx/styles.js +28 -18
  39. package/dist/xlsx/types.d.ts +5 -1
  40. package/dist/xlsx/workbook.js +3 -1
  41. package/dist/xlsx/worksheet.js +5 -2
  42. package/package.json +1 -1
@@ -7,8 +7,8 @@ const _c2 = _core("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5c
7
7
  const _c3 = _core("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671");
8
8
  const _c4 = _core("f0627ba89e5c8fcb376ebe3ce72dcc8d68c34952981f8703e36b8bb1a9894208");
9
9
  const _c5 = _core("4a089607f7cbe50e13d4382d1cc4e5f6ce32c5773bbec2df84178710f54d9a38");
10
- const _c6 = _core("477ff98f49343b8ec4213008254b57a60dd42d07cb9843b3791d5e5f8e295865");
11
- const _c7 = _core("d6587a933b36ccfdba9a2a252389924ac8461f672b3a500082cceb5e53c8b0b6");
10
+ const _c6 = _core("8f13b484030aa6b921e616d803614fd061f718241692003633375fab4c36045e");
11
+ const _c7 = _core("e5310c591178a3de9292f150e2e6f1477b94b895ef0c90840c72adef00f75974");
12
12
  const _c8 = _core("b48bcab805d4c75294dd8d8e8dc57f96d9db3f5af31a8f0ddc6562f010f566e4");
13
13
  const _c9 = _core("027aafa08408056b10d7d717d63d1f7c0ee20ecfc68213aa66feacc75ec525fe");
14
14
  const _c10 = _core("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc");
@@ -18,7 +18,7 @@ const _c13 = _core("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a
18
18
  const _c14 = _core("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3");
19
19
  const _c15 = _core("c9fde2c438e186da56f740105fcd41c265fdfdd855a4f1b811d556a02387479b");
20
20
  const _c16 = _core("227236fd7adc9472e188831b8f16fdc69338c4d779f2b69a8abbd8dbfa95b585");
21
- const _c17 = _core("a10003e971cd5ec2cee127bc9b029a0aa06fe3d50112838929d7a04a55e177c0");
21
+ const _c17 = _core("62ff1bcbf8ca07e8ab92cd1f6afbd54049346193e18160ab0afec48e03950bba");
22
22
  const _c18 = _core("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b");
23
23
  const _c19 = _core("d9c1509dff0538488752433e47cd0927ece5f93c559ad0e32dc56602dfd44596");
24
24
  const _c20 = _core("59911f0fe023545e9e97521b268551078bdc4c5f303e446a13b7d52f905e8070");
@@ -248,6 +248,23 @@ const _exports = Object.freeze({ canopyXlsxWidth: canopyXlsxWidth, canopyNumberF
248
248
  return _exports;
249
249
  })();
250
250
 
251
+ const _m19 = (() => {
252
+ /** Stable document palette for CanopyX's standard tones. Browser CSS variables and resolved cell.format are never interpreted.
253
+ * Each foreground keeps at least a 4.5:1 contrast ratio on its background. */
254
+ const canopyTonePalette = Object.freeze({
255
+ info: Object.freeze({ color: "4472C4", background: "DDEBF7", foreground: "1F4E78" }),
256
+ success: Object.freeze({ color: "70AD47", background: "E2F0D9", foreground: "375623" }),
257
+ warning: Object.freeze({ color: "FFC000", background: "FFF2CC", foreground: "7F5000" }),
258
+ danger: Object.freeze({ color: "C00000", background: "FFC7CE", foreground: "9C0006" }),
259
+ // Muted tones dim the text rather than painting the cell.
260
+ muted: Object.freeze({ color: "A6A6A6", foreground: "595959" })
261
+ });
262
+ /** Default cell presentation for a standard tone; `neutral` and unknown tones have none. */
263
+ const canopyDefaultTones = new Map(Object.entries(canopyTonePalette).map(([name, tone]) => [name, Object.freeze({ ...(tone.background === undefined ? {} : { background: tone.background }), color: tone.foreground })]));
264
+ const _exports = Object.freeze({ canopyTonePalette: canopyTonePalette, canopyDefaultTones: canopyDefaultTones });
265
+ return _exports;
266
+ })();
267
+
251
268
  const _m13 = (() => {
252
269
  const { ExportCell, checkAbort, inputRows } = _c0;
253
270
 
@@ -265,8 +282,21 @@ const { canopyDiagnostics } = _m12;
265
282
 
266
283
  const { canopyNumberFormat, canopyXlsxWidth } = _m18;
267
284
 
285
+ const { canopyDefaultTones } = _m19;
286
+
268
287
  const columnFields = ["width", "format", "wrapText", "alignment", "rowHeader", "groups"];
288
+ // Captured presentations whose cell text already carries the readable content (badge labels are appended below).
289
+ // Their visual loss is reported, never treated as an unsupported export.
290
+ const textFallbacks = new Set(["relative-link", "history-series", "badges", "custom-class", "custom-renderer"]);
291
+ const badgeSeparator = " \u00b7 ";
269
292
  const rawIdentities = new WeakMap();
293
+ // Appended badge labels, kept apart so later passes that re-render a cell's text (PDF numbers) can carry them over.
294
+ const badgeSuffixes = new WeakMap();
295
+ /** @internal The text a later pass may re-render, and the badge suffix it must append back unchanged. */
296
+ function canopyBadgeSplit(cell) {
297
+ const suffix = badgeSuffixes.get(cell), text = cell.text ?? "";
298
+ return suffix !== undefined && text.endsWith(suffix) ? { text: text.slice(0, text.length - suffix.length), suffix } : { text, suffix: "" };
299
+ }
270
300
  /** @internal Grouping uses captured identity even when a detail cell displays a relative-link label. */
271
301
  function canopyIdentityValue(value) {
272
302
  if (!(value instanceof ExportCell))
@@ -274,6 +304,20 @@ function canopyIdentityValue(value) {
274
304
  const original = rawIdentities.get(value);
275
305
  return original === undefined ? value.value : original;
276
306
  }
307
+ function badgeText(input) {
308
+ if (!Array.isArray(input) || input.length > 64)
309
+ throw new TypeError("Canopy cell badges must be a bounded array of { text, tone?, title? }.");
310
+ const labels = [];
311
+ for (const badge of input) {
312
+ const text = typeof badge === "string" ? badge : badge && typeof badge === "object" ? badge.text : undefined;
313
+ if (typeof text !== "string")
314
+ throw new TypeError("Canopy cell badges must be a bounded array of { text, tone?, title? }.");
315
+ const label = text.trim();
316
+ if (label)
317
+ labels.push(label);
318
+ }
319
+ return labels.length ? labels.join(badgeSeparator) : undefined;
320
+ }
277
321
  /** Map an immutable CanopyX record capture to a writer without querying the grid or retaining its body. */
278
322
  function createCanopyExport(capture, format, options = {}) {
279
323
  return prepareCanopyExport(capture, format, options).source;
@@ -307,7 +351,7 @@ function prepareCanopyExport(capture, format, options = {}) {
307
351
  throw new TypeError("Canopy presentation diagnostics must be strings.");
308
352
  for (const code of items) {
309
353
  const diagnostic = { code, ...(rowId === undefined ? {} : { rowId }), ...(columnId === undefined ? {} : { columnId }) };
310
- (code === "relative-link" || code === "history-series" ? fallback : report)(diagnostic);
354
+ (textFallbacks.has(code) ? fallback : report)(diagnostic);
311
355
  }
312
356
  };
313
357
  if (request.presentation !== "text" && request.presentation !== "semantic")
@@ -322,11 +366,13 @@ function prepareCanopyExport(capture, format, options = {}) {
322
366
  return undefined;
323
367
  if (typeof name !== "string")
324
368
  throw new TypeError("Canopy tones must be strings.");
325
- const style = tones.get(name);
369
+ const style = tones.get(name) ?? canopyDefaultTones.get(name);
326
370
  if (!style && name !== "neutral")
327
371
  fallback({ code: "UNMAPPED_TONE:" + name, rowId, ...(columnId === undefined ? {} : { columnId }) });
328
372
  return style;
329
373
  };
374
+ // The full writer fills this with columns read by the native rules it emits, before any row is enumerated.
375
+ const ruleOperands = new Set();
330
376
  const ids = new Set();
331
377
  const specs = (pivot?.columns ?? request.columns).map(input => {
332
378
  const fields = captureFields(input, ["id", "title", "kind", "width", "pinned", "format", "wrap", "alignment", "diagnostics"]);
@@ -385,8 +431,14 @@ function prepareCanopyExport(capture, format, options = {}) {
385
431
  diagnostics(cell.diagnostics, row.id, spec.id);
386
432
  // A relative destination is navigation metadata, not the visible label.
387
433
  // History captures already carry their frozen latest scalar (or null).
388
- const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link");
389
- let value = values === "display" || relativeLabel ? cell.text : cell.value;
434
+ // Columns read by an emitted native rule keep the raw scalar the rule compares, so the label goes to the text only.
435
+ const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link") && !ruleOperands.has(spec.id);
436
+ const badges = cell.badges === undefined ? undefined : badgeText(cell.badges);
437
+ const text = badges ? cell.text ? cell.text + badgeSeparator + badges : badges : cell.text;
438
+ // Badges belong to the visible label, so a badged text cell exports that composed label rather than a raw/label hybrid.
439
+ // Typed columns keep their scalar, and native rule operands keep the raw value the rule compares; both carry badges in the text only.
440
+ const badgedValue = !!badges && values === "raw" && !relativeLabel && spec.kind === "text" && !ruleOperands.has(spec.id);
441
+ let value = values === "display" || relativeLabel || badgedValue ? text : cell.value;
390
442
  if (format === "xlsx" && values === "raw" && spec.kind === "datetime" && typeof value === "string")
391
443
  value = datetime(value, dateMode, clock);
392
444
  const capturedFormat = pivot && spec.kind === "number" && cell.value !== null ? pivotNumberFormat(cell) : undefined;
@@ -401,9 +453,12 @@ function prepareCanopyExport(capture, format, options = {}) {
401
453
  if (format === "csv")
402
454
  result.push(value);
403
455
  else {
404
- const exported = new ExportCell(value, { text: cell.text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) });
405
- if (relativeLabel)
456
+ const exported = new ExportCell(value, { text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) });
457
+ if (relativeLabel || badgedValue)
406
458
  rawIdentities.set(exported, cell.value);
459
+ // A badge-only label is all suffix: later passes then see the captured label as empty.
460
+ if (badges)
461
+ badgeSuffixes.set(exported, cell.text ? badgeSeparator + badges : badges);
407
462
  result.push(exported);
408
463
  }
409
464
  }
@@ -415,13 +470,13 @@ function prepareCanopyExport(capture, format, options = {}) {
415
470
  if (rowCount !== null && count !== rowCount)
416
471
  throw new TypeError("Canopy capture did not produce its declared recordCount.");
417
472
  } });
418
- return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot });
473
+ return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot, ruleOperands });
419
474
  }
420
- const _exports = Object.freeze({ canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
475
+ const _exports = Object.freeze({ canopyBadgeSplit: canopyBadgeSplit, canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
421
476
  return _exports;
422
477
  })();
423
478
 
424
- const _m20 = (() => {
479
+ const _m21 = (() => {
425
480
  const { columnName, excelDate } = _c12;
426
481
 
427
482
  const { captureFields } = _c2;
@@ -429,7 +484,7 @@ const { captureFields } = _c2;
429
484
  const { datetime } = _m15;
430
485
 
431
486
  /** Compile only comparisons whose raw types and native encodings have a faithful bounded mapping. */
432
- function canopyPredicate(request, grouped, options, root, unsupported, cellTypes) {
487
+ function canopyPredicate(request, grouped, options, root, unsupported, cellTypes, operands) {
433
488
  let nodes = 0;
434
489
  const operations = { eq: "=", ne: "<>", gt: ">", ge: ">=", lt: "<", le: "<=" };
435
490
  const numeric = (value) => {
@@ -476,6 +531,7 @@ function canopyPredicate(request, grouped, options, root, unsupported, cellTypes
476
531
  const index = request.columns.findIndex(column => column.id === filter.column);
477
532
  if (index < 0)
478
533
  return unsupported("RULE_COLUMN_NOT_EXPORTED:" + filter.column);
534
+ operands?.add(filter.column);
479
535
  const column = request.columns[index], letter = columnName(index + 1 + (grouped ? 1 : 0));
480
536
  const reference = "INDEX($" + letter + ":$" + letter + ",ROW())", present = "NOT(ISBLANK(" + reference + "))";
481
537
  if (column.kind === "number")
@@ -539,24 +595,19 @@ const _exports = Object.freeze({ canopyPredicate: canopyPredicate });
539
595
  return _exports;
540
596
  })();
541
597
 
542
- const _m19 = (() => {
598
+ const _m20 = (() => {
543
599
  const { captureFields } = _c2;
544
600
 
545
- const { canopyPredicate } = _m20;
601
+ const { canopyPredicate } = _m21;
602
+
603
+ const { canopyDefaultTones, canopyTonePalette: palette } = _m19;
546
604
 
547
- // Stable document palette. Browser CSS variables and resolved cell.format are never interpreted.
548
- const palette = {
549
- info: { color: "4472C4", background: "DDEBF7", foreground: "1F4E78" },
550
- success: { color: "70AD47", background: "E2F0D9", foreground: "375623" },
551
- warning: { color: "FFC000", background: "FFF2CC", foreground: "9C6500" },
552
- danger: { color: "C00000", background: "FFC7CE", foreground: "9C0006" }
553
- };
554
605
  class UnsupportedRule extends Error {
555
606
  }
556
607
  const unsupported = (message) => { throw new UnsupportedRule(message); };
557
608
  /** Compile declarations in source order, then emit native target/aspect priorities.
558
609
  * Data-column selectors let grouped writers exclude generated headings, subtotals and grand totals. */
559
- function canopyRules(request, format, grouped, tones, report, options = {}, cellTypes) {
610
+ function canopyRules(request, format, grouped, tones, report, options = {}, cellTypes, operands) {
560
611
  if (request.formatRules === undefined || format === "csv")
561
612
  return [];
562
613
  if (!Array.isArray(request.formatRules) || request.formatRules.length > 1000)
@@ -595,7 +646,7 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
595
646
  }
596
647
  const priorStops = [];
597
648
  const priorRows = [], priorCells = new Map();
598
- const requiredCells = new Map();
649
+ const requiredCells = new Map(), emittedOperands = new Set();
599
650
  const column = (id) => {
600
651
  const index = columns.findIndex(column => column.id === id);
601
652
  if (index < 0)
@@ -613,8 +664,7 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
613
664
  return value;
614
665
  };
615
666
  const style = (name) => {
616
- const defaults = palette[name];
617
- const mapping = tones.get(name) ?? (defaults ? { background: defaults.background, color: defaults.foreground } : undefined);
667
+ const mapping = tones.get(name) ?? canopyDefaultTones.get(name);
618
668
  if (!mapping)
619
669
  return unsupported("UNMAPPED_RULE_TONE:" + name);
620
670
  if ("alignment" in mapping || "wrapText" in mapping)
@@ -687,8 +737,8 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
687
737
  const range = rule.target === "row" ? { column: columns[0].id, through: columns.at(-1).id } : { column: rule.column };
688
738
  if (rule.column !== undefined)
689
739
  column(rule.column);
690
- const ruleCells = new Map();
691
- const ownPredicate = canopyPredicate(request, grouped, options, rule.when, unsupported, ruleCells);
740
+ const ruleCells = new Map(), ruleOperands = new Set();
741
+ const ownPredicate = canopyPredicate(request, grouped, options, rule.when, unsupported, ruleCells, ruleOperands);
692
742
  const reachable = priorStops.length ? "AND(" + ownPredicate + ",NOT(OR(" + priorStops.join(",") + ")))" : ownPredicate;
693
743
  const previous = rule.target === "row" ? priorRows : priorCells.get(rule.column) ?? [];
694
744
  const formula = previous.length ? "AND(" + reachable + ",NOT(OR(" + previous.join(",") + ")))" : reachable;
@@ -700,6 +750,8 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
700
750
  priorCells.set(rule.column, previous);
701
751
  for (const [column, type] of ruleCells)
702
752
  requiredCells.set(column, type);
753
+ for (const id of ruleOperands)
754
+ emittedOperands.add(id);
703
755
  // A matched declaration still stops the row when an earlier tone on that target already won.
704
756
  if (rule.stopIfTrue)
705
757
  priorStops.push(ownPredicate);
@@ -715,6 +767,9 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
715
767
  }
716
768
  for (const [column, type] of requiredCells)
717
769
  cellTypes?.set(column, type);
770
+ // Only emitted rules read raw cells; a rejected comparison leaves its column free to carry badge labels.
771
+ for (const id of emittedOperands)
772
+ operands?.add(id);
718
773
  // Canopy paints cell visuals/tones over the row tint. Build masks before changing native priority order.
719
774
  return Object.freeze([...visuals, ...cells, ...rows]);
720
775
  }
@@ -722,7 +777,7 @@ const _exports = Object.freeze({ canopyRules: canopyRules });
722
777
  return _exports;
723
778
  })();
724
779
 
725
- const _m22 = (() => {
780
+ const _m23 = (() => {
726
781
  const { createGroupedReport } = _c13;
727
782
 
728
783
  const { checkAbort } = _c14;
@@ -931,7 +986,7 @@ const _exports = Object.freeze({ canopyGrouped: canopyGrouped });
931
986
  return _exports;
932
987
  })();
933
988
 
934
- const _m26 = (() => {
989
+ const _m27 = (() => {
935
990
  const { cellText } = _c12;
936
991
 
937
992
  const { cleanXml } = _c16;
@@ -989,7 +1044,7 @@ const _exports = Object.freeze({ canopyAbout: canopyAbout });
989
1044
  return _exports;
990
1045
  })();
991
1046
 
992
- const _m28 = (() => {
1047
+ const _m29 = (() => {
993
1048
  const { Workbook, addGroupedXlsx } = _c7;
994
1049
 
995
1050
  const { portableWorkbook } = _c17;
@@ -1049,9 +1104,11 @@ const _exports = Object.freeze({ writeCanopyWorkbook: writeCanopyWorkbook });
1049
1104
  return _exports;
1050
1105
  })();
1051
1106
 
1052
- const _m34 = (() => {
1107
+ const _m35 = (() => {
1053
1108
  const { ExportCell } = _c0;
1054
1109
 
1110
+ const { canopyBadgeSplit } = _m13;
1111
+
1055
1112
  /** Fixed numeric formats affect PDF text, not the frozen numeric value used by other writers. */
1056
1113
  function numericProfile(format) {
1057
1114
  // No declared precision: whole values (including counts) stay whole.
@@ -1099,11 +1156,11 @@ function documentDecimal(sample, columns) {
1099
1156
  const profile = numericProfile(cell.presentation?.numberFormat ?? column.format);
1100
1157
  if (!profile)
1101
1158
  continue;
1102
- const captured = capturedNumber(cell.text ?? "", profile);
1159
+ const label = canopyBadgeSplit(cell).text, captured = capturedNumber(label, profile);
1103
1160
  if (!captured)
1104
1161
  continue;
1105
1162
  // A literal percent label is a culture signal without requesting numeric scaling.
1106
- const percentageSignal = profile.percent || profile.prefix.includes("%") || profile.suffix.includes("%") || (cell.text ?? "").includes("%");
1163
+ const percentageSignal = profile.percent || profile.prefix.includes("%") || profile.suffix.includes("%") || label.includes("%");
1107
1164
  if (percentageSignal !== percent)
1108
1165
  continue;
1109
1166
  const match = /([.,])(\d+)$/.exec(captured.number.trimEnd());
@@ -1130,10 +1187,12 @@ function canopyPdfNumbers(sample, columns) {
1130
1187
  return value;
1131
1188
  const format = value.presentation?.numberFormat ?? columns[index].format;
1132
1189
  let profile = numericProfile(format);
1133
- if (!profile || value.text === "")
1190
+ // Badge labels are not part of the number: format the captured label alone, then append them unchanged.
1191
+ const { text: label, suffix: badges } = canopyBadgeSplit(value);
1192
+ if (!profile || label === "")
1134
1193
  return value;
1135
- const captured = capturedNumber(value.text ?? "", profile);
1136
- if (value.text && !captured)
1194
+ const captured = capturedNumber(label, profile);
1195
+ if (label && !captured)
1137
1196
  return value;
1138
1197
  // Undeclared formats normalize only plain numeric labels; a decoration
1139
1198
  // alone does not declare how the raw value was transformed for display.
@@ -1165,7 +1224,7 @@ function canopyPdfNumbers(sample, columns) {
1165
1224
  let suffix = captured?.suffix || profile.suffix;
1166
1225
  if (profile.percent && !profile.suffix)
1167
1226
  suffix = suffix.replace(/%/g, "");
1168
- return new ExportCell(value.value, { text: leadingSign + prefix + formatted + (profile.percent ? "%" : "") + suffix,
1227
+ return new ExportCell(value.value, { text: leadingSign + prefix + formatted + (profile.percent ? "%" : "") + suffix + badges,
1169
1228
  ...(value.presentation ? { presentation: value.presentation } : {}), ...(value.link ? { link: value.link } : {}) });
1170
1229
  });
1171
1230
  }
@@ -1173,7 +1232,7 @@ const _exports = Object.freeze({ canopyPdfNumbers: canopyPdfNumbers });
1173
1232
  return _exports;
1174
1233
  })();
1175
1234
 
1176
- const _m31 = (() => {
1235
+ const _m32 = (() => {
1177
1236
  const { ExportCell, NotSupportedError, OfficeIMOError } = _c0;
1178
1237
 
1179
1238
  const { inputRows, checkAbort, pause, taskYieldDue } = _c14;
@@ -1184,7 +1243,7 @@ const { resolveScalar, selectFont, validateFonts } = _c20;
1184
1243
 
1185
1244
  const { settings } = _c5;
1186
1245
 
1187
- const { canopyPdfNumbers } = _m34;
1246
+ const { canopyPdfNumbers } = _m35;
1188
1247
 
1189
1248
  /** A bounded lookahead is replayed once; no second capture, full-dataset copy or smaller font is needed. */
1190
1249
  async function withCanopyPdfLayout(source, captured, options, write) {
@@ -1302,15 +1361,15 @@ const { prepareCanopyExport } = _m13;
1302
1361
 
1303
1362
  const { canopyPins } = _m18;
1304
1363
 
1305
- const { canopyRules } = _m19;
1364
+ const { canopyRules } = _m20;
1306
1365
 
1307
- const { canopyGrouped } = _m22;
1366
+ const { canopyGrouped } = _m23;
1308
1367
 
1309
- const { canopyAbout } = _m26;
1368
+ const { canopyAbout } = _m27;
1310
1369
 
1311
- const { writeCanopyWorkbook } = _m28;
1370
+ const { writeCanopyWorkbook } = _m29;
1312
1371
 
1313
- const { withCanopyPdfLayout } = _m31;
1372
+ const { withCanopyPdfLayout } = _m32;
1314
1373
 
1315
1374
 
1316
1375
 
@@ -1318,6 +1377,7 @@ const { withCanopyPdfLayout } = _m31;
1318
1377
 
1319
1378
 
1320
1379
 
1380
+ const canopyHeaderFill = "E7EDF5", canopyHeaderBorder = Object.freeze({ bottom: Object.freeze({ style: "thin", color: "A6B4C8" }) });
1321
1381
  /** Write a captured CanopyX grid to a caller-owned destination; partial bytes remain caller-owned on failure. */
1322
1382
  async function writeCanopyTo(capture, format, destination, options = {}) {
1323
1383
  const selected = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "csv", "pdf", "signal", "onDiagnostic", "limits", "onProgress", "grouped", "about"]);
@@ -1357,13 +1417,14 @@ async function writeCanopyTo(capture, format, destination, options = {}) {
1357
1417
  const stream = { ...(signal ? { signal } : {}), ...progress };
1358
1418
  if (format === "xlsx") {
1359
1419
  const formatLimits = mergeAdapterLimits(xlsx.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, { ...selected, xlsx }, formatLimits, report, format);
1360
- const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes);
1420
+ const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes, prepared.ruleOperands);
1361
1421
  if (pivot && (xlsx.sheet?.rowOutline !== undefined || xlsx.sheet?.columnOutlines !== undefined || xlsx.sheet?.maxOutlineLevel !== undefined ||
1362
1422
  xlsx.sheet?.outlineSummaryBelow !== undefined || xlsx.sheet?.outlineSummaryRight !== undefined || xlsx.sheet?.table !== undefined || xlsx.sheet?.footer !== undefined))
1363
1423
  throw new TypeError("Captured pivot metadata owns outlines and totals; worksheet overrides cannot regroup or recalculate it.");
1364
1424
  if (pivot && xlsx.cellValueWriters !== undefined)
1365
1425
  throw new TypeError("Captured pivot exports use frozen values rather than custom cellValueWriters.");
1366
- const sheet = { ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
1426
+ // The header matches the PDF table heading: shaded, bold, wrapped and ruled off from the data.
1427
+ const sheet = { headerFill: canopyHeaderFill, headerBorder: canopyHeaderBorder, headerWrap: true, ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
1367
1428
  freezeHeader: xlsx.sheet?.freezeHeader ?? (xlsx.sheet?.includeHeader !== false),
1368
1429
  freezeColumns: xlsx.sheet?.freezeColumns ?? (pinned ? pinned + (grouped ? 1 : 0) : 0),
1369
1430
  conditionalFormats: [...rules, ...(xlsx.sheet?.conditionalFormats ?? [])] };