@redocly/theme 0.45.5 → 0.45.6
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/lib/components/Search/SearchAiResponse.js +13 -4
- package/lib/components/Search/SearchDialog.js +1 -4
- package/lib/core/hooks/__mocks__/use-theme-hooks.d.ts +1 -0
- package/lib/core/hooks/__mocks__/use-theme-hooks.js +3 -0
- package/lib/core/types/hooks.d.ts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
- package/src/components/Search/SearchAiResponse.tsx +13 -4
- package/src/components/Search/SearchDialog.tsx +1 -4
- package/src/core/hooks/__mocks__/use-theme-hooks.ts +3 -0
- package/src/core/types/hooks.ts +1 -0
- package/src/index.ts +1 -0
|
@@ -12,16 +12,19 @@ const DocumentIcon_1 = require("../../icons/DocumentIcon/DocumentIcon");
|
|
|
12
12
|
const Tag_1 = require("../../components/Tag/Tag");
|
|
13
13
|
const Link_1 = require("../../components/Link/Link");
|
|
14
14
|
const hooks_1 = require("../../core/hooks");
|
|
15
|
+
const Markdown_1 = require("../../components/Markdown/Markdown");
|
|
15
16
|
function SearchAiResponse(props) {
|
|
17
|
+
const { useMarkdownText } = (0, hooks_1.useThemeHooks)();
|
|
16
18
|
const { question, response, isGeneratingResponse, resources } = props;
|
|
17
19
|
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
18
20
|
const { translate } = useTranslate();
|
|
19
|
-
|
|
21
|
+
const markdownResponse = useMarkdownText(response || '');
|
|
22
|
+
return (react_1.default.createElement(ResponseWrapper, { "data-component-name": "Search/SearchAiResponse" },
|
|
20
23
|
react_1.default.createElement(ResponseHeader, null,
|
|
21
24
|
isGeneratingResponse ? (react_1.default.createElement(Spinner_1.Spinner, { size: "20px", color: "--search-ai-spinner-icon-color" })) : (react_1.default.createElement(CheckmarkFilledIcon_1.CheckmarkFilledIcon, { size: "20px", color: "--search-ai-checkmark-icon-color" })),
|
|
22
25
|
react_1.default.createElement(Question, null, question)),
|
|
23
26
|
react_1.default.createElement(ResponseBody, null,
|
|
24
|
-
response ? (react_1.default.createElement(ResponseText,
|
|
27
|
+
response ? (react_1.default.createElement(ResponseText, Object.assign({ children: markdownResponse, as: "div" }, props))) : (react_1.default.createElement(ThinkingResponseText, { "data-translation-key": "search.ai.thinkingText" }, translate('search.ai.thinkingText', 'Thinking...'))),
|
|
25
28
|
resources.length && !isGeneratingResponse ? (react_1.default.createElement(Resources, null,
|
|
26
29
|
react_1.default.createElement(ResourcesTitle, { "data-translation-key": "search.ai.resourcesFound" },
|
|
27
30
|
resources.length,
|
|
@@ -58,14 +61,20 @@ const ResponseBody = styled_components_1.default.div `
|
|
|
58
61
|
gap: var(--search-ai-response-body-gap);
|
|
59
62
|
padding: var(--search-ai-response-body-padding);
|
|
60
63
|
`;
|
|
61
|
-
const ResponseText = styled_components_1.default.
|
|
64
|
+
const ResponseText = (0, styled_components_1.default)(Markdown_1.Markdown) `
|
|
62
65
|
color: var(--search-ai-response-text-color);
|
|
63
66
|
font-size: var(--search-ai-response-text-font-size);
|
|
64
67
|
line-height: var(--search-ai-response-text-line-height);
|
|
65
68
|
font-family: inherit;
|
|
66
69
|
white-space: break-spaces;
|
|
67
70
|
`;
|
|
68
|
-
const ThinkingResponseText =
|
|
71
|
+
const ThinkingResponseText = styled_components_1.default.pre `
|
|
72
|
+
color: var(--search-ai-response-text-color);
|
|
73
|
+
font-size: var(--search-ai-response-text-font-size);
|
|
74
|
+
line-height: var(--search-ai-response-text-line-height);
|
|
75
|
+
font-family: inherit;
|
|
76
|
+
white-space: break-spaces;
|
|
77
|
+
margin: var(--md-pre-margin) 0;
|
|
69
78
|
animation: fadeIn 2s ease-in-out infinite;
|
|
70
79
|
|
|
71
80
|
@keyframes fadeIn {
|
|
@@ -188,10 +188,7 @@ const SearchDialogBody = styled_components_1.default.div `
|
|
|
188
188
|
display: flex;
|
|
189
189
|
flex-direction: row;
|
|
190
190
|
flex-grow: 1;
|
|
191
|
-
|
|
192
|
-
@media screen and (min-width: ${utils_1.breakpoints.small}) {
|
|
193
|
-
height: var(--search-modal-min-height);
|
|
194
|
-
}
|
|
191
|
+
overflow: hidden;
|
|
195
192
|
`;
|
|
196
193
|
const SearchDialogBodyMainView = styled_components_1.default.div `
|
|
197
194
|
flex: 2;
|
|
@@ -44,6 +44,7 @@ export declare const useThemeHooks: jest.Mock<{
|
|
|
44
44
|
setSearchFacet: jest.Mock<any, any, any>;
|
|
45
45
|
setSearchFacetQuery: jest.Mock<any, any, any>;
|
|
46
46
|
}, [], any>;
|
|
47
|
+
useMarkdownText: jest.Mock<null, [], any>;
|
|
47
48
|
useUserMenu: jest.Mock<{
|
|
48
49
|
userData: {
|
|
49
50
|
isAuthenticated: boolean;
|
|
@@ -70,6 +70,7 @@ export type ThemeHooks = {
|
|
|
70
70
|
url: string;
|
|
71
71
|
}[];
|
|
72
72
|
};
|
|
73
|
+
useMarkdownText: (text: string) => React.ReactNode;
|
|
73
74
|
useFacetQuery: (field: string) => {
|
|
74
75
|
searchFacet: SearchFacet | null;
|
|
75
76
|
setSearchFacet: React.Dispatch<React.SetStateAction<SearchFacet | null>>;
|
package/lib/index.d.ts
CHANGED
|
@@ -117,6 +117,7 @@ export * from './components/Search/SearchFilter';
|
|
|
117
117
|
export * from './components/Search/SearchFilterField';
|
|
118
118
|
export * from './components/Search/FilterFields/SearchFilterFieldSelect';
|
|
119
119
|
export * from './components/Search/FilterFields/SearchFilterFieldTags';
|
|
120
|
+
export * from './components/Search/SearchAiResponse';
|
|
120
121
|
export * from './icons/ArrowRightIcon/ArrowRightIcon';
|
|
121
122
|
export * from './icons/ArrowUpRightIcon/ArrowUpRightIcon';
|
|
122
123
|
export * from './icons/ArrowLeftIcon/ArrowLeftIcon';
|
package/lib/index.js
CHANGED
|
@@ -168,6 +168,7 @@ __exportStar(require("./components/Search/SearchFilter"), exports);
|
|
|
168
168
|
__exportStar(require("./components/Search/SearchFilterField"), exports);
|
|
169
169
|
__exportStar(require("./components/Search/FilterFields/SearchFilterFieldSelect"), exports);
|
|
170
170
|
__exportStar(require("./components/Search/FilterFields/SearchFilterFieldTags"), exports);
|
|
171
|
+
__exportStar(require("./components/Search/SearchAiResponse"), exports);
|
|
171
172
|
/* Icons */
|
|
172
173
|
__exportStar(require("./icons/ArrowRightIcon/ArrowRightIcon"), exports);
|
|
173
174
|
__exportStar(require("./icons/ArrowUpRightIcon/ArrowUpRightIcon"), exports);
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import { DocumentIcon } from '@redocly/theme/icons/DocumentIcon/DocumentIcon';
|
|
|
7
7
|
import { Tag } from '@redocly/theme/components/Tag/Tag';
|
|
8
8
|
import { Link } from '@redocly/theme/components/Link/Link';
|
|
9
9
|
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
10
|
+
import { Markdown } from '@redocly/theme/components/Markdown/Markdown';
|
|
10
11
|
|
|
11
12
|
export type SearchAiResponseProps = {
|
|
12
13
|
question: string;
|
|
@@ -19,13 +20,15 @@ export type SearchAiResponseProps = {
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
export function SearchAiResponse(props: SearchAiResponseProps): JSX.Element {
|
|
23
|
+
const { useMarkdownText } = useThemeHooks();
|
|
22
24
|
const { question, response, isGeneratingResponse, resources } = props;
|
|
23
25
|
|
|
24
26
|
const { useTranslate } = useThemeHooks();
|
|
25
27
|
const { translate } = useTranslate();
|
|
28
|
+
const markdownResponse = useMarkdownText(response || '');
|
|
26
29
|
|
|
27
30
|
return (
|
|
28
|
-
<ResponseWrapper data-component-name="Search/
|
|
31
|
+
<ResponseWrapper data-component-name="Search/SearchAiResponse">
|
|
29
32
|
<ResponseHeader>
|
|
30
33
|
{isGeneratingResponse ? (
|
|
31
34
|
<Spinner size="20px" color="--search-ai-spinner-icon-color" />
|
|
@@ -36,7 +39,7 @@ export function SearchAiResponse(props: SearchAiResponseProps): JSX.Element {
|
|
|
36
39
|
</ResponseHeader>
|
|
37
40
|
<ResponseBody>
|
|
38
41
|
{response ? (
|
|
39
|
-
<ResponseText
|
|
42
|
+
<ResponseText children={markdownResponse} as="div" {...props} />
|
|
40
43
|
) : (
|
|
41
44
|
<ThinkingResponseText data-translation-key="search.ai.thinkingText">
|
|
42
45
|
{translate('search.ai.thinkingText', 'Thinking...')}
|
|
@@ -98,7 +101,7 @@ const ResponseBody = styled.div`
|
|
|
98
101
|
padding: var(--search-ai-response-body-padding);
|
|
99
102
|
`;
|
|
100
103
|
|
|
101
|
-
const ResponseText = styled
|
|
104
|
+
const ResponseText = styled(Markdown)`
|
|
102
105
|
color: var(--search-ai-response-text-color);
|
|
103
106
|
font-size: var(--search-ai-response-text-font-size);
|
|
104
107
|
line-height: var(--search-ai-response-text-line-height);
|
|
@@ -106,7 +109,13 @@ const ResponseText = styled.pre`
|
|
|
106
109
|
white-space: break-spaces;
|
|
107
110
|
`;
|
|
108
111
|
|
|
109
|
-
const ThinkingResponseText = styled
|
|
112
|
+
const ThinkingResponseText = styled.pre`
|
|
113
|
+
color: var(--search-ai-response-text-color);
|
|
114
|
+
font-size: var(--search-ai-response-text-font-size);
|
|
115
|
+
line-height: var(--search-ai-response-text-line-height);
|
|
116
|
+
font-family: inherit;
|
|
117
|
+
white-space: break-spaces;
|
|
118
|
+
margin: var(--md-pre-margin) 0;
|
|
110
119
|
animation: fadeIn 2s ease-in-out infinite;
|
|
111
120
|
|
|
112
121
|
@keyframes fadeIn {
|
|
@@ -315,10 +315,7 @@ const SearchDialogBody = styled.div`
|
|
|
315
315
|
display: flex;
|
|
316
316
|
flex-direction: row;
|
|
317
317
|
flex-grow: 1;
|
|
318
|
-
|
|
319
|
-
@media screen and (min-width: ${breakpoints.small}) {
|
|
320
|
-
height: var(--search-modal-min-height);
|
|
321
|
-
}
|
|
318
|
+
overflow: hidden;
|
|
322
319
|
`;
|
|
323
320
|
|
|
324
321
|
const SearchDialogBodyMainView = styled.div`
|
package/src/core/types/hooks.ts
CHANGED
|
@@ -87,6 +87,7 @@ export type ThemeHooks = {
|
|
|
87
87
|
url: string;
|
|
88
88
|
}[];
|
|
89
89
|
};
|
|
90
|
+
useMarkdownText: (text: string) => React.ReactNode;
|
|
90
91
|
useFacetQuery: (field: string) => {
|
|
91
92
|
searchFacet: SearchFacet | null;
|
|
92
93
|
setSearchFacet: React.Dispatch<React.SetStateAction<SearchFacet | null>>;
|
package/src/index.ts
CHANGED
|
@@ -140,6 +140,7 @@ export * from '@redocly/theme/components/Search/SearchFilter';
|
|
|
140
140
|
export * from '@redocly/theme/components/Search/SearchFilterField';
|
|
141
141
|
export * from '@redocly/theme/components/Search/FilterFields/SearchFilterFieldSelect';
|
|
142
142
|
export * from '@redocly/theme/components/Search/FilterFields/SearchFilterFieldTags';
|
|
143
|
+
export * from '@redocly/theme/components/Search/SearchAiResponse';
|
|
143
144
|
/* Icons */
|
|
144
145
|
export * from '@redocly/theme/icons/ArrowRightIcon/ArrowRightIcon';
|
|
145
146
|
export * from '@redocly/theme/icons/ArrowUpRightIcon/ArrowUpRightIcon';
|