@jobber/components-native 0.42.2 → 0.42.3-pre.19
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/AtlantisContext/AtlantisContext.js +1 -2
- package/dist/src/Form/context/AtlantisFormContext.js +0 -1
- package/dist/src/Form/hooks/useScreenInformation.js +2 -2
- package/dist/src/FormatFile/components/MediaView/MediaView.js +2 -2
- 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/Form/context/AtlantisFormContext.d.ts +0 -1
- package/dist/types/src/Form/context/types.d.ts +0 -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 +4 -5
- package/src/AtlantisContext/AtlantisContext.tsx +1 -2
- package/src/Form/context/AtlantisFormContext.tsx +0 -1
- package/src/Form/context/types.ts +0 -1
- package/src/Form/hooks/useScreenInformation.ts +2 -2
- package/src/FormatFile/components/MediaView/MediaView.tsx +3 -3
- package/src/InputCurrency/InputCurrency.test.tsx +1 -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
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
|
-
import RNLocalize from "react-native-localize";
|
|
4
3
|
import { DEFAULT_CURRENCY_SYMBOL } from "../InputCurrency/constants";
|
|
5
4
|
export const defaultValues = {
|
|
6
5
|
dateFormat: "PP",
|
|
7
6
|
// The system time is "p"
|
|
8
7
|
timeFormat: "p",
|
|
9
|
-
timeZone:
|
|
8
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
10
9
|
isOnline: true,
|
|
11
10
|
onLogError: _ => {
|
|
12
11
|
return;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useWindowDimensions } from "react-native";
|
|
2
2
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
3
|
import { KEYBOARD_TOP_PADDING_AUTO_SCROLL } from "../constants";
|
|
4
|
-
import {
|
|
4
|
+
import { useAtlantisContext } from "../../AtlantisContext";
|
|
5
5
|
export function useScreenInformation() {
|
|
6
|
-
const { headerHeight } =
|
|
6
|
+
const { headerHeight } = useAtlantisContext();
|
|
7
7
|
const windowHeight = useWindowDimensions().height;
|
|
8
8
|
const headerHeightWithPadding = headerHeight + KEYBOARD_TOP_PADDING_AUTO_SCROLL;
|
|
9
9
|
const insets = useSafeAreaInsets();
|
|
@@ -13,7 +13,7 @@ export function MediaView({ accessibilityLabel, showOverlay, showError, file, st
|
|
|
13
13
|
const { formatMessage } = useIntl();
|
|
14
14
|
const { useCreateThumbnail } = useAtlantisFormatFileContext();
|
|
15
15
|
const { thumbnail, error } = useCreateThumbnail(file);
|
|
16
|
-
const [isLoading, setIsLoading] = useState(
|
|
16
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
17
17
|
const a11yLabel = computeA11yLabel({
|
|
18
18
|
accessibilityLabel,
|
|
19
19
|
showOverlay,
|
|
@@ -26,7 +26,7 @@ export function MediaView({ accessibilityLabel, showOverlay, showError, file, st
|
|
|
26
26
|
React.createElement(ImageBackground, { style: [
|
|
27
27
|
styles.imageBackground,
|
|
28
28
|
styleInGrid ? styles.imageBackgroundGrid : styles.imageBackgroundFlat,
|
|
29
|
-
], resizeMode: styleInGrid ? "cover" : "contain", source: { uri }, testID: "test-image", onLoadStart: () => setIsLoading(
|
|
29
|
+
], resizeMode: styleInGrid ? "cover" : "contain", source: { uri }, testID: "test-image", onLoadStart: () => setIsLoading(false), onLoadEnd: () => setIsLoading(true) },
|
|
30
30
|
React.createElement(Overlay, { isLoading: isLoading, showOverlay: showOverlay, hasError: hasError, file: file, onUploadComplete: onUploadComplete }))));
|
|
31
31
|
}
|
|
32
32
|
function Overlay({ isLoading, showOverlay, hasError, file, onUploadComplete, }) {
|
|
@@ -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