@grantbii/design-system 1.0.55 → 1.0.56
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.
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { GrantMatchQuery } from "@grantbii/ui-base/match/models";
|
|
2
|
-
type
|
|
2
|
+
type GrantMatchProps = {
|
|
3
3
|
query: GrantMatchQuery;
|
|
4
|
-
|
|
4
|
+
onPerformGrantMatch: (newQuery: GrantMatchQuery) => void;
|
|
5
5
|
removeQueryFile: (fileName: string) => void;
|
|
6
|
-
updateQueryText: (newText: string) => void;
|
|
7
6
|
removeQueryText: () => void;
|
|
8
7
|
resetQuery: () => void;
|
|
9
|
-
};
|
|
10
|
-
type GrantMatchProps = GrantMatchQueryProps & {
|
|
11
8
|
isModalFullScreen?: boolean;
|
|
12
9
|
};
|
|
13
|
-
declare const GrantMatch: ({ query,
|
|
10
|
+
declare const GrantMatch: ({ query, onPerformGrantMatch, removeQueryFile, removeQueryText, resetQuery, isModalFullScreen, }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
11
|
export default GrantMatch;
|
|
15
|
-
export declare const useGrantMatchQueryItems: () =>
|
|
12
|
+
export declare const useGrantMatchQueryItems: () => {
|
|
13
|
+
query: GrantMatchQuery;
|
|
14
|
+
updateQuery: (newQuery: GrantMatchQuery) => void;
|
|
15
|
+
removeQueryFile: (fileName: string) => void;
|
|
16
|
+
removeQueryText: () => void;
|
|
17
|
+
resetQuery: () => void;
|
|
18
|
+
};
|
|
@@ -5,12 +5,11 @@ import styled from "styled-components";
|
|
|
5
5
|
import { Badge, Button, Textarea } from "../atoms";
|
|
6
6
|
import { Colors, Icons } from "../foundations";
|
|
7
7
|
import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
|
|
8
|
-
const GrantMatch = ({ query,
|
|
8
|
+
const GrantMatch = ({ query, onPerformGrantMatch, removeQueryFile, removeQueryText, resetQuery, isModalFullScreen, }) => {
|
|
9
9
|
const { showModal, openModal, closeModal } = useModal();
|
|
10
10
|
const isActive = isGrantMatchActive(query);
|
|
11
|
-
const performGrantMatch = (
|
|
12
|
-
|
|
13
|
-
updateQueryText(newText);
|
|
11
|
+
const performGrantMatch = (newQuery) => {
|
|
12
|
+
onPerformGrantMatch(newQuery);
|
|
14
13
|
closeModal();
|
|
15
14
|
};
|
|
16
15
|
return (_jsxs(Container, { children: [_jsx(GrantMatchButtons, { isActive: isActive, onClickMatch: () => openModal(), onClickReset: () => resetQuery() }), isActive ? (_jsx(QueryItems, { queryFiles: query.files, removeQueryFile: removeQueryFile, queryText: query.text, removeQueryText: removeQueryText })) : (_jsx(_Fragment, {})), showModal ? (_jsx(GrantMatchModal, { activeFiles: query.files, activeText: query.text, performGrantMatch: performGrantMatch, onClickCancel: () => closeModal(), isFullScreen: isModalFullScreen })) : (_jsx(_Fragment, {}))] }));
|
|
@@ -19,19 +18,17 @@ export default GrantMatch;
|
|
|
19
18
|
const BLANK_GRANT_MATCH_QUERY = { files: [], text: "" };
|
|
20
19
|
export const useGrantMatchQueryItems = () => {
|
|
21
20
|
const [query, setQuery] = useState(() => (Object.assign({}, BLANK_GRANT_MATCH_QUERY)));
|
|
22
|
-
const
|
|
21
|
+
const updateQuery = (newQuery) => setQuery(Object.assign({}, newQuery));
|
|
23
22
|
const removeQueryFile = (fileName) => setQuery(({ files, text }) => ({
|
|
24
23
|
files: files.filter((file) => file.name !== fileName),
|
|
25
24
|
text,
|
|
26
25
|
}));
|
|
27
|
-
const updateQueryText = (text) => setQuery(({ files }) => ({ files, text }));
|
|
28
26
|
const removeQueryText = () => setQuery(({ files }) => ({ files, text: "" }));
|
|
29
27
|
const resetQuery = () => setQuery(Object.assign({}, BLANK_GRANT_MATCH_QUERY));
|
|
30
28
|
return {
|
|
31
29
|
query,
|
|
32
|
-
|
|
30
|
+
updateQuery,
|
|
33
31
|
removeQueryFile,
|
|
34
|
-
updateQueryText,
|
|
35
32
|
removeQueryText,
|
|
36
33
|
resetQuery,
|
|
37
34
|
};
|
|
@@ -93,9 +90,8 @@ const FILE_TYPE_ICON_MAP = {
|
|
|
93
90
|
};
|
|
94
91
|
const GrantMatchModal = ({ activeFiles, activeText, performGrantMatch, onClickCancel, isFullScreen, }) => {
|
|
95
92
|
const { files, uploadFiles, removeFile } = useFileDrop(activeFiles);
|
|
96
|
-
const [
|
|
97
|
-
|
|
98
|
-
return (_jsx(Modal, { header: _jsx(Header, {}), content: _jsx(Content, { files: files, uploadFiles: uploadFiles, removeFile: removeFile, queryText: queryText, updateQueryText: updateQueryText }), footer: _jsx(Button, { text: "Find My Grants", onClick: () => performGrantMatch(files, queryText), backgroundColor: Colors.accent.yellow1 }), onClickCancel: onClickCancel, isFullScreen: isFullScreen }));
|
|
93
|
+
const [text, setText] = useState(activeText);
|
|
94
|
+
return (_jsx(Modal, { header: _jsx(Header, {}), content: _jsx(Content, { files: files, uploadFiles: uploadFiles, removeFile: removeFile, queryText: text, updateQueryText: (newText) => setText(newText) }), footer: _jsx(Button, { text: "Find My Grants", onClick: () => performGrantMatch({ files, text }), backgroundColor: Colors.accent.yellow1 }), onClickCancel: onClickCancel, isFullScreen: isFullScreen }));
|
|
99
95
|
};
|
|
100
96
|
const Header = () => (_jsxs(BaseHeader, { children: [_jsx(Icons.GrantMatchIcon, { size: 24 }), _jsx("div", { children: "Grant Match" })] }));
|
|
101
97
|
const BaseHeader = styled.div `
|
|
@@ -103,10 +99,8 @@ const BaseHeader = styled.div `
|
|
|
103
99
|
align-items: center;
|
|
104
100
|
gap: 12px;
|
|
105
101
|
`;
|
|
106
|
-
const Content = ({ files, uploadFiles, removeFile, queryText, updateQueryText, }) => {
|
|
107
|
-
|
|
108
|
-
return (_jsxs(BaseContent, { children: [_jsx(FileDrop, { uploadedFiles: files, uploadFiles: uploadFiles, removeFile: removeFile }), _jsxs(QueryText, { children: [_jsx("label", { htmlFor: additionalInformationId, children: "Additional Information" }), _jsx(Textarea, { id: additionalInformationId, value: queryText, onChange: (event) => updateQueryText(event.target.value) })] })] }));
|
|
109
|
-
};
|
|
102
|
+
const Content = ({ files, uploadFiles, removeFile, queryText, updateQueryText, }) => (_jsxs(BaseContent, { children: [_jsx(FileDrop, { uploadedFiles: files, uploadFiles: uploadFiles, removeFile: removeFile }), _jsxs(QueryText, { children: [_jsx("label", { htmlFor: ADDITIONAL_INFORMATION_ID, children: "Additional Information" }), _jsx(Textarea, { id: ADDITIONAL_INFORMATION_ID, value: queryText, onChange: (event) => updateQueryText(event.target.value) })] })] }));
|
|
103
|
+
const ADDITIONAL_INFORMATION_ID = "grant-match-additional-information";
|
|
110
104
|
const BaseContent = styled.div `
|
|
111
105
|
display: flex;
|
|
112
106
|
flex-direction: column;
|
package/package.json
CHANGED
|
@@ -3,8 +3,12 @@ import { GrantMatch } from "@/.";
|
|
|
3
3
|
import { useGrantMatchQueryItems } from "@/core/organisms/GrantMatch";
|
|
4
4
|
import styled from "styled-components";
|
|
5
5
|
const GrantMatchExample = ({ isModalFullScreen }) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const { query, updateQuery, removeQueryFile, removeQueryText, resetQuery } = useGrantMatchQueryItems();
|
|
7
|
+
const onPerformGrantMatch = (newQuery) => {
|
|
8
|
+
updateQuery(newQuery);
|
|
9
|
+
console.log("finding grants...");
|
|
10
|
+
};
|
|
11
|
+
return (_jsx(Container, { children: _jsx(GrantMatch, { query: query, onPerformGrantMatch: onPerformGrantMatch, removeQueryFile: removeQueryFile, removeQueryText: removeQueryText, resetQuery: resetQuery, isModalFullScreen: isModalFullScreen }) }));
|
|
8
12
|
};
|
|
9
13
|
const Container = styled.div `
|
|
10
14
|
width: 90vw;
|