@nordicsemiconductor/pc-nrfconnect-shared 113.0.0 → 114.0.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.
package/Changelog.md CHANGED
@@ -7,6 +7,12 @@ This project does _not_ adhere to
7
7
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
8
8
  every new version is a new major version.
9
9
 
10
+ ## 114 - 2023-09-26
11
+
12
+ ### Fixed
13
+
14
+ - `MasonryLayout` excess scrolling white space.
15
+
10
16
  ## 113 - 2023-09-25
11
17
 
12
18
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" ?>
2
2
  <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
3
- <coverage lines-valid="3208" lines-covered="1788" line-rate="0.5573" branches-valid="1532" branches-covered="448" branch-rate="0.2924" timestamp="1695639056715" complexity="0" version="0.1">
3
+ <coverage lines-valid="3208" lines-covered="1788" line-rate="0.5573" branches-valid="1532" branches-covered="448" branch-rate="0.2924" timestamp="1695717218556" complexity="0" version="0.1">
4
4
  <sources>
5
5
  <source>/home/vsts/work/1/s</source>
6
6
  </sources>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/pc-nrfconnect-shared",
3
- "version": "113.0.0",
3
+ "version": "114.0.0",
4
4
  "description": "Shared commodities for developing pc-nrfconnect-* packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -103,7 +103,7 @@ export default ({
103
103
  const generateMetaData = (col: number) => {
104
104
  let child = masonryLayoutRef.current?.firstElementChild;
105
105
  const offsetHeightMatrix: number[][] = [];
106
- const scrollHeightMatrix: number[][] = [];
106
+ const scrollHeightOffsetMatrix: number[][] = [];
107
107
  const zeroHeightChildren: boolean[] = [];
108
108
 
109
109
  let i = 0;
@@ -114,12 +114,12 @@ export default ({
114
114
 
115
115
  if (offsetHeightMatrix[rowIndex] === undefined) {
116
116
  offsetHeightMatrix[rowIndex] = [];
117
- scrollHeightMatrix[rowIndex] = [];
117
+ scrollHeightOffsetMatrix[rowIndex] = [];
118
118
  }
119
119
 
120
120
  const offsetHeightRow = offsetHeightMatrix[rowIndex];
121
- const scrollHeightRow = scrollHeightMatrix[rowIndex];
122
- let scrollHeightRowDiff = 0;
121
+ const scrollHeightRow =
122
+ scrollHeightOffsetMatrix[rowIndex];
123
123
  const columnIndex = i % col;
124
124
 
125
125
  i += 1;
@@ -128,22 +128,17 @@ export default ({
128
128
  Number.parseInt(styles.margin, 10)
129
129
  ) {
130
130
  offsetHeightRow[columnIndex] = 0;
131
+ scrollHeightRow[columnIndex] = 0;
131
132
  zeroHeightChildren.push(true);
132
133
  } else {
133
134
  offsetHeightRow[columnIndex] =
134
135
  child.offsetHeight + 1; // 1px to round as value might be decimal
135
- scrollHeightRowDiff =
136
+ scrollHeightRow[columnIndex] =
136
137
  child.scrollHeight +
137
138
  9 -
138
139
  offsetHeightRow[columnIndex]; // 8 border bottom + 1px to round as value might be decimal
139
140
  zeroHeightChildren.push(false);
140
141
  }
141
-
142
- scrollHeightRow[columnIndex] =
143
- offsetHeightMatrix.reduce(
144
- (p, c) => p + c[columnIndex],
145
- 0
146
- ) + scrollHeightRowDiff;
147
142
  }
148
143
 
149
144
  child = child.nextElementSibling;
@@ -152,7 +147,7 @@ export default ({
152
147
 
153
148
  return {
154
149
  offsetHeightMatrix,
155
- scrollHeightMatrix,
150
+ scrollHeightOffsetMatrix,
156
151
  hiddenChildren: zeroHeightChildren,
157
152
  };
158
153
  };
@@ -160,22 +155,32 @@ export default ({
160
155
  const calcData = (col: number) => {
161
156
  const metaData = generateMetaData(col);
162
157
  const heights: number[] = Array(col).fill(0);
158
+ const individualHeights: number[][] = [];
163
159
  const newOrder: number[] = [];
164
160
 
165
- metaData.offsetHeightMatrix.forEach(row => {
166
- row.forEach(itemHeight => {
161
+ metaData.offsetHeightMatrix.forEach((row, rowIndex) => {
162
+ row.forEach((itemHeight, columnIndex) => {
167
163
  const smallest =
168
164
  heights.findIndex(h => h === Math.min(...heights)) ?? 0;
169
165
  heights[smallest] += itemHeight;
166
+
167
+ if (individualHeights[rowIndex] === undefined) {
168
+ individualHeights[rowIndex] = [];
169
+ }
170
+
171
+ // add all offset heights of above items excluding scroll height of above items but including scoll geight of this item
172
+ individualHeights[rowIndex][smallest] =
173
+ heights[smallest] +
174
+ metaData.scrollHeightOffsetMatrix[rowIndex][
175
+ columnIndex
176
+ ];
177
+
170
178
  newOrder.push(smallest + 1);
171
179
  });
172
180
  });
173
181
 
174
182
  return {
175
- maxHeight: Math.max(
176
- ...heights,
177
- ...metaData.scrollHeightMatrix.flat()
178
- ),
183
+ maxHeight: Math.max(...individualHeights.flat()),
179
184
  order: newOrder,
180
185
  columnHeights: heights,
181
186
  columns: Math.min(
@@ -1 +1 @@
1
- {"version":3,"file":"MasonryLayout.d.ts","sourceRoot":"","sources":["../../../../src/MasonryLayout/MasonryLayout.tsx"],"names":[],"mappings":"AAKA,OAAc,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAM9E,UAAU,uBAAuB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAiED;;;;;;GAMG;6DAKA,kBAAkB,uBAAuB,CAAC;AAJ7C,wBAiKE"}
1
+ {"version":3,"file":"MasonryLayout.d.ts","sourceRoot":"","sources":["../../../../src/MasonryLayout/MasonryLayout.tsx"],"names":[],"mappings":"AAKA,OAAc,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAM9E,UAAU,uBAAuB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAiED;;;;;;GAMG;6DAKA,kBAAkB,uBAAuB,CAAC;AAJ7C,wBAsKE"}