@jobber/components-native 0.42.2 → 0.43.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/dist/src/ThumbnailList/ThumbnailList.js +31 -0
- package/dist/src/ThumbnailList/ThumbnailList.style.js +49 -0
- package/dist/src/ThumbnailList/index.js +2 -0
- package/dist/src/ThumbnailList/types.js +5 -0
- package/dist/src/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +5 -0
- package/dist/types/src/ThumbnailList/ThumbnailList.style.d.ts +47 -0
- package/dist/types/src/ThumbnailList/index.d.ts +2 -0
- package/dist/types/src/ThumbnailList/types.d.ts +15 -0
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/ThumbnailList/ThumbnailList.style.ts +50 -0
- package/src/ThumbnailList/ThumbnailList.test.tsx +81 -0
- package/src/ThumbnailList/ThumbnailList.tsx +57 -0
- package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +154 -0
- package/src/ThumbnailList/index.ts +2 -0
- package/src/ThumbnailList/types.ts +21 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import isNil from "lodash/isNil";
|
|
4
|
+
import { RowCount } from "./types";
|
|
5
|
+
import { styles } from "./ThumbnailList.style";
|
|
6
|
+
import { FormatFile } from "../FormatFile";
|
|
7
|
+
function isImage(file) {
|
|
8
|
+
return !!file.contentType && file.contentType.includes("image/");
|
|
9
|
+
}
|
|
10
|
+
function hasValidUrl(file) {
|
|
11
|
+
return !isNil(file.url);
|
|
12
|
+
}
|
|
13
|
+
export const filterImages = (files) => {
|
|
14
|
+
return files.filter((file) => {
|
|
15
|
+
return isImage(file) && hasValidUrl(file);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export function ThumbnailList({ files, rowCount = RowCount.TwoRows, handleOpenFile, createThumbnail, }) {
|
|
19
|
+
const imageList = filterImages(files);
|
|
20
|
+
return (React.createElement(View, { style: [
|
|
21
|
+
styles.list,
|
|
22
|
+
rowCount === RowCount.ThreeRows && styles.maxDimensionsForThreeRows,
|
|
23
|
+
] }, files.map((file, index) => {
|
|
24
|
+
return (React.createElement(FormatFile, { file: file, accessibilityLabel: file.fileName, key: `${file.fileName}-${index}`, styleInGrid: true, onTap: openFile(file, index), createThumbnail: createThumbnail }));
|
|
25
|
+
})));
|
|
26
|
+
function openFile(file, index) {
|
|
27
|
+
return () => {
|
|
28
|
+
handleOpenFile === null || handleOpenFile === void 0 ? void 0 : handleOpenFile({ file, index, imageList });
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
list: {
|
|
5
|
+
display: "flex",
|
|
6
|
+
flexDirection: "row",
|
|
7
|
+
flexWrap: "wrap",
|
|
8
|
+
maxHeight: (tokens["space-extravagant"] + tokens["space-smaller"]) * 2,
|
|
9
|
+
overflow: "hidden",
|
|
10
|
+
marginTop: tokens["space-smaller"],
|
|
11
|
+
},
|
|
12
|
+
maxDimensionsForThreeRows: {
|
|
13
|
+
maxHeight: (tokens["space-extravagant"] + tokens["space-smaller"]) * 3,
|
|
14
|
+
},
|
|
15
|
+
thumbnail: {
|
|
16
|
+
width: tokens["space-extravagant"],
|
|
17
|
+
height: tokens["space-extravagant"],
|
|
18
|
+
marginRight: tokens["space-smaller"],
|
|
19
|
+
marginBottom: tokens["space-smaller"],
|
|
20
|
+
borderRadius: tokens["radius-base"],
|
|
21
|
+
borderColor: tokens["color-border"],
|
|
22
|
+
borderWidth: tokens["border-base"],
|
|
23
|
+
},
|
|
24
|
+
centerThumbnailImage: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
},
|
|
29
|
+
dimensionsThumbnailImage: {
|
|
30
|
+
width: tokens["space-extravagant"],
|
|
31
|
+
height: tokens["space-extravagant"],
|
|
32
|
+
},
|
|
33
|
+
thumbnailName: {
|
|
34
|
+
position: "absolute",
|
|
35
|
+
right: 0,
|
|
36
|
+
bottom: 0,
|
|
37
|
+
left: 0,
|
|
38
|
+
paddingHorizontal: tokens["space-smaller"],
|
|
39
|
+
paddingVertical: tokens["space-smallest"],
|
|
40
|
+
borderTopColor: tokens["color-border"],
|
|
41
|
+
borderTopWidth: tokens["space-minuscule"],
|
|
42
|
+
},
|
|
43
|
+
thumbnailIcon: {
|
|
44
|
+
top: tokens["space-smaller"],
|
|
45
|
+
display: "flex",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
justifyContent: "center",
|
|
48
|
+
},
|
|
49
|
+
});
|
package/dist/src/index.js
CHANGED