@jobber/components-native 0.40.1 → 0.42.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/AutoLink/AutoLink.js +23 -0
- package/dist/src/AutoLink/clipboard.js +9 -0
- package/dist/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.js +19 -0
- package/dist/src/AutoLink/components/Link/Link.js +7 -0
- package/dist/src/AutoLink/components/index.js +2 -0
- package/dist/src/AutoLink/hooks/useCreateLinkedText.js +24 -0
- package/dist/src/AutoLink/hooks/useTokenGenerator.js +10 -0
- package/dist/src/AutoLink/index.js +1 -0
- package/dist/src/AutoLink/messages.js +18 -0
- package/dist/src/AutoLink/types.js +1 -0
- package/dist/src/AutoLink/utils.js +45 -0
- package/dist/src/FormatFile/FormatFile.js +114 -0
- package/dist/src/FormatFile/FormatFile.style.js +16 -0
- package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.js +8 -0
- package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.style.js +10 -0
- package/dist/src/FormatFile/components/ErrorIcon/index.js +1 -0
- package/dist/src/FormatFile/components/FileView/FileView.js +67 -0
- package/dist/src/FormatFile/components/FileView/FileView.style.js +64 -0
- package/dist/src/FormatFile/components/FileView/index.js +1 -0
- package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +22 -0
- package/dist/src/FormatFile/components/FormatFileBottomSheet/index.js +1 -0
- package/dist/src/FormatFile/components/FormatFileBottomSheet/messages.js +13 -0
- package/dist/src/FormatFile/components/MediaView/MediaView.js +56 -0
- package/dist/src/FormatFile/components/MediaView/MediaView.style.js +27 -0
- package/dist/src/FormatFile/components/MediaView/index.js +1 -0
- package/dist/src/FormatFile/components/ProgressBar/ProgressBar.js +29 -0
- package/dist/src/FormatFile/components/ProgressBar/ProgressBar.style.js +15 -0
- package/dist/src/FormatFile/components/ProgressBar/index.js +1 -0
- package/dist/src/FormatFile/components/_mocks/mockFiles.js +78 -0
- package/dist/src/FormatFile/constants.js +14 -0
- package/dist/src/FormatFile/context/FormatFileContext.js +8 -0
- package/dist/src/FormatFile/context/types.js +1 -0
- package/dist/src/FormatFile/index.js +1 -0
- package/dist/src/FormatFile/messages.js +23 -0
- package/dist/src/FormatFile/types.js +8 -0
- package/dist/src/FormatFile/utils/computeA11yLabel.js +12 -0
- package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +22 -0
- package/dist/src/FormatFile/utils/index.js +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/utils/test/wait.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/AutoLink/AutoLink.d.ts +3 -0
- package/dist/types/src/AutoLink/clipboard.d.ts +2 -0
- package/dist/types/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.d.ts +3 -0
- package/dist/types/src/AutoLink/components/Link/Link.d.ts +8 -0
- package/dist/types/src/AutoLink/components/index.d.ts +2 -0
- package/dist/types/src/AutoLink/hooks/useCreateLinkedText.d.ts +12 -0
- package/dist/types/src/AutoLink/hooks/useTokenGenerator.d.ts +1 -0
- package/dist/types/src/AutoLink/index.d.ts +1 -0
- package/dist/types/src/AutoLink/messages.d.ts +17 -0
- package/dist/types/src/AutoLink/types.d.ts +32 -0
- package/dist/types/src/AutoLink/utils.d.ts +6 -0
- package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +1 -0
- package/dist/types/src/FormatFile/FormatFile.d.ts +47 -0
- package/dist/types/src/FormatFile/FormatFile.style.d.ts +14 -0
- package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -0
- package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.style.d.ts +8 -0
- package/dist/types/src/FormatFile/components/ErrorIcon/index.d.ts +1 -0
- package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +12 -0
- package/dist/types/src/FormatFile/components/FileView/FileView.style.d.ts +62 -0
- package/dist/types/src/FormatFile/components/FileView/index.d.ts +1 -0
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +11 -0
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/index.d.ts +2 -0
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/messages.d.ts +12 -0
- package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +12 -0
- package/dist/types/src/FormatFile/components/MediaView/MediaView.style.d.ts +25 -0
- package/dist/types/src/FormatFile/components/MediaView/index.d.ts +1 -0
- package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +19 -0
- package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.style.d.ts +13 -0
- package/dist/types/src/FormatFile/components/ProgressBar/index.d.ts +1 -0
- package/dist/types/src/FormatFile/components/_mocks/mockFiles.d.ts +18 -0
- package/dist/types/src/FormatFile/constants.d.ts +6 -0
- package/dist/types/src/FormatFile/context/FormatFileContext.d.ts +10 -0
- package/dist/types/src/FormatFile/context/types.d.ts +9 -0
- package/dist/types/src/FormatFile/index.d.ts +3 -0
- package/dist/types/src/FormatFile/messages.d.ts +22 -0
- package/dist/types/src/FormatFile/types.d.ts +105 -0
- package/dist/types/src/FormatFile/utils/computeA11yLabel.d.ts +9 -0
- package/dist/types/src/FormatFile/utils/createUseCreateThumbnail.d.ts +5 -0
- package/dist/types/src/FormatFile/utils/index.d.ts +1 -0
- package/dist/types/src/InputCurrency/InputCurrency.d.ts +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/package.json +5 -2
- package/src/AutoLink/AutoLink.test.tsx +203 -0
- package/src/AutoLink/AutoLink.tsx +36 -0
- package/src/AutoLink/clipboard.ts +14 -0
- package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +38 -0
- package/src/AutoLink/components/Link/Link.test.tsx +30 -0
- package/src/AutoLink/components/Link/Link.tsx +21 -0
- package/src/AutoLink/components/index.ts +2 -0
- package/src/AutoLink/hooks/useCreateLinkedText.ts +35 -0
- package/src/AutoLink/hooks/useTokenGenerator.ts +11 -0
- package/src/AutoLink/index.ts +1 -0
- package/src/AutoLink/messages.ts +19 -0
- package/src/AutoLink/types.ts +39 -0
- package/src/AutoLink/utils.ts +63 -0
- package/src/FormatFile/FormatFile.style.ts +17 -0
- package/src/FormatFile/FormatFile.test.tsx +333 -0
- package/src/FormatFile/FormatFile.tsx +300 -0
- package/src/FormatFile/components/ErrorIcon/ErrorIcon.style.ts +11 -0
- package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +12 -0
- package/src/FormatFile/components/ErrorIcon/index.ts +1 -0
- package/src/FormatFile/components/FileView/FileView.style.ts +65 -0
- package/src/FormatFile/components/FileView/FileView.tsx +134 -0
- package/src/FormatFile/components/FileView/index.ts +1 -0
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +108 -0
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +56 -0
- package/src/FormatFile/components/FormatFileBottomSheet/index.ts +2 -0
- package/src/FormatFile/components/FormatFileBottomSheet/messages.ts +14 -0
- package/src/FormatFile/components/MediaView/MediaView.style.ts +28 -0
- package/src/FormatFile/components/MediaView/MediaView.tsx +145 -0
- package/src/FormatFile/components/MediaView/index.ts +1 -0
- package/src/FormatFile/components/ProgressBar/ProgressBar.style.tsx +16 -0
- package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +57 -0
- package/src/FormatFile/components/ProgressBar/index.ts +1 -0
- package/src/FormatFile/components/_mocks/mockFiles.ts +105 -0
- package/src/FormatFile/constants.ts +15 -0
- package/src/FormatFile/context/FormatFileContext.ts +13 -0
- package/src/FormatFile/context/types.ts +12 -0
- package/src/FormatFile/index.ts +13 -0
- package/src/FormatFile/messages.ts +24 -0
- package/src/FormatFile/types.ts +126 -0
- package/src/FormatFile/utils/computeA11yLabel.ts +26 -0
- package/src/FormatFile/utils/createUseCreateThumbnail.ts +33 -0
- package/src/FormatFile/utils/index.ts +1 -0
- package/src/InputCurrency/InputCurrency.tsx +1 -1
- package/src/index.ts +2 -0
- package/src/utils/test/wait.ts +3 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { v4 } from "react-native-uuid";
|
|
2
|
+
import { StatusCode } from "../../types";
|
|
3
|
+
export const FILE_UPLOAD_MOCK_FILE = ({ progress, status = StatusCode.InProgress, }) => ({
|
|
4
|
+
batchContext: {
|
|
5
|
+
batchCount: 1,
|
|
6
|
+
batchId: "FILES",
|
|
7
|
+
},
|
|
8
|
+
uuid: v4(),
|
|
9
|
+
key: "path/test.txt",
|
|
10
|
+
name: "test.txt",
|
|
11
|
+
size: 1,
|
|
12
|
+
type: "application/txt",
|
|
13
|
+
progress: progress,
|
|
14
|
+
status: status,
|
|
15
|
+
sourcePath: "path/test.txt",
|
|
16
|
+
uploadUrl: "uploadUrl",
|
|
17
|
+
cancel: jest.fn(),
|
|
18
|
+
});
|
|
19
|
+
export const FILE_UPLOAD_MOCK_IMAGE = ({ progress, size, status = StatusCode.InProgress, }) => ({
|
|
20
|
+
batchContext: {
|
|
21
|
+
batchCount: 1,
|
|
22
|
+
batchId: "IMAGES",
|
|
23
|
+
},
|
|
24
|
+
uuid: v4(),
|
|
25
|
+
key: "path/test.png",
|
|
26
|
+
name: "test.png",
|
|
27
|
+
size: size || 1,
|
|
28
|
+
type: "image/png",
|
|
29
|
+
progress: progress,
|
|
30
|
+
status: status,
|
|
31
|
+
sourcePath: "path/test.png",
|
|
32
|
+
uploadUrl: "uploadUrl",
|
|
33
|
+
cancel: jest.fn(),
|
|
34
|
+
});
|
|
35
|
+
export const FILE_UPLOAD_MOCK_PDF = ({ progress, status = StatusCode.InProgress, }) => ({
|
|
36
|
+
batchContext: {
|
|
37
|
+
batchCount: 1,
|
|
38
|
+
batchId: "FILES",
|
|
39
|
+
},
|
|
40
|
+
uuid: v4(),
|
|
41
|
+
key: "path/test.pdf",
|
|
42
|
+
name: "test.pdf",
|
|
43
|
+
size: 1,
|
|
44
|
+
type: "file/pdf",
|
|
45
|
+
progress: progress,
|
|
46
|
+
status: status,
|
|
47
|
+
sourcePath: "path/test.pdf",
|
|
48
|
+
uploadUrl: "uploadUrl",
|
|
49
|
+
cancel: jest.fn(),
|
|
50
|
+
});
|
|
51
|
+
export const FILE_MOCK_PDF = {
|
|
52
|
+
fileName: "some_file.pdf",
|
|
53
|
+
fileSize: 1,
|
|
54
|
+
contentType: "pdf",
|
|
55
|
+
url: "https://path/to/file.pdf",
|
|
56
|
+
thumbnailUrl: "https://path/to/fileThumbnail.pdf",
|
|
57
|
+
};
|
|
58
|
+
export const FILE_MOCK_VIDEO = {
|
|
59
|
+
fileName: "some_file.mp4",
|
|
60
|
+
fileSize: 1,
|
|
61
|
+
contentType: "video",
|
|
62
|
+
url: undefined,
|
|
63
|
+
thumbnailUrl: "path/to/fileThumbnail.mp4",
|
|
64
|
+
};
|
|
65
|
+
export const FILE_MOCK_FILE = {
|
|
66
|
+
fileName: "some_file.txt",
|
|
67
|
+
fileSize: 1,
|
|
68
|
+
contentType: "file",
|
|
69
|
+
url: "https://path/to/file",
|
|
70
|
+
thumbnailUrl: "https://path/to/fileThumbnail",
|
|
71
|
+
};
|
|
72
|
+
export const FILE_MOCK_IMAGE = {
|
|
73
|
+
fileName: "some_image.jpg",
|
|
74
|
+
fileSize: 1,
|
|
75
|
+
contentType: "image/jpg",
|
|
76
|
+
url: "https://path/to/image",
|
|
77
|
+
thumbnailUrl: "https://path/to/imageThumbnail",
|
|
78
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const acceptedExtensions = [
|
|
2
|
+
{ name: "video" },
|
|
3
|
+
{ name: "pdf" },
|
|
4
|
+
{ name: "mov" },
|
|
5
|
+
{ name: "mp4" },
|
|
6
|
+
{ name: "docx" },
|
|
7
|
+
{ name: "xlsx" },
|
|
8
|
+
];
|
|
9
|
+
export const videoExtensions = [
|
|
10
|
+
{ type: "mov" },
|
|
11
|
+
{ type: "mp4" },
|
|
12
|
+
{ type: "3gpp" },
|
|
13
|
+
{ type: "hevc" },
|
|
14
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
export const formatFileContextDefaultValues = {
|
|
3
|
+
useCreateThumbnail: () => ({ thumbnail: undefined, error: false }),
|
|
4
|
+
};
|
|
5
|
+
export const AtlantisFormatFileContext = createContext(formatFileContextDefaultValues);
|
|
6
|
+
export function useAtlantisFormatFileContext() {
|
|
7
|
+
return useContext(AtlantisFormatFileContext);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormatFile } from "./FormatFile";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
defaultAccessibilityLabel: {
|
|
4
|
+
id: "defaultAccessibilityLabel",
|
|
5
|
+
defaultMessage: "Attachment Preview",
|
|
6
|
+
description: "The default accessibility label",
|
|
7
|
+
},
|
|
8
|
+
defaultAccessibilityHint: {
|
|
9
|
+
id: "defaultAccessibilityHint",
|
|
10
|
+
defaultMessage: "Select for more options",
|
|
11
|
+
description: "The default accessibility hint",
|
|
12
|
+
},
|
|
13
|
+
errorAccessibilityLabel: {
|
|
14
|
+
id: "errorAccessibilityLabel",
|
|
15
|
+
defaultMessage: "Failed upload",
|
|
16
|
+
description: "The accessibility label for error states",
|
|
17
|
+
},
|
|
18
|
+
inProgressAccessibilityLabel: {
|
|
19
|
+
id: "inProgress",
|
|
20
|
+
defaultMessage: "Upload in progress",
|
|
21
|
+
description: "The accessibility label for in-progress states",
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var StatusCode;
|
|
2
|
+
(function (StatusCode) {
|
|
3
|
+
StatusCode[StatusCode["Pending"] = 0] = "Pending";
|
|
4
|
+
StatusCode[StatusCode["Started"] = 1] = "Started";
|
|
5
|
+
StatusCode[StatusCode["InProgress"] = 2] = "InProgress";
|
|
6
|
+
StatusCode[StatusCode["Completed"] = 3] = "Completed";
|
|
7
|
+
StatusCode[StatusCode["Failed"] = 4] = "Failed";
|
|
8
|
+
})(StatusCode || (StatusCode = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { messages } from "../messages";
|
|
2
|
+
export function computeA11yLabel({ accessibilityLabel, showOverlay, showError, formatMessage, }) {
|
|
3
|
+
if (!showError && showOverlay) {
|
|
4
|
+
return formatMessage(messages.inProgressAccessibilityLabel);
|
|
5
|
+
}
|
|
6
|
+
else if (showError) {
|
|
7
|
+
return formatMessage(messages.errorAccessibilityLabel);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return (accessibilityLabel || formatMessage(messages.defaultAccessibilityLabel));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useIsMounted } from "@jobber/hooks/useIsMounted";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
export function createUseCreateThumbnail(createThumbnail) {
|
|
4
|
+
const useCreateThumbnail = useCallback((file) => {
|
|
5
|
+
const [thumbnail, setThumbnail] = useState(undefined);
|
|
6
|
+
const [error, setError] = useState(false);
|
|
7
|
+
const { current } = useIsMounted();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
createThumbnail(file)
|
|
10
|
+
.then(({ thumbnail: newThumbnail, error: newError }) => {
|
|
11
|
+
setThumbnail(newThumbnail);
|
|
12
|
+
setError(newError);
|
|
13
|
+
})
|
|
14
|
+
.catch(() => {
|
|
15
|
+
setError(true);
|
|
16
|
+
setThumbnail(undefined);
|
|
17
|
+
});
|
|
18
|
+
}, [current, file]);
|
|
19
|
+
return { thumbnail, error };
|
|
20
|
+
}, [createThumbnail]);
|
|
21
|
+
return { useCreateThumbnail };
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { computeA11yLabel } from "./computeA11yLabel";
|
package/dist/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./ActionItem";
|
|
|
2
2
|
export * from "./ActionLabel";
|
|
3
3
|
export * from "./ActivityIndicator";
|
|
4
4
|
export * from "./AtlantisContext";
|
|
5
|
+
export * from "./AutoLink";
|
|
5
6
|
export * from "./Banner";
|
|
6
7
|
export * from "./BottomSheet";
|
|
7
8
|
export * from "./Button";
|
|
@@ -16,6 +17,7 @@ export * from "./Divider";
|
|
|
16
17
|
export * from "./EmptyState";
|
|
17
18
|
export * from "./ErrorMessageWrapper";
|
|
18
19
|
export * from "./Flex";
|
|
20
|
+
export * from "./FormatFile";
|
|
19
21
|
export * from "./Form";
|
|
20
22
|
export * from "./FormField";
|
|
21
23
|
export * from "./Heading";
|
|
@@ -19,7 +19,7 @@ import { act } from "react-test-renderer";
|
|
|
19
19
|
*/
|
|
20
20
|
export function wait(milliseconds = 0) {
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
yield new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
22
|
+
yield new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
/**
|