@redocly/theme 0.58.1 → 0.59.0-next.1
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/Accordion/Accordion.d.ts +12 -0
- package/lib/components/Accordion/Accordion.js +75 -0
- package/lib/components/Accordion/AccordionBody.d.ts +8 -0
- package/lib/components/Accordion/AccordionBody.js +63 -0
- package/lib/components/Accordion/AccordionHeader.d.ts +10 -0
- package/lib/components/Accordion/AccordionHeader.js +37 -0
- package/lib/components/Accordion/AccordionTitle.d.ts +6 -0
- package/lib/components/Accordion/AccordionTitle.js +20 -0
- package/lib/components/Accordion/variables.d.ts +1 -0
- package/lib/components/Accordion/variables.js +59 -0
- package/lib/components/Buttons/AIAssistantButton.d.ts +2 -0
- package/lib/components/Buttons/AIAssistantButton.js +125 -0
- package/lib/components/Buttons/variables.d.ts +1 -0
- package/lib/components/Buttons/variables.dark.d.ts +1 -0
- package/lib/components/Buttons/variables.dark.js +10 -0
- package/lib/components/Buttons/variables.js +51 -0
- package/lib/components/Catalog/Catalog.js +3 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +1 -1
- package/lib/components/Catalog/CatalogFilter/CatalogFilter.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilter.js +35 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.js +142 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.d.ts +13 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.js +92 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterDateRange.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterDateRange.js +111 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterSelect.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterSelect.js +116 -0
- package/lib/components/Catalog/CatalogSelector.js +0 -1
- package/lib/components/Catalog/variables.js +0 -1
- package/lib/components/Filter/FilterInput.d.ts +1 -0
- package/lib/components/Filter/FilterInput.js +2 -2
- package/lib/components/Filter/FilterOptions.js +2 -0
- package/lib/components/Filter/variables.js +7 -4
- package/lib/components/Search/SearchAiDialog.js +2 -3
- package/lib/components/Search/SearchAiResponse.js +2 -3
- package/lib/components/Search/SearchDialog.d.ts +2 -1
- package/lib/components/Search/SearchDialog.js +2 -2
- package/lib/components/Tag/Tag.d.ts +3 -2
- package/lib/components/Tag/Tag.js +21 -5
- package/lib/components/Tag/variables.dark.js +135 -0
- package/lib/components/Tag/variables.js +120 -58
- package/lib/core/hooks/use-tabs.d.ts +11 -6
- package/lib/core/hooks/use-tabs.js +117 -207
- package/lib/core/styles/dark.js +29 -26
- package/lib/core/styles/global.js +64 -59
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/core/utils/tabs.d.ts +1 -0
- package/lib/core/utils/tabs.js +8 -0
- package/lib/icons/RedoclyIcon/RedoclyIcon.d.ts +9 -0
- package/lib/icons/RedoclyIcon/RedoclyIcon.js +27 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/layouts/RootLayout.js +6 -1
- package/lib/markdoc/components/Tabs/Tab.js +1 -1
- package/lib/markdoc/components/Tabs/TabList.d.ts +2 -14
- package/lib/markdoc/components/Tabs/TabList.js +63 -16
- package/lib/markdoc/components/Tabs/Tabs.d.ts +2 -2
- package/lib/markdoc/components/Tabs/Tabs.js +11 -87
- package/lib/markdoc/tags/tabs.js +5 -0
- package/package.json +2 -2
- package/src/components/Accordion/Accordion.tsx +100 -0
- package/src/components/Accordion/AccordionBody.tsx +65 -0
- package/src/components/Accordion/AccordionHeader.tsx +68 -0
- package/src/components/Accordion/AccordionTitle.tsx +26 -0
- package/src/components/Accordion/variables.ts +56 -0
- package/src/components/Buttons/AIAssistantButton.tsx +141 -0
- package/src/components/Buttons/variables.dark.ts +7 -0
- package/src/components/Buttons/variables.ts +48 -0
- package/src/components/Catalog/Catalog.tsx +3 -2
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +1 -1
- package/src/components/Catalog/CatalogFilter/CatalogFilter.tsx +56 -0
- package/src/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.tsx +169 -0
- package/src/components/Catalog/CatalogFilter/CatalogFilterContent.tsx +121 -0
- package/src/components/Catalog/CatalogFilter/CatalogFilterDateRange.tsx +147 -0
- package/src/components/Catalog/CatalogFilter/CatalogFilterSelect.tsx +136 -0
- package/src/components/Catalog/CatalogSelector.tsx +0 -1
- package/src/components/Catalog/variables.ts +0 -1
- package/src/components/Filter/FilterInput.tsx +3 -2
- package/src/components/Filter/FilterOptions.tsx +2 -0
- package/src/components/Filter/variables.ts +7 -4
- package/src/components/Search/SearchAiDialog.tsx +2 -2
- package/src/components/Search/SearchAiResponse.tsx +2 -2
- package/src/components/Search/SearchDialog.tsx +7 -2
- package/src/components/Tag/Tag.tsx +33 -8
- package/src/components/Tag/variables.dark.ts +135 -0
- package/src/components/Tag/variables.ts +120 -58
- package/src/core/hooks/use-tabs.ts +160 -238
- package/src/core/styles/dark.ts +11 -8
- package/src/core/styles/global.ts +7 -2
- package/src/core/types/l10n.ts +1 -0
- package/src/core/utils/index.ts +1 -0
- package/src/core/utils/tabs.ts +4 -0
- package/src/icons/RedoclyIcon/RedoclyIcon.tsx +44 -0
- package/src/index.ts +2 -0
- package/src/layouts/RootLayout.tsx +6 -0
- package/src/markdoc/components/Tabs/Tab.tsx +1 -0
- package/src/markdoc/components/Tabs/TabList.tsx +84 -30
- package/src/markdoc/components/Tabs/Tabs.tsx +12 -125
- package/src/markdoc/tags/tabs.ts +5 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CatalogFilterCheckboxes = CatalogFilterCheckboxes;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const highlight_words_core_1 = require("highlight-words-core");
|
|
33
|
+
const FilterOptions_1 = require("../../../components/Filter/FilterOptions");
|
|
34
|
+
const FilterOption_1 = require("../../../components/Filter/FilterOption");
|
|
35
|
+
const FilterOptionLabel_1 = require("../../../components/Filter/FilterOptionLabel");
|
|
36
|
+
const FilterInput_1 = require("../../../components/Filter/FilterInput");
|
|
37
|
+
const hooks_1 = require("../../../core/hooks");
|
|
38
|
+
const CheckboxIcon_1 = require("../../../icons/CheckboxIcon/CheckboxIcon");
|
|
39
|
+
const CounterTag_1 = require("../../../components/Tags/CounterTag");
|
|
40
|
+
const utils_1 = require("../../../core/utils");
|
|
41
|
+
const Accordion_1 = require("../../../components/Accordion/Accordion");
|
|
42
|
+
function CatalogFilterCheckboxes({ filter, filterValuesCasing, showCounter = true, className, }) {
|
|
43
|
+
const { useTranslate, useTelemetry } = (0, hooks_1.useThemeHooks)();
|
|
44
|
+
const { translate } = useTranslate();
|
|
45
|
+
const telemetry = useTelemetry();
|
|
46
|
+
const [searchTerm, setSearchTerm] = (0, react_1.useState)('');
|
|
47
|
+
const [isExpanded, setIsExpanded] = (0, react_1.useState)(false);
|
|
48
|
+
const filteredOptions = (0, react_1.useMemo)(() => {
|
|
49
|
+
const options = filter.filteredOptions || filter.options;
|
|
50
|
+
if (!searchTerm.trim())
|
|
51
|
+
return options;
|
|
52
|
+
const lowerSearchTerm = searchTerm.toLowerCase();
|
|
53
|
+
return options.filter(({ value }) => {
|
|
54
|
+
const translatedValue = (0, utils_1.changeTextCasing)(translate(value), filterValuesCasing);
|
|
55
|
+
if (!translatedValue)
|
|
56
|
+
return false;
|
|
57
|
+
return translatedValue.toLowerCase().includes(lowerSearchTerm);
|
|
58
|
+
});
|
|
59
|
+
}, [searchTerm, filter.filteredOptions, filter.options, translate, filterValuesCasing]);
|
|
60
|
+
const selectedCount = (0, react_1.useMemo)(() => {
|
|
61
|
+
if (filter.selectedOptions instanceof Set) {
|
|
62
|
+
return filter.selectedOptions.size;
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}, [filter.selectedOptions]);
|
|
66
|
+
const highlightText = (text) => {
|
|
67
|
+
if (!searchTerm.trim()) {
|
|
68
|
+
return react_1.default.createElement(react_1.default.Fragment, null, text);
|
|
69
|
+
}
|
|
70
|
+
const chunks = (0, highlight_words_core_1.findAll)({
|
|
71
|
+
searchWords: [searchTerm],
|
|
72
|
+
textToHighlight: text,
|
|
73
|
+
});
|
|
74
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, chunks.map((chunk, idx) => {
|
|
75
|
+
const { end, highlight, start } = chunk;
|
|
76
|
+
const chunkText = text.substr(start, end - start);
|
|
77
|
+
if (highlight) {
|
|
78
|
+
return react_1.default.createElement(HighlightedText, { key: idx }, chunkText);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return react_1.default.createElement("span", { key: idx }, chunkText);
|
|
82
|
+
}
|
|
83
|
+
})));
|
|
84
|
+
};
|
|
85
|
+
const headerContent = (react_1.default.createElement(AccordionHeaderContent, null,
|
|
86
|
+
react_1.default.createElement("span", null, translate(filter.titleTranslationKey, filter.title)),
|
|
87
|
+
selectedCount > 0 && react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, selectedCount)));
|
|
88
|
+
return (react_1.default.createElement(AccordionWrapper, { className: className, "$hasSelection": selectedCount > 0 && !isExpanded, "data-component-name": "Catalog/CatalogFilterCheckboxes" },
|
|
89
|
+
react_1.default.createElement(Accordion_1.Accordion, { expanded: isExpanded, header: headerContent, onToggle: setIsExpanded },
|
|
90
|
+
react_1.default.createElement(FilterSearchWrapper, null,
|
|
91
|
+
react_1.default.createElement(FilterInput_1.FilterInput, { value: searchTerm, onChange: setSearchTerm })),
|
|
92
|
+
react_1.default.createElement(FilterOptions_1.FilterOptions, null, filteredOptions.map(({ value, count }) => {
|
|
93
|
+
const id = 'filter--' + filter.property + '--' + value;
|
|
94
|
+
return (react_1.default.createElement(FilterCheckboxOption, { key: id, role: "link", onClick: () => {
|
|
95
|
+
filter.toggleOption(value);
|
|
96
|
+
telemetry.sendFilterCheckboxToggledMessage({ id });
|
|
97
|
+
} },
|
|
98
|
+
react_1.default.createElement(CheckboxIcon_1.CheckboxIcon, { checked: filter.selectedOptions instanceof Set
|
|
99
|
+
? filter.selectedOptions.has(value) ||
|
|
100
|
+
filter.selectedOptions.has(value === null || value === void 0 ? void 0 : value.toLowerCase())
|
|
101
|
+
: false }),
|
|
102
|
+
react_1.default.createElement(FilterOptionLabel_1.FilterOptionLabel, { "data-translation-key": value }, highlightText((0, utils_1.changeTextCasing)(translate(value), filterValuesCasing) || '')),
|
|
103
|
+
showCounter && react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, count)));
|
|
104
|
+
})))));
|
|
105
|
+
}
|
|
106
|
+
const AccordionWrapper = styled_components_1.default.div `
|
|
107
|
+
position: relative;
|
|
108
|
+
border-right: 4px solid transparent;
|
|
109
|
+
|
|
110
|
+
${({ $hasSelection }) => $hasSelection &&
|
|
111
|
+
`
|
|
112
|
+
border-right-color: var(--color-blueberry-6);
|
|
113
|
+
|
|
114
|
+
&::after {
|
|
115
|
+
content: '';
|
|
116
|
+
position: absolute;
|
|
117
|
+
bottom: -1px;
|
|
118
|
+
right: -4px;
|
|
119
|
+
width: 4px;
|
|
120
|
+
height: 1px;
|
|
121
|
+
background-color: var(--color-blueberry-6);
|
|
122
|
+
z-index: 1;
|
|
123
|
+
}
|
|
124
|
+
`}
|
|
125
|
+
`;
|
|
126
|
+
const AccordionHeaderContent = styled_components_1.default.div `
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
gap: var(--spacing-xs);
|
|
130
|
+
width: 100%;
|
|
131
|
+
`;
|
|
132
|
+
const HighlightedText = styled_components_1.default.span `
|
|
133
|
+
background-color: var(--catalog-highlight-bg-color);
|
|
134
|
+
color: var(--catalog-highlight-text-color);
|
|
135
|
+
`;
|
|
136
|
+
const FilterCheckboxOption = (0, styled_components_1.default)(FilterOption_1.FilterOption) `
|
|
137
|
+
padding-left: var(--filter-option-checkbox-padding-left);
|
|
138
|
+
`;
|
|
139
|
+
const FilterSearchWrapper = styled_components_1.default.div `
|
|
140
|
+
padding: var(--filter-content-search-padding);
|
|
141
|
+
`;
|
|
142
|
+
//# sourceMappingURL=CatalogFilterCheckboxes.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { ResolvedFilter } from '../../../core/types';
|
|
3
|
+
import type { RedoclyConfig } from '../../../config';
|
|
4
|
+
export type CatalogFilterContentProps = {
|
|
5
|
+
setFilterTerm: (value: string) => void;
|
|
6
|
+
filters: ResolvedFilter[];
|
|
7
|
+
filterTerm: string;
|
|
8
|
+
filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'] | ((str: string) => string);
|
|
9
|
+
hideSearch?: boolean;
|
|
10
|
+
showCounter?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function CatalogFilterContent({ setFilterTerm, filters, filterTerm, filterValuesCasing, hideSearch, showCounter, className, }: CatalogFilterContentProps): JSX.Element | null;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CatalogFilterContent = CatalogFilterContent;
|
|
30
|
+
const react_1 = __importDefault(require("react"));
|
|
31
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
32
|
+
const FilterInput_1 = require("../../../components/Filter/FilterInput");
|
|
33
|
+
const hooks_1 = require("../../../core/hooks");
|
|
34
|
+
const Button_1 = require("../../../components/Button/Button");
|
|
35
|
+
const CatalogFilter_1 = require("../../../components/Catalog/CatalogFilter/CatalogFilter");
|
|
36
|
+
const utils_1 = require("../../../core/utils");
|
|
37
|
+
function CatalogFilterContent({ setFilterTerm, filters, filterTerm, filterValuesCasing, hideSearch, showCounter = true, className, }) {
|
|
38
|
+
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
39
|
+
const { translate } = useTranslate();
|
|
40
|
+
const hasActiveFilters = filters.some((filter) => {
|
|
41
|
+
if (filterTerm)
|
|
42
|
+
return true;
|
|
43
|
+
if (filter.selectedOptions && filter.selectedOptions instanceof Set) {
|
|
44
|
+
return filter.selectedOptions.size;
|
|
45
|
+
}
|
|
46
|
+
else if ((0, utils_1.isFromToSelectedOptions)(filter.selectedOptions) &&
|
|
47
|
+
filter.selectedOptions.from &&
|
|
48
|
+
filter.selectedOptions.to) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const handleClearAll = () => {
|
|
53
|
+
filters.forEach((filter) => filter.selectOption(''));
|
|
54
|
+
setFilterTerm('');
|
|
55
|
+
};
|
|
56
|
+
if (!filters.length) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return (react_1.default.createElement(CatalogFilterContentWrapper, { className: className, "data-component-name": "Catalog/CatalogFilterContent" },
|
|
60
|
+
react_1.default.createElement(FiltersHeader, null,
|
|
61
|
+
react_1.default.createElement(FiltersTitle, { "data-translation-key": "catalog.filters.title" }, translate('catalog.filters.title', 'Filters')),
|
|
62
|
+
hasActiveFilters ? (react_1.default.createElement(Button_1.Button, { size: "medium", tone: "danger", variant: "ghost", onClick: handleClearAll }, translate('catalog.filters.clearAll', 'Clear filters'))) : null),
|
|
63
|
+
!hideSearch && (react_1.default.createElement(FilterInput_1.FilterInput, { value: filterTerm, onChange: (updatedTerm) => setFilterTerm(updatedTerm) })),
|
|
64
|
+
react_1.default.createElement(FilterItems, { hideSearch: hideSearch }, filters.map((filter, idx) => (react_1.default.createElement(CatalogFilter_1.CatalogFilter, { filter: filter, key: filter.property + '-' + idx, filterValuesCasing: filterValuesCasing, showCounter: showCounter }))))));
|
|
65
|
+
}
|
|
66
|
+
const CatalogFilterContentWrapper = styled_components_1.default.div `
|
|
67
|
+
padding: 0 0 var(--filter-content-padding-vertical) 0;
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
`;
|
|
71
|
+
const FiltersHeader = styled_components_1.default.div `
|
|
72
|
+
display: flex;
|
|
73
|
+
padding: var(--filter-content-header-padding-vertical)
|
|
74
|
+
var(--filter-content-header-padding-horizontal);
|
|
75
|
+
`;
|
|
76
|
+
const FiltersTitle = styled_components_1.default.div `
|
|
77
|
+
margin-right: auto;
|
|
78
|
+
font-size: var(--filter-content-title-font-size);
|
|
79
|
+
font-weight: var(--filter-content-title-font-weight);
|
|
80
|
+
line-height: var(--filter-content-title-line-height);
|
|
81
|
+
`;
|
|
82
|
+
const FilterItems = styled_components_1.default.div `
|
|
83
|
+
height: 100%;
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
border-top: 1px solid var(--border-color-secondary);
|
|
87
|
+
${({ hideSearch }) => hideSearch &&
|
|
88
|
+
(0, styled_components_1.css) `
|
|
89
|
+
border-top: none;
|
|
90
|
+
`}
|
|
91
|
+
`;
|
|
92
|
+
//# sourceMappingURL=CatalogFilterContent.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { FilterProps } from '../../../core/types';
|
|
3
|
+
export type CatalogFilterDateRangeProps = FilterProps & {
|
|
4
|
+
className?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function CatalogFilterDateRange({ filter, className, }: CatalogFilterDateRangeProps): JSX.Element;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CatalogFilterDateRange = CatalogFilterDateRange;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const FilterOptions_1 = require("../../../components/Filter/FilterOptions");
|
|
33
|
+
const DatePicker_1 = require("../../../components/DatePicker/DatePicker");
|
|
34
|
+
const CounterTag_1 = require("../../../components/Tags/CounterTag");
|
|
35
|
+
const hooks_1 = require("../../../core/hooks");
|
|
36
|
+
const utils_1 = require("../../../core/utils");
|
|
37
|
+
const Accordion_1 = require("../../../components/Accordion/Accordion");
|
|
38
|
+
function CatalogFilterDateRange({ filter, className, }) {
|
|
39
|
+
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
40
|
+
const { translate } = useTranslate();
|
|
41
|
+
const from = (0, react_1.useMemo)(() => (filter.selectedOptions.from ? new Date(filter.selectedOptions.from) : undefined), [filter.selectedOptions.from]);
|
|
42
|
+
const to = (0, react_1.useMemo)(() => (filter.selectedOptions.to ? new Date(filter.selectedOptions.to) : undefined), [filter.selectedOptions.to]);
|
|
43
|
+
const selectedCount = (0, react_1.useMemo)(() => {
|
|
44
|
+
return from && to ? 1 : 0;
|
|
45
|
+
}, [from, to]);
|
|
46
|
+
const headerContent = (react_1.default.createElement(AccordionHeaderContent, null,
|
|
47
|
+
react_1.default.createElement("span", null, translate(filter.titleTranslationKey, filter.title)),
|
|
48
|
+
selectedCount > 0 && react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, selectedCount)));
|
|
49
|
+
return (react_1.default.createElement(AccordionWrapper, { className: className, "$hasSelection": selectedCount > 0, "data-component-name": "Catalog/CatalogFilterDateRange" },
|
|
50
|
+
react_1.default.createElement(Accordion_1.Accordion, { expanded: false, header: headerContent },
|
|
51
|
+
react_1.default.createElement(FilterOptions_1.FilterOptions, null,
|
|
52
|
+
react_1.default.createElement(DateRangeWrapper, null,
|
|
53
|
+
react_1.default.createElement(DateRangeRow, null,
|
|
54
|
+
react_1.default.createElement("span", null, "From:"),
|
|
55
|
+
react_1.default.createElement(DatePicker_1.DatePicker, { closeCalendar: true, format: "y-MM-dd", dayPlaceholder: "DD", monthPlaceholder: "MM", yearPlaceholder: "YYYY", value: from, maxDate: new Date(), onChange: (from) => {
|
|
56
|
+
if (Array.isArray(from))
|
|
57
|
+
return;
|
|
58
|
+
filter.selectOption(Object.assign(Object.assign({}, filter.selectedOptions), { from: (0, utils_1.formatDateWithoutTimeZone)(from), to: (0, utils_1.formatDateWithoutTimeZone)(to) }));
|
|
59
|
+
} })),
|
|
60
|
+
react_1.default.createElement(DateRangeRow, null,
|
|
61
|
+
react_1.default.createElement("span", null, "To:"),
|
|
62
|
+
react_1.default.createElement(DatePicker_1.DatePicker, { closeCalendar: true, dayPlaceholder: "DD", monthPlaceholder: "MM", yearPlaceholder: "YYYY", format: "y-MM-dd", minDate: from, value: to, onChange: (to) => {
|
|
63
|
+
if (Array.isArray(to))
|
|
64
|
+
return;
|
|
65
|
+
filter.selectOption(Object.assign(Object.assign({}, filter.selectedOptions), { from: (0, utils_1.formatDateWithoutTimeZone)(from), to: (0, utils_1.formatDateWithoutTimeZone)(to) }));
|
|
66
|
+
} })))))));
|
|
67
|
+
}
|
|
68
|
+
const AccordionWrapper = styled_components_1.default.div `
|
|
69
|
+
position: relative;
|
|
70
|
+
border-right: 4px solid transparent;
|
|
71
|
+
|
|
72
|
+
${({ $hasSelection }) => $hasSelection &&
|
|
73
|
+
`border-right-color: var(--color-blueberry-6);
|
|
74
|
+
|
|
75
|
+
&::after {
|
|
76
|
+
content: '';
|
|
77
|
+
position: absolute;
|
|
78
|
+
bottom: -1px;
|
|
79
|
+
right: -4px;
|
|
80
|
+
width: 4px;
|
|
81
|
+
height: 1px;
|
|
82
|
+
background-color: var(--color-blueberry-6);
|
|
83
|
+
z-index: 1;
|
|
84
|
+
}
|
|
85
|
+
`}
|
|
86
|
+
`;
|
|
87
|
+
const AccordionHeaderContent = styled_components_1.default.div `
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: var(--spacing-xs);
|
|
91
|
+
width: 100%;
|
|
92
|
+
`;
|
|
93
|
+
const DateRangeWrapper = styled_components_1.default.div `
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: var(--filter-options-gap);
|
|
97
|
+
`;
|
|
98
|
+
const DateRangeRow = styled_components_1.default.div `
|
|
99
|
+
color: var(--filter-date-picker-color);
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: row;
|
|
102
|
+
|
|
103
|
+
align-items: center;
|
|
104
|
+
gap: var(--filter-date-picker-gap);
|
|
105
|
+
|
|
106
|
+
> span {
|
|
107
|
+
width: var(--filter-date-picker-width);
|
|
108
|
+
color: var(--filter-option-label-color);
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
//# sourceMappingURL=CatalogFilterDateRange.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { FilterProps } from '../../../core/types';
|
|
3
|
+
export type CatalogFilterSelectProps = FilterProps & {
|
|
4
|
+
className?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function CatalogFilterSelect({ filter, filterValuesCasing, showCounter, className, }: CatalogFilterSelectProps): JSX.Element;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CatalogFilterSelect = CatalogFilterSelect;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const FilterOption_1 = require("../../../components/Filter/FilterOption");
|
|
33
|
+
const FilterOptionLabel_1 = require("../../../components/Filter/FilterOptionLabel");
|
|
34
|
+
const Select_1 = require("../../../components/Select/Select");
|
|
35
|
+
const CounterTag_1 = require("../../../components/Tags/CounterTag");
|
|
36
|
+
const utils_1 = require("../../../core/utils");
|
|
37
|
+
const hooks_1 = require("../../../core/hooks");
|
|
38
|
+
const Accordion_1 = require("../../../components/Accordion/Accordion");
|
|
39
|
+
function CatalogFilterSelect({ filter, filterValuesCasing, showCounter = true, className, }) {
|
|
40
|
+
var _a;
|
|
41
|
+
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
42
|
+
const { translate } = useTranslate();
|
|
43
|
+
const [isExpanded, setIsExpanded] = (0, react_1.useState)(false);
|
|
44
|
+
const selectedCount = (0, react_1.useMemo)(() => {
|
|
45
|
+
var _a;
|
|
46
|
+
if (filter.selectedOptions instanceof Set) {
|
|
47
|
+
const firstValue = (_a = filter.selectedOptions.values().next()) === null || _a === void 0 ? void 0 : _a.value;
|
|
48
|
+
return firstValue && firstValue !== '' ? 1 : 0;
|
|
49
|
+
}
|
|
50
|
+
return 0;
|
|
51
|
+
}, [filter.selectedOptions]);
|
|
52
|
+
let selectOptions = [];
|
|
53
|
+
const defaultOptionCount = filter.options.reduce((acc, option) => acc + option.count, 0);
|
|
54
|
+
selectOptions = [
|
|
55
|
+
{
|
|
56
|
+
value: '',
|
|
57
|
+
element: (react_1.default.createElement(FilterOption_1.FilterOption, { key: "all", onClick: () => filter.selectOption('') },
|
|
58
|
+
react_1.default.createElement(FilterOptionLabel_1.FilterOptionLabel, { "data-translation-key": "catalog.filters.select.all" }, translate('catalog.filters.select.all', 'All')),
|
|
59
|
+
react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, defaultOptionCount))),
|
|
60
|
+
},
|
|
61
|
+
...filter.options.map((option) => ({
|
|
62
|
+
value: option.value,
|
|
63
|
+
element: (react_1.default.createElement(FilterOption_1.FilterOption, { key: option.value },
|
|
64
|
+
react_1.default.createElement(FilterOptionLabel_1.FilterOptionLabel, { "data-translation-key": option.value }, (0, utils_1.changeTextCasing)(translate(option.value), filterValuesCasing)),
|
|
65
|
+
showCounter && react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, option.count))),
|
|
66
|
+
})),
|
|
67
|
+
];
|
|
68
|
+
const headerContent = (react_1.default.createElement(AccordionHeaderContent, null,
|
|
69
|
+
react_1.default.createElement("span", null, translate(filter.titleTranslationKey, filter.title)),
|
|
70
|
+
selectedCount > 0 && react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, selectedCount)));
|
|
71
|
+
return (react_1.default.createElement(AccordionWrapper, { className: className, "$hasSelection": selectedCount > 0 && !isExpanded, "data-component-name": "Catalog/CatalogFilterSelect" },
|
|
72
|
+
react_1.default.createElement(Accordion_1.Accordion, { expanded: isExpanded, header: headerContent, onToggle: setIsExpanded },
|
|
73
|
+
react_1.default.createElement(StyledSelect, { value: ((_a = (filter.selectedOptions instanceof Set ? filter.selectedOptions : new Set())
|
|
74
|
+
.values()
|
|
75
|
+
.next()) === null || _a === void 0 ? void 0 : _a.value) || '', onChange: (value) => filter.selectOption(value), options: selectOptions }))));
|
|
76
|
+
}
|
|
77
|
+
const AccordionWrapper = styled_components_1.default.div `
|
|
78
|
+
position: relative;
|
|
79
|
+
border-right: 4px solid transparent;
|
|
80
|
+
|
|
81
|
+
${({ $hasSelection }) => $hasSelection &&
|
|
82
|
+
`border-right-color: var(--color-blueberry-6);
|
|
83
|
+
|
|
84
|
+
&::after {
|
|
85
|
+
content: '';
|
|
86
|
+
position: absolute;
|
|
87
|
+
bottom: -1px;
|
|
88
|
+
right: -4px;
|
|
89
|
+
width: 4px;
|
|
90
|
+
height: 1px;
|
|
91
|
+
background-color: var(--color-blueberry-6);
|
|
92
|
+
z-index: 1;
|
|
93
|
+
}
|
|
94
|
+
`}
|
|
95
|
+
`;
|
|
96
|
+
const AccordionHeaderContent = styled_components_1.default.div `
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
gap: var(--spacing-xs);
|
|
100
|
+
width: 100%;
|
|
101
|
+
`;
|
|
102
|
+
const StyledSelect = (0, styled_components_1.default)(Select_1.Select) `
|
|
103
|
+
--select-list-max-width: var(--filter-select-max-width);
|
|
104
|
+
|
|
105
|
+
min-height: var(--filter-select-min-height);
|
|
106
|
+
--select-text-color: var(--filter-select-color);
|
|
107
|
+
border: 1px solid var(--filter-select-border-color);
|
|
108
|
+
--select-border-radius: var(--filter-select-border-radius);
|
|
109
|
+
padding: var(--filter-select-padding);
|
|
110
|
+
|
|
111
|
+
:hover {
|
|
112
|
+
border-color: var(--filter-select-border-color-hover);
|
|
113
|
+
}
|
|
114
|
+
--filter-option-margin: var(--filter-select-option-margin);
|
|
115
|
+
`;
|
|
116
|
+
//# sourceMappingURL=CatalogFilterSelect.js.map
|
|
@@ -33,7 +33,6 @@ function CatalogSelector({ catalogSwitcherItems, setSearchQuery, setSortOption,
|
|
|
33
33
|
}
|
|
34
34
|
exports.CatalogSelectWrapper = styled_components_1.default.div `
|
|
35
35
|
margin-top: var(--catalog-select-wrapper-margin-top);
|
|
36
|
-
margin-bottom: var(--catalog-select-wrapper-margin-bottom);
|
|
37
36
|
`;
|
|
38
37
|
exports.CatalogSelectLabel = styled_components_1.default.label `
|
|
39
38
|
display: block;
|
|
@@ -82,7 +82,6 @@ exports.catalog = (0, styled_components_1.css) `
|
|
|
82
82
|
* @tokens Catalog selector
|
|
83
83
|
*/
|
|
84
84
|
--catalog-select-wrapper-margin-top: var(--spacing-xxs);
|
|
85
|
-
--catalog-select-wrapper-margin-bottom: var(--spacing-base);
|
|
86
85
|
--catalog-select-label-margin-bottom: var(--spacing-xxs);
|
|
87
86
|
--catalog-select-label-font-weight: var(--filter-title-font-weight);
|
|
88
87
|
--catalog-select-label-font-size: var(--filter-title-font-size);
|
|
@@ -32,7 +32,7 @@ const styled_components_1 = __importDefault(require("styled-components"));
|
|
|
32
32
|
const hooks_1 = require("../../core/hooks");
|
|
33
33
|
const SearchIcon_1 = require("../../icons/SearchIcon/SearchIcon");
|
|
34
34
|
function FilterInput(props) {
|
|
35
|
-
const { value: initialValue, onChange } = props;
|
|
35
|
+
const { value: initialValue, onChange, dataTestId } = props;
|
|
36
36
|
const [value, setValue] = (0, react_1.useState)(initialValue);
|
|
37
37
|
(0, react_1.useEffect)(() => {
|
|
38
38
|
setValue(initialValue);
|
|
@@ -44,7 +44,7 @@ function FilterInput(props) {
|
|
|
44
44
|
};
|
|
45
45
|
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
46
46
|
const { translate } = useTranslate();
|
|
47
|
-
return (react_1.default.createElement(InputWrapper, { "data-component-name": "Filter/FilterInput" },
|
|
47
|
+
return (react_1.default.createElement(InputWrapper, { "data-component-name": "Filter/FilterInput", "data-testid": dataTestId },
|
|
48
48
|
react_1.default.createElement(InputIcon, null),
|
|
49
49
|
react_1.default.createElement(Input, { value: value, onChange: handleChange, placeholder: translate('catalog.filters.placeholder', 'Search') })));
|
|
50
50
|
}
|
|
@@ -14,5 +14,7 @@ const FilterOptionsComponent = styled_components_1.default.div `
|
|
|
14
14
|
display: flex;
|
|
15
15
|
flex-direction: column;
|
|
16
16
|
gap: var(--filter-options-gap);
|
|
17
|
+
max-height: var(--filter-options-max-height);
|
|
18
|
+
overflow-y: scroll;
|
|
17
19
|
`;
|
|
18
20
|
//# sourceMappingURL=FilterOptions.js.map
|
|
@@ -17,6 +17,7 @@ exports.filter = (0, styled_components_1.css) `
|
|
|
17
17
|
--filter-options-padding-vertical: 0;
|
|
18
18
|
--filter-options-padding-horizontal: 0;
|
|
19
19
|
--filter-options-gap: var(--spacing-sm);
|
|
20
|
+
--filter-options-max-height: 350px;
|
|
20
21
|
|
|
21
22
|
--filter-option-font-size: var(--font-size-base);
|
|
22
23
|
--filter-option-gap: var(--spacing-xs);
|
|
@@ -27,12 +28,14 @@ exports.filter = (0, styled_components_1.css) `
|
|
|
27
28
|
|
|
28
29
|
--filter-option-checkbox-padding-left: var(--spacing-xs);
|
|
29
30
|
|
|
30
|
-
--filter-content-header-padding-vertical:
|
|
31
|
-
--filter-content-header-padding-horizontal:
|
|
31
|
+
--filter-content-header-padding-vertical: var(--spacing-xs) var(--spacing-sm);
|
|
32
|
+
--filter-content-header-padding-horizontal: var(--spacing-base);
|
|
32
33
|
|
|
33
|
-
--filter-content-title-font-size: var(--font-size-
|
|
34
|
-
--filter-content-title-line-height: var(--line-height-
|
|
34
|
+
--filter-content-title-font-size: var(--font-size-lg);
|
|
35
|
+
--filter-content-title-line-height: var(--line-height-lg);
|
|
35
36
|
--filter-content-title-font-weight: var(--font-weight-semibold);
|
|
37
|
+
|
|
38
|
+
--filter-content-search-padding: 0 var(--spacing-xs) var(--spacing-sm);
|
|
36
39
|
|
|
37
40
|
--filter-content-padding-vertical: var(--spacing-sm);
|
|
38
41
|
--filter-content-padding-horizontal: var(--spacing-base);
|
|
@@ -37,12 +37,11 @@ const SearchAiMessage_1 = require("../../components/Search/SearchAiMessage");
|
|
|
37
37
|
const Admonition_1 = require("../../components/Admonition/Admonition");
|
|
38
38
|
const AiStarsIcon_1 = require("../../icons/AiStarsIcon/AiStarsIcon");
|
|
39
39
|
function SearchAiDialog({ isGeneratingResponse, response, initialMessage, error, resources, onMessageSent, className, conversation, setConversation, }) {
|
|
40
|
-
var _a;
|
|
41
40
|
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
42
|
-
const {
|
|
41
|
+
const { aiAssistant } = (0, hooks_1.useThemeConfig)();
|
|
43
42
|
const { translate } = useTranslate();
|
|
44
43
|
const conversationEndRef = react_1.default.useRef(null);
|
|
45
|
-
const suggestions =
|
|
44
|
+
const suggestions = aiAssistant === null || aiAssistant === void 0 ? void 0 : aiAssistant.suggestions;
|
|
46
45
|
const placeholder = isGeneratingResponse
|
|
47
46
|
? translate('search.ai.generatingResponse', 'Generating response...')
|
|
48
47
|
: conversation.length > 0
|
|
@@ -19,15 +19,14 @@ const ErrorFilledIcon_1 = require("../../icons/ErrorFilledIcon/ErrorFilledIcon")
|
|
|
19
19
|
const constants_1 = require("../../core/constants");
|
|
20
20
|
const ChatIcon_1 = require("../../icons/ChatIcon/ChatIcon");
|
|
21
21
|
function SearchAiResponse(props) {
|
|
22
|
-
var _a;
|
|
23
22
|
const { useMarkdownText } = (0, hooks_1.useThemeHooks)();
|
|
24
23
|
const { question, response, isGeneratingResponse, resources, error, onSuggestionClick } = props;
|
|
25
|
-
const {
|
|
24
|
+
const { aiAssistant } = (0, hooks_1.useThemeConfig)();
|
|
26
25
|
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
27
26
|
const { translate } = useTranslate();
|
|
28
27
|
const markdownResponse = useMarkdownText(response || '');
|
|
29
28
|
let responseContainer = null;
|
|
30
|
-
const suggestions =
|
|
29
|
+
const suggestions = aiAssistant === null || aiAssistant === void 0 ? void 0 : aiAssistant.suggestions;
|
|
31
30
|
const hasPendingOrReceivedResponse = response || isGeneratingResponse || error;
|
|
32
31
|
if (hasPendingOrReceivedResponse) {
|
|
33
32
|
let icon;
|
|
@@ -2,5 +2,6 @@ import type { JSX } from 'react';
|
|
|
2
2
|
export type SearchDialogProps = {
|
|
3
3
|
onClose: () => void;
|
|
4
4
|
className?: string;
|
|
5
|
+
initialMode?: 'search' | 'ai-dialog';
|
|
5
6
|
};
|
|
6
|
-
export declare function SearchDialog({ onClose, className }: SearchDialogProps): JSX.Element;
|
|
7
|
+
export declare function SearchDialog({ onClose, className, initialMode, }: SearchDialogProps): JSX.Element;
|
|
@@ -50,13 +50,13 @@ const ReturnKeyIcon_1 = require("../../icons/ReturnKeyIcon/ReturnKeyIcon");
|
|
|
50
50
|
const ChevronLeftIcon_1 = require("../../icons/ChevronLeftIcon/ChevronLeftIcon");
|
|
51
51
|
const EditIcon_1 = require("../../icons/EditIcon/EditIcon");
|
|
52
52
|
const AiStarsGradientIcon_1 = require("../../icons/AiStarsGradientIcon/AiStarsGradientIcon");
|
|
53
|
-
function SearchDialog({ onClose, className }) {
|
|
53
|
+
function SearchDialog({ onClose, className, initialMode = 'search', }) {
|
|
54
54
|
const { useTranslate, useCurrentProduct, useSearch, useProducts, useAiSearch, useTelemetry } = (0, hooks_1.useThemeHooks)();
|
|
55
55
|
const telemetry = useTelemetry();
|
|
56
56
|
const products = useProducts();
|
|
57
57
|
const currentProduct = useCurrentProduct();
|
|
58
58
|
const [product, setProduct] = (0, react_1.useState)(currentProduct);
|
|
59
|
-
const [mode, setMode] = (0, react_1.useState)(
|
|
59
|
+
const [mode, setMode] = (0, react_1.useState)(initialMode);
|
|
60
60
|
const autoSearchDisabled = mode !== 'search';
|
|
61
61
|
const { query, setQuery, filter, setFilter, items, isSearchLoading, facets, setLoadMore, advancedSearch, askAi, groupField, } = useSearch(product === null || product === void 0 ? void 0 : product.name, autoSearchDisabled);
|
|
62
62
|
const { isFilterOpen, onFilterToggle, onFilterChange, onFilterReset, onFacetReset, onQuickFilterReset, } = (0, hooks_1.useSearchFilter)(filter, setFilter);
|