@grantbii/design-system 1.0.51 → 1.0.53
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/core/organisms/GrantMatch.d.ts +11 -17
- package/core/organisms/GrantMatch.js +30 -54
- package/core/organisms/YesNoOptions.js +1 -1
- package/package.json +2 -2
- package/stories/molecules/RadioButtons.stories.js +1 -1
- package/stories/organisms/GrantMatch.stories.d.ts +6 -2
- package/stories/organisms/GrantMatch.stories.js +12 -5
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
type GrantMatchProps = {
|
|
6
|
-
query: MatchQuery;
|
|
1
|
+
import { GrantMatchQuery } from "@grantbii/ui-base/match/models";
|
|
2
|
+
type GrantMatchQueryProps = {
|
|
3
|
+
query: GrantMatchQuery;
|
|
7
4
|
updateQueryFiles: (newFiles: File[]) => void;
|
|
5
|
+
removeQueryFile: (fileName: string) => void;
|
|
8
6
|
updateQueryText: (newText: string) => void;
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
removeQueryText: () => void;
|
|
8
|
+
resetQuery: () => void;
|
|
11
9
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const useMatchQuery: () => {
|
|
15
|
-
query: {
|
|
16
|
-
files: File[];
|
|
17
|
-
text: string;
|
|
18
|
-
};
|
|
19
|
-
updateQueryFiles: (newFiles: File[]) => void;
|
|
20
|
-
updateQueryText: (newText: string) => void;
|
|
10
|
+
type GrantMatchProps = GrantMatchQueryProps & {
|
|
11
|
+
isModalFullScreen?: boolean;
|
|
21
12
|
};
|
|
13
|
+
declare const GrantMatch: ({ query, updateQueryFiles, removeQueryFile, updateQueryText, removeQueryText, resetQuery, isModalFullScreen, }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default GrantMatch;
|
|
15
|
+
export declare const useGrantMatchQueryItems: () => GrantMatchQueryProps;
|
|
@@ -1,65 +1,41 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isGrantMatchActive } from "@grantbii/ui-base/match/mappings";
|
|
2
3
|
import { useState } from "react";
|
|
3
4
|
import styled from "styled-components";
|
|
4
5
|
import { Badge, Button, Textarea } from "../atoms";
|
|
5
6
|
import { Colors, Icons } from "../foundations";
|
|
6
7
|
import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
|
|
7
|
-
const GrantMatch = ({ query, updateQueryFiles, updateQueryText,
|
|
8
|
+
const GrantMatch = ({ query, updateQueryFiles, removeQueryFile, updateQueryText, removeQueryText, resetQuery, isModalFullScreen, }) => {
|
|
8
9
|
const { showModal, openModal, closeModal } = useModal();
|
|
9
|
-
const
|
|
10
|
-
return (_jsxs(Container, { children: [_jsx(GrantMatchButtons, { active: isQueryActive(query), onClickMatch: () => openModal(), onClickReset: () => resetGrantMatch() }), isQueryActive(query) ? (_jsx(QueryItems, { uploadedFiles: query.files, removeUploadedFile: removeUploadedFile, queryText: query.text, removeQueryText: removeQueryText })) : (_jsx(_Fragment, {})), showModal ? (_jsx(GrantMatchModal, { activeFiles: query.files, activeText: query.text, performGrantMatch: performGrantMatch, onClickCancel: () => closeModal() })) : (_jsx(_Fragment, {}))] }));
|
|
11
|
-
};
|
|
12
|
-
export default GrantMatch;
|
|
13
|
-
export const useMatchQuery = () => {
|
|
14
|
-
const [files, setFiles] = useState([]);
|
|
15
|
-
const [text, setText] = useState("");
|
|
16
|
-
return {
|
|
17
|
-
query: { files, text },
|
|
18
|
-
updateQueryFiles: (newFiles) => setFiles(newFiles),
|
|
19
|
-
updateQueryText: (newText) => setText(newText),
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const useGrantMatch = (matchQuery, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, closeModal) => {
|
|
10
|
+
const isActive = isGrantMatchActive(query);
|
|
23
11
|
const performGrantMatch = (newFiles, newText) => {
|
|
24
12
|
updateQueryFiles(newFiles);
|
|
25
13
|
updateQueryText(newText);
|
|
26
|
-
onPerformGrantMatch({ files: newFiles, text: newText });
|
|
27
14
|
closeModal();
|
|
28
15
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const removeQueryText = () => {
|
|
46
|
-
updateQueryText("");
|
|
47
|
-
const newQuery = { files: matchQuery.files, text: "" };
|
|
48
|
-
if (isQueryActive(newQuery)) {
|
|
49
|
-
onPerformGrantMatch(newQuery);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
onResetGrantMatch();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
16
|
+
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, {}))] }));
|
|
17
|
+
};
|
|
18
|
+
export default GrantMatch;
|
|
19
|
+
const BLANK_GRANT_MATCH_QUERY = { files: [], text: "" };
|
|
20
|
+
export const useGrantMatchQueryItems = () => {
|
|
21
|
+
const [query, setQuery] = useState(() => (Object.assign({}, BLANK_GRANT_MATCH_QUERY)));
|
|
22
|
+
const updateQueryFiles = (files) => setQuery(({ text }) => ({ files, text }));
|
|
23
|
+
const removeQueryFile = (fileName) => setQuery(({ files, text }) => ({
|
|
24
|
+
files: files.filter((file) => file.name !== fileName),
|
|
25
|
+
text,
|
|
26
|
+
}));
|
|
27
|
+
const updateQueryText = (text) => setQuery(({ files }) => ({ files, text }));
|
|
28
|
+
const removeQueryText = () => setQuery(({ files }) => ({ files, text: "" }));
|
|
29
|
+
const resetQuery = () => setQuery(Object.assign({}, BLANK_GRANT_MATCH_QUERY));
|
|
55
30
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
31
|
+
query,
|
|
32
|
+
updateQueryFiles,
|
|
33
|
+
removeQueryFile,
|
|
34
|
+
updateQueryText,
|
|
59
35
|
removeQueryText,
|
|
36
|
+
resetQuery,
|
|
60
37
|
};
|
|
61
38
|
};
|
|
62
|
-
const isQueryActive = (query) => query.files.length !== 0 || query.text.trim() !== "";
|
|
63
39
|
const Container = styled.div `
|
|
64
40
|
display: flex;
|
|
65
41
|
flex-direction: column;
|
|
@@ -70,13 +46,13 @@ const Container = styled.div `
|
|
|
70
46
|
width: 100%;
|
|
71
47
|
max-width: 100vw;
|
|
72
48
|
`;
|
|
73
|
-
const GrantMatchButtons = ({
|
|
49
|
+
const GrantMatchButtons = ({ isActive, onClickMatch, onClickReset, }) => (_jsxs(Buttons, { children: [_jsx(GrantMatchButton, { isActive: isActive, onClick: onClickMatch }), isActive ? (_jsx(Button, { text: "Reset", onClick: onClickReset, color: Colors.typography.blackMedium, underline: true })) : (_jsx(_Fragment, {}))] }));
|
|
74
50
|
const Buttons = styled.div `
|
|
75
51
|
display: flex;
|
|
76
52
|
align-items: center;
|
|
77
53
|
gap: 8px;
|
|
78
54
|
`;
|
|
79
|
-
const GrantMatchButton = ({
|
|
55
|
+
const GrantMatchButton = ({ isActive, onClick }) => (_jsxs(BaseGrantMatchButton, { type: "button", "$isActive": isActive, onClick: onClick, children: [_jsx(Icons.GrantMatchIcon, { size: 20 }), _jsx("p", { children: "Find grants that match your needs" }), _jsx(Icons.MagnifyingGlassIcon, { size: 20 })] }));
|
|
80
56
|
const BaseGrantMatchButton = styled.button `
|
|
81
57
|
display: flex;
|
|
82
58
|
align-items: center;
|
|
@@ -92,12 +68,12 @@ const BaseGrantMatchButton = styled.button `
|
|
|
92
68
|
color: ${Colors.typography.blackMedium};
|
|
93
69
|
background-color: ${Colors.base.white};
|
|
94
70
|
border: 1px solid
|
|
95
|
-
${({ $
|
|
71
|
+
${({ $isActive }) => $isActive ? Colors.accent.yellow1 : Colors.neutral.grey3};
|
|
96
72
|
`;
|
|
97
|
-
const QueryItems = ({
|
|
73
|
+
const QueryItems = ({ queryFiles, removeQueryFile, queryText, removeQueryText, }) => (_jsxs(BaseQueryItems, { children: [queryFiles.map((file) => {
|
|
98
74
|
var _a;
|
|
99
|
-
return (_jsx(Badge, { text: file.name, Icon: (_a = FILE_TYPE_ICON_MAP[file.type]) !== null && _a !== void 0 ? _a : Icons.FileIcon, onClickClose: () =>
|
|
100
|
-
}), queryText === "" ? (_jsx(_Fragment, {})) : (_jsx(Badge, { text: "Additional Information", Icon: Icons.TextAaIcon, onClickClose: () => removeQueryText(), textWidthPixels:
|
|
75
|
+
return (_jsx(Badge, { text: file.name, Icon: (_a = FILE_TYPE_ICON_MAP[file.type]) !== null && _a !== void 0 ? _a : Icons.FileIcon, onClickClose: () => removeQueryFile(file.name), textWidthPixels: 160 }, file.name));
|
|
76
|
+
}), queryText === "" ? (_jsx(_Fragment, {})) : (_jsx(Badge, { text: "Additional Information", Icon: Icons.TextAaIcon, onClickClose: () => removeQueryText(), textWidthPixels: 180 }, "additional-information-query-item"))] }));
|
|
101
77
|
const BaseQueryItems = styled.div `
|
|
102
78
|
display: flex;
|
|
103
79
|
align-items: center;
|
|
@@ -115,11 +91,11 @@ const BaseQueryItems = styled.div `
|
|
|
115
91
|
const FILE_TYPE_ICON_MAP = {
|
|
116
92
|
"application/pdf": Icons.FilePdfIcon,
|
|
117
93
|
};
|
|
118
|
-
const GrantMatchModal = ({ activeFiles, activeText, performGrantMatch, onClickCancel, }) => {
|
|
94
|
+
const GrantMatchModal = ({ activeFiles, activeText, performGrantMatch, onClickCancel, isFullScreen, }) => {
|
|
119
95
|
const { files, uploadFiles, removeFile } = useFileDrop(activeFiles);
|
|
120
96
|
const [queryText, setQueryText] = useState(activeText);
|
|
121
97
|
const updateQueryText = (newText) => setQueryText(newText);
|
|
122
|
-
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 }));
|
|
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 }));
|
|
123
99
|
};
|
|
124
100
|
const Header = () => (_jsxs(BaseHeader, { children: [_jsx(Icons.GrantMatchIcon, { size: 24 }), _jsx("div", { children: "Grant Match" })] }));
|
|
125
101
|
const BaseHeader = styled.div `
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { LogicOption } from "@grantbii/ui-base/grant/enums";
|
|
2
3
|
import styled from "styled-components";
|
|
3
4
|
import { RadioButton } from "../atoms";
|
|
4
|
-
import { LogicOption } from "@grantbii/ui-base/enums";
|
|
5
5
|
const YesNoOptions = ({ name, yesProps, noProps, unsureProps, }) => (_jsxs(RadioGroup, { children: [_jsx(RadioButton, Object.assign({}, yesProps, { id: `${name}-yes`, label: LogicOption.YES, value: LogicOption.YES, name: name })), _jsx(RadioButton, Object.assign({}, noProps, { id: `${name}-no`, label: LogicOption.NO, value: LogicOption.NO, name: name })), unsureProps ? (_jsx(RadioButton, Object.assign({}, unsureProps, { id: `${name}-unsure`, label: LogicOption.UNSURE, value: LogicOption.UNSURE, name: name }))) : (_jsx(_Fragment, {}))] }));
|
|
6
6
|
export default YesNoOptions;
|
|
7
7
|
const RadioGroup = styled.div `
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grantbii/design-system",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
4
4
|
"description": "Grantbii's Design System",
|
|
5
5
|
"homepage": "https://design.grantbii.com",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build-storybook": "storybook build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@grantbii/ui-base": "1.0.
|
|
21
|
+
"@grantbii/ui-base": "1.0.14",
|
|
22
22
|
"@phosphor-icons/react": "^2.1.10",
|
|
23
23
|
"country-flag-icons": "^1.5.19",
|
|
24
24
|
"next": "^15.3.5",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { RadioButtons } from "@/.";
|
|
3
|
-
import { Location } from "@grantbii/ui-base/enums";
|
|
3
|
+
import { Location } from "@grantbii/ui-base/grant/enums";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
const RadioButtonsExample = ({ controlled }) => {
|
|
6
6
|
const [location, setLocation] = useState("");
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
2
|
-
|
|
2
|
+
type GrantMatchExampleProps = {
|
|
3
|
+
isModalFullScreen?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const GrantMatchExample: ({ isModalFullScreen }: GrantMatchExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
6
|
declare const meta: Meta<typeof GrantMatchExample>;
|
|
4
7
|
export default meta;
|
|
5
8
|
type Story = StoryObj<typeof meta>;
|
|
6
|
-
export declare const
|
|
9
|
+
export declare const PopUp: Story;
|
|
10
|
+
export declare const FullScreen: Story;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { GrantMatch } from "@/.";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { useGrantMatchQueryItems } from "@/core/organisms/GrantMatch";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
const GrantMatchExample = ({ isModalFullScreen }) => {
|
|
6
|
+
const grantMatchProps = useGrantMatchQueryItems();
|
|
7
|
+
return (_jsx(Container, { children: _jsx(GrantMatch, Object.assign({}, grantMatchProps, { isModalFullScreen: isModalFullScreen })) }));
|
|
7
8
|
};
|
|
9
|
+
const Container = styled.div `
|
|
10
|
+
width: 90vw;
|
|
11
|
+
`;
|
|
8
12
|
const meta = {
|
|
9
13
|
title: "Organisms/Grant Match",
|
|
10
14
|
component: GrantMatchExample,
|
|
@@ -14,6 +18,9 @@ const meta = {
|
|
|
14
18
|
},
|
|
15
19
|
};
|
|
16
20
|
export default meta;
|
|
17
|
-
export const
|
|
21
|
+
export const PopUp = {
|
|
18
22
|
args: {},
|
|
19
23
|
};
|
|
24
|
+
export const FullScreen = {
|
|
25
|
+
args: { isModalFullScreen: true },
|
|
26
|
+
};
|