react-justified-layout-ts 1.1.0 → 1.1.2
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/dist/TSJustifiedLayout.js +11 -10
- package/package.json +29 -44
- package/dist/TSJustifiedLayout.d.ts.map +0 -1
|
@@ -82,6 +82,7 @@ function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing
|
|
|
82
82
|
}
|
|
83
83
|
const rows = [];
|
|
84
84
|
let rowBuffer = [];
|
|
85
|
+
console.log(rows);
|
|
85
86
|
layoutItems.forEach((value) => {
|
|
86
87
|
const isItemSuccessfullyAdded = addItem(value);
|
|
87
88
|
if (!isItemSuccessfullyAdded) {
|
|
@@ -89,26 +90,26 @@ function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing
|
|
|
89
90
|
}
|
|
90
91
|
});
|
|
91
92
|
// Handle leftover content
|
|
93
|
+
console.log(rows);
|
|
92
94
|
if (showWidows) {
|
|
93
95
|
rows.push({ items: rowBuffer, height: rows.length === 0 ? targetRowHeight : rows[rows.length - 1].height });
|
|
94
96
|
}
|
|
95
97
|
let childNodeCounter = -1;
|
|
96
98
|
/**
|
|
97
99
|
* Clone the children element, and inject the height of the element as a prop
|
|
98
|
-
* @param
|
|
100
|
+
* @param isLast If the element belongs to the last row, and therefore should use height instead of flex
|
|
99
101
|
*/
|
|
100
|
-
function renderChildren(
|
|
102
|
+
function renderChildren(isLast) {
|
|
101
103
|
childNodeCounter++;
|
|
102
|
-
return (0, react_1.cloneElement)(children[childNodeCounter], Object.assign(Object.assign({}, children[childNodeCounter].props), { style: Object.assign(Object.assign({}, children[childNodeCounter].props.style), {
|
|
104
|
+
return (0, react_1.cloneElement)(children[childNodeCounter], Object.assign(Object.assign({}, children[childNodeCounter].props), { style: Object.assign(Object.assign(Object.assign({}, children[childNodeCounter].props.style), { maxWidth: '100%' }), (isLast ? { maxHeight: '100%' } : {})) }));
|
|
103
105
|
}
|
|
104
106
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
105
|
-
react_1.default.createElement("div", { style: { width: "100%" } },
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
} }, value.items.map(() => react_1.default.createElement("div", { style: { height: value.height } }, renderChildren(value.height))));
|
|
107
|
+
react_1.default.createElement("div", { style: { width: "100%" } }),
|
|
108
|
+
react_1.default.createElement("div", { style: { width: "100%" } }, rows.map((value, index, array) => {
|
|
109
|
+
let isLastRow = index === array.length - 1 && showWidows;
|
|
110
|
+
return react_1.default.createElement("div", { style: Object.assign({ display: "flex", flexDirection: "row", gap: itemSpacing, marginBottom: rowSpacing }, (isLastRow ? { height: value.height } : {})) }, value.items.map((aspectRatio) => {
|
|
111
|
+
return react_1.default.createElement("div", { style: isLastRow ? { aspectRatio: aspectRatio } : { flex: aspectRatio } }, renderChildren(isLastRow));
|
|
112
|
+
}));
|
|
112
113
|
}))));
|
|
113
114
|
}
|
|
114
115
|
exports.TSJustifiedLayout = TSJustifiedLayout;
|
package/package.json
CHANGED
|
@@ -1,44 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-justified-layout-ts",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "A component based off Flickr's justified layout that is compatible with Typescript",
|
|
5
|
-
"main": "./dist/TSJustifiedLayout.js",
|
|
6
|
-
"types": "./dist/TSJustifiedLayout.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
-
"typescript": "tsc"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"react
|
|
22
|
-
"react
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"@storybook/addon-webpack5-compiler-swc": "^1.0.3",
|
|
31
|
-
"@storybook/blocks": "^8.1.5",
|
|
32
|
-
"@storybook/react": "^8.1.5",
|
|
33
|
-
"@storybook/react-webpack5": "^8.1.5",
|
|
34
|
-
"@storybook/test": "^8.1.5",
|
|
35
|
-
"@types/react": "^18.2.47",
|
|
36
|
-
"react": "^18.2.0",
|
|
37
|
-
"storybook": "^8.1.5",
|
|
38
|
-
"typescript": "^5.3.3"
|
|
39
|
-
},
|
|
40
|
-
"peerDependencies": {
|
|
41
|
-
"react": "^18.2.0"
|
|
42
|
-
},
|
|
43
|
-
"repository": "https://github.com/Alan19/react-justified-layout-ts"
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "react-justified-layout-ts",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "A component based off Flickr's justified layout that is compatible with Typescript",
|
|
5
|
+
"main": "./dist/TSJustifiedLayout.js",
|
|
6
|
+
"types": "./dist/TSJustifiedLayout.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
+
"typescript": "tsc"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "Alan19",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@types/node": "^20.10.7"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/react": "^18.2.47",
|
|
22
|
+
"react": "^18.2.0",
|
|
23
|
+
"typescript": "^5.3.3"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "^18.2.0"
|
|
27
|
+
},
|
|
28
|
+
"repository": "https://github.com/Alan19/react-justified-layout-ts"
|
|
29
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TSJustifiedLayout.d.ts","sourceRoot":"","sources":["../src/components/TSJustifiedLayout/TSJustifiedLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,MAAM,WAAW,sBAAsB;IACnC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,GAAG,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CAIxB;AAED,iBAAS,iBAAiB,CAAC,EACW,QAAQ,EACR,MAAM,EACN,WAAgB,EAChB,UAAe,EACf,UAAiB,EACjB,eAAqB,EACrB,wBAA8B,EAC9B,KAAK,EACR,EAAE,sBAAsB,qBA4G1D;AAED,OAAO,EAAC,iBAAiB,EAAC,CAAA"}
|