@smart-cloud/ai-kit-ui 1.5.9 → 1.5.11
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/doc-search/DocSearch.d.ts +3 -0
- package/dist/doc-search/initialFilters.d.ts +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.js +9 -9
- package/package.json +2 -2
- package/src/doc-search/DocSearch.tsx +17 -4
- package/src/doc-search/initialFilters.ts +10 -0
- package/tests/doc-search-initial-filters.test.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart-cloud/ai-kit-ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@emotion/cache": "^11.14.0",
|
|
23
23
|
"@emotion/react": "^11.14.0",
|
|
24
24
|
"@mantine/colors-generator": "^8.3.18",
|
|
25
|
-
"@smart-cloud/ai-kit-core": "^1.5.
|
|
25
|
+
"@smart-cloud/ai-kit-core": "^1.5.6",
|
|
26
26
|
"@smart-cloud/wpsuite-core": "^2.3.2",
|
|
27
27
|
"@tabler/icons-react": "^3.46.0",
|
|
28
28
|
"chroma-js": "^3.2.0",
|
|
@@ -47,6 +47,7 @@ import { translations } from "../i18n";
|
|
|
47
47
|
import { PoweredBy } from "../poweredBy";
|
|
48
48
|
import { useAiRun } from "../useAiRun";
|
|
49
49
|
import { AiKitShellInjectedProps, withAiKitShell } from "../withAiKitShell";
|
|
50
|
+
import { normalizeInitialFilterValues } from "./initialFilters";
|
|
50
51
|
|
|
51
52
|
I18n.putVocabularies(translations);
|
|
52
53
|
|
|
@@ -198,6 +199,9 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
198
199
|
enableUserFilters = false,
|
|
199
200
|
availableCategories,
|
|
200
201
|
availableTags,
|
|
202
|
+
initialSelectedCategories,
|
|
203
|
+
initialSelectedSubcategories,
|
|
204
|
+
initialSelectedTags,
|
|
201
205
|
|
|
202
206
|
variation,
|
|
203
207
|
rootElement,
|
|
@@ -219,12 +223,21 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
219
223
|
const analyserRef = useRef<AnalyserNode | null>(null);
|
|
220
224
|
|
|
221
225
|
// User filter states
|
|
222
|
-
const [filtersOpen, setFiltersOpen] = useState(
|
|
223
|
-
|
|
226
|
+
const [filtersOpen, setFiltersOpen] = useState(
|
|
227
|
+
() =>
|
|
228
|
+
normalizeInitialFilterValues(initialSelectedCategories).length > 0 ||
|
|
229
|
+
normalizeInitialFilterValues(initialSelectedSubcategories).length > 0 ||
|
|
230
|
+
normalizeInitialFilterValues(initialSelectedTags).length > 0,
|
|
231
|
+
);
|
|
232
|
+
const [selectedCategories, setSelectedCategories] = useState<string[]>(() =>
|
|
233
|
+
normalizeInitialFilterValues(initialSelectedCategories),
|
|
234
|
+
);
|
|
224
235
|
const [selectedSubcategories, setSelectedSubcategories] = useState<string[]>(
|
|
225
|
-
|
|
236
|
+
() => normalizeInitialFilterValues(initialSelectedSubcategories),
|
|
237
|
+
);
|
|
238
|
+
const [selectedTags, setSelectedTags] = useState<string[]>(() =>
|
|
239
|
+
normalizeInitialFilterValues(initialSelectedTags),
|
|
226
240
|
);
|
|
227
|
-
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
|
228
241
|
const [tagSearchValue, setTagSearchValue] = useState<string>("");
|
|
229
242
|
const [metadataOptions, setMetadataOptions] =
|
|
230
243
|
useState<MetadataOptions | null>(null);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { normalizeInitialFilterValues } from "../src/doc-search/initialFilters.ts";
|
|
5
|
+
|
|
6
|
+
test("normalizes, deduplicates, and preserves initial DocSearch filters", () => {
|
|
7
|
+
assert.deepEqual(
|
|
8
|
+
normalizeInitialFilterValues([
|
|
9
|
+
" Solutions ",
|
|
10
|
+
"",
|
|
11
|
+
"Solution Guide",
|
|
12
|
+
"Solutions",
|
|
13
|
+
]),
|
|
14
|
+
["Solutions", "Solution Guide"],
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("uses an empty selection when initial DocSearch filters are omitted", () => {
|
|
19
|
+
assert.deepEqual(normalizeInitialFilterValues(undefined), []);
|
|
20
|
+
});
|