@factorearth/component-library 5.2.4-alpha.0 → 5.3.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/README.md +11 -11
- package/dist/Atoms/Accordion/Accordion.js +18 -18
- package/dist/Atoms/Badge/Badge.js +18 -18
- package/dist/Atoms/Box/Box.js +15 -15
- package/dist/Atoms/Buttons/Button.js +23 -23
- package/dist/Atoms/ContentDropdown/ContentDropdown.js +24 -24
- package/dist/Atoms/DateField/DateField.js +94 -94
- package/dist/Atoms/FieldWrapper/FieldWrapper.js +35 -35
- package/dist/Atoms/MoreHorizonButton/MoreHorizonButton.js +52 -52
- package/dist/Atoms/NoteField/NoteField.js +38 -38
- package/dist/Atoms/NumberField/NumberField.js +63 -63
- package/dist/Atoms/OptionsDropdown/OptionsDropdown.js +38 -38
- package/dist/Atoms/Pagination/Pagination.js +25 -25
- package/dist/Atoms/PhoneNumberField/PhoneNumberField.js +4 -4
- package/dist/Atoms/ProgressBar/ProgressBar.js +16 -16
- package/dist/Atoms/SortDropdown/SortDropdown.js +39 -39
- package/dist/Atoms/Tab/Tab.js +18 -18
- package/dist/Atoms/TextField/TextField.js +24 -24
- package/dist/Atoms/Toggle/Toggle.js +11 -11
- package/dist/Atoms/Typography/Typography.js +7 -7
- package/dist/Molecules/Form/Form.js +8 -8
- package/dist/Molecules/NavMenu/NavMenu.js +102 -102
- package/dist/Molecules/TableHeader/TableHeader.js +14 -14
- package/dist/Molecules/TableRow/TableRow.js +27 -27
- package/dist/Molecules/Thumbnail/Thumbnail.d.ts +4 -4
- package/dist/Molecules/Thumbnail/Thumbnail.js +50 -126
- package/dist/Molecules/Thumbnail/Thumbnail.js.map +1 -1
- package/dist/Organisms/Card/Card.js +33 -33
- package/dist/Organisms/EditUserPerms/EditUserPerms.js +67 -67
- package/dist/Organisms/ErrorSplash/ErrorSplash.js +44 -44
- package/dist/Organisms/Modal/Modal.d.ts +5 -0
- package/dist/Organisms/Modal/Modal.js +88 -74
- package/dist/Organisms/Modal/Modal.js.map +1 -1
- package/dist/Organisms/Splash/Splash.d.ts +10 -0
- package/dist/Organisms/Splash/Splash.js +82 -0
- package/dist/Organisms/Splash/Splash.js.map +1 -0
- package/dist/Organisms/TabManager/TabManager.js +13 -13
- package/dist/Organisms/Table/Table.js +14 -14
- package/dist/Organisms/Tutorial/Tutorial.js +51 -51
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/Atoms/Spinner/Spinner.d.ts +0 -7
- package/dist/Atoms/Spinner/Spinner.js +0 -10
- package/dist/Atoms/Spinner/Spinner.js.map +0 -1
|
@@ -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,
|
|
3
|
+
export declare const Thumbnail: ({ colorPalette, handleSubmit, settingsChildren, showImage, setShowImage, fieldInstance, s3Key, signedUrl, uploadButtonText, handleRemove, changed, 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
|
|
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
|
-
|
|
18
|
+
uploadButtonText: string;
|
|
19
19
|
handleRemove?: () => void;
|
|
20
20
|
changed: boolean;
|
|
21
21
|
}) => React.JSX.Element;
|
|
@@ -2,64 +2,59 @@ 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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
flex-shrink: 0;
|
|
14
|
-
${({ showImage }) => showImage && `height: 278px; width: 200px`}
|
|
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`}
|
|
15
13
|
`;
|
|
16
|
-
const InputArea = styled.div `
|
|
17
|
-
width: 150px;
|
|
18
|
-
height: 132px;
|
|
19
|
-
display: flex;
|
|
20
|
-
justify-content: center;
|
|
21
|
-
align-items: center;
|
|
22
|
-
background-color: ${({ colors }) => colors.background.tertiary};
|
|
23
|
-
border-style: solid;
|
|
24
|
-
border-width: 1px;
|
|
25
|
-
border-color: ${({ colors }) => colors.border.primary};
|
|
26
|
-
position: relative;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
overflow: hidden;
|
|
29
|
-
border-radius: 4px;
|
|
30
|
-
padding: 24px;
|
|
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;
|
|
31
29
|
`;
|
|
32
|
-
const SettingsArea = styled.div `
|
|
33
|
-
width: 168px;
|
|
34
|
-
height: 148px;
|
|
35
|
-
display: flex;
|
|
36
|
-
justify-content: center;
|
|
37
|
-
align-items: center;
|
|
38
|
-
background-color: ${({ colors }) => colors.background.secondary};
|
|
39
|
-
border-style: solid;
|
|
40
|
-
border-width: 1px;
|
|
41
|
-
border-color: ${({ colors }) => colors.border.primary};
|
|
42
|
-
cursor: pointer;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
border-radius: 4px;
|
|
45
|
-
gap: 16px;
|
|
46
|
-
padding: 16px;
|
|
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;
|
|
47
45
|
`;
|
|
48
|
-
const PreviewImage = styled.img `
|
|
49
|
-
width: 100%;
|
|
50
|
-
height: 100%;
|
|
51
|
-
object-fit: cover;
|
|
52
|
-
position: absolute;
|
|
53
|
-
top: 0;
|
|
54
|
-
left: 0;
|
|
55
|
-
z-index: 1;
|
|
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;
|
|
56
54
|
`;
|
|
57
|
-
export const Thumbnail = ({ colorPalette, handleSubmit, settingsChildren, showImage, setShowImage, fieldInstance, s3Key, signedUrl,
|
|
55
|
+
export const Thumbnail = ({ colorPalette, handleSubmit, settingsChildren, showImage, setShowImage, fieldInstance, s3Key, signedUrl, uploadButtonText, handleRemove, changed, handleChange, }) => {
|
|
58
56
|
const [selectedImage, setSelectedImage] = useState(null);
|
|
59
57
|
const [showSettings, setShowSettings] = useState(false);
|
|
60
|
-
const [prevImage, setPrevImage] = useState(null);
|
|
61
|
-
const [openSubmitModal, setOpenSubmitModal] = useState(false);
|
|
62
|
-
const [deletingImage, setDeletingImage] = useState(false);
|
|
63
58
|
const acceptedFileTypes = [
|
|
64
59
|
"image/jpeg",
|
|
65
60
|
"image/png",
|
|
@@ -73,131 +68,60 @@ export const Thumbnail = ({ colorPalette, handleSubmit, settingsChildren, showIm
|
|
|
73
68
|
if (file) {
|
|
74
69
|
const imageUrl = URL.createObjectURL(file);
|
|
75
70
|
setSelectedImage(imageUrl);
|
|
76
|
-
setDeletingImage(false);
|
|
77
|
-
setPrevImage(null);
|
|
78
71
|
}
|
|
79
72
|
}
|
|
80
73
|
else if (signedUrl && typeof signedUrl === "string") {
|
|
81
74
|
setSelectedImage(signedUrl);
|
|
82
|
-
setDeletingImage(false);
|
|
83
|
-
setPrevImage(null);
|
|
84
75
|
}
|
|
85
76
|
else {
|
|
86
77
|
setSelectedImage(null);
|
|
87
78
|
}
|
|
88
79
|
}, [signedUrl, s3Key]);
|
|
89
|
-
/**
|
|
90
|
-
* Handles the image upload from the input element.
|
|
91
|
-
* @param event from the input element
|
|
92
|
-
*/
|
|
93
80
|
const handleImageUpload = (event) => {
|
|
94
81
|
const file = event.target.files?.[0];
|
|
95
82
|
if (file) {
|
|
96
83
|
const imageUrl = URL.createObjectURL(file);
|
|
97
84
|
setSelectedImage(imageUrl);
|
|
98
|
-
setDeletingImage(false);
|
|
99
|
-
setOpenSubmitModal(true);
|
|
100
85
|
handleChange(event);
|
|
101
86
|
}
|
|
102
87
|
};
|
|
103
|
-
/**
|
|
104
|
-
* Handles the image upload from the drag and drop event.
|
|
105
|
-
* @param event from the drag event
|
|
106
|
-
*/
|
|
107
88
|
const handleDrop = (event) => {
|
|
108
89
|
event.preventDefault();
|
|
109
90
|
const file = event.dataTransfer.files[0];
|
|
110
91
|
if (file) {
|
|
111
92
|
const imageUrl = URL.createObjectURL(file);
|
|
112
93
|
setSelectedImage(imageUrl);
|
|
113
|
-
setOpenSubmitModal(true);
|
|
114
|
-
setDeletingImage(false);
|
|
115
94
|
const dropEvent = { target: { files: event.dataTransfer.files, name: "key", type: "file" } };
|
|
116
95
|
if (inputRef.current)
|
|
117
96
|
inputRef.current.files = event.dataTransfer.files;
|
|
118
97
|
handleChange(dropEvent);
|
|
119
98
|
}
|
|
120
99
|
};
|
|
121
|
-
/**
|
|
122
|
-
* HAndles the image upload from the drag and drop event.
|
|
123
|
-
* @param event from the drag event
|
|
124
|
-
*/
|
|
125
100
|
const handleDragOver = (event) => {
|
|
126
101
|
event.preventDefault();
|
|
127
|
-
const file = event.dataTransfer.files[0];
|
|
128
|
-
if (file) {
|
|
129
|
-
const imageUrl = URL.createObjectURL(file);
|
|
130
|
-
setSelectedImage(imageUrl);
|
|
131
|
-
setOpenSubmitModal(true);
|
|
132
|
-
setDeletingImage(false);
|
|
133
|
-
const dropEvent = { target: { files: event.dataTransfer.files, name: "key", type: "file" } };
|
|
134
|
-
if (inputRef.current)
|
|
135
|
-
inputRef.current.files = event.dataTransfer.files;
|
|
136
|
-
handleChange(dropEvent);
|
|
137
|
-
}
|
|
138
102
|
};
|
|
139
|
-
|
|
140
|
-
* Handles the click event of the browse button.
|
|
141
|
-
*/
|
|
142
|
-
const handleBrowseClick = () => {
|
|
103
|
+
const handleBrowseClick = (event) => {
|
|
143
104
|
if (inputRef && inputRef.current)
|
|
144
105
|
inputRef.current.click();
|
|
145
106
|
};
|
|
146
|
-
/**
|
|
147
|
-
* Handles toggling the image preview.
|
|
148
|
-
*/
|
|
149
107
|
const handleToggleImage = () => {
|
|
150
108
|
setShowImage(!showImage);
|
|
151
109
|
setShowSettings(false);
|
|
152
110
|
};
|
|
153
|
-
/**
|
|
154
|
-
* Handles toggling the settings.
|
|
155
|
-
*/
|
|
156
111
|
const handleToggleSettings = () => {
|
|
157
112
|
setShowSettings(!showSettings);
|
|
158
113
|
};
|
|
159
|
-
/**
|
|
160
|
-
* Handles clearing the input and removing the image.
|
|
161
|
-
*/
|
|
162
|
-
const clearInput = () => {
|
|
163
|
-
if (inputRef.current) {
|
|
164
|
-
setPrevImage(selectedImage);
|
|
165
|
-
setSelectedImage(null);
|
|
166
|
-
inputRef.current.value = "";
|
|
167
|
-
}
|
|
168
|
-
if (handleRemove) {
|
|
169
|
-
setDeletingImage(true);
|
|
170
|
-
setOpenSubmitModal(true);
|
|
171
|
-
handleRemove();
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Handles the cancel click event from the modal.
|
|
176
|
-
*/
|
|
177
|
-
const undoDelete = () => {
|
|
178
|
-
setSelectedImage(prevImage);
|
|
179
|
-
setOpenSubmitModal(false);
|
|
180
|
-
setDeletingImage(false);
|
|
181
|
-
setPrevImage(null);
|
|
182
|
-
};
|
|
183
|
-
/**
|
|
184
|
-
* Handles the submit click event from the modal.
|
|
185
|
-
*/
|
|
186
|
-
const handleSubmitClick = async () => {
|
|
187
|
-
await handleSubmit();
|
|
188
|
-
setOpenSubmitModal(false);
|
|
189
|
-
};
|
|
190
114
|
return (React.createElement(Container, { colors: colorPalette, showImage: showImage, showSettings: showSettings, key: `thumbnail_${fieldInstance.id}` },
|
|
191
115
|
React.createElement("div", { style: { display: "flex" } },
|
|
192
116
|
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" }),
|
|
193
117
|
showImage && selectedImage && (React.createElement(React.Fragment, null,
|
|
194
118
|
React.createElement(Button, { colorPalette: colorPalette, icon: React.createElement(FiSettings, null), variant: "outlined", style: { borderColor: "transparent" }, onClick: handleToggleSettings }),
|
|
195
|
-
React.createElement(Button, { colorPalette: colorPalette, icon: React.createElement(FiTrash2, null), variant: "destructive", onClick:
|
|
119
|
+
handleRemove && (React.createElement(Button, { colorPalette: colorPalette, icon: React.createElement(FiTrash2, null), variant: "destructive", onClick: handleRemove }))))),
|
|
196
120
|
showImage && !showSettings && (React.createElement(InputArea, { onDrop: handleDrop, onDragOver: handleDragOver, colors: colorPalette },
|
|
197
121
|
selectedImage && (React.createElement(PreviewImage, { alt: s3Key || "Uploaded Image", src: selectedImage })),
|
|
198
122
|
React.createElement(Button, { colorPalette: colorPalette, label: "Browse", variant: "filled", onClick: handleBrowseClick },
|
|
199
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" } })))),
|
|
200
124
|
showSettings && showImage && (React.createElement(SettingsArea, { colors: colorPalette }, settingsChildren)),
|
|
201
|
-
|
|
125
|
+
changed && (React.createElement(Button, { colorPalette: colorPalette, onClick: handleSubmit, variant: "filled", style: { margin: "0 auto" } }, uploadButtonText))));
|
|
202
126
|
};
|
|
203
127
|
//# sourceMappingURL=Thumbnail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Thumbnail.js","sourceRoot":"","sources":["../../../lib/Molecules/Thumbnail/Thumbnail.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACb,QAAQ,EAER,MAAM,EAGN,SAAS,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