react-justified-layout-ts 2.1.4 → 2.1.5

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.
@@ -42,18 +42,17 @@ function JustifiedGrid(props) {
42
42
  const { targetRowHeightTolerance = .25, width, targetRowHeight = 320, itemSpacing = 8, rowSpacing = 8, children, containerStyle, aspectRatioList } = props;
43
43
  const rows = getJustifiedGridRowConfiguration(width, targetRowHeightTolerance, aspectRatioList, targetRowHeight, itemSpacing);
44
44
  let childNodeCounter = -1;
45
+ function renderRowItem(value, aspectRatio) {
46
+ childNodeCounter++;
47
+ return react_1.default.createElement("div", { style: Object.assign({ flex: value.length === 1 ? 1 : aspectRatio }, containerStyle) }, children[childNodeCounter]);
48
+ }
45
49
  return (react_1.default.createElement("div", { style: {
46
50
  display: 'flex',
47
51
  flexDirection: 'column',
48
52
  gap: rowSpacing
49
- } }, rows.map((value) => {
50
- return react_1.default.createElement("div", { className: 'justified-row', style: {
51
- display: "flex",
52
- flexDirection: "row",
53
- gap: itemSpacing,
54
- } }, value.map((aspectRatio) => {
55
- childNodeCounter++;
56
- return react_1.default.createElement("div", { style: Object.assign({ flex: value.length === 1 ? 1 : aspectRatio }, containerStyle) }, children[childNodeCounter]);
57
- }));
58
- })));
53
+ } }, rows.map(value => react_1.default.createElement("div", { className: 'justified-row', style: {
54
+ display: "flex",
55
+ flexDirection: "row",
56
+ gap: itemSpacing,
57
+ } }, value.map(aspectRatio => renderRowItem(value, aspectRatio))))));
59
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-justified-layout-ts",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "A component based off Flickr's justified layout that is compatible with Typescript",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -52,29 +52,28 @@ export function JustifiedGrid(props: Readonly<JustifiedGridProps>) {
52
52
  const rows = getJustifiedGridRowConfiguration(width, targetRowHeightTolerance, aspectRatioList, targetRowHeight, itemSpacing);
53
53
 
54
54
  let childNodeCounter = -1;
55
+
56
+ function renderRowItem(value: number[], aspectRatio: number) {
57
+ childNodeCounter++;
58
+ return <div style={{flex: value.length === 1 ? 1 : aspectRatio, ...containerStyle}}>
59
+ {children[childNodeCounter]}
60
+ </div>;
61
+ }
62
+
55
63
  return (
56
64
  <div style={{
57
65
  display: 'flex',
58
66
  flexDirection: 'column',
59
67
  gap: rowSpacing
60
68
  }}>
61
- {rows.map((value) => {
62
- return <div className={'justified-row'} style={{
69
+ {rows.map(value =>
70
+ <div className={'justified-row'} style={{
63
71
  display: "flex",
64
72
  flexDirection: "row",
65
73
  gap: itemSpacing,
66
74
  }}>
67
- {value.map((aspectRatio) => {
68
- childNodeCounter++;
69
- return <div style={{
70
- flex: value.length === 1 ? 1 : aspectRatio,
71
- ...containerStyle
72
- }}>
73
- {children[childNodeCounter]}
74
- </div>;
75
- })}
76
- </div>
77
- })}
75
+ {value.map(aspectRatio => renderRowItem(value, aspectRatio))}
76
+ </div>)}
78
77
  </div>
79
78
  );
80
79
  }