@gooddata/sdk-ui-semantic-search 10.7.0-alpha.28

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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2020-2022 GoodData Corporation
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # GoodData.UI SDK - Semantic Search
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@gooddata/sdk-ui-charts)](https://www.npmjs.com/@gooddata/sdk-ui-charts) 
4
+ [![npm monthly downloads](https://img.shields.io/npm/dm/@gooddata/sdk-ui-charts)](https://npmcharts.com/compare/@gooddata/sdk-ui-charts?minimal=true) 
5
+ ![typescript](https://img.shields.io/badge/typescript-first-blue?logo=typescript)
6
+
7
+ This package is a part of the [GoodData.UI SDK](https://sdk.gooddata.com/gooddata-ui/docs/about_gooddataui.html).
8
+ To learn more, check [the source monorepo](https://github.com/gooddata/gooddata-ui-sdk).
9
+
10
+ This package provides a set of React-based UI components and hooks for semantic search within your metadata.
11
+
12
+ Example usage:
13
+
14
+ ```tsx
15
+ import { SemanticSearch } from "@gooddata/sdk-ui-semantic-search";
16
+
17
+ const App = () => {
18
+ return (
19
+ <SemanticSearch
20
+ workspaceId="your-workspace-id"
21
+ backend={tigerBackend}
22
+ onSelect={handleSearchItemSelection}
23
+ onError={handleError}
24
+ />
25
+ );
26
+ };
27
+ ```
28
+
29
+ You can also use providers for backend and workspace.
30
+
31
+ ## License
32
+
33
+ (C) 2017-2022 GoodData Corporation
34
+
35
+ This project is under commercial license. See [LICENSE](https://github.com/gooddata/gooddata-ui-sdk/blob/master/libs/sdk-ui-charts/LICENSE).
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+ import { ISemanticSearchResultItem } from "@gooddata/sdk-model";
3
+ /**
4
+ * Props for the ResultsItem component.
5
+ * @internal
6
+ */
7
+ export type ResultsItemProps = {
8
+ /**
9
+ * The item to render.
10
+ */
11
+ item: ISemanticSearchResultItem;
12
+ /**
13
+ * The height of the item.
14
+ */
15
+ height: number;
16
+ /**
17
+ * The width of the item.
18
+ */
19
+ width: number;
20
+ /**
21
+ * Whether the item is selected.
22
+ */
23
+ selected: boolean;
24
+ /**
25
+ * Callback to trigger when the item is hovered.
26
+ */
27
+ onHover: () => void;
28
+ /**
29
+ * Callback to trigger when the item is clicked.
30
+ */
31
+ onClick: () => void;
32
+ };
33
+ /**
34
+ * A single result item in the search results.
35
+ * @internal
36
+ */
37
+ export declare const ResultsItem: React.FC<ResultsItemProps>;
38
+ //# sourceMappingURL=ResultsItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultsItem.d.ts","sourceRoot":"","sources":["../src/ResultsItem.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGhE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B;;OAEG;IACH,IAAI,EAAE,yBAAyB,CAAC;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAyBlD,CAAC"}
@@ -0,0 +1,53 @@
1
+ // (C) 2024 GoodData Corporation
2
+ import * as React from "react";
3
+ import classnames from "classnames";
4
+ import { Icon, Typography } from "@gooddata/sdk-ui-kit";
5
+ /**
6
+ * A single result item in the search results.
7
+ * @internal
8
+ */
9
+ export const ResultsItem = ({ item, onHover, onClick, selected }) => {
10
+ const onMouseEnter = (e) => {
11
+ // Prevent multiple triggers
12
+ if (e.target !== e.currentTarget) {
13
+ return;
14
+ }
15
+ onHover();
16
+ };
17
+ const className = classnames({
18
+ "gd-semantic-search__results-item": true,
19
+ "gd-semantic-search__results-item--selected": selected,
20
+ });
21
+ // Use mouse enter with the target check instead of hover to prevent multiple triggers
22
+ // Use mouse down instead of click to prevent the the dialog from disappearing before the click event is caught
23
+ return (React.createElement("div", { className: className, onMouseEnter: onMouseEnter, onMouseDown: onClick },
24
+ React.createElement("div", { className: "gd-semantic-search__results-item__icon" }, renderItemIcon(item)),
25
+ React.createElement("div", { className: "gd-semantic-search__results-item__text" },
26
+ React.createElement(Typography, { tagName: "p" }, item.title))));
27
+ };
28
+ /**
29
+ * Pick an icon according to the item type.
30
+ */
31
+ const renderItemIcon = (item) => {
32
+ switch (item.type) {
33
+ case "dashboard":
34
+ return React.createElement(Icon.Dashboard, null);
35
+ case "visualization":
36
+ return React.createElement(Icon.Insight, null);
37
+ case "dataset":
38
+ return React.createElement(Icon.Dataset, null);
39
+ case "attribute":
40
+ return React.createElement(Icon.Attribute, null);
41
+ case "label":
42
+ return React.createElement(Icon.Label, null);
43
+ case "fact":
44
+ return React.createElement(Icon.Fact, null);
45
+ case "metric":
46
+ return React.createElement(Icon.Metric, null);
47
+ case "date":
48
+ return React.createElement(Icon.Date, null);
49
+ default:
50
+ return null;
51
+ }
52
+ };
53
+ //# sourceMappingURL=ResultsItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultsItem.js","sourceRoot":"","sources":["../src/ResultsItem.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAiCxD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAA+B,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC5F,MAAM,YAAY,GAAG,CAAC,CAAmC,EAAE,EAAE;QACzD,4BAA4B;QAC5B,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;YAC/B,OAAO;QACX,CAAC;QAED,OAAO,EAAE,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,UAAU,CAAC;QACzB,kCAAkC,EAAE,IAAI;QACxC,4CAA4C,EAAE,QAAQ;KACzD,CAAC,CAAC;IAEH,sFAAsF;IACtF,+GAA+G;IAC/G,OAAO,CACH,6BAAK,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO;QACvE,6BAAK,SAAS,EAAC,wCAAwC,IAAE,cAAc,CAAC,IAAI,CAAC,CAAO;QACpF,6BAAK,SAAS,EAAC,wCAAwC;YACnD,oBAAC,UAAU,IAAC,OAAO,EAAC,GAAG,IAAE,IAAI,CAAC,KAAK,CAAc,CAC/C,CACJ,CACT,CAAC;AACN,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,IAA+B,EAAE,EAAE;IACvD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,WAAW;YACZ,OAAO,oBAAC,IAAI,CAAC,SAAS,OAAG,CAAC;QAC9B,KAAK,eAAe;YAChB,OAAO,oBAAC,IAAI,CAAC,OAAO,OAAG,CAAC;QAC5B,KAAK,SAAS;YACV,OAAO,oBAAC,IAAI,CAAC,OAAO,OAAG,CAAC;QAC5B,KAAK,WAAW;YACZ,OAAO,oBAAC,IAAI,CAAC,SAAS,OAAG,CAAC;QAC9B,KAAK,OAAO;YACR,OAAO,oBAAC,IAAI,CAAC,KAAK,OAAG,CAAC;QAC1B,KAAK,MAAM;YACP,OAAO,oBAAC,IAAI,CAAC,IAAI,OAAG,CAAC;QACzB,KAAK,QAAQ;YACT,OAAO,oBAAC,IAAI,CAAC,MAAM,OAAG,CAAC;QAC3B,KAAK,MAAM;YACP,OAAO,oBAAC,IAAI,CAAC,IAAI,OAAG,CAAC;QACzB;YACI,OAAO,IAAI,CAAC;IACpB,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import * as React from "react";
2
+ import { ISemanticSearchResultItem } from "@gooddata/sdk-model";
3
+ /**
4
+ * Search results props.
5
+ * @internal
6
+ */
7
+ type SearchResultsProps = {
8
+ /**
9
+ * Search result items.
10
+ */
11
+ searchResults: ISemanticSearchResultItem[];
12
+ /**
13
+ * Loading flag.
14
+ */
15
+ searchLoading: boolean;
16
+ /**
17
+ * Mobile flag.
18
+ */
19
+ isMobile: boolean;
20
+ /**
21
+ * Width of the dropdown.
22
+ */
23
+ width: number;
24
+ /**
25
+ * Callback for item selection.
26
+ */
27
+ onSelect: (item: ISemanticSearchResultItem) => void;
28
+ };
29
+ /**
30
+ * A dropdown list with the search results.
31
+ * @internal
32
+ */
33
+ export declare const SearchResults: React.FC<SearchResultsProps>;
34
+ export {};
35
+ //# sourceMappingURL=SearchResults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchResults.d.ts","sourceRoot":"","sources":["../src/SearchResults.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAIhE;;;GAGG;AACH,KAAK,kBAAkB,GAAG;IACtB;;OAEG;IACH,aAAa,EAAE,yBAAyB,EAAE,CAAC;IAC3C;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,IAAI,CAAC;CACvD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA6DtD,CAAC"}
@@ -0,0 +1,43 @@
1
+ // (C) 2024 GoodData Corporation
2
+ import * as React from "react";
3
+ import { DropdownList } from "@gooddata/sdk-ui-kit";
4
+ import { ResultsItem } from "./ResultsItem.js";
5
+ /**
6
+ * A dropdown list with the search results.
7
+ * @internal
8
+ */
9
+ export const SearchResults = ({ searchResults, searchLoading, isMobile, width, onSelect, }) => {
10
+ const [selected, setSelected] = React.useState(0);
11
+ React.useEffect(() => {
12
+ setSelected(0);
13
+ }, [searchResults]);
14
+ React.useEffect(() => {
15
+ const listener = (event) => {
16
+ if (["ArrowDown", "ArrowUp", "Enter"].indexOf(event.key) === -1)
17
+ return;
18
+ event.preventDefault();
19
+ event.stopImmediatePropagation();
20
+ switch (event.key) {
21
+ case "ArrowDown":
22
+ setSelected(Math.min(selected + 1, searchResults.length - 1));
23
+ break;
24
+ case "ArrowUp":
25
+ setSelected(Math.max(selected - 1, 0));
26
+ break;
27
+ case "Enter":
28
+ onSelect(searchResults[selected]);
29
+ }
30
+ };
31
+ // Listen to keyboard events while the component is mounted
32
+ document.addEventListener("keydown", listener);
33
+ return () => {
34
+ document.removeEventListener("keydown", listener);
35
+ };
36
+ }, [searchResults, onSelect, selected]);
37
+ return (React.createElement(DropdownList, { width: width, isMobile: isMobile, isLoading: searchLoading, itemHeight: 45, renderItem: ({ rowIndex, item, ...props }) => {
38
+ return (React.createElement(ResultsItem, { onHover: () => setSelected(rowIndex), onClick: () => {
39
+ onSelect(item);
40
+ }, selected: rowIndex === selected, item: item, ...props }));
41
+ }, items: searchResults }));
42
+ };
43
+ //# sourceMappingURL=SearchResults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchResults.js","sourceRoot":"","sources":["../src/SearchResults.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA6B/C;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EACxD,aAAa,EACb,aAAa,EACb,QAAQ,EACR,KAAK,EACL,QAAQ,GACX,EAAE,EAAE;IACD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,WAAW,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAE,EAAE;YACtC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAAE,OAAO;YAExE,KAAK,CAAC,cAAc,EAAE,CAAC;Y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,CACL,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import * as React from "react";
2
+ import { GenAISemanticSearchType, ISemanticSearchResultItem } from "@gooddata/sdk-model";
3
+ import { IAnalyticalBackend } from "@gooddata/sdk-backend-spi";
4
+ /**
5
+ * Core semantic search component props.
6
+ * @alpha
7
+ */
8
+ export type SemanticSearchCoreProps = {
9
+ backend?: IAnalyticalBackend;
10
+ workspace?: string;
11
+ onSelect: (item: ISemanticSearchResultItem) => void;
12
+ onError?: (errorMessage: string) => void;
13
+ className?: string;
14
+ objectTypes?: GenAISemanticSearchType[];
15
+ deepSearch?: boolean;
16
+ limit?: number;
17
+ };
18
+ /**
19
+ * Semantic search component props.
20
+ * @alpha
21
+ */
22
+ export type SemanticSearchProps = SemanticSearchCoreProps & {
23
+ locale?: string;
24
+ };
25
+ /**
26
+ * Semantic search filed with dropdown for selecting items.
27
+ * @alpha
28
+ */
29
+ export declare const SemanticSearch: React.FC<SemanticSearchProps>;
30
+ //# sourceMappingURL=SemanticSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SemanticSearch.d.ts","sourceRoot":"","sources":["../src/SemanticSearch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAIzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAClC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACpD,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAiGF;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAMxD,CAAC"}
@@ -0,0 +1,65 @@
1
+ // (C) 2024 GoodData Corporation
2
+ import * as React from "react";
3
+ import { useDebouncedState, Input, Dropdown } from "@gooddata/sdk-ui-kit";
4
+ import { IntlWrapper } from "@gooddata/sdk-ui";
5
+ import { SearchResults } from "./SearchResults.js";
6
+ import { useSemanticSearch } from "./hooks/index.js";
7
+ import classnames from "classnames";
8
+ /**
9
+ * Search input debounce time.
10
+ * I.e. how long to wait after the user stops typing before sending the search request.
11
+ */
12
+ const DEBOUNCE = 300;
13
+ /**
14
+ * Semantic search component core.
15
+ * @alpha
16
+ */
17
+ const SemanticSearchCore = ({ backend, workspace, onSelect, onError, objectTypes, deepSearch = false, limit = 10, className, }) => {
18
+ // Input value handling
19
+ const [value, setValue, searchTerm] = useDebouncedState("", DEBOUNCE);
20
+ // Search results
21
+ const { searchLoading, searchResults, searchError } = useSemanticSearch({
22
+ backend,
23
+ workspace,
24
+ searchTerm,
25
+ objectTypes,
26
+ deepSearch,
27
+ limit,
28
+ });
29
+ // Match the width of the drop-down to the input field
30
+ const [width, setWidth] = React.useState(0);
31
+ const inputRef = React.useRef(null);
32
+ React.useLayoutEffect(() => {
33
+ const input = inputRef.current?.inputNodeRef?.inputNodeRef;
34
+ if (input) {
35
+ setWidth(input.offsetWidth);
36
+ }
37
+ }, []);
38
+ const onItemSelect = React.useCallback((item) => {
39
+ onSelect(item);
40
+ inputRef.current?.inputNodeRef?.inputNodeRef?.blur();
41
+ }, [onSelect]);
42
+ // Report errors
43
+ React.useEffect(() => {
44
+ if (onError && searchError) {
45
+ onError(searchError);
46
+ }
47
+ }, [onError, searchError]);
48
+ return (React.createElement(Dropdown, { className: classnames("gd-semantic-search", className), closeOnMouseDrag: false, closeOnOutsideClick: false, closeOnParentScroll: false, renderBody: ({ isMobile }) => {
49
+ if (!searchResults.length && !searchLoading) {
50
+ return null;
51
+ }
52
+ return (React.createElement(SearchResults, { width: width, isMobile: isMobile, searchResults: searchResults, searchLoading: searchLoading, onSelect: onItemSelect }));
53
+ }, renderButton: ({ openDropdown, closeDropdown }) => {
54
+ return (React.createElement(Input, { ref: inputRef, isSearch: true, clearOnEsc: true, value: value, onChange: (e) => setValue(String(e)), onFocus: openDropdown, onBlur: closeDropdown }));
55
+ } }));
56
+ };
57
+ /**
58
+ * Semantic search filed with dropdown for selecting items.
59
+ * @alpha
60
+ */
61
+ export const SemanticSearch = ({ locale, ...coreProps }) => {
62
+ return (React.createElement(IntlWrapper, { locale: locale },
63
+ React.createElement(SemanticSearchCore, { ...coreProps })));
64
+ };
65
+ //# sourceMappingURL=SemanticSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SemanticSearch.js","sourceRoot":"","sources":["../src/SemanticSearch.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,UAAU,MAAM,YAAY,CAAC;AAiBpC;;;GAGG;AACH,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;;GAGG;AACH,MAAM,kBAAkB,GAAsC,CAAC,EAC3D,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO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","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAEA,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,3 @@
1
+ // (C) 2024 GoodData Corporation
2
+ export * from "./useSemanticSearch.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { ISemanticSearchResultItem, GenAISemanticSearchType } from "@gooddata/sdk-model";
2
+ import { IAnalyticalBackend } from "@gooddata/sdk-backend-spi";
3
+ /**
4
+ * The result of the semantic search hook.
5
+ * @alpha
6
+ */
7
+ export type SemanticSearchInputResult = {
8
+ /**
9
+ * Flag indicating whether the search is in progress.
10
+ */
11
+ searchLoading: boolean;
12
+ /**
13
+ * Error message if the search failed.
14
+ */
15
+ searchError: string;
16
+ /**
17
+ * The search results.
18
+ */
19
+ searchResults: ISemanticSearchResultItem[];
20
+ };
21
+ /**
22
+ * Input parameters for the semantic search hook.
23
+ * @alpha
24
+ */
25
+ export type SemanticSearchHookInput = {
26
+ /**
27
+ * The search term.
28
+ */
29
+ searchTerm: string;
30
+ /**
31
+ * The object types to search for.
32
+ */
33
+ objectTypes?: GenAISemanticSearchType[];
34
+ /**
35
+ * Whether to perform deep search.
36
+ * E.g. find dashboard if it contains matching insight.
37
+ */
38
+ deepSearch?: boolean;
39
+ /**
40
+ * The number of results to return.
41
+ */
42
+ limit?: number;
43
+ /**
44
+ * The backend to use for the search.
45
+ * If omitted, will be retrieved from the context.
46
+ */
47
+ backend?: IAnalyticalBackend;
48
+ /**
49
+ * The workspace to use for the search.
50
+ * If omitted, will be retrieved from the context.
51
+ */
52
+ workspace?: string;
53
+ };
54
+ /**
55
+ * Hook to perform semantic search.
56
+ * Makes the request to server and returns the search results.
57
+ * The request is cancellable and auto-updates when the search term changes.
58
+ * @alpha
59
+ */
60
+ export declare const useSemanticSearch: ({ searchTerm, objectTypes, deepSearch, limit, backend, workspace, }: SemanticSearchHookInput) => SemanticSearchInputResult;
61
+ //# sourceMappingURL=useSemanticSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSemanticSearch.d.ts","sourceRoot":"","sources":["../../src/hooks/useSemanticSearch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACpC;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,EAAE,yBAAyB,EAAE,CAAC;CAC9C,CAAC;AAWF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAClC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACxC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,wEAO3B,uBAAuB,KAAG,yBA+D5B,CAAC"}
@@ -0,0 +1,85 @@
1
+ // (C) 2024 GoodData Corporation
2
+ import { useState, useEffect } from "react";
3
+ import { useBackendStrict, useWorkspaceStrict } from "@gooddata/sdk-ui";
4
+ /**
5
+ * Default state of the semantic search hook.
6
+ */
7
+ const DEFAULT_STATE = {
8
+ searchLoading: false,
9
+ searchError: "",
10
+ searchResults: [],
11
+ };
12
+ const DEFAULT_OBJECT_TYPES = [];
13
+ /**
14
+ * Hook to perform semantic search.
15
+ * Makes the request to server and returns the search results.
16
+ * The request is cancellable and auto-updates when the search term changes.
17
+ * @alpha
18
+ */
19
+ export const useSemanticSearch = ({ searchTerm, objectTypes = DEFAULT_OBJECT_TYPES, deepSearch, limit, backend, workspace, }) => {
20
+ const [state, setState] = useState(DEFAULT_STATE);
21
+ const effectiveBackend = useBackendStrict(backend);
22
+ const effectiveWorkspace = useWorkspaceStrict(workspace);
23
+ useEffect(() => {
24
+ if (searchTerm === "") {
25
+ setState(DEFAULT_STATE);
26
+ return;
27
+ }
28
+ setState((oldState) => ({
29
+ // Keep the previous state of results/error, only update the loading flag
30
+ ...oldState,
31
+ searchLoading: true,
32
+ }));
33
+ // Construct the query
34
+ let qb = effectiveBackend
35
+ .workspace(effectiveWorkspace)
36
+ .genAI()
37
+ .getSemanticSearchQuery()
38
+ .withQuestion(searchTerm);
39
+ if (objectTypes.length) {
40
+ qb = qb.withObjectTypes(objectTypes);
41
+ }
42
+ if (deepSearch) {
43
+ qb = qb.withDeepSearch(deepSearch);
44
+ }
45
+ if (limit) {
46
+ qb = qb.withLimit(limit);
47
+ }
48
+ // Execute the query
49
+ const searchController = new AbortController();
50
+ qb.query({
51
+ signal: searchController.signal,
52
+ })
53
+ .then((res) => {
54
+ setState({
55
+ searchLoading: false,
56
+ searchError: "",
57
+ searchResults: res.results,
58
+ });
59
+ })
60
+ .catch((e) => {
61
+ if (searchController.signal.aborted)
62
+ // Ignore Aborted error
63
+ return;
64
+ setState({
65
+ searchLoading: false,
66
+ searchError: errorMessage(e),
67
+ searchResults: [],
68
+ });
69
+ });
70
+ return () => {
71
+ searchController.abort();
72
+ };
73
+ }, [effectiveBackend, effectiveWorkspace, searchTerm, objectTypes, deepSearch, limit]);
74
+ return state;
75
+ };
76
+ /**
77
+ * Retrieve error message from the error object.
78
+ */
79
+ const errorMessage = (e) => {
80
+ if (e instanceof Error) {
81
+ return e.message;
82
+ }
83
+ return String(e);
84
+ };
85
+ //# sourceMappingURL=useSemanticSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSemanticSearch.js","sourceRoot":"","sources":["../../src/hooks/useSemanticSearch.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAsBxE;;GAEG;AACH,MAAM,aAAa,GAA8B;IAC7C,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,EAAE;IACf,aAAa,EAAE,EAAE;CACpB,CAAC;AAoCF,MAAM,oBAAoB,GAA8B,EAAE,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAC9B,UAAU,EACV,WAAW,GAAG,oBAAoB,EAClC,UAAU,EACV,KAAK,EACL,OAAO,EACP,SAAS,GACa,EAA6B,EAAE;IACrD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA4B,aAAa,CAAC,CAAC;IAC7E,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAEzD,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,UAAU,KAAK,EAAE,EAAE,CAAC;YACpB,QAAQ,CAAC,aAAa,CAAC,CAAC;YACxB,OAAO;QACX,CAAC;QAED,QAAQ,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACpB,yEAAyE;YACzE,GAAG,QAAQ;YACX,aAAa,EAAE,IAAI;SACtB,CAAC,CAAC,CAAC;QAEJ,sBAAsB;QACtB,IAAI,EAAE,GAAG,gBAAgB;aACpB,SAAS,CAAC,kBAAkB,CAAC;aAC7B,KAAK,EAAE;aACP,sBAAsB,EAAE;aACxB,YAAY,CAAC,UAAU,C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C,YAAY,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC,OAAO,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC"}
package/esm/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This package provides React hooks and components for semantic search.
3
+ * @packageDocumentation
4
+ * @alpha
5
+ */
6
+ export * from "./hooks/index.js";
7
+ export * from "./SemanticSearch.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
package/esm/index.js ADDED
@@ -0,0 +1,9 @@
1
+ // (C) 2024 GoodData Corporation
2
+ /**
3
+ * This package provides React hooks and components for semantic search.
4
+ * @packageDocumentation
5
+ * @alpha
6
+ */
7
+ export * from "./hooks/index.js";
8
+ export * from "./SemanticSearch.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * This package provides React hooks and components for semantic search.
3
+ * @packageDocumentation
4
+ * @alpha
5
+ */
6
+
7
+ import { GenAISemanticSearchType } from '@gooddata/sdk-model';
8
+ import { IAnalyticalBackend } from '@gooddata/sdk-backend-spi';
9
+ import { ISemanticSearchResultItem } from '@gooddata/sdk-model';
10
+ import * as React_2 from 'react';
11
+
12
+ /**
13
+ * Semantic search filed with dropdown for selecting items.
14
+ * @alpha
15
+ */
16
+ export declare const SemanticSearch: React_2.FC<SemanticSearchProps>;
17
+
18
+ /**
19
+ * Core semantic search component props.
20
+ * @alpha
21
+ */
22
+ export declare type SemanticSearchCoreProps = {
23
+ backend?: IAnalyticalBackend;
24
+ workspace?: string;
25
+ onSelect: (item: ISemanticSearchResultItem) => void;
26
+ onError?: (errorMessage: string) => void;
27
+ className?: string;
28
+ objectTypes?: GenAISemanticSearchType[];
29
+ deepSearch?: boolean;
30
+ limit?: number;
31
+ };
32
+
33
+ /**
34
+ * Input parameters for the semantic search hook.
35
+ * @alpha
36
+ */
37
+ export declare type SemanticSearchHookInput = {
38
+ /**
39
+ * The search term.
40
+ */
41
+ searchTerm: string;
42
+ /**
43
+ * The object types to search for.
44
+ */
45
+ objectTypes?: GenAISemanticSearchType[];
46
+ /**
47
+ * Whether to perform deep search.
48
+ * E.g. find dashboard if it contains matching insight.
49
+ */
50
+ deepSearch?: boolean;
51
+ /**
52
+ * The number of results to return.
53
+ */
54
+ limit?: number;
55
+ /**
56
+ * The backend to use for the search.
57
+ * If omitted, will be retrieved from the context.
58
+ */
59
+ backend?: IAnalyticalBackend;
60
+ /**
61
+ * The workspace to use for the search.
62
+ * If omitted, will be retrieved from the context.
63
+ */
64
+ workspace?: string;
65
+ };
66
+
67
+ /**
68
+ * The result of the semantic search hook.
69
+ * @alpha
70
+ */
71
+ export declare type SemanticSearchInputResult = {
72
+ /**
73
+ * Flag indicating whether the search is in progress.
74
+ */
75
+ searchLoading: boolean;
76
+ /**
77
+ * Error message if the search failed.
78
+ */
79
+ searchError: string;
80
+ /**
81
+ * The search results.
82
+ */
83
+ searchResults: ISemanticSearchResultItem[];
84
+ };
85
+
86
+ /**
87
+ * Semantic search component props.
88
+ * @alpha
89
+ */
90
+ export declare type SemanticSearchProps = SemanticSearchCoreProps & {
91
+ locale?: string;
92
+ };
93
+
94
+ /**
95
+ * Hook to perform semantic search.
96
+ * Makes the request to server and returns the search results.
97
+ * The request is cancellable and auto-updates when the search term changes.
98
+ * @alpha
99
+ */
100
+ export declare const useSemanticSearch: ({ searchTerm, objectTypes, deepSearch, limit, backend, workspace, }: SemanticSearchHookInput) => SemanticSearchInputResult;
101
+
102
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.38.5"
9
+ }
10
+ ]
11
+ }
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "@gooddata/sdk-ui-semantic-search",
3
+ "version": "10.7.0-alpha.28",
4
+ "description": "GoodData SDK TypeScript & React skeleton",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/gooddata/gooddata-ui-sdk.git",
8
+ "directory": "libs/sdk-ui-semantic-search"
9
+ },
10
+ "author": "GoodData Corporation",
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "browser": "./esm/index.js",
14
+ "exports": {
15
+ ".": "./esm/index.js",
16
+ "./styles/css/*": "./styles/css/*"
17
+ },
18
+ "types": "./esm/index.d.ts",
19
+ "sideEffects": [
20
+ "*.css",
21
+ "*.svg"
22
+ ],
23
+ "files": [
24
+ "esm/**/*.js",
25
+ "esm/**/*.json",
26
+ "esm/**/*.d.ts",
27
+ "esm/**/*.map",
28
+ "esm/**/*.svg",
29
+ "styles"
30
+ ],
31
+ "config": {
32
+ "eslint": "-c .eslintrc.cjs --ext ts,tsx src/"
33
+ },
34
+ "dependencies": {
35
+ "lodash": "^4.17.21",
36
+ "react-intl": "^6.4.1",
37
+ "tslib": "^2.5.0",
38
+ "classnames": "^2.3.1",
39
+ "@gooddata/sdk-model": "10.7.0-alpha.28",
40
+ "@gooddata/sdk-ui-kit": "10.7.0-alpha.28",
41
+ "@gooddata/sdk-ui": "10.7.0-alpha.28",
42
+ "@gooddata/sdk-backend-spi": "10.7.0-alpha.28"
43
+ },
44
+ "peerDependencies": {
45
+ "react": "^16.10.0 || ^17.0.0 || ^18.0.0",
46
+ "react-dom": "^16.10.0 || ^17.0.0 || ^18.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "@gooddata/eslint-config": "^4.1.0",
50
+ "@microsoft/api-documenter": "^7.17.0",
51
+ "@microsoft/api-extractor": "^7.36.0",
52
+ "@testing-library/react": "^14.0.0",
53
+ "@types/lodash": "^4.14.202",
54
+ "@types/raf": "^3.4.0",
55
+ "@types/react-dom": "^18.2.1",
56
+ "@types/react": "^18.2.0",
57
+ "@typescript-eslint/eslint-plugin": "^5.57.1",
58
+ "@typescript-eslint/parser": "^5.57.1",
59
+ "concurrently": "^6.0.2",
60
+ "dependency-cruiser": "^13.0.3",
61
+ "eslint": "^8.25.0",
62
+ "eslint-plugin-header": "^3.0.0",
63
+ "eslint-plugin-import": "^2.22.0",
64
+ "eslint-plugin-import-esm": "^1.2.1",
65
+ "eslint-plugin-jest": "^27.1.1",
66
+ "eslint-plugin-no-only-tests": "^2.4.0",
67
+ "eslint-plugin-prettier": "^4.0.0",
68
+ "eslint-plugin-react-hooks": "^4.5.0",
69
+ "eslint-plugin-react": "^7.31.10",
70
+ "eslint-plugin-regexp": "^1.9.0",
71
+ "eslint-plugin-sonarjs": "^0.16.0",
72
+ "eslint-plugin-tsdoc": "^0.2.14",
73
+ "prettier": "~2.5.0",
74
+ "raf": "^3.4.1",
75
+ "react": "^18.2.0",
76
+ "react-dom": "^18.2.0",
77
+ "typescript": "5.3.3",
78
+ "vitest": "1.0.4",
79
+ "vitest-dom": "0.1.1",
80
+ "sass": "^1.52.3",
81
+ "stylelint": "^13.8.0",
82
+ "stylelint-checkstyle-formatter": "^0.1.2",
83
+ "stylelint-config-prettier": "^8.0.2",
84
+ "@gooddata/sdk-backend-mockingbird": "10.7.0-alpha.28"
85
+ },
86
+ "scripts": {
87
+ "clean": "rm -rf ci dist esm coverage *.log styles/css tsconfig.tsbuildinfo",
88
+ "api-extractor": "mkdir -p api && [ -z \"${CI}\" ] && (api-extractor run -l) || (api-extractor run)",
89
+ "build": "./scripts/build.sh",
90
+ "test": "vitest watch",
91
+ "test-once": "vitest run",
92
+ "test-ci": "vitest run --reporter=junit --outputFile=./ci/results/test-results.xml",
93
+ "eslint": "eslint $npm_package_config_eslint",
94
+ "eslint-ci": "mkdir -p ./ci/results && eslint -f checkstyle -o ci/results/eslint-results.xml $npm_package_config_eslint",
95
+ "prettier-check": "prettier --check '{src,stories,styles,__mocks__}/**/*.{ts,tsx,json,scss,md,yaml,html}'",
96
+ "prettier-write": "prettier --write '{src,stories,styles,__mocks__}/**/*.{ts,tsx,json,scss,md,yaml,html}'",
97
+ "dep-cruiser": "depcruise --validate .dependency-cruiser.cjs --output-type err-long src/",
98
+ "dep-cruiser-ci": "depcruise --validate .dependency-cruiser.cjs --output-type err-long src/",
99
+ "validate": "npm run dep-cruiser && npm run eslint && npm run prettier-check",
100
+ "validate-ci": "npm run dep-cruiser-ci && npm run eslint-ci && npm run prettier-check"
101
+ }
102
+ }
@@ -0,0 +1,34 @@
1
+ .gd-semantic-search__results-item {
2
+ display: flex;
3
+ flex-direction: row;
4
+ align-items: center;
5
+ cursor: pointer;
6
+ gap: 1em;
7
+ padding: 0 1em;
8
+ height: 45px;
9
+ }
10
+ .gd-semantic-search__results-item--selected {
11
+ color: var(--gd-palette-complementary-9, #000);
12
+ background: var(--gd-palette-complementary-2, #ebeff4);
13
+ }
14
+ .gd-semantic-search__results-item__icon {
15
+ width: 16px;
16
+ height: 16px;
17
+ display: flex;
18
+ align-items: center;
19
+ }
20
+ .gd-semantic-search__results-item__icon > svg {
21
+ width: 16px;
22
+ height: 16px;
23
+ }
24
+ .gd-semantic-search__results-item__text {
25
+ flex-grow: 1;
26
+ min-width: 0;
27
+ }
28
+ .gd-semantic-search__results-item__text > p {
29
+ overflow: hidden;
30
+ text-overflow: ellipsis;
31
+ white-space: nowrap;
32
+ }
33
+
34
+ /*# sourceMappingURL=main.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../scss/main.scss","../../node_modules/@gooddata/sdk-ui-kit/styles/scss/variables.scss"],"names":[],"mappings":"AAOI;EAGI;EACA;EACA;EACA;EACA;EACA;EACA,QARc;;AAUd;EACI,OCiBI;EDhBJ,YCyFY;;ADtFhB;EAEI,OADY;EAEZ,QAFY;EAGZ;EACA;;AAEA;EAEI,OARQ;EASR,QATQ;;AAahB;EACI;EACA;;AAGJ;EACI;EACA;EACA","file":"main.css"}
@@ -0,0 +1,49 @@
1
+ // (C) 2024 GoodData Corporation
2
+
3
+ @use "sass:color";
4
+ @use "sass:meta";
5
+ @use "@gooddata/sdk-ui-kit/styles/scss/variables" as kit-variables;
6
+
7
+ .gd-semantic-search {
8
+ &__results-item {
9
+ $line-height: 45px;
10
+
11
+ display: flex;
12
+ flex-direction: row;
13
+ align-items: center;
14
+ cursor: pointer;
15
+ gap: 1em;
16
+ padding: 0 1em;
17
+ height: $line-height;
18
+
19
+ &--selected {
20
+ color: kit-variables.$is-focused-color;
21
+ background: kit-variables.$is-focused-background;
22
+ }
23
+
24
+ &__icon {
25
+ $icon_size: 16px;
26
+ width: $icon_size;
27
+ height: $icon_size;
28
+ display: flex;
29
+ align-items: center;
30
+
31
+ > svg {
32
+ // dashboard icon needs explicit size
33
+ width: $icon_size;
34
+ height: $icon_size;
35
+ }
36
+ }
37
+
38
+ &__text {
39
+ flex-grow: 1;
40
+ min-width: 0; // A hack to make ellipsis work in flexbox
41
+ }
42
+
43
+ &__text > p {
44
+ overflow: hidden;
45
+ text-overflow: ellipsis;
46
+ white-space: nowrap;
47
+ }
48
+ }
49
+ }