@smart-cloud/ai-kit-ui 1.3.8 → 1.3.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.
- package/dist/index.cjs +6 -6
- package/dist/index.js +6 -6
- package/package.json +1 -1
- package/src/doc-search/DocSearch.tsx +71 -64
package/package.json
CHANGED
|
@@ -197,6 +197,23 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
197
197
|
return hasCategories || hasTags;
|
|
198
198
|
}, [metadataOptions]);
|
|
199
199
|
|
|
200
|
+
const subcategories = useMemo(() => {
|
|
201
|
+
if (selectedCategories.length === 0 || !metadataOptions) {
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
return selectedCategories
|
|
205
|
+
.flatMap(
|
|
206
|
+
(cat) =>
|
|
207
|
+
metadataOptions.allowedCategories[
|
|
208
|
+
cat
|
|
209
|
+
] || [],
|
|
210
|
+
)
|
|
211
|
+
.filter(
|
|
212
|
+
(subcat, index, self) =>
|
|
213
|
+
self.indexOf(subcat) === index,
|
|
214
|
+
)
|
|
215
|
+
}, [selectedCategories, metadataOptions]);
|
|
216
|
+
|
|
200
217
|
const startRecording = useCallback(async () => {
|
|
201
218
|
try {
|
|
202
219
|
// Clear query input when starting audio recording
|
|
@@ -399,7 +416,7 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
399
416
|
"Reusing cached audio (no re-upload needed within",
|
|
400
417
|
Math.round(
|
|
401
418
|
(AUDIO_CACHE_TTL - (now - audioCacheRef.current!.uploadTimestamp)) /
|
|
402
|
-
|
|
419
|
+
1000,
|
|
403
420
|
),
|
|
404
421
|
"seconds)",
|
|
405
422
|
);
|
|
@@ -421,8 +438,8 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
421
438
|
}),
|
|
422
439
|
...(enableUserFilters &&
|
|
423
440
|
selectedSubcategories.length > 0 && {
|
|
424
|
-
|
|
425
|
-
|
|
441
|
+
userSelectedSubcategories: selectedSubcategories,
|
|
442
|
+
}),
|
|
426
443
|
...(enableUserFilters &&
|
|
427
444
|
selectedTags.length > 0 && { userSelectedTags: selectedTags }),
|
|
428
445
|
},
|
|
@@ -745,9 +762,9 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
745
762
|
style={
|
|
746
763
|
recording
|
|
747
764
|
? {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
765
|
+
transform: `scale(${1 + audioLevel / 300})`,
|
|
766
|
+
transition: "transform 0.1s ease-out",
|
|
767
|
+
}
|
|
751
768
|
: undefined
|
|
752
769
|
}
|
|
753
770
|
>
|
|
@@ -813,70 +830,60 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
813
830
|
{/* Main categories as checkboxes */}
|
|
814
831
|
{Object.keys(metadataOptions.allowedCategories)
|
|
815
832
|
.length > 0 && (
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
833
|
+
<div>
|
|
834
|
+
<Text size="sm" fw={500} mb="xs">
|
|
835
|
+
{I18n.get("Categories")}
|
|
836
|
+
</Text>
|
|
837
|
+
<Group gap="md">
|
|
838
|
+
{Object.keys(
|
|
839
|
+
metadataOptions.allowedCategories,
|
|
840
|
+
).map((category) => (
|
|
841
|
+
<Checkbox
|
|
842
|
+
key={category}
|
|
843
|
+
label={I18n.get(category)}
|
|
844
|
+
checked={selectedCategories.includes(
|
|
845
|
+
category,
|
|
846
|
+
)}
|
|
847
|
+
onChange={(e) => {
|
|
848
|
+
if (e.currentTarget.checked) {
|
|
849
|
+
setSelectedCategories([
|
|
850
|
+
...selectedCategories,
|
|
851
|
+
category,
|
|
852
|
+
]);
|
|
853
|
+
} else {
|
|
854
|
+
setSelectedCategories(
|
|
855
|
+
selectedCategories.filter(
|
|
856
|
+
(c) => c !== category,
|
|
857
|
+
),
|
|
858
|
+
);
|
|
859
|
+
// Remove subcategories of unchecked category
|
|
860
|
+
const subcatsToRemove =
|
|
861
|
+
metadataOptions.allowedCategories[
|
|
845
862
|
category
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
863
|
+
] || [];
|
|
864
|
+
setSelectedSubcategories(
|
|
865
|
+
selectedSubcategories.filter(
|
|
866
|
+
(sc) =>
|
|
867
|
+
!subcatsToRemove.includes(sc),
|
|
868
|
+
),
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
}}
|
|
872
|
+
disabled={busy || loadingMetadata}
|
|
873
|
+
/>
|
|
874
|
+
))}
|
|
875
|
+
</Group>
|
|
876
|
+
</div>
|
|
877
|
+
)}
|
|
861
878
|
|
|
862
879
|
{/* Subcategories for selected categories */}
|
|
863
|
-
{
|
|
880
|
+
{subcategories.length > 0 && (
|
|
864
881
|
<div>
|
|
865
882
|
<Text size="sm" fw={500} mb="xs">
|
|
866
883
|
{I18n.get("Subcategories")}
|
|
867
884
|
</Text>
|
|
868
885
|
<Group gap="md">
|
|
869
|
-
{
|
|
870
|
-
.flatMap(
|
|
871
|
-
(cat) =>
|
|
872
|
-
metadataOptions.allowedCategories[
|
|
873
|
-
cat
|
|
874
|
-
] || [],
|
|
875
|
-
)
|
|
876
|
-
.filter(
|
|
877
|
-
(subcat, index, self) =>
|
|
878
|
-
self.indexOf(subcat) === index,
|
|
879
|
-
)
|
|
886
|
+
{subcategories
|
|
880
887
|
.map((subcat) => (
|
|
881
888
|
<Checkbox
|
|
882
889
|
key={subcat}
|
|
@@ -1019,8 +1026,8 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
1019
1026
|
) : null}
|
|
1020
1027
|
|
|
1021
1028
|
{showSources &&
|
|
1022
|
-
|
|
1023
|
-
|
|
1029
|
+
(result?.citations?.docs?.length ||
|
|
1030
|
+
result?.citations?.chunks?.length) ? (
|
|
1024
1031
|
<>
|
|
1025
1032
|
<Divider />
|
|
1026
1033
|
<Stack gap="sm" data-doc-search-sources>
|