@bsuite/page-builder 1.0.2 → 1.0.3

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.
@@ -44,6 +44,40 @@ export interface ComputeAutoHeightRowsOptions {
44
44
  * time. Ceiling always over-allocates rather than under-allocates, trading
45
45
  * a few pixels of empty card padding for a guarantee that content is never
46
46
  * cut off.
47
+ *
48
+ * THE MARGIN IS *BETWEEN* ROWS, NOT INSIDE EVERY ROW. This is the correction
49
+ * that this file existed for a month without.
50
+ *
51
+ * react-grid-layout allocates an item of `n` rows exactly:
52
+ *
53
+ * px(n) = n * rowHeight + (n - 1) * marginY
54
+ *
55
+ * so `n` rows are worth `n * (rowHeight + marginY) - marginY` pixels — one
56
+ * margin LESS than the row unit suggests. Dividing the needed height by the
57
+ * bare row unit therefore credits every item with `marginY` pixels it does
58
+ * not get, and `Math.ceil` cannot rescue that: the shortfall is inside the
59
+ * rounding, not beyond it.
60
+ *
61
+ * Inverting the real formula for the smallest `n` that fits:
62
+ *
63
+ * n * rowHeight + (n - 1) * marginY >= needed
64
+ * n >= (needed + marginY) / (rowHeight + marginY)
65
+ *
66
+ * MEASURED ON PRODUCTION, 2026-08-20, crm7 /clients/create at 1366x768. The
67
+ * card holding the form's Create/Cancel row measured 32px tall around a 36px
68
+ * button, with `overflow-hidden`, so the button was cut off and a neighbouring
69
+ * card's helper text was painted over what remained — `elementFromPoint` at the
70
+ * button's centre returned a `<p>`, not the button. The form could not be
71
+ * submitted by a person. rowHeight 32 + marginY 6: 36px of content came to
72
+ * `ceil((36 + 2) / 38) = 1` row, and one row is 32 pixels.
73
+ *
74
+ * The old form clips whenever the needed height lands 1..marginY pixels above a
75
+ * row boundary — 6 of every 38 possible heights, about one card in six.
76
+ *
77
+ * It survived because the tests asserted the ARITHMETIC rather than the
78
+ * OUTCOME: they checked the division, never whether the resulting row count
79
+ * buys enough pixels. Three of them encoded a clipping case as the expected
80
+ * answer. They now assert against react-grid-layout's own formula instead.
47
81
  */
48
82
  export declare function computeAutoHeightRows({ contentPx, cardChromePx, rowHeightPx, marginYPx, minRows, }: ComputeAutoHeightRowsOptions): number;
49
83
  //# sourceMappingURL=autoHeight.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"autoHeight.d.ts","sourceRoot":"","sources":["../src/autoHeight.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,4BAA4B;IAC3C;;;;;;;;;;;OAWG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAW,GACZ,EAAE,4BAA4B,GAAG,MAAM,CAKvC"}
1
+ {"version":3,"file":"autoHeight.d.ts","sourceRoot":"","sources":["../src/autoHeight.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,4BAA4B;IAC3C;;;;;;;;;;;OAWG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAW,GACZ,EAAE,4BAA4B,GAAG,MAAM,CAOvC"}
@@ -6,11 +6,47 @@
6
6
  * time. Ceiling always over-allocates rather than under-allocates, trading
7
7
  * a few pixels of empty card padding for a guarantee that content is never
8
8
  * cut off.
9
+ *
10
+ * THE MARGIN IS *BETWEEN* ROWS, NOT INSIDE EVERY ROW. This is the correction
11
+ * that this file existed for a month without.
12
+ *
13
+ * react-grid-layout allocates an item of `n` rows exactly:
14
+ *
15
+ * px(n) = n * rowHeight + (n - 1) * marginY
16
+ *
17
+ * so `n` rows are worth `n * (rowHeight + marginY) - marginY` pixels — one
18
+ * margin LESS than the row unit suggests. Dividing the needed height by the
19
+ * bare row unit therefore credits every item with `marginY` pixels it does
20
+ * not get, and `Math.ceil` cannot rescue that: the shortfall is inside the
21
+ * rounding, not beyond it.
22
+ *
23
+ * Inverting the real formula for the smallest `n` that fits:
24
+ *
25
+ * n * rowHeight + (n - 1) * marginY >= needed
26
+ * n >= (needed + marginY) / (rowHeight + marginY)
27
+ *
28
+ * MEASURED ON PRODUCTION, 2026-08-20, crm7 /clients/create at 1366x768. The
29
+ * card holding the form's Create/Cancel row measured 32px tall around a 36px
30
+ * button, with `overflow-hidden`, so the button was cut off and a neighbouring
31
+ * card's helper text was painted over what remained — `elementFromPoint` at the
32
+ * button's centre returned a `<p>`, not the button. The form could not be
33
+ * submitted by a person. rowHeight 32 + marginY 6: 36px of content came to
34
+ * `ceil((36 + 2) / 38) = 1` row, and one row is 32 pixels.
35
+ *
36
+ * The old form clips whenever the needed height lands 1..marginY pixels above a
37
+ * row boundary — 6 of every 38 possible heights, about one card in six.
38
+ *
39
+ * It survived because the tests asserted the ARITHMETIC rather than the
40
+ * OUTCOME: they checked the division, never whether the resulting row count
41
+ * buys enough pixels. Three of them encoded a clipping case as the expected
42
+ * answer. They now assert against react-grid-layout's own formula instead.
9
43
  */
10
44
  export function computeAutoHeightRows({ contentPx, cardChromePx, rowHeightPx, marginYPx, minRows = 1, }) {
11
45
  const rowUnitPx = rowHeightPx + marginYPx;
12
46
  if (rowUnitPx <= 0)
13
47
  return minRows;
14
- const raw = Math.ceil((contentPx + cardChromePx) / rowUnitPx);
48
+ // `+ marginYPx` inverts px(n) = n*rowHeight + (n-1)*marginY. Without it every
49
+ // item is credited with one margin it never receives. See the docblock.
50
+ const raw = Math.ceil((contentPx + cardChromePx + marginYPx) / rowUnitPx);
15
51
  return Math.max(minRows, raw);
16
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsuite/page-builder",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Shared BSuite responsive page-builder grid and layout persistence primitives",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",