@json-to-office/core-docx 4.3.0 → 4.4.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.
@@ -9307,6 +9307,15 @@ function compileColumns(component, scope) {
9307
9307
  if (configs.length === 0) return [];
9308
9308
  const available = getAvailableWidthTwips(ctx.theme, ctx.themeName);
9309
9309
  const { widths, gaps } = columnMetrics(configs, props.gap, available);
9310
+ const stated = widths.map(
9311
+ (width, index) => width + gaps[index] / 2 + (index > 0 ? gaps[index - 1] / 2 : 0)
9312
+ );
9313
+ const statedTotal = stated.reduce((sum, cell) => sum + cell, 0);
9314
+ const scale = statedTotal > available ? available / statedTotal : 1;
9315
+ const exact = stated.map((cell) => cell * scale);
9316
+ const cells = exact.map((cell) => Math.round(cell));
9317
+ const total = exact.reduce((sum, cell) => sum + cell, 0);
9318
+ cells[cells.length - 1] += Math.round(total) - cells.reduce((a, b) => a + b, 0);
9310
9319
  const contents = configs.map(() => []);
9311
9320
  const children = component.children ?? [];
9312
9321
  children.forEach((child, index) => {
@@ -9318,7 +9327,7 @@ function compileColumns(component, scope) {
9318
9327
  kind: "table",
9319
9328
  id: scope.id,
9320
9329
  path: path3,
9321
- columnGrid: { unit: "twips", values: [] },
9330
+ columnGrid: { unit: "twips", values: cells },
9322
9331
  width: { kind: "percent", value: 100 },
9323
9332
  layout: "fixed",
9324
9333
  borders: NO_BORDERS,
@@ -9343,7 +9352,7 @@ function compileColumns(component, scope) {
9343
9352
  children: []
9344
9353
  }
9345
9354
  ],
9346
- widthTwips: widths[index],
9355
+ widthTwips: cells[index],
9347
9356
  margins: {
9348
9357
  topTwips: 0,
9349
9358
  rightTwips: gaps[index] / 2,
@@ -11688,12 +11697,6 @@ function determineComponentLayout(component) {
11688
11697
  }
11689
11698
  return "single";
11690
11699
  }
11691
- if ("children" in component && component.children) {
11692
- const hasColumns = component.children.some(
11693
- (child) => isColumnsComponent(child)
11694
- );
11695
- return hasColumns ? "multi-column" : "single";
11696
- }
11697
11700
  return "single";
11698
11701
  }
11699
11702
  function processLayoutComponents(components) {