@redocly/theme 0.45.5 → 0.45.7

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.
@@ -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
- return (react_1.default.createElement(ResponseWrapper, { "data-component-name": "Search/AiResponse" },
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, null, response)) : (react_1.default.createElement(ThinkingResponseText, { "data-translation-key": "search.ai.thinkingText" }, translate('search.ai.thinkingText', 'Thinking...'))),
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.pre `
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 = (0, styled_components_1.default)(ResponseText) `
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 {
@@ -167,13 +167,20 @@ const SearchDialogWrapper = styled_components_1.default.div `
167
167
  box-shadow: var(--search-modal-box-shadow);
168
168
  border-radius: 0;
169
169
 
170
+ @media screen and (max-width: ${utils_1.breakpoints.small}) {
171
+ /* Ignore resize on mobile */
172
+ width: 100vw !important;
173
+ height: 100vh !important;
174
+ }
175
+
170
176
  @media screen and (min-width: ${utils_1.breakpoints.small}) {
171
177
  border-radius: var(--search-modal-border-radius);
172
178
  width: var(--search-modal-width);
173
179
  min-height: var(--search-modal-min-height);
180
+ min-width: var(--search-modal-min-width);
174
181
  max-width: 95vw;
175
182
  max-height: 95vh;
176
- height: auto;
183
+ height: var(--search-modal-min-height);
177
184
  resize: both;
178
185
  }
179
186
  `;
@@ -188,10 +195,7 @@ const SearchDialogBody = styled_components_1.default.div `
188
195
  display: flex;
189
196
  flex-direction: row;
190
197
  flex-grow: 1;
191
-
192
- @media screen and (min-width: ${utils_1.breakpoints.small}) {
193
- height: var(--search-modal-min-height);
194
- }
198
+ overflow: hidden;
195
199
  `;
196
200
  const SearchDialogBodyMainView = styled_components_1.default.div `
197
201
  flex: 2;
@@ -7,6 +7,7 @@ exports.search = (0, styled_components_1.css) `
7
7
  * @tokens Search
8
8
  */
9
9
  --search-modal-width: 1100px;
10
+ --search-modal-min-width: 460px;
10
11
  --search-modal-min-height: 705px;
11
12
  --search-modal-bg-color: var(--modal-bg-color);
12
13
  --search-modal-box-shadow: var(--modal-box-shadow);
@@ -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;
@@ -52,6 +52,9 @@ exports.useThemeHooks = jest.fn(() => ({
52
52
  setSearchFacet: jest.fn(),
53
53
  setSearchFacetQuery: jest.fn(),
54
54
  })),
55
+ useMarkdownText: jest.fn(() => {
56
+ return null;
57
+ }),
55
58
  useUserMenu: jest.fn(() => ({
56
59
  userData: {
57
60
  isAuthenticated: true,
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.45.5",
3
+ "version": "0.45.7",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -81,7 +81,7 @@
81
81
  "timeago.js": "4.0.2",
82
82
  "i18next": "22.4.15",
83
83
  "nprogress": "0.2.0",
84
- "@redocly/config": "0.16.0"
84
+ "@redocly/config": "0.17.0"
85
85
  },
86
86
  "scripts": {
87
87
  "watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
@@ -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/AiResponse">
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>{response}</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.pre`
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(ResponseText)`
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 {
@@ -292,13 +292,20 @@ const SearchDialogWrapper = styled.div`
292
292
  box-shadow: var(--search-modal-box-shadow);
293
293
  border-radius: 0;
294
294
 
295
+ @media screen and (max-width: ${breakpoints.small}) {
296
+ /* Ignore resize on mobile */
297
+ width: 100vw !important;
298
+ height: 100vh !important;
299
+ }
300
+
295
301
  @media screen and (min-width: ${breakpoints.small}) {
296
302
  border-radius: var(--search-modal-border-radius);
297
303
  width: var(--search-modal-width);
298
304
  min-height: var(--search-modal-min-height);
305
+ min-width: var(--search-modal-min-width);
299
306
  max-width: 95vw;
300
307
  max-height: 95vh;
301
- height: auto;
308
+ height: var(--search-modal-min-height);
302
309
  resize: both;
303
310
  }
304
311
  `;
@@ -315,10 +322,7 @@ const SearchDialogBody = styled.div`
315
322
  display: flex;
316
323
  flex-direction: row;
317
324
  flex-grow: 1;
318
-
319
- @media screen and (min-width: ${breakpoints.small}) {
320
- height: var(--search-modal-min-height);
321
- }
325
+ overflow: hidden;
322
326
  `;
323
327
 
324
328
  const SearchDialogBodyMainView = styled.div`
@@ -5,6 +5,7 @@ export const search = css`
5
5
  * @tokens Search
6
6
  */
7
7
  --search-modal-width: 1100px;
8
+ --search-modal-min-width: 460px;
8
9
  --search-modal-min-height: 705px;
9
10
  --search-modal-bg-color: var(--modal-bg-color);
10
11
  --search-modal-box-shadow: var(--modal-box-shadow);
@@ -51,6 +51,9 @@ export const useThemeHooks = jest.fn(() => ({
51
51
  setSearchFacet: jest.fn(),
52
52
  setSearchFacetQuery: jest.fn(),
53
53
  })),
54
+ useMarkdownText: jest.fn(() => {
55
+ return null;
56
+ }),
54
57
  useUserMenu: jest.fn(() => ({
55
58
  userData: {
56
59
  isAuthenticated: true,
@@ -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';