@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.
Files changed (128) hide show
  1. package/dist/src/AutoLink/AutoLink.js +23 -0
  2. package/dist/src/AutoLink/clipboard.js +9 -0
  3. package/dist/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.js +19 -0
  4. package/dist/src/AutoLink/components/Link/Link.js +7 -0
  5. package/dist/src/AutoLink/components/index.js +2 -0
  6. package/dist/src/AutoLink/hooks/useCreateLinkedText.js +24 -0
  7. package/dist/src/AutoLink/hooks/useTokenGenerator.js +10 -0
  8. package/dist/src/AutoLink/index.js +1 -0
  9. package/dist/src/AutoLink/messages.js +18 -0
  10. package/dist/src/AutoLink/types.js +1 -0
  11. package/dist/src/AutoLink/utils.js +45 -0
  12. package/dist/src/FormatFile/FormatFile.js +114 -0
  13. package/dist/src/FormatFile/FormatFile.style.js +16 -0
  14. package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.js +8 -0
  15. package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.style.js +10 -0
  16. package/dist/src/FormatFile/components/ErrorIcon/index.js +1 -0
  17. package/dist/src/FormatFile/components/FileView/FileView.js +67 -0
  18. package/dist/src/FormatFile/components/FileView/FileView.style.js +64 -0
  19. package/dist/src/FormatFile/components/FileView/index.js +1 -0
  20. package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +22 -0
  21. package/dist/src/FormatFile/components/FormatFileBottomSheet/index.js +1 -0
  22. package/dist/src/FormatFile/components/FormatFileBottomSheet/messages.js +13 -0
  23. package/dist/src/FormatFile/components/MediaView/MediaView.js +56 -0
  24. package/dist/src/FormatFile/components/MediaView/MediaView.style.js +27 -0
  25. package/dist/src/FormatFile/components/MediaView/index.js +1 -0
  26. package/dist/src/FormatFile/components/ProgressBar/ProgressBar.js +29 -0
  27. package/dist/src/FormatFile/components/ProgressBar/ProgressBar.style.js +15 -0
  28. package/dist/src/FormatFile/components/ProgressBar/index.js +1 -0
  29. package/dist/src/FormatFile/components/_mocks/mockFiles.js +78 -0
  30. package/dist/src/FormatFile/constants.js +14 -0
  31. package/dist/src/FormatFile/context/FormatFileContext.js +8 -0
  32. package/dist/src/FormatFile/context/types.js +1 -0
  33. package/dist/src/FormatFile/index.js +1 -0
  34. package/dist/src/FormatFile/messages.js +23 -0
  35. package/dist/src/FormatFile/types.js +8 -0
  36. package/dist/src/FormatFile/utils/computeA11yLabel.js +12 -0
  37. package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +22 -0
  38. package/dist/src/FormatFile/utils/index.js +1 -0
  39. package/dist/src/index.js +2 -0
  40. package/dist/src/utils/test/wait.js +1 -1
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/dist/types/src/AutoLink/AutoLink.d.ts +3 -0
  43. package/dist/types/src/AutoLink/clipboard.d.ts +2 -0
  44. package/dist/types/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.d.ts +3 -0
  45. package/dist/types/src/AutoLink/components/Link/Link.d.ts +8 -0
  46. package/dist/types/src/AutoLink/components/index.d.ts +2 -0
  47. package/dist/types/src/AutoLink/hooks/useCreateLinkedText.d.ts +12 -0
  48. package/dist/types/src/AutoLink/hooks/useTokenGenerator.d.ts +1 -0
  49. package/dist/types/src/AutoLink/index.d.ts +1 -0
  50. package/dist/types/src/AutoLink/messages.d.ts +17 -0
  51. package/dist/types/src/AutoLink/types.d.ts +32 -0
  52. package/dist/types/src/AutoLink/utils.d.ts +6 -0
  53. package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +1 -0
  54. package/dist/types/src/FormatFile/FormatFile.d.ts +47 -0
  55. package/dist/types/src/FormatFile/FormatFile.style.d.ts +14 -0
  56. package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -0
  57. package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.style.d.ts +8 -0
  58. package/dist/types/src/FormatFile/components/ErrorIcon/index.d.ts +1 -0
  59. package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +12 -0
  60. package/dist/types/src/FormatFile/components/FileView/FileView.style.d.ts +62 -0
  61. package/dist/types/src/FormatFile/components/FileView/index.d.ts +1 -0
  62. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +11 -0
  63. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/index.d.ts +2 -0
  64. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/messages.d.ts +12 -0
  65. package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +12 -0
  66. package/dist/types/src/FormatFile/components/MediaView/MediaView.style.d.ts +25 -0
  67. package/dist/types/src/FormatFile/components/MediaView/index.d.ts +1 -0
  68. package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +19 -0
  69. package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.style.d.ts +13 -0
  70. package/dist/types/src/FormatFile/components/ProgressBar/index.d.ts +1 -0
  71. package/dist/types/src/FormatFile/components/_mocks/mockFiles.d.ts +18 -0
  72. package/dist/types/src/FormatFile/constants.d.ts +6 -0
  73. package/dist/types/src/FormatFile/context/FormatFileContext.d.ts +10 -0
  74. package/dist/types/src/FormatFile/context/types.d.ts +9 -0
  75. package/dist/types/src/FormatFile/index.d.ts +3 -0
  76. package/dist/types/src/FormatFile/messages.d.ts +22 -0
  77. package/dist/types/src/FormatFile/types.d.ts +105 -0
  78. package/dist/types/src/FormatFile/utils/computeA11yLabel.d.ts +9 -0
  79. package/dist/types/src/FormatFile/utils/createUseCreateThumbnail.d.ts +5 -0
  80. package/dist/types/src/FormatFile/utils/index.d.ts +1 -0
  81. package/dist/types/src/InputCurrency/InputCurrency.d.ts +1 -1
  82. package/dist/types/src/index.d.ts +2 -0
  83. package/package.json +5 -2
  84. package/src/AutoLink/AutoLink.test.tsx +203 -0
  85. package/src/AutoLink/AutoLink.tsx +36 -0
  86. package/src/AutoLink/clipboard.ts +14 -0
  87. package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +38 -0
  88. package/src/AutoLink/components/Link/Link.test.tsx +30 -0
  89. package/src/AutoLink/components/Link/Link.tsx +21 -0
  90. package/src/AutoLink/components/index.ts +2 -0
  91. package/src/AutoLink/hooks/useCreateLinkedText.ts +35 -0
  92. package/src/AutoLink/hooks/useTokenGenerator.ts +11 -0
  93. package/src/AutoLink/index.ts +1 -0
  94. package/src/AutoLink/messages.ts +19 -0
  95. package/src/AutoLink/types.ts +39 -0
  96. package/src/AutoLink/utils.ts +63 -0
  97. package/src/FormatFile/FormatFile.style.ts +17 -0
  98. package/src/FormatFile/FormatFile.test.tsx +333 -0
  99. package/src/FormatFile/FormatFile.tsx +300 -0
  100. package/src/FormatFile/components/ErrorIcon/ErrorIcon.style.ts +11 -0
  101. package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +12 -0
  102. package/src/FormatFile/components/ErrorIcon/index.ts +1 -0
  103. package/src/FormatFile/components/FileView/FileView.style.ts +65 -0
  104. package/src/FormatFile/components/FileView/FileView.tsx +134 -0
  105. package/src/FormatFile/components/FileView/index.ts +1 -0
  106. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +108 -0
  107. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +56 -0
  108. package/src/FormatFile/components/FormatFileBottomSheet/index.ts +2 -0
  109. package/src/FormatFile/components/FormatFileBottomSheet/messages.ts +14 -0
  110. package/src/FormatFile/components/MediaView/MediaView.style.ts +28 -0
  111. package/src/FormatFile/components/MediaView/MediaView.tsx +145 -0
  112. package/src/FormatFile/components/MediaView/index.ts +1 -0
  113. package/src/FormatFile/components/ProgressBar/ProgressBar.style.tsx +16 -0
  114. package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +57 -0
  115. package/src/FormatFile/components/ProgressBar/index.ts +1 -0
  116. package/src/FormatFile/components/_mocks/mockFiles.ts +105 -0
  117. package/src/FormatFile/constants.ts +15 -0
  118. package/src/FormatFile/context/FormatFileContext.ts +13 -0
  119. package/src/FormatFile/context/types.ts +12 -0
  120. package/src/FormatFile/index.ts +13 -0
  121. package/src/FormatFile/messages.ts +24 -0
  122. package/src/FormatFile/types.ts +126 -0
  123. package/src/FormatFile/utils/computeA11yLabel.ts +26 -0
  124. package/src/FormatFile/utils/createUseCreateThumbnail.ts +33 -0
  125. package/src/FormatFile/utils/index.ts +1 -0
  126. package/src/InputCurrency/InputCurrency.tsx +1 -1
  127. package/src/index.ts +2 -0
  128. 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
  /**