@json-to-office/core-docx 4.4.2 → 4.5.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 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/blocks/document.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAMlB,sBAAsB,EAEtB,KAAK,qBAAqB,EAG3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,YAAY,EACV,eAAe,EACf,cAAc,EACd,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAO7C,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnC,eAAO,MAAM,iBAAiB,+BAAyB,CAAC;AAExD,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,EAAE,CA0B3E;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,GAAG,CAuCL;AAED,2EAA2E;AAC3E,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,WAAW,EAClB,KAAK,GAAE,OAAO,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G;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,EAAE,CA0B3E;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,GAAG,CAuCL;AAED,2EAA2E;AAC3E,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,WAAW,EAClB,KAAK,GAAE,OAAO,CAAC,qBAAqB,CAAM,EAC1C,OAAO,GAAE,SAAS,kBAAkB,EAAkC,GACrE,kBAAkB,CAWpB;AAED,wBAAgB,YAAY,CAAC,CAAC,EAC5B,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,WAAW,GACjB,cAAc,CAAC,CAAC,CAAC,CAkBnB;AAoJD,8EAA8E;AAC9E,wBAAsB,uBAAuB,CAAC,CAAC,EAC7C,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,EAC5D,QAAQ,GAAE,WAAW,CAAC,MAAM,CAAa,GACxC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,CAAC,CA+C/C"}
package/dist/index.js CHANGED
@@ -12322,6 +12322,7 @@ function finishDocxBlocks(expanded, document, theme, evaluator, effects, sources
12322
12322
  }
12323
12323
  const props = isBlockRecord(section2.props) ? { ...section2.props } : {};
12324
12324
  if (chrome) {
12325
+ const declaring = local.includes(chrome);
12325
12326
  const environment = {
12326
12327
  ...chrome.environment,
12327
12328
  context: {
@@ -12344,7 +12345,7 @@ function finishDocxBlocks(expanded, document, theme, evaluator, effects, sources
12344
12345
  );
12345
12346
  props[part] = evaluator.expand(compiled, `${path4}/props/${part}`);
12346
12347
  }
12347
- if (props.pageBreak === void 0)
12348
+ if (props.pageBreak === void 0 && declaring)
12348
12349
  props.pageBreak = chrome.settings.pageBreak ?? true;
12349
12350
  }
12350
12351
  for (const effect of local)
@@ -14631,6 +14632,39 @@ var docxRequiredChromeRule = {
14631
14632
  }));
14632
14633
  }
14633
14634
  };
14635
+ var docxExhibitRequiredRule = {
14636
+ id: "docx/exhibit-required",
14637
+ description: "Fewer data exhibits \u2014 charts, or tables of two or more columns \u2014 than a profile or policy expects. Off until one sets a minimum.",
14638
+ code: QUALITY_CODES.EXHIBIT_MISSING,
14639
+ category: "composition",
14640
+ defaultSeverity: "warning",
14641
+ defaultCertainty: "deterministic",
14642
+ formats: ["docx"],
14643
+ defaultEnabled: false,
14644
+ defaultParameters: { minimumExhibits: 1 },
14645
+ evaluate: ({ facts, configuration, profile }) => {
14646
+ const minimum = numberParameter(
14647
+ configuration.parameters,
14648
+ "minimumExhibits",
14649
+ 1
14650
+ );
14651
+ if (minimum <= 0) return [];
14652
+ const charts = facts.filter((fact) => fact.kind === "docx/chart").length;
14653
+ const tables = facts.filter(
14654
+ (fact) => fact.kind === "docx/table" && fact.columns.length >= 2
14655
+ ).length;
14656
+ const exhibits = charts + tables;
14657
+ if (exhibits >= minimum) return [];
14658
+ return [
14659
+ {
14660
+ path: themeFact(facts)?.path ?? "/props",
14661
+ message: exhibits === 0 ? `The document carries no data exhibit \u2014 no chart, no table of two or more columns; the ${profile?.id ?? "selected"} profile expects at least ${minimum}.` : `The document carries ${exhibits} data exhibit(s); the ${profile?.id ?? "selected"} profile expects at least ${minimum}.`,
14662
+ suggestion: "Put the numbers the argument leans on into a chart-figure or a data-table block, with a takeaway and a source, where the text discusses them. A kpi-row summarises; it does not count.",
14663
+ context: { charts, tables, minimum }
14664
+ }
14665
+ ];
14666
+ }
14667
+ };
14634
14668
  var SECTION_CHROME_PARTS = ["header", "footer", "pageNumber"];
14635
14669
  var docxRunningHeadRule = {
14636
14670
  id: "docx/running-head",
@@ -14660,7 +14694,7 @@ var docxRunningHeadRule = {
14660
14694
  {
14661
14695
  path: fact.path,
14662
14696
  message: `Section ${fact.index + 1} carries no ${parts}; the ${profile?.id ?? "selected"} profile expects a running head on every section after the cover.`,
14663
- suggestion: "Invoke a running-head block at the top of the first body section: its section effect fills every later section with the tracker and n / N.",
14697
+ suggestion: "Invoke a running-head block at the top of the first body section: its section effect fills every later section with the title and n / N.",
14664
14698
  context: { section: fact.index, missing }
14665
14699
  }
14666
14700
  ];
@@ -14848,6 +14882,7 @@ var DOCX_QUALITY_RULES = {
14848
14882
  docxPaletteRule,
14849
14883
  docxRequiredChromeRule,
14850
14884
  docxRunningHeadRule,
14885
+ docxExhibitRequiredRule,
14851
14886
  docxTypeScaleRule,
14852
14887
  docxSizeCountRule,
14853
14888
  docxRoleDriftRule
@@ -14857,7 +14892,7 @@ var DOCX_QUALITY_PROFILES = {
14857
14892
  "client-report": {
14858
14893
  id: "client-report",
14859
14894
  formats: ["docx"],
14860
- description: "Client or public-administration report: a running head with page numbers on every section after the cover, a takeaway and a source wherever a block declares them, no heading skipped, every size on the theme scale with at most eight in play, and no page rendered empty under the running head.",
14895
+ description: "Client or public-administration report: a running head with page numbers on every section after the cover, a takeaway and a source wherever a block declares them, no heading skipped, every size on the theme scale with at most eight in play, no page rendered empty or left half blank under the running head, and at least one chart or table.",
14861
14896
  rules: {
14862
14897
  "docx/required-chrome": {
14863
14898
  parameters: { required: ["takeaway", "source"] }
@@ -14876,7 +14911,12 @@ var DOCX_QUALITY_PROFILES = {
14876
14911
  // with no text under the running head is a stray break or an empty
14877
14912
  // section, not a plate. A genuine full-page figure suppresses this at
14878
14913
  // its page through the policy.
14879
- "rendered/empty-page": { severity: "warning" }
14914
+ "rendered/empty-page": { severity: "warning" },
14915
+ // A section that ends early on its own page reads as unfinished; the
14916
+ // judge calls a page two-thirds blank a defect.
14917
+ "rendered/page-underfilled": { severity: "warning" },
14918
+ // A client report argues numbers: at least one chart or real table.
14919
+ "docx/exhibit-required": { enabled: true }
14880
14920
  }
14881
14921
  },
14882
14922
  "executive-report": {
@@ -15137,8 +15177,7 @@ var client_report_docx_blueprint_default = {
15137
15177
  ref: "section-opener",
15138
15178
  slots: {
15139
15179
  number: "01",
15140
- title: "{{Section title: the finding, as a statement}}",
15141
- tracker: "{{Tracker: one word}}"
15180
+ title: "{{Section title: the finding, as a statement}}"
15142
15181
  }
15143
15182
  }
15144
15183
  },
@@ -15195,8 +15234,7 @@ var client_report_docx_blueprint_default = {
15195
15234
  ref: "section-opener",
15196
15235
  slots: {
15197
15236
  number: "02",
15198
- title: "{{Section title: the finding, as a statement}}",
15199
- tracker: "{{Tracker: one word}}"
15237
+ title: "{{Section title: the finding, as a statement}}"
15200
15238
  }
15201
15239
  }
15202
15240
  },
@@ -15268,8 +15306,7 @@ var client_report_docx_blueprint_default = {
15268
15306
  ref: "section-opener",
15269
15307
  slots: {
15270
15308
  number: "03",
15271
- title: "{{Section title: the finding, as a statement}}",
15272
- tracker: "{{Tracker: one word}}"
15309
+ title: "{{Section title: the finding, as a statement}}"
15273
15310
  }
15274
15311
  }
15275
15312
  },
@@ -15322,8 +15359,7 @@ var client_report_docx_blueprint_default = {
15322
15359
  ref: "section-opener",
15323
15360
  slots: {
15324
15361
  number: "04",
15325
- title: "{{Section title: the finding, as a statement}}",
15326
- tracker: "{{Tracker: one word}}"
15362
+ title: "{{Section title: the finding, as a statement}}"
15327
15363
  }
15328
15364
  }
15329
15365
  },
@@ -15344,7 +15380,7 @@ var client_report_docx_blueprint_default = {
15344
15380
  ]
15345
15381
  },
15346
15382
  narrative: {
15347
- description: "Argument-led: takeaways, then three sections of prose with one KPI row and one note as evidence, next steps last.",
15383
+ description: "Argument-led: takeaways, then three sections of prose with one KPI row and one note as evidence, next steps last; one data table in the analysis section carries the numbers the argument leans on.",
15348
15384
  whenToUse: "The brief is a position, an assessment or a recommendation with few numbers; the reader follows an argument.",
15349
15385
  pages: {
15350
15386
  min: 3,
@@ -15394,8 +15430,7 @@ var client_report_docx_blueprint_default = {
15394
15430
  ref: "section-opener",
15395
15431
  slots: {
15396
15432
  number: "01",
15397
- title: "{{Section title: the finding, as a statement}}",
15398
- tracker: "{{Tracker: one word}}"
15433
+ title: "{{Section title: the finding, as a statement}}"
15399
15434
  }
15400
15435
  }
15401
15436
  },
@@ -15435,8 +15470,7 @@ var client_report_docx_blueprint_default = {
15435
15470
  ref: "section-opener",
15436
15471
  slots: {
15437
15472
  number: "02",
15438
- title: "{{Section title: the finding, as a statement}}",
15439
- tracker: "{{Tracker: one word}}"
15473
+ title: "{{Section title: the finding, as a statement}}"
15440
15474
  }
15441
15475
  }
15442
15476
  },
@@ -15473,8 +15507,7 @@ var client_report_docx_blueprint_default = {
15473
15507
  ref: "section-opener",
15474
15508
  slots: {
15475
15509
  number: "03",
15476
- title: "{{Section title: the finding, as a statement}}",
15477
- tracker: "{{Tracker: one word}}"
15510
+ title: "{{Section title: the finding, as a statement}}"
15478
15511
  }
15479
15512
  }
15480
15513
  },
@@ -15484,6 +15517,28 @@ var client_report_docx_blueprint_default = {
15484
15517
  text: "{{Body: two or three short paragraphs of evidence for the section title, each opening with its claim}}"
15485
15518
  }
15486
15519
  },
15520
+ {
15521
+ name: "block",
15522
+ props: {
15523
+ ref: "data-table",
15524
+ slots: {
15525
+ title: "{{Table title: what it compares, and the period}}",
15526
+ labelHeader: "{{Row label}}",
15527
+ labels: ["{{Row 1}}", "{{Row 2}}", "{{Row 3}}"],
15528
+ columns: [
15529
+ {
15530
+ header: "{{Measure (unit)}}",
15531
+ cells: ["{{0.0}}", "{{0.0}}", "{{0.0}}"]
15532
+ },
15533
+ {
15534
+ header: "{{Change}}",
15535
+ cells: ["{{0.0}}", "{{0.0}}", "{{0.0}}"]
15536
+ }
15537
+ ],
15538
+ source: "{{Source: system or document, date}}"
15539
+ }
15540
+ }
15541
+ },
15487
15542
  {
15488
15543
  name: "block",
15489
15544
  props: {
@@ -15524,8 +15579,7 @@ var client_report_docx_blueprint_default = {
15524
15579
  ref: "section-opener",
15525
15580
  slots: {
15526
15581
  number: "04",
15527
- title: "{{Section title: the finding, as a statement}}",
15528
- tracker: "{{Tracker: one word}}"
15582
+ title: "{{Section title: the finding, as a statement}}"
15529
15583
  }
15530
15584
  }
15531
15585
  },