@grantbii/design-system 1.0.51 → 1.0.52

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,12 +1,9 @@
1
- type MatchQuery = {
2
- files: File[];
3
- text: string;
4
- };
1
+ import { GrantMatchQuery } from "@grantbii/ui-base/match/models";
5
2
  type GrantMatchProps = {
6
- query: MatchQuery;
3
+ query: GrantMatchQuery;
7
4
  updateQueryFiles: (newFiles: File[]) => void;
8
5
  updateQueryText: (newText: string) => void;
9
- onPerformGrantMatch: (query: MatchQuery) => void;
6
+ onPerformGrantMatch: (query: GrantMatchQuery) => void;
10
7
  onResetGrantMatch: () => void;
11
8
  };
12
9
  declare const GrantMatch: ({ query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
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";
@@ -7,7 +8,8 @@ import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
7
8
  const GrantMatch = ({ query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, }) => {
8
9
  const { showModal, openModal, closeModal } = useModal();
9
10
  const { performGrantMatch, resetGrantMatch, removeUploadedFile, removeQueryText, } = useGrantMatch(query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, closeModal);
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
+ const isActive = isGrantMatchActive(query);
12
+ return (_jsxs(Container, { children: [_jsx(GrantMatchButtons, { isActive: isActive, onClickMatch: () => openModal(), onClickReset: () => resetGrantMatch() }), isActive ? (_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
13
  };
12
14
  export default GrantMatch;
13
15
  export const useMatchQuery = () => {
@@ -19,7 +21,7 @@ export const useMatchQuery = () => {
19
21
  updateQueryText: (newText) => setText(newText),
20
22
  };
21
23
  };
22
- const useGrantMatch = (matchQuery, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, closeModal) => {
24
+ const useGrantMatch = (query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, closeModal) => {
23
25
  const performGrantMatch = (newFiles, newText) => {
24
26
  updateQueryFiles(newFiles);
25
27
  updateQueryText(newText);
@@ -32,10 +34,10 @@ const useGrantMatch = (matchQuery, updateQueryFiles, updateQueryText, onPerformG
32
34
  onResetGrantMatch();
33
35
  };
34
36
  const removeUploadedFile = (fileName) => {
35
- const newFiles = matchQuery.files.filter((file) => file.name !== fileName);
37
+ const newFiles = query.files.filter((file) => file.name !== fileName);
36
38
  updateQueryFiles(newFiles);
37
- const newQuery = { files: newFiles, text: matchQuery.text };
38
- if (isQueryActive(newQuery)) {
39
+ const newQuery = { files: newFiles, text: query.text };
40
+ if (isGrantMatchActive(newQuery)) {
39
41
  onPerformGrantMatch(newQuery);
40
42
  }
41
43
  else {
@@ -44,8 +46,8 @@ const useGrantMatch = (matchQuery, updateQueryFiles, updateQueryText, onPerformG
44
46
  };
45
47
  const removeQueryText = () => {
46
48
  updateQueryText("");
47
- const newQuery = { files: matchQuery.files, text: "" };
48
- if (isQueryActive(newQuery)) {
49
+ const newQuery = { files: query.files, text: "" };
50
+ if (isGrantMatchActive(newQuery)) {
49
51
  onPerformGrantMatch(newQuery);
50
52
  }
51
53
  else {
@@ -59,7 +61,6 @@ const useGrantMatch = (matchQuery, updateQueryFiles, updateQueryText, onPerformG
59
61
  removeQueryText,
60
62
  };
61
63
  };
62
- const isQueryActive = (query) => query.files.length !== 0 || query.text.trim() !== "";
63
64
  const Container = styled.div `
64
65
  display: flex;
65
66
  flex-direction: column;
@@ -70,13 +71,13 @@ const Container = styled.div `
70
71
  width: 100%;
71
72
  max-width: 100vw;
72
73
  `;
73
- const GrantMatchButtons = ({ active, onClickMatch, onClickReset, }) => (_jsxs(Buttons, { children: [_jsx(GrantMatchButton, { active: active, onClick: onClickMatch }), active ? (_jsx(Button, { text: "Reset", onClick: onClickReset, color: Colors.typography.blackMedium, underline: true })) : (_jsx(_Fragment, {}))] }));
74
+ 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
75
  const Buttons = styled.div `
75
76
  display: flex;
76
77
  align-items: center;
77
78
  gap: 8px;
78
79
  `;
79
- const GrantMatchButton = ({ active, onClick }) => (_jsxs(BaseGrantMatchButton, { type: "button", "$active": active, onClick: onClick, children: [_jsx(Icons.GrantMatchIcon, { size: 20 }), _jsx("p", { children: "Find grants that match your needs" }), _jsx(Icons.MagnifyingGlassIcon, { size: 20 })] }));
80
+ 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
81
  const BaseGrantMatchButton = styled.button `
81
82
  display: flex;
82
83
  align-items: center;
@@ -92,7 +93,7 @@ const BaseGrantMatchButton = styled.button `
92
93
  color: ${Colors.typography.blackMedium};
93
94
  background-color: ${Colors.base.white};
94
95
  border: 1px solid
95
- ${({ $active }) => ($active ? Colors.accent.yellow1 : Colors.neutral.grey3)};
96
+ ${({ $isActive }) => $isActive ? Colors.accent.yellow1 : Colors.neutral.grey3};
96
97
  `;
97
98
  const QueryItems = ({ uploadedFiles, removeUploadedFile, queryText, removeQueryText, }) => (_jsxs(BaseQueryItems, { children: [uploadedFiles.map((file) => {
98
99
  var _a;
@@ -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.51",
3
+ "version": "1.0.52",
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.13",
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,10 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { GrantMatch } from "@/.";
3
3
  import { useMatchQuery } from "@/core/organisms/GrantMatch";
4
+ import styled from "styled-components";
4
5
  const GrantMatchExample = () => {
5
6
  const matchQuery = useMatchQuery();
6
- return (_jsx(GrantMatch, Object.assign({}, matchQuery, { onPerformGrantMatch: () => console.log("finding grants..."), onResetGrantMatch: () => console.log("resetting grant match...") })));
7
+ return (_jsx(Container, { children: _jsx(GrantMatch, Object.assign({}, matchQuery, { onPerformGrantMatch: () => console.log("finding grants..."), onResetGrantMatch: () => console.log("resetting grant match...") })) }));
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,