@redocly/theme 0.68.0-next.7 → 0.68.0-next.9

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.
@@ -41,6 +41,7 @@ const react_1 = __importStar(require("react"));
41
41
  const styled_components_1 = __importDefault(require("styled-components"));
42
42
  const SearchInput_1 = require("../../components/Search/SearchInput");
43
43
  const SearchShortcut_1 = require("../../components/Search/SearchShortcut");
44
+ const should_show_load_more_1 = require("../../components/Search/should-show-load-more");
44
45
  const Button_1 = require("../../components/Button/Button");
45
46
  const utils_1 = require("../../core/utils");
46
47
  const Portal_1 = require("../../components/Portal/Portal");
@@ -73,7 +74,7 @@ function SearchDialog({ onClose, className, initialMode = 'search', }) {
73
74
  const [product, setProduct] = (0, react_1.useState)(currentProduct);
74
75
  const [mode, setMode] = (0, react_1.useState)(initialMode);
75
76
  const autoSearchDisabled = mode !== 'search';
76
- const { query, setQuery, filter, setFilter, items, isSearchLoading, facets, setLoadMore, advancedSearch, askAi, groupField, searchError, retrySearch, } = useSearch(product === null || product === void 0 ? void 0 : product.name, autoSearchDisabled);
77
+ const { query, setQuery, filter, setFilter, items, isSearchLoading, facets, groupCounts, setLoadMore, advancedSearch, askAi, groupField, searchError, retrySearch, } = useSearch(product === null || product === void 0 ? void 0 : product.name, autoSearchDisabled);
77
78
  const { isFilterOpen, onFilterToggle, onFilterChange, onFilterReset, onFacetReset, onQuickFilterReset, } = (0, hooks_1.useSearchFilter)(filter, setFilter);
78
79
  const { addSearchHistoryItem } = (0, hooks_1.useRecentSearches)();
79
80
  const aiSearch = useAiSearch({ filter: filter, product: product === null || product === void 0 ? void 0 : product.name });
@@ -146,21 +147,7 @@ function SearchDialog({ onClose, className, initialMode = 'search', }) {
146
147
  onClose();
147
148
  } }));
148
149
  }, [onClose, product, products, addSearchHistoryItem, query, telemetry, mode, searchSessionId]);
149
- const showLoadMore = (0, react_1.useCallback)((groupKey, currentCount = 0) => {
150
- const groupFacet = facets.find((facet) => facet.field === groupField);
151
- let needLoadMore = false;
152
- if (groupFacet) {
153
- const groupValue = groupFacet.values.find((value) => {
154
- if (typeof value === 'object') {
155
- return value.value === groupKey;
156
- }
157
- else
158
- return false;
159
- });
160
- needLoadMore = groupValue ? groupValue.count > currentCount : false;
161
- }
162
- return needLoadMore;
163
- }, [facets, groupField]);
150
+ const showLoadMore = (0, react_1.useCallback)((groupKey, currentCount = 0) => (0, should_show_load_more_1.shouldShowLoadMore)({ groupKey, currentCount, groupCounts, facets, groupField }), [groupCounts, facets, groupField]);
164
151
  const showResults = !!((filter && filter.length) || query);
165
152
  const showSearchFilterButton = advancedSearch && mode === 'search';
166
153
  const showAiSearchButton = askAi && mode === 'search';
@@ -0,0 +1,9 @@
1
+ import type { SearchFacet } from '../../core/types';
2
+ export type ShouldShowLoadMoreParams = {
3
+ groupKey: string;
4
+ currentCount: number;
5
+ groupCounts?: Record<string, number>;
6
+ facets: SearchFacet[];
7
+ groupField: string;
8
+ };
9
+ export declare function shouldShowLoadMore({ groupKey, currentCount, groupCounts, facets, groupField, }: ShouldShowLoadMoreParams): boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldShowLoadMore = shouldShowLoadMore;
4
+ function shouldShowLoadMore({ groupKey, currentCount, groupCounts, facets, groupField, }) {
5
+ if (groupCounts && groupKey in groupCounts) {
6
+ return groupCounts[groupKey] > currentCount;
7
+ }
8
+ const groupFacet = facets.find((facet) => facet.field === groupField);
9
+ if (!groupFacet) {
10
+ return false;
11
+ }
12
+ const groupValue = groupFacet.values.find((value) => typeof value === 'object' && value.value === groupKey);
13
+ return groupValue ? groupValue.count > currentCount : false;
14
+ }
15
+ //# sourceMappingURL=should-show-load-more.js.map
@@ -30,4 +30,4 @@ export declare const DEFAULT_COLOR_MODES: {
30
30
  readonly LIGHT: 'light';
31
31
  readonly DARK: 'dark';
32
32
  };
33
- export declare const DEFAULT_LINE_POSITION = "top";
33
+ export declare const DEFAULT_LINE_POSITION = "bottom";
@@ -37,5 +37,5 @@ exports.DEFAULT_COLOR_MODES = {
37
37
  LIGHT: 'light',
38
38
  DARK: 'dark',
39
39
  };
40
- exports.DEFAULT_LINE_POSITION = 'top';
40
+ exports.DEFAULT_LINE_POSITION = 'bottom';
41
41
  //# sourceMappingURL=common.js.map
@@ -69,5 +69,9 @@ exports.TOOL_CALL_DISPLAY_TEXT = {
69
69
  inProgressText: 'Discovering available tools...',
70
70
  completedText: 'Discovered available tools',
71
71
  },
72
+ [search_1.ToolCallName.ContactSupport]: {
73
+ inProgressText: 'Opening the contact support option...',
74
+ completedText: 'Offered to contact support',
75
+ },
72
76
  };
73
77
  //# sourceMappingURL=search.js.map
@@ -79,6 +79,7 @@ export type ThemeHooks = {
79
79
  isSearchLoading: boolean;
80
80
  searchError: string | null;
81
81
  facets: SearchFacet[];
82
+ groupCounts?: Record<string, number>;
82
83
  groupField: string;
83
84
  setLoadMore: React.Dispatch<React.SetStateAction<{
84
85
  groupKey: string;
@@ -112,6 +112,7 @@ export type ContentSegment = {
112
112
  export type AiSearchConversationItem = {
113
113
  role: AiSearchConversationRole;
114
114
  content: string;
115
+ sentAt?: string;
115
116
  resources?: SearchAiMessageResource[];
116
117
  messageId?: string;
117
118
  feedback?: FeedbackType;
@@ -126,5 +127,6 @@ export declare enum ToolCallName {
126
127
  GetSecuritySchemes = "get-security-schemes",
127
128
  GetFullApiDescription = "get-full-api-description",
128
129
  Execute = "execute",
129
- DescribeTools = "describe-tools"
130
+ DescribeTools = "describe-tools",
131
+ ContactSupport = "contact-support"
130
132
  }
@@ -16,5 +16,6 @@ var ToolCallName;
16
16
  ToolCallName["GetFullApiDescription"] = "get-full-api-description";
17
17
  ToolCallName["Execute"] = "execute";
18
18
  ToolCallName["DescribeTools"] = "describe-tools";
19
+ ToolCallName["ContactSupport"] = "contact-support";
19
20
  })(ToolCallName || (exports.ToolCallName = ToolCallName = {}));
20
21
  //# sourceMappingURL=search.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.68.0-next.7",
3
+ "version": "0.68.0-next.9",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -68,7 +68,7 @@
68
68
  "vitest": "4.1.10",
69
69
  "vitest-when": "0.6.2",
70
70
  "webpack": "5.105.2",
71
- "@redocly/realm-asyncapi-sdk": "0.14.0-next.3"
71
+ "@redocly/realm-asyncapi-sdk": "0.14.0-next.4"
72
72
  },
73
73
  "dependencies": {
74
74
  "@tanstack/react-query": "5.62.3",
@@ -2,10 +2,11 @@ import React, { Fragment, useRef, useState, useEffect, useCallback } from 'react
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import type { JSX, PointerEvent } from 'react';
5
- import type { SearchFacetCount, SearchItemData } from '@redocly/theme/core/types';
5
+ import type { SearchItemData } from '@redocly/theme/core/types';
6
6
 
7
7
  import { SearchInput } from '@redocly/theme/components/Search/SearchInput';
8
8
  import { SearchShortcut } from '@redocly/theme/components/Search/SearchShortcut';
9
+ import { shouldShowLoadMore } from '@redocly/theme/components/Search/should-show-load-more';
9
10
  import { Button } from '@redocly/theme/components/Button/Button';
10
11
  import { breakpoints, concatClassNames, getBaseDataAttributes } from '@redocly/theme/core/utils';
11
12
  import { Portal } from '@redocly/theme/components/Portal/Portal';
@@ -64,6 +65,7 @@ export function SearchDialog({
64
65
  items,
65
66
  isSearchLoading,
66
67
  facets,
68
+ groupCounts,
67
69
  setLoadMore,
68
70
  advancedSearch,
69
71
  askAi,
@@ -189,20 +191,9 @@ export function SearchDialog({
189
191
  );
190
192
 
191
193
  const showLoadMore = useCallback(
192
- (groupKey: string, currentCount: number = 0) => {
193
- const groupFacet = facets.find((facet) => facet.field === groupField);
194
- let needLoadMore = false;
195
- if (groupFacet) {
196
- const groupValue = groupFacet.values.find((value) => {
197
- if (typeof value === 'object') {
198
- return value.value === groupKey;
199
- } else return false;
200
- }) as SearchFacetCount;
201
- needLoadMore = groupValue ? groupValue.count > currentCount : false;
202
- }
203
- return needLoadMore;
204
- },
205
- [facets, groupField],
194
+ (groupKey: string, currentCount: number = 0) =>
195
+ shouldShowLoadMore({ groupKey, currentCount, groupCounts, facets, groupField }),
196
+ [groupCounts, facets, groupField],
206
197
  );
207
198
 
208
199
  const showResults = !!((filter && filter.length) || query);
@@ -0,0 +1,30 @@
1
+ import type { SearchFacet, SearchFacetCount } from '@redocly/theme/core/types';
2
+
3
+ export type ShouldShowLoadMoreParams = {
4
+ groupKey: string;
5
+ currentCount: number;
6
+ // Per-group result totals reported by Typesense
7
+ groupCounts?: Record<string, number>;
8
+ facets: SearchFacet[];
9
+ groupField: string;
10
+ };
11
+
12
+ export function shouldShowLoadMore({
13
+ groupKey,
14
+ currentCount,
15
+ groupCounts,
16
+ facets,
17
+ groupField,
18
+ }: ShouldShowLoadMoreParams): boolean {
19
+ if (groupCounts && groupKey in groupCounts) {
20
+ return groupCounts[groupKey] > currentCount;
21
+ }
22
+ const groupFacet = facets.find((facet) => facet.field === groupField);
23
+ if (!groupFacet) {
24
+ return false;
25
+ }
26
+ const groupValue = groupFacet.values.find(
27
+ (value): value is SearchFacetCount => typeof value === 'object' && value.value === groupKey,
28
+ );
29
+ return groupValue ? groupValue.count > currentCount : false;
30
+ }
@@ -36,4 +36,4 @@ export const DEFAULT_COLOR_MODES = {
36
36
  DARK: 'dark',
37
37
  } as const;
38
38
 
39
- export const DEFAULT_LINE_POSITION = 'top';
39
+ export const DEFAULT_LINE_POSITION = 'bottom';
@@ -79,4 +79,8 @@ export const TOOL_CALL_DISPLAY_TEXT: Partial<
79
79
  inProgressText: 'Discovering available tools...',
80
80
  completedText: 'Discovered available tools',
81
81
  },
82
+ [ToolCallName.ContactSupport]: {
83
+ inProgressText: 'Opening the contact support option...',
84
+ completedText: 'Offered to contact support',
85
+ },
82
86
  };
@@ -101,6 +101,7 @@ export type ThemeHooks = {
101
101
  isSearchLoading: boolean;
102
102
  searchError: string | null;
103
103
  facets: SearchFacet[];
104
+ groupCounts?: Record<string, number>;
104
105
  groupField: string;
105
106
  setLoadMore: React.Dispatch<
106
107
  React.SetStateAction<
@@ -118,6 +118,7 @@ export type ContentSegment = { type: 'text'; text: string } | { type: 'tool'; to
118
118
  export type AiSearchConversationItem = {
119
119
  role: AiSearchConversationRole;
120
120
  content: string;
121
+ sentAt?: string;
121
122
  resources?: SearchAiMessageResource[];
122
123
  messageId?: string;
123
124
  feedback?: FeedbackType;
@@ -134,4 +135,5 @@ export enum ToolCallName {
134
135
  GetFullApiDescription = 'get-full-api-description',
135
136
  Execute = 'execute',
136
137
  DescribeTools = 'describe-tools',
138
+ ContactSupport = 'contact-support',
137
139
  }