synapse-react-client 4.0.11 → 4.0.12
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/dist/SWC.index.d.ts +1 -1
- package/dist/SWC.index.js +1 -1
- package/dist/components/AdaptiveTwoColumnLayout/AdaptiveTwoColumnLayout.d.ts +44 -0
- package/dist/components/AdaptiveTwoColumnLayout/AdaptiveTwoColumnLayout.d.ts.map +1 -0
- package/dist/components/AdaptiveTwoColumnLayout/AdaptiveTwoColumnLayout.js +46 -0
- package/dist/components/AdaptiveTwoColumnLayout/AdaptiveTwoColumnLayout.js.map +1 -0
- package/dist/components/DownloadCart/DownloadCartPage.d.ts.map +1 -1
- package/dist/components/DownloadCart/DownloadCartPage.js +183 -185
- package/dist/components/DownloadCart/DownloadCartPage.js.map +1 -1
- package/dist/components/DownloadCart/DownloadIneligibleForPackagingFilesFromListButton.d.ts.map +1 -1
- package/dist/components/DownloadCart/DownloadIneligibleForPackagingFilesFromListButton.js +1 -1
- package/dist/components/DownloadCart/DownloadIneligibleForPackagingFilesFromListButton.js.map +1 -1
- package/dist/components/EntityAclEditor/EntityAclEditor.js +8 -8
- package/dist/components/EntityAclEditor/EntityAclEditor.js.map +1 -1
- package/dist/components/EntityAclEditor/InheritanceMessage.d.ts.map +1 -1
- package/dist/components/EntityAclEditor/InheritanceMessage.js +1 -2
- package/dist/components/EntityAclEditor/InheritanceMessage.js.map +1 -1
- package/dist/components/FullTextSearch/FullTextSearch.d.ts.map +1 -1
- package/dist/components/FullTextSearch/FullTextSearch.js +86 -47
- package/dist/components/FullTextSearch/FullTextSearch.js.map +1 -1
- package/dist/components/GenericCard/TableRowGenericCard.d.ts.map +1 -1
- package/dist/components/GenericCard/TableRowGenericCard.js +157 -157
- package/dist/components/GenericCard/TableRowGenericCard.js.map +1 -1
- package/dist/components/HeaderCard.d.ts.map +1 -1
- package/dist/components/HeaderCard.js +131 -130
- package/dist/components/HeaderCard.js.map +1 -1
- package/dist/components/MailchimpSubscribeSection/MailchimpSubscribeSection.d.ts +4 -1
- package/dist/components/MailchimpSubscribeSection/MailchimpSubscribeSection.d.ts.map +1 -1
- package/dist/components/MailchimpSubscribeSection/MailchimpSubscribeSection.js +3 -2
- package/dist/components/MailchimpSubscribeSection/MailchimpSubscribeSection.js.map +1 -1
- package/dist/components/QueryContext/QueryContext.d.ts +6 -0
- package/dist/components/QueryContext/QueryContext.d.ts.map +1 -1
- package/dist/components/QueryContext/QueryContext.js.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.d.ts.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.js +12 -11
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.js.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.d.ts +5 -0
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.d.ts.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.js +32 -29
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.js.map +1 -1
- package/dist/components/QueryWrapperPlotNav/UseRowSet.d.ts.map +1 -1
- package/dist/components/QueryWrapperPlotNav/UseRowSet.js +4 -1
- package/dist/components/QueryWrapperPlotNav/UseRowSet.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.d.ts +59 -0
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.d.ts.map +1 -0
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js +174 -0
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js.map +1 -0
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.d.ts +40 -0
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.d.ts.map +1 -0
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.js +100 -0
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.js.map +1 -0
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.d.ts +56 -0
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.d.ts.map +1 -0
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js +73 -0
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js.map +1 -0
- package/dist/components/ShareThisPage/ShareThisPage.js +1 -1
- package/dist/components/ShareThisPage/ShareThisPage.js.map +1 -1
- package/dist/components/SynapseChat/GridAgentChat.d.ts.map +1 -1
- package/dist/components/SynapseChat/GridAgentChat.js +20 -14
- package/dist/components/SynapseChat/GridAgentChat.js.map +1 -1
- package/dist/components/SynapseChat/SynapseChat.d.ts +3 -1
- package/dist/components/SynapseChat/SynapseChat.d.ts.map +1 -1
- package/dist/components/SynapseChat/SynapseChat.js +51 -36
- package/dist/components/SynapseChat/SynapseChat.js.map +1 -1
- package/dist/components/SynapseHomepageV2/HotdropsAndNews.css +1 -1
- package/dist/components/SynapseHomepageV2/HotdropsAndNews.module.js +8 -7
- package/dist/components/SynapseHomepageV2/HotdropsAndNews.module.js.map +1 -1
- package/dist/components/SynapseHomepageV2/HotdropsAndNews.module.scss +16 -0
- package/dist/components/SynapseHomepageV2/WordPressNews.d.ts +3 -1
- package/dist/components/SynapseHomepageV2/WordPressNews.d.ts.map +1 -1
- package/dist/components/SynapseHomepageV2/WordPressNews.js +9 -8
- package/dist/components/SynapseHomepageV2/WordPressNews.js.map +1 -1
- package/dist/components/SynapseHomepageV2/WordPressNewsItem.d.ts +2 -1
- package/dist/components/SynapseHomepageV2/WordPressNewsItem.d.ts.map +1 -1
- package/dist/components/SynapseHomepageV2/WordPressNewsItem.js +2 -2
- package/dist/components/SynapseHomepageV2/WordPressNewsItem.js.map +1 -1
- package/dist/components/SynapseTable/SearchV2.d.ts +7 -0
- package/dist/components/SynapseTable/SearchV2.d.ts.map +1 -1
- package/dist/components/SynapseTable/SearchV2.js.map +1 -1
- package/dist/components/SynapseTable/SynapseTableRenderers.d.ts.map +1 -1
- package/dist/components/SynapseTable/SynapseTableRenderers.js +1 -1
- package/dist/components/SynapseTable/SynapseTableRenderers.js.map +1 -1
- package/dist/components/SynapseTable/usePrefetchTableData.d.ts.map +1 -1
- package/dist/components/SynapseTable/usePrefetchTableData.js +6 -5
- package/dist/components/SynapseTable/usePrefetchTableData.js.map +1 -1
- package/dist/components/ToastMessage/ToastMessage.d.ts +1 -1
- package/dist/components/ToastMessage/ToastMessage.d.ts.map +1 -1
- package/dist/components/ToastMessage/ToastMessage.js +2 -2
- package/dist/components/ToastMessage/ToastMessage.js.map +1 -1
- package/dist/components/error/ErrorPage.d.ts +0 -4
- package/dist/components/error/ErrorPage.d.ts.map +1 -1
- package/dist/components/error/ErrorPage.js +25 -30
- package/dist/components/error/ErrorPage.js.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +41 -39
- package/dist/components/widgets/query-filter/FacetFilterControls.d.ts.map +1 -1
- package/dist/components/widgets/query-filter/FacetFilterControls.js +2 -2
- package/dist/components/widgets/query-filter/FacetFilterControls.js.map +1 -1
- package/dist/index.js +52 -50
- package/dist/index.js.map +1 -1
- package/dist/mocks/entity/index.d.ts.map +1 -1
- package/dist/mocks/entity/index.js +18 -16
- package/dist/mocks/entity/index.js.map +1 -1
- package/dist/mocks/mockSearchQueryData.d.ts +14 -0
- package/dist/mocks/mockSearchQueryData.d.ts.map +1 -0
- package/dist/mocks/mockSearchQueryData.js +564 -0
- package/dist/mocks/mockSearchQueryData.js.map +1 -0
- package/dist/mocks/msw/handlers/searchQueryHandlers.d.ts +22 -0
- package/dist/mocks/msw/handlers/searchQueryHandlers.d.ts.map +1 -0
- package/dist/mocks/msw/handlers/searchQueryHandlers.js +63 -0
- package/dist/mocks/msw/handlers/searchQueryHandlers.js.map +1 -0
- package/dist/mocks/msw/handlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers.js +9 -7
- package/dist/mocks/msw/handlers.js.map +1 -1
- package/dist/style/components/_cards.scss +15 -0
- package/dist/style/main.css +1 -1
- package/dist/synapse-client/SynapseClient.d.ts +7 -1
- package/dist/synapse-client/SynapseClient.d.ts.map +1 -1
- package/dist/synapse-client/SynapseClient.js +422 -417
- package/dist/synapse-client/SynapseClient.js.map +1 -1
- package/dist/synapse-client/index.js +3 -3
- package/dist/synapse-queries/KeyFactory.d.ts +2 -0
- package/dist/synapse-queries/KeyFactory.d.ts.map +1 -1
- package/dist/synapse-queries/KeyFactory.js +3 -0
- package/dist/synapse-queries/KeyFactory.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/APIConstants.d.ts +2 -0
- package/dist/utils/APIConstants.d.ts.map +1 -1
- package/dist/utils/APIConstants.js +2 -2
- package/dist/utils/APIConstants.js.map +1 -1
- package/dist/utils/functions/calculateFriendlyFileSize.d.ts.map +1 -1
- package/dist/utils/functions/calculateFriendlyFileSize.js +3 -3
- package/dist/utils/functions/calculateFriendlyFileSize.js.map +1 -1
- package/package.json +3 -3
|
@@ -6,32 +6,38 @@ import { useState as r } from "react";
|
|
|
6
6
|
import { jsx as i } from "react/jsx-runtime";
|
|
7
7
|
import { AgentAccessLevel as a } from "@sage-bionetworks/synapse-types";
|
|
8
8
|
//#region src/components/SynapseChat/GridAgentChat.tsx
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
var o = [
|
|
10
|
+
"Help me fill this out",
|
|
11
|
+
"Help me understand this",
|
|
12
|
+
"Find missing fields"
|
|
13
|
+
];
|
|
14
|
+
function s({ gridSessionId: s, usersReplicaId: c, chatbotName: l = "Grid Assistant", initialMessage: u, open: d, onClose: f, agentRegistrationId: p }) {
|
|
15
|
+
let [m, h] = r(), g = e(m);
|
|
11
16
|
return /* @__PURE__ */ i(n, {
|
|
12
|
-
open:
|
|
13
|
-
onClose:
|
|
14
|
-
title:
|
|
17
|
+
open: d,
|
|
18
|
+
onClose: f,
|
|
19
|
+
title: l,
|
|
15
20
|
children: /* @__PURE__ */ i(t, {
|
|
16
|
-
agentRegistrationId:
|
|
17
|
-
chatbotName:
|
|
18
|
-
initialMessage:
|
|
21
|
+
agentRegistrationId: p,
|
|
22
|
+
chatbotName: l,
|
|
23
|
+
initialMessage: u,
|
|
19
24
|
sessionContext: {
|
|
20
25
|
concreteType: "org.sagebionetworks.repo.model.agent.GridAgentSessionContext",
|
|
21
|
-
gridSessionId:
|
|
22
|
-
usersReplicaId:
|
|
26
|
+
gridSessionId: s,
|
|
27
|
+
usersReplicaId: c
|
|
23
28
|
},
|
|
24
29
|
textboxPositionOffset: "16px",
|
|
25
30
|
hideTitle: !0,
|
|
26
31
|
showAccessLevelMenu: !1,
|
|
27
32
|
defaultAgentAccessLevel: a.WRITE_YOUR_PRIVATE_DATA,
|
|
28
|
-
externalSession:
|
|
29
|
-
setExternalSession:
|
|
30
|
-
externalChatState:
|
|
33
|
+
externalSession: m,
|
|
34
|
+
setExternalSession: h,
|
|
35
|
+
externalChatState: g,
|
|
36
|
+
suggestedPrompts: o
|
|
31
37
|
})
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
40
|
//#endregion
|
|
35
|
-
export {
|
|
41
|
+
export { s as GridAgentChat, s as default };
|
|
36
42
|
|
|
37
43
|
//# sourceMappingURL=GridAgentChat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridAgentChat.js","names":[],"sources":["../../../src/components/SynapseChat/GridAgentChat.tsx"],"sourcesContent":["import { useChatState } from '@/components/SynapseChat/useChatState'\nimport { GridAgentSessionContext } from '@sage-bionetworks/synapse-client'\nimport { AgentAccessLevel, AgentSession } from '@sage-bionetworks/synapse-types'\nimport { useState } from 'react'\nimport DraggableDialog from '../DraggableDialog/DraggableDialog'\nimport { SynapseChat } from './index'\n\nexport type GridAgentChatProps = {\n gridSessionId: string\n usersReplicaId: number\n chatbotName?: string\n initialMessage?: string\n open: boolean\n onClose: () => void\n /** Optional ID to use a different agent registered in Synapse */\n agentRegistrationId?: string\n}\n\nexport function GridAgentChat({\n gridSessionId,\n usersReplicaId,\n chatbotName = 'Grid Assistant',\n initialMessage,\n open,\n onClose,\n agentRegistrationId,\n}: GridAgentChatProps) {\n // Storing state for the chat session here preserves chat history while the dialog is opened and closed.\n const [agentSession, setAgentSession] = useState<AgentSession | undefined>()\n const chatState = useChatState(agentSession)\n\n // Create session context for grid sessions\n const sessionContext: GridAgentSessionContext = {\n concreteType:\n 'org.sagebionetworks.repo.model.agent.GridAgentSessionContext',\n gridSessionId,\n usersReplicaId,\n }\n\n return (\n <DraggableDialog open={open} onClose={onClose} title={chatbotName}>\n <SynapseChat\n agentRegistrationId={agentRegistrationId}\n chatbotName={chatbotName}\n initialMessage={initialMessage}\n sessionContext={sessionContext}\n textboxPositionOffset=\"16px\"\n hideTitle={true}\n showAccessLevelMenu={false}\n defaultAgentAccessLevel={AgentAccessLevel.WRITE_YOUR_PRIVATE_DATA}\n // lift state: allow GridAgentChat to control the agent session and interactions\n externalSession={agentSession}\n setExternalSession={setAgentSession}\n externalChatState={chatState}\n />\n </DraggableDialog>\n )\n}\n\nexport default GridAgentChat\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"GridAgentChat.js","names":[],"sources":["../../../src/components/SynapseChat/GridAgentChat.tsx"],"sourcesContent":["import { useChatState } from '@/components/SynapseChat/useChatState'\nimport { GridAgentSessionContext } from '@sage-bionetworks/synapse-client'\nimport { AgentAccessLevel, AgentSession } from '@sage-bionetworks/synapse-types'\nimport { useState } from 'react'\nimport DraggableDialog from '../DraggableDialog/DraggableDialog'\nimport { SynapseChat } from './index'\n\nconst suggestedPrompts = [\n 'Help me fill this out',\n 'Help me understand this',\n 'Find missing fields',\n]\n\nexport type GridAgentChatProps = {\n gridSessionId: string\n usersReplicaId: number\n chatbotName?: string\n initialMessage?: string\n open: boolean\n onClose: () => void\n /** Optional ID to use a different agent registered in Synapse */\n agentRegistrationId?: string\n}\n\nexport function GridAgentChat({\n gridSessionId,\n usersReplicaId,\n chatbotName = 'Grid Assistant',\n initialMessage,\n open,\n onClose,\n agentRegistrationId,\n}: GridAgentChatProps) {\n // Storing state for the chat session here preserves chat history while the dialog is opened and closed.\n const [agentSession, setAgentSession] = useState<AgentSession | undefined>()\n const chatState = useChatState(agentSession)\n\n // Create session context for grid sessions\n const sessionContext: GridAgentSessionContext = {\n concreteType:\n 'org.sagebionetworks.repo.model.agent.GridAgentSessionContext',\n gridSessionId,\n usersReplicaId,\n }\n\n return (\n <DraggableDialog open={open} onClose={onClose} title={chatbotName}>\n <SynapseChat\n agentRegistrationId={agentRegistrationId}\n chatbotName={chatbotName}\n initialMessage={initialMessage}\n sessionContext={sessionContext}\n textboxPositionOffset=\"16px\"\n hideTitle={true}\n showAccessLevelMenu={false}\n defaultAgentAccessLevel={AgentAccessLevel.WRITE_YOUR_PRIVATE_DATA}\n // lift state: allow GridAgentChat to control the agent session and interactions\n externalSession={agentSession}\n setExternalSession={setAgentSession}\n externalChatState={chatState}\n suggestedPrompts={suggestedPrompts}\n />\n </DraggableDialog>\n )\n}\n\nexport default GridAgentChat\n"],"mappings":";;;;;;;;AAOA,IAAM,IAAmB;CACvB;CACA;CACA;CACD;AAaD,SAAgB,EAAc,EAC5B,kBACA,mBACA,iBAAc,kBACd,mBACA,SACA,YACA,0BACqB;CAErB,IAAM,CAAC,GAAc,KAAmB,GAAoC,EACtE,IAAY,EAAa,EAAa;AAU5C,QACE,kBAAC,GAAD;EAAuB;EAAe;EAAS,OAAO;YACpD,kBAAC,GAAD;GACuB;GACR;GACG;GACA,gBAAA;IAZpB,cACE;IACF;IACA;IASoB;GAChB,uBAAsB;GACtB,WAAW;GACX,qBAAqB;GACrB,yBAAyB,EAAiB;GAE1C,iBAAiB;GACjB,oBAAoB;GACpB,mBAAmB;GACD;GAClB,CAAA;EACc,CAAA"}
|
|
@@ -19,6 +19,8 @@ export type SynapseChatProps = {
|
|
|
19
19
|
* Called in the mutation onSuccess handler so it runs exactly once per response.
|
|
20
20
|
*/
|
|
21
21
|
onChatResponse?: (responseText: string) => void;
|
|
22
|
+
/** Optional list of prompt suggestions shown as clickable pills above the text input */
|
|
23
|
+
suggestedPrompts?: string[];
|
|
22
24
|
};
|
|
23
25
|
export type ChatInteraction = {
|
|
24
26
|
userMessage: string;
|
|
@@ -29,6 +31,6 @@ export type ChatInteraction = {
|
|
|
29
31
|
export type TraceEventWithFriendlyMessage = {
|
|
30
32
|
friendlyMessage?: string;
|
|
31
33
|
} & TraceEvent;
|
|
32
|
-
export declare function SynapseChat({ initialMessage, agentRegistrationId, chatbotName, hideTitle, textboxPositionOffset, sessionContext, externalSession, setExternalSession, externalChatState, showAccessLevelMenu, onChatResponse, }: SynapseChatProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare function SynapseChat({ initialMessage, agentRegistrationId, chatbotName, hideTitle, textboxPositionOffset, sessionContext, externalSession, setExternalSession, externalChatState, showAccessLevelMenu, onChatResponse, suggestedPrompts, }: SynapseChatProps): import("react/jsx-runtime").JSX.Element;
|
|
33
35
|
export default SynapseChat;
|
|
34
36
|
//# sourceMappingURL=SynapseChat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SynapseChat.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseChat/SynapseChat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,MAAM,uCAAuC,CAAA;
|
|
1
|
+
{"version":3,"file":"SynapseChat.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseChat/SynapseChat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,MAAM,uCAAuC,CAAA;AAmB/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC1E,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACX,MAAM,iCAAiC,CAAA;AAQxC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAE9B,cAAc,CAAC,EAAE,uBAAuB,CAAA;IAExC,eAAe,CAAC,EAAE,YAAY,CAAA;IAE9B,kBAAkB,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,GAAG,SAAS,KAAK,IAAI,CAAA;IAE1D,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAE7B,uBAAuB,CAAC,EAAE,gBAAgB,CAAA;IAE1C,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/C,wFAAwF;IACxF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,6BAA6B,EAAE,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,GAAG,UAAU,CAAA;AAEd,wBAAgB,WAAW,CAAC,EAC1B,cAAc,EACd,mBAAmB,EACnB,WAA2B,EAC3B,SAAiB,EACjB,qBAA6B,EAC7B,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,mBAA0B,EAC1B,cAAc,EACd,gBAAgB,GACjB,EAAE,gBAAgB,2CA+QlB;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -10,47 +10,47 @@ import { AccessLevelMenu as o } from "./AccessLevelMenu.js";
|
|
|
10
10
|
import { SynapseChatInteraction as s } from "./SynapseChatInteraction.js";
|
|
11
11
|
import ee from "./SynapseChatMessage.js";
|
|
12
12
|
import { useEffect as c, useState as l } from "react";
|
|
13
|
-
import { Alert as u, Box as d,
|
|
14
|
-
import { jsx as
|
|
15
|
-
import { AgentAccessLevel as
|
|
16
|
-
import { ArrowUpward as
|
|
13
|
+
import { Alert as u, Box as d, Chip as f, IconButton as p, List as m, Stack as h, TextField as g, Typography as _, useTheme as te } from "@mui/material";
|
|
14
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
15
|
+
import { AgentAccessLevel as b } from "@sage-bionetworks/synapse-types";
|
|
16
|
+
import { ArrowUpward as x } from "@mui/icons-material";
|
|
17
17
|
//#region src/components/SynapseChat/SynapseChat.tsx
|
|
18
|
-
function
|
|
19
|
-
let { accessToken: M } = t(), [N, P] = l(), F =
|
|
18
|
+
function S({ initialMessage: S, agentRegistrationId: C, chatbotName: w = "SynapseChat", hideTitle: ne = !1, textboxPositionOffset: re = "0px", sessionContext: T, externalSession: E, setExternalSession: D, externalChatState: O, showAccessLevelMenu: k = !0, onChatResponse: A, suggestedPrompts: j }) {
|
|
19
|
+
let { accessToken: M } = t(), [N, P] = l(), F = E ?? N, I = D ?? P, { mutate: L, error: R } = r({ onSuccess: (e) => I(e) }), { mutate: z } = i({
|
|
20
20
|
onSuccess: (e) => I(e),
|
|
21
21
|
onError: (t) => e(`Unable to update the agent session: ${t.message}`, "danger")
|
|
22
|
-
}), B =
|
|
22
|
+
}), B = te(), [V, H] = l(T ? b.WRITE_YOUR_PRIVATE_DATA : b.PUBLICLY_ACCESSIBLE), U = a(F, A), { pendingMessage: W, chatJobIds: G, sendChat: K } = O ?? U, [q, J] = l(""), [Y, X] = l(!1);
|
|
23
23
|
c(() => {
|
|
24
24
|
L && !F && L({
|
|
25
25
|
agentAccessLevel: V,
|
|
26
|
-
agentRegistrationId:
|
|
27
|
-
sessionContext:
|
|
26
|
+
agentRegistrationId: C,
|
|
27
|
+
sessionContext: T
|
|
28
28
|
});
|
|
29
29
|
}, [
|
|
30
30
|
L,
|
|
31
31
|
F,
|
|
32
32
|
M,
|
|
33
|
-
|
|
33
|
+
T,
|
|
34
34
|
V,
|
|
35
|
-
|
|
35
|
+
C
|
|
36
36
|
]), c(() => {
|
|
37
|
-
F &&
|
|
37
|
+
F && S && !Y && (K(S), X(!0));
|
|
38
38
|
}, [
|
|
39
39
|
F,
|
|
40
|
-
|
|
40
|
+
S,
|
|
41
41
|
Y,
|
|
42
42
|
K
|
|
43
43
|
]);
|
|
44
44
|
let Z = () => {
|
|
45
45
|
q.trim() && (K(q.trim()), J(""));
|
|
46
|
-
}, Q = !F || !q || !!W,
|
|
46
|
+
}, Q = !F || !q || !!W, ie = (e) => {
|
|
47
47
|
!Q && e.key === "Enter" && !e.shiftKey && (e.preventDefault(), Z());
|
|
48
48
|
}, $ = B.palette.secondary[300];
|
|
49
|
-
return R ? /* @__PURE__ */
|
|
49
|
+
return R ? /* @__PURE__ */ v(u, {
|
|
50
50
|
severity: "error",
|
|
51
51
|
sx: { my: 2 },
|
|
52
52
|
children: R.reason
|
|
53
|
-
}) : /* @__PURE__ */
|
|
53
|
+
}) : /* @__PURE__ */ y(d, {
|
|
54
54
|
sx: {
|
|
55
55
|
display: "flex",
|
|
56
56
|
flexDirection: "column",
|
|
@@ -60,7 +60,7 @@ function x({ initialMessage: x, agentRegistrationId: S, chatbotName: C = "Synaps
|
|
|
60
60
|
height: "100%"
|
|
61
61
|
},
|
|
62
62
|
children: [
|
|
63
|
-
!
|
|
63
|
+
!ne && /* @__PURE__ */ v(_, {
|
|
64
64
|
variant: "headline1",
|
|
65
65
|
sx: {
|
|
66
66
|
p: "20px",
|
|
@@ -71,9 +71,9 @@ function x({ initialMessage: x, agentRegistrationId: S, chatbotName: C = "Synaps
|
|
|
71
71
|
backgroundColor: "white",
|
|
72
72
|
zIndex: 1
|
|
73
73
|
},
|
|
74
|
-
children:
|
|
74
|
+
children: w
|
|
75
75
|
}),
|
|
76
|
-
|
|
76
|
+
k && /* @__PURE__ */ v(o, {
|
|
77
77
|
initAccessLevel: V,
|
|
78
78
|
onChange: (e) => {
|
|
79
79
|
H(e), z({
|
|
@@ -82,14 +82,14 @@ function x({ initialMessage: x, agentRegistrationId: S, chatbotName: C = "Synaps
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
}),
|
|
85
|
-
!F && /* @__PURE__ */
|
|
86
|
-
F && /* @__PURE__ */
|
|
85
|
+
!F && /* @__PURE__ */ v(n, { numRows: 10 }),
|
|
86
|
+
F && /* @__PURE__ */ v(d, {
|
|
87
87
|
sx: {
|
|
88
88
|
flexGrow: 1,
|
|
89
89
|
overflowY: "auto",
|
|
90
90
|
mb: 2
|
|
91
91
|
},
|
|
92
|
-
children: /* @__PURE__ */
|
|
92
|
+
children: /* @__PURE__ */ y(m, {
|
|
93
93
|
sx: {
|
|
94
94
|
flex: 1,
|
|
95
95
|
overflowY: "auto",
|
|
@@ -97,10 +97,10 @@ function x({ initialMessage: x, agentRegistrationId: S, chatbotName: C = "Synaps
|
|
|
97
97
|
display: "flex",
|
|
98
98
|
flexDirection: "column"
|
|
99
99
|
},
|
|
100
|
-
children: [G.map((e) => /* @__PURE__ */
|
|
100
|
+
children: [G.map((e) => /* @__PURE__ */ v(ee, {
|
|
101
101
|
chatJobId: e,
|
|
102
102
|
onSendChat: K
|
|
103
|
-
}, e)), W && /* @__PURE__ */
|
|
103
|
+
}, e)), W && /* @__PURE__ */ v(s, {
|
|
104
104
|
userMessage: W,
|
|
105
105
|
chatResponseText: "",
|
|
106
106
|
chatErrorReason: "",
|
|
@@ -109,13 +109,28 @@ function x({ initialMessage: x, agentRegistrationId: S, chatbotName: C = "Synaps
|
|
|
109
109
|
})]
|
|
110
110
|
})
|
|
111
111
|
}),
|
|
112
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ y(d, {
|
|
113
113
|
sx: {
|
|
114
114
|
position: "sticky",
|
|
115
|
-
bottom:
|
|
115
|
+
bottom: re,
|
|
116
116
|
backgroundColor: "white"
|
|
117
117
|
},
|
|
118
|
-
children: /* @__PURE__ */ v(
|
|
118
|
+
children: [j && j.length > 0 && G.length === 0 && !W && /* @__PURE__ */ v(h, {
|
|
119
|
+
direction: "row",
|
|
120
|
+
spacing: 1,
|
|
121
|
+
sx: {
|
|
122
|
+
pt: "8px",
|
|
123
|
+
flexWrap: "wrap",
|
|
124
|
+
gap: 1
|
|
125
|
+
},
|
|
126
|
+
children: j.map((e) => /* @__PURE__ */ v(f, {
|
|
127
|
+
label: e,
|
|
128
|
+
variant: "outlined",
|
|
129
|
+
onClick: () => J(e),
|
|
130
|
+
disabled: !F,
|
|
131
|
+
sx: { cursor: "pointer" }
|
|
132
|
+
}, e))
|
|
133
|
+
}), /* @__PURE__ */ y(d, {
|
|
119
134
|
component: "form",
|
|
120
135
|
sx: {
|
|
121
136
|
pt: "8px",
|
|
@@ -126,15 +141,15 @@ function x({ initialMessage: x, agentRegistrationId: S, chatbotName: C = "Synaps
|
|
|
126
141
|
borderColor: "grey.400"
|
|
127
142
|
},
|
|
128
143
|
onSubmit: Z,
|
|
129
|
-
children: [/* @__PURE__ */
|
|
144
|
+
children: [/* @__PURE__ */ v(g, {
|
|
130
145
|
fullWidth: !0,
|
|
131
146
|
value: q,
|
|
132
147
|
onChange: (e) => J(e.target.value),
|
|
133
|
-
onKeyDown:
|
|
134
|
-
placeholder: `Message ${
|
|
148
|
+
onKeyDown: ie,
|
|
149
|
+
placeholder: `Message ${w}`,
|
|
135
150
|
slotProps: { input: {
|
|
136
151
|
sx: { borderRadius: 96.6 },
|
|
137
|
-
endAdornment: /* @__PURE__ */
|
|
152
|
+
endAdornment: /* @__PURE__ */ v(p, {
|
|
138
153
|
disabled: Q,
|
|
139
154
|
onClick: Z,
|
|
140
155
|
sx: {
|
|
@@ -145,23 +160,23 @@ function x({ initialMessage: x, agentRegistrationId: S, chatbotName: C = "Synaps
|
|
|
145
160
|
borderWidth: Q ? "1px" : "2px",
|
|
146
161
|
borderColor: Q ? "gray" : $
|
|
147
162
|
},
|
|
148
|
-
children: /* @__PURE__ */
|
|
163
|
+
children: /* @__PURE__ */ v(x, {})
|
|
149
164
|
})
|
|
150
165
|
} }
|
|
151
|
-
}), /* @__PURE__ */
|
|
166
|
+
}), /* @__PURE__ */ y(_, {
|
|
152
167
|
variant: "smallText1",
|
|
153
168
|
sx: {
|
|
154
169
|
pt: "8px",
|
|
155
170
|
textAlign: "center"
|
|
156
171
|
},
|
|
157
|
-
children: [
|
|
172
|
+
children: [w, " can make mistakes."]
|
|
158
173
|
})]
|
|
159
|
-
})
|
|
174
|
+
})]
|
|
160
175
|
})
|
|
161
176
|
]
|
|
162
177
|
});
|
|
163
178
|
}
|
|
164
179
|
//#endregion
|
|
165
|
-
export {
|
|
180
|
+
export { S as SynapseChat, S as default };
|
|
166
181
|
|
|
167
182
|
//# sourceMappingURL=SynapseChat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SynapseChat.js","names":[],"sources":["../../../src/components/SynapseChat/SynapseChat.tsx"],"sourcesContent":["import { ChatState, useChatState } from '@/components/SynapseChat/useChatState'\nimport {\n useCreateAgentSession,\n useUpdateAgentSession,\n} from '@/synapse-queries/chat/useChat'\nimport { useSynapseContext } from '@/utils'\nimport { ArrowUpward } from '@mui/icons-material'\nimport {\n Alert,\n Box,\n IconButton,\n List,\n TextField,\n Typography,\n useTheme,\n} from '@mui/material'\nimport { Color } from '@mui/material/styles'\nimport { GridAgentSessionContext } from '@sage-bionetworks/synapse-client'\nimport {\n AgentAccessLevel,\n AgentSession,\n TraceEvent,\n} from '@sage-bionetworks/synapse-types'\nimport { KeyboardEventHandler, useEffect, useState } from 'react'\nimport { SkeletonParagraph } from '../Skeleton'\nimport { displayToast } from '../ToastMessage'\nimport AccessLevelMenu from './AccessLevelMenu'\nimport SynapseChatInteraction from './SynapseChatInteraction'\nimport SynapseChatMessage from './SynapseChatMessage'\n\nexport type SynapseChatProps = {\n initialMessage?: string //optional initial message\n agentRegistrationId?: string // if provided, use this agent\n chatbotName?: string // optional name of this chatbot agent\n hideTitle?: boolean\n textboxPositionOffset?: string // when embedded in a form, the textbox (form) stuck to the bottom may need to be offset due to container padding (dialog content for example!)\n /* optional session context for the agent session */\n sessionContext?: GridAgentSessionContext\n /* The current session, if state is lifted out of this component */\n externalSession?: AgentSession\n /* A callback invoked to bootstrap the current session, if state is to be lifted out of this component */\n setExternalSession?: (s: AgentSession | undefined) => void\n /* The current chat history, if state is lifted out of this component */\n externalChatState?: ChatState\n // default access level for the agent session.\n defaultAgentAccessLevel?: AgentAccessLevel\n // Whether to show the access level menu for the agent session.\n showAccessLevelMenu?: boolean\n /**\n * Optional callback invoked once when a chat response is received from the server.\n * Use this for side effects such as navigation based on the response content.\n * Called in the mutation onSuccess handler so it runs exactly once per response.\n */\n onChatResponse?: (responseText: string) => void\n}\n\nexport type ChatInteraction = {\n userMessage: string\n chatResponseText?: string\n chatErrorReason?: string\n chatResponseTrace?: TraceEventWithFriendlyMessage[]\n}\n\nexport type TraceEventWithFriendlyMessage = {\n friendlyMessage?: string\n} & TraceEvent\n\nexport function SynapseChat({\n initialMessage,\n agentRegistrationId,\n chatbotName = 'SynapseChat',\n hideTitle = false,\n textboxPositionOffset = '0px',\n sessionContext,\n externalSession,\n setExternalSession,\n externalChatState,\n showAccessLevelMenu = true,\n onChatResponse,\n}: SynapseChatProps) {\n const { accessToken } = useSynapseContext()\n const [localAgentSession, setLocalAgentSession] = useState<AgentSession>()\n const agentSession = externalSession ?? localAgentSession\n const setAgentSession = setExternalSession ?? setLocalAgentSession\n\n const { mutate: createAgentSession, error: createAgentSessionError } =\n useCreateAgentSession({\n onSuccess: newAgentSession => setAgentSession(newAgentSession),\n })\n\n const { mutate: updateAgentSession } = useUpdateAgentSession({\n onSuccess: updatedAgentSession => setAgentSession(updatedAgentSession),\n onError: err =>\n displayToast(\n `Unable to update the agent session: ${err.message}`,\n 'danger',\n ),\n })\n const theme = useTheme()\n const [agentAccessLevel, setAgentAccessLevel] = useState<AgentAccessLevel>(\n sessionContext\n ? AgentAccessLevel.WRITE_YOUR_PRIVATE_DATA\n : AgentAccessLevel.PUBLICLY_ACCESSIBLE,\n )\n\n const internalChatState = useChatState(agentSession, onChatResponse)\n const chatState = externalChatState ?? internalChatState\n const { pendingMessage, chatJobIds, sendChat } = chatState\n\n // Keep track of the text that the user is currently typing into the textfield\n const [userChatTextfieldValue, setUserChatTextfieldValue] = useState('')\n const [initialMessageProcessed, setInitialMessageProcessed] = useState(false)\n\n // Restore chat session history, if exists.\n // TODO: currently only a single page is restored. Add support for multiple pages (and detect the user scrolling up to restore the next page of results older)\n // const {\n // data: sessionHistoryInfiniteData,\n // } = //, hasNextPage: hasMoreSessionHistory, fetchNextPage: fetchNextSessionHistoryPage, isLoading: isSessionHistoryLoading } =\n // useGetAgentChatSessionHistoryInfinite(\n // {\n // sessionId: agentSession?.sessionId,\n // },\n // {\n // enabled: !!agentSession,\n // },\n // )\n\n // const sessionHistory = useMemo(\n // () =>\n // sessionHistoryInfiniteData?.pages\n // .flatMap(page => page.page)\n // /* Note: session history is ordered from most recent to least recent in each page, so reverse the order when restoring the chat interface */\n // .reverse() ?? [],\n // [sessionHistoryInfiniteData],\n // )\n\n useEffect(() => {\n // on mount, create a new agent session!\n if (createAgentSession && !agentSession) {\n createAgentSession({\n agentAccessLevel,\n agentRegistrationId,\n sessionContext,\n })\n }\n }, [\n createAgentSession,\n agentSession,\n accessToken,\n sessionContext,\n agentAccessLevel,\n agentRegistrationId,\n ])\n\n useEffect(() => {\n // on mount, resolve the initial message chat interaction (if set)\n if (agentSession && initialMessage && !initialMessageProcessed) {\n sendChat(initialMessage)\n setInitialMessageProcessed(true)\n }\n }, [agentSession, initialMessage, initialMessageProcessed, sendChat])\n\n const handleSendMessage = () => {\n if (userChatTextfieldValue.trim()) {\n sendChat(userChatTextfieldValue.trim())\n setUserChatTextfieldValue('')\n }\n }\n\n const isDisabled =\n !agentSession || !userChatTextfieldValue || !!pendingMessage\n\n const handleKeyDown: KeyboardEventHandler<HTMLDivElement> = event => {\n if (!isDisabled && event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault()\n handleSendMessage()\n }\n }\n\n const sendMessageButtonColor = (\n theme.palette.secondary as unknown as Color\n )[300]\n if (createAgentSessionError) {\n return (\n <Alert severity={'error'} sx={{ my: 2 }}>\n {createAgentSessionError.reason}\n </Alert>\n )\n }\n\n return (\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n maxWidth: '1100px',\n mx: 'auto',\n height: '100%',\n }}\n >\n {!hideTitle && (\n <Typography\n variant=\"headline1\"\n sx={{\n p: '20px',\n borderBottom: '1px solid',\n borderColor: 'grey.300',\n position: 'sticky',\n top: '0px',\n backgroundColor: 'white',\n zIndex: 1,\n }}\n >\n {chatbotName}\n </Typography>\n )}\n {showAccessLevelMenu && (\n <AccessLevelMenu\n initAccessLevel={agentAccessLevel}\n onChange={newAccessLevel => {\n setAgentAccessLevel(newAccessLevel)\n updateAgentSession({\n agentAccessLevel: newAccessLevel,\n sessionId: agentSession!.sessionId,\n })\n }}\n />\n )}\n {!agentSession && <SkeletonParagraph numRows={10} />}\n {agentSession && (\n <Box sx={{ flexGrow: 1, overflowY: 'auto', mb: 2 }}>\n <List\n sx={{\n flex: 1,\n overflowY: 'auto',\n pt: '20px',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n {/* {sessionHistory &&\n sessionHistory.map((interaction, index) => {\n return (\n <SynapseChatInteraction\n key={index}\n userMessage={interaction.usersRequestText}\n chatResponseText={interaction.agentResponseText}\n />\n )\n })} */}\n {chatJobIds.map(jobId => {\n return (\n <SynapseChatMessage\n key={jobId}\n chatJobId={jobId}\n onSendChat={sendChat}\n />\n )\n })}\n {pendingMessage && (\n <SynapseChatInteraction\n userMessage={pendingMessage}\n chatResponseText={''}\n chatErrorReason={''}\n scrollIntoView\n onSendChat={sendChat}\n />\n )}\n </List>\n </Box>\n )}\n <Box\n sx={{\n position: 'sticky',\n bottom: textboxPositionOffset,\n backgroundColor: 'white',\n }}\n >\n <Box\n component=\"form\"\n sx={{\n pt: '8px',\n mt: '5px',\n pb: '10px',\n position: 'sticky',\n borderTop: '1px solid',\n borderColor: 'grey.400',\n }}\n onSubmit={handleSendMessage}\n >\n <TextField\n fullWidth\n value={userChatTextfieldValue}\n onChange={e => setUserChatTextfieldValue(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={`Message ${chatbotName}`}\n slotProps={{\n input: {\n sx: { borderRadius: 96.6 },\n endAdornment: (\n <IconButton\n disabled={isDisabled}\n onClick={handleSendMessage}\n sx={{\n ml: '7px',\n mr: '-8px',\n color: sendMessageButtonColor,\n borderStyle: 'solid',\n borderWidth: isDisabled ? '1px' : '2px',\n borderColor: isDisabled ? 'gray' : sendMessageButtonColor,\n }}\n >\n <ArrowUpward />\n </IconButton>\n ),\n },\n }}\n />\n <Typography\n variant=\"smallText1\"\n sx={{ pt: '8px', textAlign: 'center' }}\n >\n {chatbotName} can make mistakes.\n </Typography>\n </Box>\n </Box>\n </Box>\n )\n}\n\nexport default SynapseChat\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"SynapseChat.js","names":[],"sources":["../../../src/components/SynapseChat/SynapseChat.tsx"],"sourcesContent":["import { ChatState, useChatState } from '@/components/SynapseChat/useChatState'\nimport {\n useCreateAgentSession,\n useUpdateAgentSession,\n} from '@/synapse-queries/chat/useChat'\nimport { useSynapseContext } from '@/utils'\nimport { ArrowUpward } from '@mui/icons-material'\nimport {\n Alert,\n Box,\n Chip,\n IconButton,\n List,\n Stack,\n TextField,\n Typography,\n useTheme,\n} from '@mui/material'\nimport { Color } from '@mui/material/styles'\nimport { GridAgentSessionContext } from '@sage-bionetworks/synapse-client'\nimport {\n AgentAccessLevel,\n AgentSession,\n TraceEvent,\n} from '@sage-bionetworks/synapse-types'\nimport { KeyboardEventHandler, useEffect, useState } from 'react'\nimport { SkeletonParagraph } from '../Skeleton'\nimport { displayToast } from '../ToastMessage'\nimport AccessLevelMenu from './AccessLevelMenu'\nimport SynapseChatInteraction from './SynapseChatInteraction'\nimport SynapseChatMessage from './SynapseChatMessage'\n\nexport type SynapseChatProps = {\n initialMessage?: string //optional initial message\n agentRegistrationId?: string // if provided, use this agent\n chatbotName?: string // optional name of this chatbot agent\n hideTitle?: boolean\n textboxPositionOffset?: string // when embedded in a form, the textbox (form) stuck to the bottom may need to be offset due to container padding (dialog content for example!)\n /* optional session context for the agent session */\n sessionContext?: GridAgentSessionContext\n /* The current session, if state is lifted out of this component */\n externalSession?: AgentSession\n /* A callback invoked to bootstrap the current session, if state is to be lifted out of this component */\n setExternalSession?: (s: AgentSession | undefined) => void\n /* The current chat history, if state is lifted out of this component */\n externalChatState?: ChatState\n // default access level for the agent session.\n defaultAgentAccessLevel?: AgentAccessLevel\n // Whether to show the access level menu for the agent session.\n showAccessLevelMenu?: boolean\n /**\n * Optional callback invoked once when a chat response is received from the server.\n * Use this for side effects such as navigation based on the response content.\n * Called in the mutation onSuccess handler so it runs exactly once per response.\n */\n onChatResponse?: (responseText: string) => void\n /** Optional list of prompt suggestions shown as clickable pills above the text input */\n suggestedPrompts?: string[]\n}\n\nexport type ChatInteraction = {\n userMessage: string\n chatResponseText?: string\n chatErrorReason?: string\n chatResponseTrace?: TraceEventWithFriendlyMessage[]\n}\n\nexport type TraceEventWithFriendlyMessage = {\n friendlyMessage?: string\n} & TraceEvent\n\nexport function SynapseChat({\n initialMessage,\n agentRegistrationId,\n chatbotName = 'SynapseChat',\n hideTitle = false,\n textboxPositionOffset = '0px',\n sessionContext,\n externalSession,\n setExternalSession,\n externalChatState,\n showAccessLevelMenu = true,\n onChatResponse,\n suggestedPrompts,\n}: SynapseChatProps) {\n const { accessToken } = useSynapseContext()\n const [localAgentSession, setLocalAgentSession] = useState<AgentSession>()\n const agentSession = externalSession ?? localAgentSession\n const setAgentSession = setExternalSession ?? setLocalAgentSession\n\n const { mutate: createAgentSession, error: createAgentSessionError } =\n useCreateAgentSession({\n onSuccess: newAgentSession => setAgentSession(newAgentSession),\n })\n\n const { mutate: updateAgentSession } = useUpdateAgentSession({\n onSuccess: updatedAgentSession => setAgentSession(updatedAgentSession),\n onError: err =>\n displayToast(\n `Unable to update the agent session: ${err.message}`,\n 'danger',\n ),\n })\n const theme = useTheme()\n const [agentAccessLevel, setAgentAccessLevel] = useState<AgentAccessLevel>(\n sessionContext\n ? AgentAccessLevel.WRITE_YOUR_PRIVATE_DATA\n : AgentAccessLevel.PUBLICLY_ACCESSIBLE,\n )\n\n const internalChatState = useChatState(agentSession, onChatResponse)\n const chatState = externalChatState ?? internalChatState\n const { pendingMessage, chatJobIds, sendChat } = chatState\n\n // Keep track of the text that the user is currently typing into the textfield\n const [userChatTextfieldValue, setUserChatTextfieldValue] = useState('')\n const [initialMessageProcessed, setInitialMessageProcessed] = useState(false)\n\n // Restore chat session history, if exists.\n // TODO: currently only a single page is restored. Add support for multiple pages (and detect the user scrolling up to restore the next page of results older)\n // const {\n // data: sessionHistoryInfiniteData,\n // } = //, hasNextPage: hasMoreSessionHistory, fetchNextPage: fetchNextSessionHistoryPage, isLoading: isSessionHistoryLoading } =\n // useGetAgentChatSessionHistoryInfinite(\n // {\n // sessionId: agentSession?.sessionId,\n // },\n // {\n // enabled: !!agentSession,\n // },\n // )\n\n // const sessionHistory = useMemo(\n // () =>\n // sessionHistoryInfiniteData?.pages\n // .flatMap(page => page.page)\n // /* Note: session history is ordered from most recent to least recent in each page, so reverse the order when restoring the chat interface */\n // .reverse() ?? [],\n // [sessionHistoryInfiniteData],\n // )\n\n useEffect(() => {\n // on mount, create a new agent session!\n if (createAgentSession && !agentSession) {\n createAgentSession({\n agentAccessLevel,\n agentRegistrationId,\n sessionContext,\n })\n }\n }, [\n createAgentSession,\n agentSession,\n accessToken,\n sessionContext,\n agentAccessLevel,\n agentRegistrationId,\n ])\n\n useEffect(() => {\n // on mount, resolve the initial message chat interaction (if set)\n if (agentSession && initialMessage && !initialMessageProcessed) {\n sendChat(initialMessage)\n setInitialMessageProcessed(true)\n }\n }, [agentSession, initialMessage, initialMessageProcessed, sendChat])\n\n const handleSendMessage = () => {\n if (userChatTextfieldValue.trim()) {\n sendChat(userChatTextfieldValue.trim())\n setUserChatTextfieldValue('')\n }\n }\n\n const isDisabled =\n !agentSession || !userChatTextfieldValue || !!pendingMessage\n\n const handleKeyDown: KeyboardEventHandler<HTMLDivElement> = event => {\n if (!isDisabled && event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault()\n handleSendMessage()\n }\n }\n\n const sendMessageButtonColor = (\n theme.palette.secondary as unknown as Color\n )[300]\n if (createAgentSessionError) {\n return (\n <Alert severity={'error'} sx={{ my: 2 }}>\n {createAgentSessionError.reason}\n </Alert>\n )\n }\n\n return (\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n maxWidth: '1100px',\n mx: 'auto',\n height: '100%',\n }}\n >\n {!hideTitle && (\n <Typography\n variant=\"headline1\"\n sx={{\n p: '20px',\n borderBottom: '1px solid',\n borderColor: 'grey.300',\n position: 'sticky',\n top: '0px',\n backgroundColor: 'white',\n zIndex: 1,\n }}\n >\n {chatbotName}\n </Typography>\n )}\n {showAccessLevelMenu && (\n <AccessLevelMenu\n initAccessLevel={agentAccessLevel}\n onChange={newAccessLevel => {\n setAgentAccessLevel(newAccessLevel)\n updateAgentSession({\n agentAccessLevel: newAccessLevel,\n sessionId: agentSession!.sessionId,\n })\n }}\n />\n )}\n {!agentSession && <SkeletonParagraph numRows={10} />}\n {agentSession && (\n <Box sx={{ flexGrow: 1, overflowY: 'auto', mb: 2 }}>\n <List\n sx={{\n flex: 1,\n overflowY: 'auto',\n pt: '20px',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n {/* {sessionHistory &&\n sessionHistory.map((interaction, index) => {\n return (\n <SynapseChatInteraction\n key={index}\n userMessage={interaction.usersRequestText}\n chatResponseText={interaction.agentResponseText}\n />\n )\n })} */}\n {chatJobIds.map(jobId => {\n return (\n <SynapseChatMessage\n key={jobId}\n chatJobId={jobId}\n onSendChat={sendChat}\n />\n )\n })}\n {pendingMessage && (\n <SynapseChatInteraction\n userMessage={pendingMessage}\n chatResponseText={''}\n chatErrorReason={''}\n scrollIntoView\n onSendChat={sendChat}\n />\n )}\n </List>\n </Box>\n )}\n <Box\n sx={{\n position: 'sticky',\n bottom: textboxPositionOffset,\n backgroundColor: 'white',\n }}\n >\n {suggestedPrompts &&\n suggestedPrompts.length > 0 &&\n chatJobIds.length === 0 &&\n !pendingMessage && (\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ pt: '8px', flexWrap: 'wrap', gap: 1 }}\n >\n {suggestedPrompts.map(prompt => (\n <Chip\n key={prompt}\n label={prompt}\n variant=\"outlined\"\n onClick={() => setUserChatTextfieldValue(prompt)}\n disabled={!agentSession}\n sx={{ cursor: 'pointer' }}\n />\n ))}\n </Stack>\n )}\n <Box\n component=\"form\"\n sx={{\n pt: '8px',\n mt: '5px',\n pb: '10px',\n position: 'sticky',\n borderTop: '1px solid',\n borderColor: 'grey.400',\n }}\n onSubmit={handleSendMessage}\n >\n <TextField\n fullWidth\n value={userChatTextfieldValue}\n onChange={e => setUserChatTextfieldValue(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={`Message ${chatbotName}`}\n slotProps={{\n input: {\n sx: { borderRadius: 96.6 },\n endAdornment: (\n <IconButton\n disabled={isDisabled}\n onClick={handleSendMessage}\n sx={{\n ml: '7px',\n mr: '-8px',\n color: sendMessageButtonColor,\n borderStyle: 'solid',\n borderWidth: isDisabled ? '1px' : '2px',\n borderColor: isDisabled ? 'gray' : sendMessageButtonColor,\n }}\n >\n <ArrowUpward />\n </IconButton>\n ),\n },\n }}\n />\n <Typography\n variant=\"smallText1\"\n sx={{ pt: '8px', textAlign: 'center' }}\n >\n {chatbotName} can make mistakes.\n </Typography>\n </Box>\n </Box>\n </Box>\n )\n}\n\nexport default SynapseChat\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._container_1tem6_1{background-color:#fff3;border-radius:9px;grid-template-columns:100%;justify-items:start;max-width:1300px;margin:auto;padding-top:0;padding-bottom:40px;display:grid}@media (width>=600px){._container_1tem6_1{grid-template-columns:50% 50%;padding-top:80px;padding-bottom:60px}}._item_1tem6_20{border-right:1px solid var(--synapse-gray-400);border-bottom:1px solid var(--synapse-gray-400);border-left:1px solid var(--synapse-gray-400);grid-template-columns:80% 20%;display:grid}._item_1tem6_20:first-child{border-top:1px solid var(--synapse-gray-400)}@media (width>=600px){._item_1tem6_20{border-top:none;border-left:none}._item_1tem6_20:nth-child(odd){border-left:1px solid var(--synapse-gray-400)}._item_1tem6_20:nth-child(-n+2){border-top:1px solid var(--synapse-gray-400)}}._item_1tem6_20{background-color:#ffffffe6;width:100%;padding:15px 0;text-decoration:none}._item_1tem6_20:hover{cursor:pointer;background-color:#e9f3fef2;text-decoration:none!important}._item_1tem6_20 ._itemTitle_1tem6_53{color:var(--synapse-gray-900);font-size:16px;font-weight:700}._item_1tem6_20 ._itemMeta_1tem6_58{color:var(--synapse-gray-700)}._adkpVariant_1tem6_62 ._item_1tem6_20:hover{background:linear-gradient(91deg,#7761b7 5.34%,#9067b6 24.31%,#816dc8 91.15%)}._adkpVariant_1tem6_62 ._item_1tem6_20:hover ._itemTitle_1tem6_53,._adkpVariant_1tem6_62 ._item_1tem6_20:hover ._itemMeta_1tem6_58{color:#fff}._itemContent_1tem6_70{color:var(--synapse-gray-900);padding-left:15px;padding-right:10px}._itemAction_1tem6_76{place-self:start end;padding-right:15px}._chip_1tem6_82.MuiChip-root{border-radius:5px;height:24px}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import './HotdropsAndNews.css';var e = {
|
|
2
|
-
container: "
|
|
3
|
-
item: "
|
|
4
|
-
itemTitle: "
|
|
5
|
-
itemMeta: "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
container: "_container_1tem6_1",
|
|
3
|
+
item: "_item_1tem6_20",
|
|
4
|
+
itemTitle: "_itemTitle_1tem6_53",
|
|
5
|
+
itemMeta: "_itemMeta_1tem6_58",
|
|
6
|
+
adkpVariant: "_adkpVariant_1tem6_62",
|
|
7
|
+
itemContent: "_itemContent_1tem6_70",
|
|
8
|
+
itemAction: "_itemAction_1tem6_76",
|
|
9
|
+
chip: "_chip_1tem6_82"
|
|
9
10
|
};
|
|
10
11
|
//#endregion
|
|
11
12
|
export { e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HotdropsAndNews.module.js","names":[],"sources":["../../../src/components/SynapseHomepageV2/HotdropsAndNews.module.scss"],"sourcesContent":["// ---------------------------------------------------------------------------\n// Grid container (SynapseHotDrops / WordPressNews outer wrapper)\n// ---------------------------------------------------------------------------\n\n.container {\n display: grid;\n justify-items: start;\n background-color: rgba(255, 255, 255, 0.2);\n border-radius: 9px;\n max-width: 1300px;\n margin: auto;\n\n // Mobile-first: single column\n grid-template-columns: 100%;\n padding-top: 0;\n padding-bottom: 40px;\n\n // ≥ MUI 'sm' breakpoint (600px)\n @media (min-width: 600px) {\n grid-template-columns: 50% 50%;\n padding-top: 80px;\n padding-bottom: 60px;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Individual item row\n// ---------------------------------------------------------------------------\n\n.item {\n display: grid;\n grid-template-columns: 80% 20%;\n // Each item provides its own right + bottom edge.\n // Leading edges (top/left) are added selectively to avoid doubling.\n border-right: 1px solid var(--synapse-gray-400); // lighter interior border\n border-bottom: 1px solid var(--synapse-gray-400);\n\n // Mobile: single column — every item is the left edge; only the first has a top edge.\n border-left: 1px solid var(--synapse-gray-400);\n &:first-child {\n border-top: 1px solid var(--synapse-gray-400);\n }\n\n // Desktop: two columns — left edge belongs to odd items (col 1); top edge to the first two (row 1).\n @media (min-width: 600px) {\n border-left: none;\n border-top: none;\n\n &:nth-child(odd) {\n border-left: 1px solid var(--synapse-gray-400);\n }\n\n &:nth-child(-n + 2) {\n border-top: 1px solid var(--synapse-gray-400);\n }\n }\n\n width: 100%;\n background-color: rgba(255, 255, 255, 0.9);\n padding: 15px 0;\n\n text-decoration: none;\n\n &:hover {\n background-color: rgba(233, 243, 254, 0.95);\n cursor: pointer;\n text-decoration: none !important;\n }\n\n .itemTitle {\n color: var(--synapse-gray-900);\n font-size: 16px;\n font-weight: 700;\n }\n .itemMeta {\n color: var(--synapse-gray-700);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Item: left content area\n// ---------------------------------------------------------------------------\n\n.itemContent {\n color: var(--synapse-gray-900);\n padding-left: 15px;\n padding-right: 10px;\n}\n\n// ---------------------------------------------------------------------------\n// Item: right action area (chip container)\n// ---------------------------------------------------------------------------\n\n.itemAction {\n justify-self: end;\n align-self: start;\n padding-right: 15px;\n}\n\n// ---------------------------------------------------------------------------\n// Category / type chip\n// ---------------------------------------------------------------------------\n\n.chip:global(.MuiChip-root) {\n border-radius: 5px;\n height: 24px;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"HotdropsAndNews.module.js","names":[],"sources":["../../../src/components/SynapseHomepageV2/HotdropsAndNews.module.scss"],"sourcesContent":["// ---------------------------------------------------------------------------\n// Grid container (SynapseHotDrops / WordPressNews outer wrapper)\n// ---------------------------------------------------------------------------\n\n.container {\n display: grid;\n justify-items: start;\n background-color: rgba(255, 255, 255, 0.2);\n border-radius: 9px;\n max-width: 1300px;\n margin: auto;\n\n // Mobile-first: single column\n grid-template-columns: 100%;\n padding-top: 0;\n padding-bottom: 40px;\n\n // ≥ MUI 'sm' breakpoint (600px)\n @media (min-width: 600px) {\n grid-template-columns: 50% 50%;\n padding-top: 80px;\n padding-bottom: 60px;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Individual item row\n// ---------------------------------------------------------------------------\n\n.item {\n display: grid;\n grid-template-columns: 80% 20%;\n // Each item provides its own right + bottom edge.\n // Leading edges (top/left) are added selectively to avoid doubling.\n border-right: 1px solid var(--synapse-gray-400); // lighter interior border\n border-bottom: 1px solid var(--synapse-gray-400);\n\n // Mobile: single column — every item is the left edge; only the first has a top edge.\n border-left: 1px solid var(--synapse-gray-400);\n &:first-child {\n border-top: 1px solid var(--synapse-gray-400);\n }\n\n // Desktop: two columns — left edge belongs to odd items (col 1); top edge to the first two (row 1).\n @media (min-width: 600px) {\n border-left: none;\n border-top: none;\n\n &:nth-child(odd) {\n border-left: 1px solid var(--synapse-gray-400);\n }\n\n &:nth-child(-n + 2) {\n border-top: 1px solid var(--synapse-gray-400);\n }\n }\n\n width: 100%;\n background-color: rgba(255, 255, 255, 0.9);\n padding: 15px 0;\n\n text-decoration: none;\n\n &:hover {\n background-color: rgba(233, 243, 254, 0.95);\n cursor: pointer;\n text-decoration: none !important;\n }\n\n .itemTitle {\n color: var(--synapse-gray-900);\n font-size: 16px;\n font-weight: 700;\n }\n .itemMeta {\n color: var(--synapse-gray-700);\n }\n}\n\n.adkpVariant {\n .item:hover {\n background: linear-gradient(\n 91deg,\n #7761b7 5.34%,\n #9067b6 24.31%,\n #816dc8 91.15%\n );\n\n .itemTitle,\n .itemMeta {\n color: #fff;\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Item: left content area\n// ---------------------------------------------------------------------------\n\n.itemContent {\n color: var(--synapse-gray-900);\n padding-left: 15px;\n padding-right: 10px;\n}\n\n// ---------------------------------------------------------------------------\n// Item: right action area (chip container)\n// ---------------------------------------------------------------------------\n\n.itemAction {\n justify-self: end;\n align-self: start;\n padding-right: 15px;\n}\n\n// ---------------------------------------------------------------------------\n// Category / type chip\n// ---------------------------------------------------------------------------\n\n.chip:global(.MuiChip-root) {\n border-radius: 5px;\n height: 24px;\n}\n"],"mappings":""}
|
|
@@ -77,6 +77,22 @@
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
.adkpVariant {
|
|
81
|
+
.item:hover {
|
|
82
|
+
background: linear-gradient(
|
|
83
|
+
91deg,
|
|
84
|
+
#7761b7 5.34%,
|
|
85
|
+
#9067b6 24.31%,
|
|
86
|
+
#816dc8 91.15%
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
.itemTitle,
|
|
90
|
+
.itemMeta {
|
|
91
|
+
color: #fff;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
// ---------------------------------------------------------------------------
|
|
81
97
|
// Item: left content area
|
|
82
98
|
// ---------------------------------------------------------------------------
|
|
@@ -3,6 +3,8 @@ export type WordPressNewsProps = {
|
|
|
3
3
|
wordpressSiteUrl: string;
|
|
4
4
|
/** Number of posts to display. Defaults to 10. */
|
|
5
5
|
postCount?: number;
|
|
6
|
+
showCategoryChips?: boolean;
|
|
7
|
+
variant?: 'adkp';
|
|
6
8
|
};
|
|
7
|
-
export declare function WordPressNews({ wordpressSiteUrl, postCount, }: WordPressNewsProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function WordPressNews({ wordpressSiteUrl, postCount, showCategoryChips, variant, }: WordPressNewsProps): import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
//# sourceMappingURL=WordPressNews.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WordPressNews.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseHomepageV2/WordPressNews.tsx"],"names":[],"mappings":"AASA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gFAAgF;IAChF,gBAAgB,EAAE,MAAM,CAAA;IACxB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"WordPressNews.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseHomepageV2/WordPressNews.tsx"],"names":[],"mappings":"AASA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gFAAgF;IAChF,gBAAgB,EAAE,MAAM,CAAA;IACxB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAgCD,wBAAgB,aAAa,CAAC,EAC5B,gBAAgB,EAChB,SAAc,EACd,iBAAwB,EACxB,OAAO,GACR,EAAE,kBAAkB,2CAoCpB"}
|
|
@@ -18,24 +18,25 @@ async function s(e) {
|
|
|
18
18
|
if (!n.ok) throw Error(`Failed to fetch WordPress categories: ${n.statusText}`);
|
|
19
19
|
return n.json();
|
|
20
20
|
}
|
|
21
|
-
function c({ wordpressSiteUrl: c, postCount: l = 10 }) {
|
|
22
|
-
let { data:
|
|
21
|
+
function c({ wordpressSiteUrl: c, postCount: l = 10, showCategoryChips: u = !0, variant: d }) {
|
|
22
|
+
let { data: f } = a({
|
|
23
23
|
queryKey: [
|
|
24
24
|
"wordpressPosts",
|
|
25
25
|
c,
|
|
26
26
|
l
|
|
27
27
|
],
|
|
28
28
|
queryFn: () => o(c, l)
|
|
29
|
-
}), { data:
|
|
29
|
+
}), { data: p } = a({
|
|
30
30
|
queryKey: ["wordpressCategories", c],
|
|
31
31
|
queryFn: () => s(c)
|
|
32
|
-
}),
|
|
33
|
-
return !
|
|
34
|
-
className: e.container
|
|
32
|
+
}), m = new Map((p ?? []).map((e) => [e.id, e.name]));
|
|
33
|
+
return !f || f.length === 0 ? /* @__PURE__ */ i(r, {}) : /* @__PURE__ */ i(n, {
|
|
34
|
+
className: `${e.container}${d === "adkp" ? ` ${e.adkpVariant}` : ""}`,
|
|
35
35
|
sx: { color: "primary.100" },
|
|
36
|
-
children:
|
|
36
|
+
children: f.map((e) => /* @__PURE__ */ i(t, {
|
|
37
37
|
post: e,
|
|
38
|
-
categoryName:
|
|
38
|
+
categoryName: m.get(e.categories[0]),
|
|
39
|
+
showCategoryChip: u
|
|
39
40
|
}, e.id))
|
|
40
41
|
});
|
|
41
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WordPressNews.js","names":[],"sources":["../../../src/components/SynapseHomepageV2/WordPressNews.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { Box } from '@mui/material'\nimport {\n WordPressCategory,\n WordPressNewsItem,\n WordPressPost,\n} from './WordPressNewsItem'\nimport styles from './HotdropsAndNews.module.scss'\n\nexport type WordPressNewsProps = {\n /** Base URL of the WordPress site, e.g. \"https://news.adknowledgeportal.org\" */\n wordpressSiteUrl: string\n /** Number of posts to display. Defaults to 10. */\n postCount?: number\n}\n\nasync function fetchWordPressPosts(\n wordpressSiteUrl: string,\n postCount: number,\n): Promise<WordPressPost[]> {\n const url = new URL(`${wordpressSiteUrl}/wp-json/wp/v2/posts`)\n url.searchParams.set('per_page', String(postCount))\n url.searchParams.set('orderby', 'date')\n url.searchParams.set('order', 'desc')\n url.searchParams.set('_fields', 'id,date,link,title,categories')\n const response = await fetch(url.toString())\n if (!response.ok) {\n throw new Error(`Failed to fetch WordPress posts: ${response.statusText}`)\n }\n return response.json() as Promise<WordPressPost[]>\n}\n\nasync function fetchWordPressCategories(\n wordpressSiteUrl: string,\n): Promise<WordPressCategory[]> {\n const url = new URL(`${wordpressSiteUrl}/wp-json/wp/v2/categories`)\n url.searchParams.set('_fields', 'id,name,slug')\n const response = await fetch(url.toString())\n if (!response.ok) {\n throw new Error(\n `Failed to fetch WordPress categories: ${response.statusText}`,\n )\n }\n return response.json() as Promise<WordPressCategory[]>\n}\n\nexport function WordPressNews({\n wordpressSiteUrl,\n postCount = 10,\n}: WordPressNewsProps) {\n const { data: posts } = useQuery({\n queryKey: ['wordpressPosts', wordpressSiteUrl, postCount],\n queryFn: () => fetchWordPressPosts(wordpressSiteUrl, postCount),\n })\n\n const { data: categories } = useQuery({\n queryKey: ['wordpressCategories', wordpressSiteUrl],\n queryFn: () => fetchWordPressCategories(wordpressSiteUrl),\n })\n\n const categoryMap = new Map<number, string>(\n (categories ?? []).map(c => [c.id, c.name]),\n )\n\n if (!posts || posts.length === 0) {\n return <></>\n }\n\n return (\n <Box
|
|
1
|
+
{"version":3,"file":"WordPressNews.js","names":[],"sources":["../../../src/components/SynapseHomepageV2/WordPressNews.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { Box } from '@mui/material'\nimport {\n WordPressCategory,\n WordPressNewsItem,\n WordPressPost,\n} from './WordPressNewsItem'\nimport styles from './HotdropsAndNews.module.scss'\n\nexport type WordPressNewsProps = {\n /** Base URL of the WordPress site, e.g. \"https://news.adknowledgeportal.org\" */\n wordpressSiteUrl: string\n /** Number of posts to display. Defaults to 10. */\n postCount?: number\n showCategoryChips?: boolean\n variant?: 'adkp'\n}\n\nasync function fetchWordPressPosts(\n wordpressSiteUrl: string,\n postCount: number,\n): Promise<WordPressPost[]> {\n const url = new URL(`${wordpressSiteUrl}/wp-json/wp/v2/posts`)\n url.searchParams.set('per_page', String(postCount))\n url.searchParams.set('orderby', 'date')\n url.searchParams.set('order', 'desc')\n url.searchParams.set('_fields', 'id,date,link,title,categories')\n const response = await fetch(url.toString())\n if (!response.ok) {\n throw new Error(`Failed to fetch WordPress posts: ${response.statusText}`)\n }\n return response.json() as Promise<WordPressPost[]>\n}\n\nasync function fetchWordPressCategories(\n wordpressSiteUrl: string,\n): Promise<WordPressCategory[]> {\n const url = new URL(`${wordpressSiteUrl}/wp-json/wp/v2/categories`)\n url.searchParams.set('_fields', 'id,name,slug')\n const response = await fetch(url.toString())\n if (!response.ok) {\n throw new Error(\n `Failed to fetch WordPress categories: ${response.statusText}`,\n )\n }\n return response.json() as Promise<WordPressCategory[]>\n}\n\nexport function WordPressNews({\n wordpressSiteUrl,\n postCount = 10,\n showCategoryChips = true,\n variant,\n}: WordPressNewsProps) {\n const { data: posts } = useQuery({\n queryKey: ['wordpressPosts', wordpressSiteUrl, postCount],\n queryFn: () => fetchWordPressPosts(wordpressSiteUrl, postCount),\n })\n\n const { data: categories } = useQuery({\n queryKey: ['wordpressCategories', wordpressSiteUrl],\n queryFn: () => fetchWordPressCategories(wordpressSiteUrl),\n })\n\n const categoryMap = new Map<number, string>(\n (categories ?? []).map(c => [c.id, c.name]),\n )\n\n if (!posts || posts.length === 0) {\n return <></>\n }\n\n return (\n <Box\n className={`${styles.container}${\n variant === 'adkp' ? ` ${styles.adkpVariant}` : ''\n }`}\n sx={{ color: 'primary.100' }}\n >\n {posts.map(post => (\n <WordPressNewsItem\n key={post.id}\n post={post}\n categoryName={categoryMap.get(post.categories[0])}\n showCategoryChip={showCategoryChips}\n />\n ))}\n </Box>\n )\n}\n"],"mappings":";;;;;;AAkBA,eAAe,EACb,GACA,GAC0B;CAC1B,IAAM,IAAM,IAAI,IAAI,GAAG,EAAiB,sBAAsB;AAI9D,CAHA,EAAI,aAAa,IAAI,YAAY,OAAO,EAAU,CAAC,EACnD,EAAI,aAAa,IAAI,WAAW,OAAO,EACvC,EAAI,aAAa,IAAI,SAAS,OAAO,EACrC,EAAI,aAAa,IAAI,WAAW,gCAAgC;CAChE,IAAM,IAAW,MAAM,MAAM,EAAI,UAAU,CAAC;AAC5C,KAAI,CAAC,EAAS,GACZ,OAAU,MAAM,oCAAoC,EAAS,aAAa;AAE5E,QAAO,EAAS,MAAM;;AAGxB,eAAe,EACb,GAC8B;CAC9B,IAAM,IAAM,IAAI,IAAI,GAAG,EAAiB,2BAA2B;AACnE,GAAI,aAAa,IAAI,WAAW,eAAe;CAC/C,IAAM,IAAW,MAAM,MAAM,EAAI,UAAU,CAAC;AAC5C,KAAI,CAAC,EAAS,GACZ,OAAU,MACR,yCAAyC,EAAS,aACnD;AAEH,QAAO,EAAS,MAAM;;AAGxB,SAAgB,EAAc,EAC5B,qBACA,eAAY,IACZ,uBAAoB,IACpB,cACqB;CACrB,IAAM,EAAE,MAAM,MAAU,EAAS;EAC/B,UAAU;GAAC;GAAkB;GAAkB;GAAU;EACzD,eAAe,EAAoB,GAAkB,EAAU;EAChE,CAAC,EAEI,EAAE,MAAM,MAAe,EAAS;EACpC,UAAU,CAAC,uBAAuB,EAAiB;EACnD,eAAe,EAAyB,EAAiB;EAC1D,CAAC,EAEI,IAAc,IAAI,KACrB,KAAc,EAAE,EAAE,KAAI,MAAK,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAC5C;AAMD,QAJI,CAAC,KAAS,EAAM,WAAW,IACtB,kBAAA,GAAA,EAAK,CAAA,GAIZ,kBAAC,GAAD;EACE,WAAW,GAAG,EAAO,YACnB,MAAY,SAAS,IAAI,EAAO,gBAAgB;EAElD,IAAI,EAAE,OAAO,eAAe;YAE3B,EAAM,KAAI,MACT,kBAAC,GAAD;GAEQ;GACN,cAAc,EAAY,IAAI,EAAK,WAAW,GAAG;GACjD,kBAAkB;GAClB,EAJK,EAAK,GAIV,CACF;EACE,CAAA"}
|
|
@@ -15,6 +15,7 @@ export type WordPressCategory = {
|
|
|
15
15
|
export type WordPressNewsItemProps = {
|
|
16
16
|
post: WordPressPost;
|
|
17
17
|
categoryName: string | undefined;
|
|
18
|
+
showCategoryChip?: boolean;
|
|
18
19
|
};
|
|
19
|
-
export declare function WordPressNewsItem({ post, categoryName, }: WordPressNewsItemProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function WordPressNewsItem({ post, categoryName, showCategoryChip, }: WordPressNewsItemProps): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
//# sourceMappingURL=WordPressNewsItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WordPressNewsItem.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseHomepageV2/WordPressNewsItem.tsx"],"names":[],"mappings":"AAOA,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,aAAa,CAAA;IACnB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"WordPressNewsItem.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseHomepageV2/WordPressNewsItem.tsx"],"names":[],"mappings":"AAOA,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,aAAa,CAAA;IACnB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,YAAY,EACZ,gBAAuB,GACxB,EAAE,sBAAsB,2CA2BxB"}
|
|
@@ -5,7 +5,7 @@ import o from "dayjs";
|
|
|
5
5
|
import s from "dayjs/plugin/relativeTime";
|
|
6
6
|
//#region src/components/SynapseHomepageV2/WordPressNewsItem.tsx
|
|
7
7
|
o.extend(s);
|
|
8
|
-
function c({ post: s, categoryName: c }) {
|
|
8
|
+
function c({ post: s, categoryName: c, showCategoryChip: l = !0 }) {
|
|
9
9
|
return /* @__PURE__ */ a(t, {
|
|
10
10
|
component: "a",
|
|
11
11
|
href: s.link,
|
|
@@ -26,7 +26,7 @@ function c({ post: s, categoryName: c }) {
|
|
|
26
26
|
})]
|
|
27
27
|
}), /* @__PURE__ */ i(t, {
|
|
28
28
|
className: e.itemAction,
|
|
29
|
-
children: c && /* @__PURE__ */ i(n, {
|
|
29
|
+
children: c && l && /* @__PURE__ */ i(n, {
|
|
30
30
|
className: e.chip,
|
|
31
31
|
label: c,
|
|
32
32
|
color: "primary"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WordPressNewsItem.js","names":[],"sources":["../../../src/components/SynapseHomepageV2/WordPressNewsItem.tsx"],"sourcesContent":["import { Box, Chip, Typography } from '@mui/material'\nimport dayjs from 'dayjs'\nimport relativeTime from 'dayjs/plugin/relativeTime'\nimport styles from './HotdropsAndNews.module.scss'\n\ndayjs.extend(relativeTime)\n\nexport type WordPressPost = {\n id: number\n date: string\n link: string\n title: { rendered: string }\n categories: number[]\n}\n\nexport type WordPressCategory = {\n id: number\n name: string\n slug: string\n}\n\nexport type WordPressNewsItemProps = {\n post: WordPressPost\n categoryName: string | undefined\n}\n\nexport function WordPressNewsItem({\n post,\n categoryName,\n}: WordPressNewsItemProps) {\n return (\n <Box\n component=\"a\"\n href={post.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={styles.item}\n >\n <Box className={styles.itemContent}>\n <Typography\n variant=\"body1\"\n className={styles.itemTitle}\n noWrap\n dangerouslySetInnerHTML={{ __html: post.title.rendered }}\n />\n <Typography variant=\"body1\" className={styles.itemMeta}>\n {dayjs(post.date).fromNow()}\n </Typography>\n </Box>\n <Box className={styles.itemAction}>\n {categoryName && (\n <Chip className={styles.chip} label={categoryName} color=\"primary\" />\n )}\n </Box>\n </Box>\n )\n}\n"],"mappings":";;;;;;AAKA,EAAM,OAAO,EAAa;
|
|
1
|
+
{"version":3,"file":"WordPressNewsItem.js","names":[],"sources":["../../../src/components/SynapseHomepageV2/WordPressNewsItem.tsx"],"sourcesContent":["import { Box, Chip, Typography } from '@mui/material'\nimport dayjs from 'dayjs'\nimport relativeTime from 'dayjs/plugin/relativeTime'\nimport styles from './HotdropsAndNews.module.scss'\n\ndayjs.extend(relativeTime)\n\nexport type WordPressPost = {\n id: number\n date: string\n link: string\n title: { rendered: string }\n categories: number[]\n}\n\nexport type WordPressCategory = {\n id: number\n name: string\n slug: string\n}\n\nexport type WordPressNewsItemProps = {\n post: WordPressPost\n categoryName: string | undefined\n showCategoryChip?: boolean\n}\n\nexport function WordPressNewsItem({\n post,\n categoryName,\n showCategoryChip = true,\n}: WordPressNewsItemProps) {\n return (\n <Box\n component=\"a\"\n href={post.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={styles.item}\n >\n <Box className={styles.itemContent}>\n <Typography\n variant=\"body1\"\n className={styles.itemTitle}\n noWrap\n dangerouslySetInnerHTML={{ __html: post.title.rendered }}\n />\n <Typography variant=\"body1\" className={styles.itemMeta}>\n {dayjs(post.date).fromNow()}\n </Typography>\n </Box>\n <Box className={styles.itemAction}>\n {categoryName && showCategoryChip && (\n <Chip className={styles.chip} label={categoryName} color=\"primary\" />\n )}\n </Box>\n </Box>\n )\n}\n"],"mappings":";;;;;;AAKA,EAAM,OAAO,EAAa;AAsB1B,SAAgB,EAAkB,EAChC,SACA,iBACA,sBAAmB,MACM;AACzB,QACE,kBAAC,GAAD;EACE,WAAU;EACV,MAAM,EAAK;EACX,QAAO;EACP,KAAI;EACJ,WAAW,EAAO;YALpB,CAOE,kBAAC,GAAD;GAAK,WAAW,EAAO;aAAvB,CACE,kBAAC,GAAD;IACE,SAAQ;IACR,WAAW,EAAO;IAClB,QAAA;IACA,yBAAyB,EAAE,QAAQ,EAAK,MAAM,UAAU;IACxD,CAAA,EACF,kBAAC,GAAD;IAAY,SAAQ;IAAQ,WAAW,EAAO;cAC3C,EAAM,EAAK,KAAK,CAAC,SAAS;IAChB,CAAA,CACT;MACN,kBAAC,GAAD;GAAK,WAAW,EAAO;aACpB,KAAgB,KACf,kBAAC,GAAD;IAAM,WAAW,EAAO;IAAM,OAAO;IAAc,OAAM;IAAY,CAAA;GAEnE,CAAA,CACF"}
|
|
@@ -22,6 +22,13 @@ export type FTSConfig = {
|
|
|
22
22
|
textMatchesMode: TextMatchesMode;
|
|
23
23
|
distance?: number;
|
|
24
24
|
searchHelpURL?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional function to provide autocomplete suggestions for the search bar.
|
|
27
|
+
* When provided, the search input will show a dropdown of suggestions as the user types.
|
|
28
|
+
* @param searchText - The current text in the search input
|
|
29
|
+
* @returns A promise resolving to an array of suggestion strings
|
|
30
|
+
*/
|
|
31
|
+
getSuggestions?: (searchText: string) => Promise<string[]>;
|
|
25
32
|
};
|
|
26
33
|
export default function Search(props: SearchV2Props): import("react/jsx-runtime").JSX.Element;
|
|
27
34
|
//# sourceMappingURL=SearchV2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchV2.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseTable/SearchV2.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACb,MAAM,SAAS,CAAA;AAoBhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAA;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAexC,MAAM,MAAM,mBAAmB,GAAG,MAAM,EAAE,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,EAAE,gBAAgB,CAAA;IAC9B,yBAAyB,EAAE,6BAA6B,CAAA;IACxD,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAA;AAC5D,MAAM,MAAM,SAAS,GAAG;IACtB,eAAe,EAAE,eAAe,CAAA;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"SearchV2.d.ts","sourceRoot":"","sources":["../../../src/components/SynapseTable/SearchV2.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACb,MAAM,SAAS,CAAA;AAoBhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAA;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAexC,MAAM,MAAM,mBAAmB,GAAG,MAAM,EAAE,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,EAAE,gBAAgB,CAAA;IAC9B,yBAAyB,EAAE,6BAA6B,CAAA;IACxD,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAA;AAC5D,MAAM,MAAM,SAAS,GAAG;IACtB,eAAe,EAAE,eAAe,CAAA;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;CAC3D,CAAA;AA0SD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,aAAa,2CAGlD"}
|