@factorearth/component-library 5.3.0 → 5.3.1-alpha.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 (43) hide show
  1. package/README.md +11 -11
  2. package/dist/Atoms/Accordion/Accordion.js +18 -18
  3. package/dist/Atoms/Badge/Badge.js +18 -18
  4. package/dist/Atoms/Box/Box.js +15 -15
  5. package/dist/Atoms/Buttons/Button.js +23 -23
  6. package/dist/Atoms/ContentDropdown/ContentDropdown.js +24 -24
  7. package/dist/Atoms/DateField/DateField.js +94 -94
  8. package/dist/Atoms/FieldWrapper/FieldWrapper.js +35 -35
  9. package/dist/Atoms/MoreHorizonButton/MoreHorizonButton.js +52 -52
  10. package/dist/Atoms/NoteField/NoteField.js +38 -38
  11. package/dist/Atoms/NumberField/NumberField.js +63 -63
  12. package/dist/Atoms/OptionsDropdown/OptionsDropdown.js +38 -38
  13. package/dist/Atoms/Pagination/Pagination.js +25 -25
  14. package/dist/Atoms/PhoneNumberField/PhoneNumberField.js +4 -4
  15. package/dist/Atoms/ProgressBar/ProgressBar.js +16 -16
  16. package/dist/Atoms/SortDropdown/SortDropdown.js +39 -39
  17. package/dist/Atoms/Spinner/Spinner.d.ts +7 -0
  18. package/dist/Atoms/Spinner/Spinner.js +10 -0
  19. package/dist/Atoms/Spinner/Spinner.js.map +1 -0
  20. package/dist/Atoms/Tab/Tab.js +18 -18
  21. package/dist/Atoms/TextField/TextField.js +24 -24
  22. package/dist/Atoms/Toggle/Toggle.js +11 -11
  23. package/dist/Atoms/Typography/Typography.js +7 -7
  24. package/dist/Molecules/Form/Form.js +8 -8
  25. package/dist/Molecules/NavMenu/NavMenu.js +102 -102
  26. package/dist/Molecules/TableHeader/TableHeader.js +14 -14
  27. package/dist/Molecules/TableRow/TableRow.js +27 -27
  28. package/dist/Molecules/Thumbnail/Thumbnail.d.ts +4 -4
  29. package/dist/Molecules/Thumbnail/Thumbnail.js +131 -53
  30. package/dist/Molecules/Thumbnail/Thumbnail.js.map +1 -1
  31. package/dist/Organisms/Card/Card.js +33 -33
  32. package/dist/Organisms/EditUserPerms/EditUserPerms.js +67 -67
  33. package/dist/Organisms/ErrorSplash/ErrorSplash.js +44 -44
  34. package/dist/Organisms/TabManager/TabManager.js +13 -13
  35. package/dist/Organisms/Table/Table.js +14 -14
  36. package/dist/Organisms/Tutorial/Tutorial.js +51 -51
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +1 -0
  39. package/dist/index.js.map +1 -1
  40. package/package.json +2 -2
  41. package/dist/Organisms/Splash/Splash.d.ts +0 -10
  42. package/dist/Organisms/Splash/Splash.js +0 -82
  43. package/dist/Organisms/Splash/Splash.js.map +0 -1
@@ -1,17 +1,17 @@
1
1
  import styled from "@emotion/styled";
2
2
  import React, { useState } from 'react';
3
- const ToggleLabel = styled.div `
4
- font-size: 14px;
5
- font-style: normal;
6
- font-weight: 700;
7
- line-height: 21px;
8
- color: ${({ colorPalette }) => colorPalette.text.primary};
9
- text-align: right;
3
+ const ToggleLabel = styled.div `
4
+ font-size: 14px;
5
+ font-style: normal;
6
+ font-weight: 700;
7
+ line-height: 21px;
8
+ color: ${({ colorPalette }) => colorPalette.text.primary};
9
+ text-align: right;
10
10
  `;
11
- const ToggleIcon = styled.div `
12
- width: 16px;
13
- height: 16px;
14
- color: ${({ colorPalette }) => colorPalette.text.primary};
11
+ const ToggleIcon = styled.div `
12
+ width: 16px;
13
+ height: 16px;
14
+ color: ${({ colorPalette }) => colorPalette.text.primary};
15
15
  `;
16
16
  const Toggle = (props) => {
17
17
  const { modes, setState, colorPalette, state, ...htmlProps } = props;
@@ -1,13 +1,13 @@
1
1
  import styled from "@emotion/styled";
2
2
  import React from "react";
3
3
  import tokens from "../../Theme/tokens.json";
4
- const StyledText = styled.p `
5
- color: ${({ textColor }) => textColor};
6
- font-size: ${({ text }) => text.fontSize};
7
- line-height: ${({ text }) => text.lineHeight};
8
- font-weight: ${({ text }) => text.fontWeight};
9
- padding: none;
10
- margin: 0px;
4
+ const StyledText = styled.p `
5
+ color: ${({ textColor }) => textColor};
6
+ font-size: ${({ text }) => text.fontSize};
7
+ line-height: ${({ text }) => text.lineHeight};
8
+ font-weight: ${({ text }) => text.fontWeight};
9
+ padding: none;
10
+ margin: 0px;
11
11
  `;
12
12
  export const Typography = (props) => {
13
13
  const { textColor, variant, content, children, ...htmlProps } = props;
@@ -1,13 +1,13 @@
1
1
  import styled from "@emotion/styled";
2
2
  import React from "react";
3
- export const ContentContainer = styled.div `
4
- display: flex;
5
- padding: 24px;
6
- flex-direction: column;
7
- align-items: center;
8
- gap: 8px;
9
- align-self: stretch;
10
- background-color: ${({ colors }) => colors.background.primary};
3
+ export const ContentContainer = styled.div `
4
+ display: flex;
5
+ padding: 24px;
6
+ flex-direction: column;
7
+ align-items: center;
8
+ gap: 8px;
9
+ align-self: stretch;
10
+ background-color: ${({ colors }) => colors.background.primary};
11
11
  `;
12
12
  function Form(props) {
13
13
  const { children, colors } = props;
@@ -3,121 +3,121 @@ import { keyframes } from "@emotion/react";
3
3
  import React, { useState, useMemo, useRef } from "react";
4
4
  import { FiMenu, FiCloud, FiCloudOff, FiSun, FiMoon, FiChevronRight, FiX, } from "react-icons/fi";
5
5
  import Toggle from "../../Atoms/Toggle/Toggle";
6
- const slideInLeft = keyframes `
7
- 0% {
8
- transform: translateX(-100%);
9
- opacity: 0;
10
- }
11
- 100% {
12
- transform: translateX(0);
13
- opacity: 1;
14
- }
6
+ const slideInLeft = keyframes `
7
+ 0% {
8
+ transform: translateX(-100%);
9
+ opacity: 0;
10
+ }
11
+ 100% {
12
+ transform: translateX(0);
13
+ opacity: 1;
14
+ }
15
15
  `;
16
- const NavMenu = styled.div `
17
- display: flex;
18
- flex-direction: column;
19
- background: ${({ colorPalette }) => colorPalette.background.primary};
20
- width: 100vw;
16
+ const NavMenu = styled.div `
17
+ display: flex;
18
+ flex-direction: column;
19
+ background: ${({ colorPalette }) => colorPalette.background.primary};
20
+ width: 100vw;
21
21
  `;
22
- const NavBarHeader = styled.div `
23
- display: flex;
24
- justify-content: space-between;
25
- align-items: center;
26
- height: 88px;
27
- border-width: 0 0 1px 0;
28
- border-style: solid;
29
- border-color: ${({ colorPalette }) => colorPalette.background.secondary};
22
+ const NavBarHeader = styled.div `
23
+ display: flex;
24
+ justify-content: space-between;
25
+ align-items: center;
26
+ height: 88px;
27
+ border-width: 0 0 1px 0;
28
+ border-style: solid;
29
+ border-color: ${({ colorPalette }) => colorPalette.background.secondary};
30
30
  `;
31
- const OnlineStatus = styled.div `
32
- display: flex;
33
- padding: 8px 12px;
34
- justify-content: center;
35
- align-items: center;
36
- gap: 8px;
37
- border-radius: 32px;
38
- font-weight: 700;
39
- border-width: 1px;
40
- border-style: solid;
41
- border-color: ${({ colorPalette }) => colorPalette.buttonBackground.success};
42
- color: ${({ colorPalette }) => colorPalette.buttonBackground.success};
43
- background: #ebfaed;
31
+ const OnlineStatus = styled.div `
32
+ display: flex;
33
+ padding: 8px 12px;
34
+ justify-content: center;
35
+ align-items: center;
36
+ gap: 8px;
37
+ border-radius: 32px;
38
+ font-weight: 700;
39
+ border-width: 1px;
40
+ border-style: solid;
41
+ border-color: ${({ colorPalette }) => colorPalette.buttonBackground.success};
42
+ color: ${({ colorPalette }) => colorPalette.buttonBackground.success};
43
+ background: #ebfaed;
44
44
  `;
45
- const OfflineStatus = styled.div `
46
- display: flex;
47
- padding: 8px 12px;
48
- justify-content: center;
49
- align-items: center;
50
- gap: 8px;
51
- border-radius: 32px;
52
- font-weight: 700;
53
- border-width: 1px;
54
- border-style: solid;
55
- border-color: ${({ colorPalette }) => colorPalette.utils.icon};
56
- color: ${({ colorPalette }) => colorPalette.utils.icon};
45
+ const OfflineStatus = styled.div `
46
+ display: flex;
47
+ padding: 8px 12px;
48
+ justify-content: center;
49
+ align-items: center;
50
+ gap: 8px;
51
+ border-radius: 32px;
52
+ font-weight: 700;
53
+ border-width: 1px;
54
+ border-style: solid;
55
+ border-color: ${({ colorPalette }) => colorPalette.utils.icon};
56
+ color: ${({ colorPalette }) => colorPalette.utils.icon};
57
57
  `;
58
- const NavMenuDropdown = styled.div `
59
- width: 320px;
60
- position: absolute;
61
- top: 88px;
62
- z-index: 1000;
63
- box-shadow: 5px 5px 5px rgba(64, 64, 64, 0.2);
64
- background: ${({ colorPalette }) => colorPalette.background.primary};
65
- animation: ${slideInLeft} 0.5s ease-out forwards;
66
- display: ${({ navOpen }) => (navOpen ? "flex" : "none")};
67
- flex-direction: column;
68
- &:focus {
69
- outline: none;
70
- }
58
+ const NavMenuDropdown = styled.div `
59
+ width: 320px;
60
+ position: absolute;
61
+ top: 88px;
62
+ z-index: 1000;
63
+ box-shadow: 5px 5px 5px rgba(64, 64, 64, 0.2);
64
+ background: ${({ colorPalette }) => colorPalette.background.primary};
65
+ animation: ${slideInLeft} 0.5s ease-out forwards;
66
+ display: ${({ navOpen }) => (navOpen ? "flex" : "none")};
67
+ flex-direction: column;
68
+ &:focus {
69
+ outline: none;
70
+ }
71
71
  `;
72
- const MenuItems = styled.div `
73
- align-items: flex-start;
74
- align-self: stretch;
72
+ const MenuItems = styled.div `
73
+ align-items: flex-start;
74
+ align-self: stretch;
75
75
  `;
76
- const MenuItem = styled.div `
77
- display: flex;
78
- padding: 8px 16px;
79
- align-items: center;
80
- color: ${({ colorPalette }) => colorPalette.text.tertiary};
81
- font-weight: 700;
82
- border-width: 0 0 1px 0;
83
- border-style: solid;
84
- border-color: ${({ colorPalette }) => colorPalette.background.secondary};
85
- width: 288px;
86
- cursor: pointer;
76
+ const MenuItem = styled.div `
77
+ display: flex;
78
+ padding: 8px 16px;
79
+ align-items: center;
80
+ color: ${({ colorPalette }) => colorPalette.text.tertiary};
81
+ font-weight: 700;
82
+ border-width: 0 0 1px 0;
83
+ border-style: solid;
84
+ border-color: ${({ colorPalette }) => colorPalette.background.secondary};
85
+ width: 288px;
86
+ cursor: pointer;
87
87
  `;
88
- const Location = styled.div `
89
- display: flex;
90
- align-items: center;
91
- gap: 10px;
92
- flex: 1 0 0;
93
- font-size: 16px;
94
- line-height: 150%;
88
+ const Location = styled.div `
89
+ display: flex;
90
+ align-items: center;
91
+ gap: 10px;
92
+ flex: 1 0 0;
93
+ font-size: 16px;
94
+ line-height: 150%;
95
95
  `;
96
- const Toggles = styled.div `
97
- padding: 24px 0px;
96
+ const Toggles = styled.div `
97
+ padding: 24px 0px;
98
98
  `;
99
- const AppInfo = styled.div `
100
- padding: 16px;
101
- width: 288px;
102
- background: ${({ colorPalette }) => colorPalette.background.tertiary};
99
+ const AppInfo = styled.div `
100
+ padding: 16px;
101
+ width: 288px;
102
+ background: ${({ colorPalette }) => colorPalette.background.tertiary};
103
103
  `;
104
- const LogoAndCopyRights = styled.div `
105
- display: flex;
106
- gap: 16px;
107
- margin-bottom: 12px;
108
- color: ${({ colorPalette }) => colorPalette.text.primary};
104
+ const LogoAndCopyRights = styled.div `
105
+ display: flex;
106
+ gap: 16px;
107
+ margin-bottom: 12px;
108
+ color: ${({ colorPalette }) => colorPalette.text.primary};
109
109
  `;
110
- const CopyRights = styled.div `
111
- font-size: 12px;
112
- font-style: normal;
113
- font-weight: 400;
114
- line-height: 55%;
110
+ const CopyRights = styled.div `
111
+ font-size: 12px;
112
+ font-style: normal;
113
+ font-weight: 400;
114
+ line-height: 55%;
115
115
  `;
116
- const Version = styled.div `
117
- text-align: center;
118
- font-size: 14px;
119
- font-weight: 400;
120
- color: ${({ colorPalette }) => colorPalette.text.primary};
116
+ const Version = styled.div `
117
+ text-align: center;
118
+ font-size: 14px;
119
+ font-weight: 400;
120
+ color: ${({ colorPalette }) => colorPalette.text.primary};
121
121
  `;
122
122
  const NavBar = (props) => {
123
123
  const { colorPalette, locations, appInfo } = props;
@@ -1,20 +1,20 @@
1
1
  import React from "react";
2
2
  import styled from "@emotion/styled";
3
3
  import { SortDropdown } from "../../Atoms/SortDropdown/SortDropdown";
4
- const HeaderCell = styled.th `
5
- display: flex;
6
- height: 56px;
7
- padding: 0px 8px;
8
- align-items: center;
9
- gap: 16px;
10
- align-self: stretch;
11
- color: ${({ colorPalette }) => colorPalette.text.primary};
12
- align-items: center;
13
- min-height: 40px;
14
- font-size: 16px;
15
- justify-content: space-between;
16
- width: 100%;
17
- display: flex;
4
+ const HeaderCell = styled.th `
5
+ display: flex;
6
+ height: 56px;
7
+ padding: 0px 8px;
8
+ align-items: center;
9
+ gap: 16px;
10
+ align-self: stretch;
11
+ color: ${({ colorPalette }) => colorPalette.text.primary};
12
+ align-items: center;
13
+ min-height: 40px;
14
+ font-size: 16px;
15
+ justify-content: space-between;
16
+ width: 100%;
17
+ display: flex;
18
18
  `;
19
19
  export const TableHeader = (props) => {
20
20
  const { columns, colorPalette } = props;
@@ -1,33 +1,33 @@
1
1
  import React from "react";
2
2
  import styled from "@emotion/styled";
3
- const StyledTableRow = styled.tr `
4
- display: flex;
5
- border-width: 1px;
6
- border-style: solid;
7
- border-color: ${({ colorPalette }) => colorPalette.border.secondary};
8
- background: $ ${({ colorPalette }) => colorPalette.background.primary};
9
- border-right: none;
10
- border-left: none;
11
- border-top: none;
3
+ const StyledTableRow = styled.tr `
4
+ display: flex;
5
+ border-width: 1px;
6
+ border-style: solid;
7
+ border-color: ${({ colorPalette }) => colorPalette.border.secondary};
8
+ background: $ ${({ colorPalette }) => colorPalette.background.primary};
9
+ border-right: none;
10
+ border-left: none;
11
+ border-top: none;
12
12
  `;
13
- export const TableCell = styled.td `
14
- width: 100%;
15
- min-height: 50px;
16
- display: flex;
17
- padding: 0px 8px;
18
- justify-content: flex-start;
19
- align-items: center;
20
- align-self: stretch;
21
- justify-content: start;
22
- flex: 1;
23
- font-size: 16px;
24
- font-weight: 400;
25
- word-break: break-word;
26
- white-space: normal;
27
- flex-wrap: wrap;
28
- :hover: {
29
- background: ${({ colorPalette }) => colorPalette.background.secondary};
30
- }
13
+ export const TableCell = styled.td `
14
+ width: 100%;
15
+ min-height: 50px;
16
+ display: flex;
17
+ padding: 0px 8px;
18
+ justify-content: flex-start;
19
+ align-items: center;
20
+ align-self: stretch;
21
+ justify-content: start;
22
+ flex: 1;
23
+ font-size: 16px;
24
+ font-weight: 400;
25
+ word-break: break-word;
26
+ white-space: normal;
27
+ flex-wrap: wrap;
28
+ :hover: {
29
+ background: ${({ colorPalette }) => colorPalette.background.secondary};
30
+ }
31
31
  `;
32
32
  export const TableRow = ({ index, colorPalette, rowData, columnConfig, }) => {
33
33
  const rows = Object.entries(rowData)
@@ -1,13 +1,13 @@
1
1
  import React, { ReactNode, Dispatch, SetStateAction } from "react";
2
2
  import { Colors } from "Theme/types";
3
- export declare const Thumbnail: ({ colorPalette, handleSubmit, settingsChildren, showImage, setShowImage, fieldInstance, s3Key, signedUrl, uploadButtonText, handleRemove, changed, handleChange, }: {
3
+ export declare const Thumbnail: ({ colorPalette, handleSubmit, settingsChildren, showImage, setShowImage, fieldInstance, s3Key, signedUrl, loading, handleRemove, handleChange, }: {
4
4
  colorPalette: Colors;
5
- handleSubmit: (newValueData: {
5
+ handleSubmit: (newValueData?: {
6
6
  target: {
7
7
  name: string;
8
8
  value: string;
9
9
  };
10
- }, useNewValue: boolean) => Promise<void>;
10
+ }, useNewValue?: boolean) => Promise<void>;
11
11
  handleChange(e: React.DragEvent<HTMLDivElement> | React.ChangeEvent<HTMLInputElement>): void;
12
12
  settingsChildren: ReactNode;
13
13
  showImage: boolean;
@@ -15,7 +15,7 @@ export declare const Thumbnail: ({ colorPalette, handleSubmit, settingsChildren,
15
15
  fieldInstance: any;
16
16
  s3Key: string;
17
17
  signedUrl: any;
18
- uploadButtonText: string;
18
+ loading: boolean;
19
19
  handleRemove?: () => void;
20
20
  changed: boolean;
21
21
  }) => React.JSX.Element;
@@ -2,59 +2,63 @@ import React, { useState, useRef, useEffect, } from "react";
2
2
  import styled from "@emotion/styled";
3
3
  import { FiTrash2, FiEye, FiEyeOff, FiSettings } from "react-icons/fi";
4
4
  import { Button } from "../../Atoms/Buttons/Button";
5
- const Container = styled.div `
6
- display: flex;
7
- flex-direction: column;
8
- align-items: end;
9
- justify-content: start;
10
- gap: 16px;
11
- flex-shrink: 0;
12
- ${({ showImage }) => showImage && `height: 278px; width: 200px`}
5
+ import { Spinner } from "../../Atoms/Spinner/Spinner";
6
+ const Container = styled.div `
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: end;
10
+ justify-content: start;
11
+ gap: 16px;
12
+ flex-shrink: 0;
13
+ ${({ showImage }) => showImage && `height: 278px; width: 200px`}
13
14
  `;
14
- const InputArea = styled.div `
15
- width: 150px;
16
- height: 132px;
17
- display: flex;
18
- justify-content: center;
19
- align-items: center;
20
- background-color: ${({ colors }) => colors.background.tertiary};
21
- border-style: solid;
22
- border-width: 1px;
23
- border-color: ${({ colors }) => colors.border.primary};
24
- position: relative;
25
- cursor: pointer;
26
- overflow: hidden;
27
- border-radius: 4px;
28
- padding: 24px;
15
+ const InputArea = styled.div `
16
+ width: 150px;
17
+ height: 132px;
18
+ display: flex;
19
+ justify-content: center;
20
+ align-items: center;
21
+ background-color: ${({ colors }) => colors.background.tertiary};
22
+ border-style: solid;
23
+ border-width: 1px;
24
+ border-color: ${({ colors }) => colors.border.primary};
25
+ position: relative;
26
+ cursor: pointer;
27
+ overflow: hidden;
28
+ border-radius: 4px;
29
+ padding: 24px;
29
30
  `;
30
- const SettingsArea = styled.div `
31
- width: 168px;
32
- height: 148px;
33
- display: flex;
34
- justify-content: center;
35
- align-items: center;
36
- background-color: ${({ colors }) => colors.background.secondary};
37
- border-style: solid;
38
- border-width: 1px;
39
- border-color: ${({ colors }) => colors.border.primary};
40
- cursor: pointer;
41
- overflow: hidden;
42
- border-radius: 4px;
43
- gap: 16px;
44
- padding: 16px;
31
+ const SettingsArea = styled.div `
32
+ width: 168px;
33
+ height: 148px;
34
+ display: flex;
35
+ justify-content: center;
36
+ align-items: center;
37
+ background-color: ${({ colors }) => colors.background.secondary};
38
+ border-style: solid;
39
+ border-width: 1px;
40
+ border-color: ${({ colors }) => colors.border.primary};
41
+ cursor: pointer;
42
+ overflow: hidden;
43
+ border-radius: 4px;
44
+ gap: 16px;
45
+ padding: 16px;
45
46
  `;
46
- const PreviewImage = styled.img `
47
- width: 100%;
48
- height: 100%;
49
- object-fit: cover;
50
- position: absolute;
51
- top: 0;
52
- left: 0;
53
- z-index: 1;
47
+ const PreviewImage = styled.img `
48
+ width: 100%;
49
+ height: 100%;
50
+ object-fit: cover;
51
+ position: absolute;
52
+ top: 0;
53
+ left: 0;
54
+ z-index: 1;
54
55
  `;
55
- export const Thumbnail = ({ colorPalette, handleSubmit, settingsChildren, showImage, setShowImage, fieldInstance, s3Key, signedUrl, uploadButtonText, handleRemove, changed, handleChange, }) => {
56
+ export const Thumbnail = ({ colorPalette, handleSubmit, settingsChildren, showImage, setShowImage, fieldInstance, s3Key, signedUrl, loading, handleRemove, handleChange, }) => {
56
57
  const [selectedImage, setSelectedImage] = useState(null);
57
58
  const [showSettings, setShowSettings] = useState(false);
59
+ const [prevImage, setPrevImage] = useState(null);
60
+ const [openSubmitModal, setOpenSubmitModal] = useState(false);
61
+ const [deletingImage, setDeletingImage] = useState(false);
58
62
  const acceptedFileTypes = [
59
63
  "image/jpeg",
60
64
  "image/png",
@@ -68,60 +72,134 @@ export const Thumbnail = ({ colorPalette, handleSubmit, settingsChildren, showIm
68
72
  if (file) {
69
73
  const imageUrl = URL.createObjectURL(file);
70
74
  setSelectedImage(imageUrl);
75
+ setDeletingImage(false);
76
+ setPrevImage(null);
71
77
  }
72
78
  }
73
79
  else if (signedUrl && typeof signedUrl === "string") {
74
80
  setSelectedImage(signedUrl);
81
+ setDeletingImage(false);
82
+ setPrevImage(null);
75
83
  }
76
84
  else {
77
85
  setSelectedImage(null);
78
86
  }
79
87
  }, [signedUrl, s3Key]);
88
+ /**
89
+ * Handles the image upload from the input element.
90
+ * @param event from the input element
91
+ */
80
92
  const handleImageUpload = (event) => {
81
93
  const file = event.target.files?.[0];
82
94
  if (file) {
83
95
  const imageUrl = URL.createObjectURL(file);
84
96
  setSelectedImage(imageUrl);
97
+ setDeletingImage(false);
98
+ setOpenSubmitModal(true);
85
99
  handleChange(event);
100
+ handleSubmit();
86
101
  }
87
102
  };
103
+ /**
104
+ * Handles the image upload from the drag and drop event.
105
+ * @param event from the drag event
106
+ */
88
107
  const handleDrop = (event) => {
89
108
  event.preventDefault();
90
109
  const file = event.dataTransfer.files[0];
91
110
  if (file) {
92
111
  const imageUrl = URL.createObjectURL(file);
93
112
  setSelectedImage(imageUrl);
113
+ setOpenSubmitModal(true);
114
+ setDeletingImage(false);
94
115
  const dropEvent = { target: { files: event.dataTransfer.files, name: "key", type: "file" } };
95
116
  if (inputRef.current)
96
117
  inputRef.current.files = event.dataTransfer.files;
97
118
  handleChange(dropEvent);
119
+ handleSubmit();
98
120
  }
99
121
  };
122
+ /**
123
+ * HAndles the image upload from the drag and drop event.
124
+ * @param event from the drag event
125
+ */
100
126
  const handleDragOver = (event) => {
101
127
  event.preventDefault();
128
+ const file = event.dataTransfer.files[0];
129
+ if (file) {
130
+ const imageUrl = URL.createObjectURL(file);
131
+ setSelectedImage(imageUrl);
132
+ setOpenSubmitModal(true);
133
+ setDeletingImage(false);
134
+ const dropEvent = { target: { files: event.dataTransfer.files, name: "key", type: "file" } };
135
+ if (inputRef.current)
136
+ inputRef.current.files = event.dataTransfer.files;
137
+ handleChange(dropEvent);
138
+ handleSubmit();
139
+ }
102
140
  };
103
- const handleBrowseClick = (event) => {
141
+ /**
142
+ * Handles the click event of the browse button.
143
+ */
144
+ const handleBrowseClick = () => {
104
145
  if (inputRef && inputRef.current)
105
146
  inputRef.current.click();
106
147
  };
148
+ /**
149
+ * Handles toggling the image preview.
150
+ */
107
151
  const handleToggleImage = () => {
108
152
  setShowImage(!showImage);
109
153
  setShowSettings(false);
110
154
  };
155
+ /**
156
+ * Handles toggling the settings.
157
+ */
111
158
  const handleToggleSettings = () => {
112
159
  setShowSettings(!showSettings);
113
160
  };
161
+ /**
162
+ * Handles clearing the input and removing the image.
163
+ */
164
+ const clearInput = () => {
165
+ if (inputRef.current) {
166
+ setPrevImage(selectedImage);
167
+ setSelectedImage(null);
168
+ inputRef.current.value = "";
169
+ }
170
+ if (handleRemove) {
171
+ setDeletingImage(true);
172
+ setOpenSubmitModal(true);
173
+ handleRemove();
174
+ handleSubmit();
175
+ }
176
+ };
177
+ /**
178
+ * Handles the cancel click event from the modal.
179
+ */
180
+ const undoDelete = () => {
181
+ setSelectedImage(prevImage);
182
+ setOpenSubmitModal(false);
183
+ setDeletingImage(false);
184
+ setPrevImage(null);
185
+ };
186
+ /**
187
+ * Handles the submit click event from the modal.
188
+ */
189
+ const handleSubmitClick = async () => {
190
+ await handleSubmit();
191
+ setOpenSubmitModal(false);
192
+ };
114
193
  return (React.createElement(Container, { colors: colorPalette, showImage: showImage, showSettings: showSettings, key: `thumbnail_${fieldInstance.id}` },
115
194
  React.createElement("div", { style: { display: "flex" } },
116
195
  React.createElement(Button, { colorPalette: colorPalette, icon: !showImage ? React.createElement(FiEye, null) : React.createElement(FiEyeOff, null), variant: "outlined", onClick: handleToggleImage, "aria-label": !showImage ? "show-image" : "hide-image" }),
117
196
  showImage && selectedImage && (React.createElement(React.Fragment, null,
118
197
  React.createElement(Button, { colorPalette: colorPalette, icon: React.createElement(FiSettings, null), variant: "outlined", style: { borderColor: "transparent" }, onClick: handleToggleSettings }),
119
- handleRemove && (React.createElement(Button, { colorPalette: colorPalette, icon: React.createElement(FiTrash2, null), variant: "destructive", onClick: handleRemove }))))),
120
- showImage && !showSettings && (React.createElement(InputArea, { onDrop: handleDrop, onDragOver: handleDragOver, colors: colorPalette },
198
+ React.createElement(Button, { colorPalette: colorPalette, icon: React.createElement(FiTrash2, null), variant: "destructive", onClick: clearInput })))),
199
+ showImage && !showSettings && (loading ? (React.createElement(Spinner, { colorPalette: colorPalette })) : (React.createElement(InputArea, { onDrop: handleDrop, onDragOver: handleDragOver, colors: colorPalette },
121
200
  selectedImage && (React.createElement(PreviewImage, { alt: s3Key || "Uploaded Image", src: selectedImage })),
122
201
  React.createElement(Button, { colorPalette: colorPalette, label: "Browse", variant: "filled", onClick: handleBrowseClick },
123
- React.createElement("input", { type: "file", name: "key", accept: acceptedFileTypes.join(","), onChange: handleImageUpload, ref: inputRef, id: `upload-image-${fieldInstance.id}`, multiple: false, style: { display: "none" } })))),
124
- showSettings && showImage && (React.createElement(SettingsArea, { colors: colorPalette }, settingsChildren)),
125
- changed && (React.createElement(Button, { colorPalette: colorPalette, onClick: handleSubmit, variant: "filled", style: { margin: "0 auto" } }, uploadButtonText))));
202
+ React.createElement("input", { type: "file", name: "key", accept: acceptedFileTypes.join(","), onChange: handleImageUpload, ref: inputRef, id: `upload-image-${fieldInstance.id}`, multiple: false, style: { display: "none" } }))))),
203
+ showSettings && showImage && (React.createElement(SettingsArea, { colors: colorPalette }, settingsChildren))));
126
204
  };
127
205
  //# sourceMappingURL=Thumbnail.js.map