@gooddata/sdk-ui-semantic-search 10.8.0-alpha.9 → 10.8.0-beta.0
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/esm/ResultsItem.d.ts +3 -33
- package/esm/ResultsItem.d.ts.map +1 -1
- package/esm/ResultsItem.js +12 -67
- package/esm/ResultsItem.js.map +1 -1
- package/esm/SearchResultsDropdownList.d.ts +4 -3
- package/esm/SearchResultsDropdownList.d.ts.map +1 -1
- package/esm/SearchResultsDropdownList.js +6 -4
- package/esm/SearchResultsDropdownList.js.map +1 -1
- package/esm/SemanticSearch.d.ts.map +1 -1
- package/esm/SemanticSearch.js +23 -7
- package/esm/SemanticSearch.js.map +1 -1
- package/esm/hooks/useListSelector.d.ts +1 -1
- package/esm/hooks/useListSelector.d.ts.map +1 -1
- package/esm/hooks/useListSelector.js +3 -3
- package/esm/hooks/useListSelector.js.map +1 -1
- package/esm/hooks/useSemanticSearch.d.ts +3 -2
- package/esm/hooks/useSemanticSearch.d.ts.map +1 -1
- package/esm/hooks/useSemanticSearch.js +4 -11
- package/esm/hooks/useSemanticSearch.js.map +1 -1
- package/esm/internal/AnnotatedResultsItem.d.ts +5 -0
- package/esm/internal/AnnotatedResultsItem.d.ts.map +1 -0
- package/esm/internal/AnnotatedResultsItem.js +30 -0
- package/esm/internal/AnnotatedResultsItem.js.map +1 -0
- package/esm/internal/HeaderSearchButton.d.ts +12 -3
- package/esm/internal/HeaderSearchButton.d.ts.map +1 -1
- package/esm/internal/HeaderSearchButton.js +5 -3
- package/esm/internal/HeaderSearchButton.js.map +1 -1
- package/esm/internal/HistoryItem.d.ts +8 -0
- package/esm/internal/HistoryItem.d.ts.map +1 -0
- package/esm/internal/HistoryItem.js +21 -0
- package/esm/internal/HistoryItem.js.map +1 -0
- package/esm/internal/SearchList.d.ts +30 -0
- package/esm/internal/SearchList.d.ts.map +1 -0
- package/esm/internal/SearchList.js +16 -0
- package/esm/internal/SearchList.js.map +1 -0
- package/esm/internal/SearchOverlay.d.ts +3 -3
- package/esm/internal/SearchOverlay.d.ts.map +1 -1
- package/esm/internal/SearchOverlay.js +68 -8
- package/esm/internal/SearchOverlay.js.map +1 -1
- package/esm/internal/UpdateDate.d.ts +10 -0
- package/esm/internal/UpdateDate.d.ts.map +1 -0
- package/esm/internal/UpdateDate.js +29 -0
- package/esm/internal/UpdateDate.js.map +1 -0
- package/esm/sdk-ui-semantic-search.d.ts +4 -3
- package/esm/types.d.ts +33 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/types.js +3 -0
- package/esm/types.js.map +1 -0
- package/esm/utils/renderDetails.d.ts +8 -0
- package/esm/utils/renderDetails.d.ts.map +1 -0
- package/esm/utils/renderDetails.js +52 -0
- package/esm/utils/renderDetails.js.map +1 -0
- package/esm/utils/renderItemIcon.d.ts +9 -0
- package/esm/utils/renderItemIcon.d.ts.map +1 -0
- package/esm/utils/renderItemIcon.js +32 -0
- package/esm/utils/renderItemIcon.js.map +1 -0
- package/package.json +7 -7
- package/styles/css/internal.css +58 -16
- package/styles/css/internal.css.map +1 -1
- package/styles/css/main.css +52 -15
- package/styles/css/main.css.map +1 -1
- package/styles/scss/internal.scss +8 -1
- package/styles/scss/main.scss +61 -24
- package/esm/internal/SearchResultsList.d.ts +0 -26
- package/esm/internal/SearchResultsList.d.ts.map +0 -1
- package/esm/internal/SearchResultsList.js +0 -16
- package/esm/internal/SearchResultsList.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ListItem, ListItemProps } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Search results props.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export type SearchListProps<T> = {
|
|
8
|
+
/**
|
|
9
|
+
* Search result items.
|
|
10
|
+
*/
|
|
11
|
+
items: ListItem<T>[];
|
|
12
|
+
/**
|
|
13
|
+
* Width of the list.
|
|
14
|
+
*/
|
|
15
|
+
width: number;
|
|
16
|
+
/**
|
|
17
|
+
* Callback for item selection.
|
|
18
|
+
*/
|
|
19
|
+
onSelect: (item: ListItem<T>, e: MouseEvent | KeyboardEvent) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Component to render the item.
|
|
22
|
+
*/
|
|
23
|
+
ItemComponent: React.ComponentType<ListItemProps<T>>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A dropdown list with the search results.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare const SearchList: <T>({ items, width, onSelect, ItemComponent }: SearchListProps<T>) => React.JSX.Element;
|
|
30
|
+
//# sourceMappingURL=SearchList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchList.d.ts","sourceRoot":"","sources":["../../src/internal/SearchList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAItD;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B;;OAEG;IACH,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,GAAG,aAAa,KAAK,IAAI,CAAC;IACrE;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACxD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,yFAqBtB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// (C) 2024 GoodData Corporation
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { List } from "@gooddata/sdk-ui-kit";
|
|
4
|
+
import { useListSelector } from "../hooks/index.js";
|
|
5
|
+
const ITEM_HEIGHT = 50;
|
|
6
|
+
/**
|
|
7
|
+
* A dropdown list with the search results.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const SearchList = ({ items, width, onSelect, ItemComponent }) => {
|
|
11
|
+
const [selected, setSelected] = useListSelector(items, onSelect);
|
|
12
|
+
return (React.createElement(List, { width: width, height: ITEM_HEIGHT * items.length, itemHeight: ITEM_HEIGHT, renderItem: ({ item }) => {
|
|
13
|
+
return (React.createElement(ItemComponent, { listItem: item, isActive: item === selected, setActive: setSelected, onSelect: onSelect }));
|
|
14
|
+
}, items: items }));
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=SearchList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchList.js","sourceRoot":"","sources":["../../src/internal/SearchList.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,MAAM,WAAW,GAAG,EAAE,CAAC;AAyBvB;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAsB,EAAE,EAAE;IAC5F,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEjE,OAAO,CACH,oBAAC,IAAI,IACD,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,WAAW,GAAG,KAAK,CAAC,MAAM,EAClC,UAAU,EAAE,WAAW,EACvB,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YACrB,OAAO,CACH,oBAAC,aAAa,IACV,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,IAAI,KAAK,QAAQ,EAC3B,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,QAAQ,GACpB,CACL,CAAC;QACN,CAAC,EACD,KAAK,EAAE,KAAK,GACd,CACL,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { IAnalyticalBackend } from "@gooddata/sdk-backend-spi";
|
|
3
|
-
import { GenAISemanticSearchType, ISemanticSearchResultItemWithUrl } from "@gooddata/sdk-model";
|
|
4
2
|
import { WrappedComponentProps } from "react-intl";
|
|
3
|
+
import { GenAISemanticSearchType, ISemanticSearchResultItem } from "@gooddata/sdk-model";
|
|
4
|
+
import { IAnalyticalBackend } from "@gooddata/sdk-backend-spi";
|
|
5
5
|
/**
|
|
6
6
|
* Props for the SemanticSearchOverlay component.
|
|
7
7
|
* @internal
|
|
@@ -10,7 +10,7 @@ export type SearchOverlayProps = WrappedComponentProps & {
|
|
|
10
10
|
/**
|
|
11
11
|
* A function called when the user selects an item from the search results.
|
|
12
12
|
*/
|
|
13
|
-
onSelect: (item:
|
|
13
|
+
onSelect: (item: ISemanticSearchResultItem, e: MouseEvent | KeyboardEvent, itemUrl?: string) => void;
|
|
14
14
|
/**
|
|
15
15
|
* An analytical backend to use for the search. Can be omitted and taken from context.
|
|
16
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchOverlay.d.ts","sourceRoot":"","sources":["../../src/internal/SearchOverlay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchOverlay.d.ts","sourceRoot":"","sources":["../../src/internal/SearchOverlay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAoB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAmC/D;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG;IACrD;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,yBAAyB,EAAE,CAAC,EAAE,UAAU,GAAG,aAAa,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrG;;OAEG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACxC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsJtD,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// (C) 2024 GoodData Corporation
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Input, LoadingMask, useDebouncedState } from "@gooddata/sdk-ui-kit";
|
|
4
|
-
import { useSemanticSearch } from "../hooks/index.js";
|
|
5
|
-
import { SearchResultsList } from "./SearchResultsList.js";
|
|
6
3
|
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { Input, LoadingMask, Message, useDebouncedState } from "@gooddata/sdk-ui-kit";
|
|
5
|
+
import { useWorkspaceStrict, useLocalStorage } from "@gooddata/sdk-ui";
|
|
6
|
+
import { useSemanticSearch } from "../hooks/index.js";
|
|
7
|
+
import { getUIPath } from "../utils/getUIPath.js";
|
|
8
|
+
import { SearchList } from "./SearchList.js";
|
|
9
|
+
import { HistoryItem } from "./HistoryItem.js";
|
|
10
|
+
import { AnnotatedResultsItem } from "./AnnotatedResultsItem.js";
|
|
7
11
|
/**
|
|
8
12
|
* A time in milliseconds to wait before sending a search request after the user stops typing.
|
|
9
13
|
*/
|
|
@@ -16,6 +20,18 @@ const LOADING_HEIGHT = 100;
|
|
|
16
20
|
* A width of the search drop-down.
|
|
17
21
|
*/
|
|
18
22
|
const SEARCH_OVERLAY_WIDTH = 440;
|
|
23
|
+
/**
|
|
24
|
+
* Max search history length.
|
|
25
|
+
*/
|
|
26
|
+
const MAX_SEARCH_HISTORY_LENGTH = 5;
|
|
27
|
+
/**
|
|
28
|
+
* A key for the search history in the local storage.
|
|
29
|
+
*/
|
|
30
|
+
const SEARCH_HISTORY_KEY = "gd-semantic-search-history";
|
|
31
|
+
/**
|
|
32
|
+
* An initial value for the search history.
|
|
33
|
+
*/
|
|
34
|
+
const SEARCH_HISTORY_EMPTY = [];
|
|
19
35
|
/**
|
|
20
36
|
* A component that allows users to search for insights, metrics, attributes, and other objects using semantic search.
|
|
21
37
|
* The internal version is meant to be used in an overlay inside the Header.
|
|
@@ -23,16 +39,53 @@ const SEARCH_OVERLAY_WIDTH = 440;
|
|
|
23
39
|
*/
|
|
24
40
|
export const SearchOverlay = ({ onSelect, backend, workspace, objectTypes, deepSearch, limit = 6, intl, }) => {
|
|
25
41
|
// Input value handling
|
|
26
|
-
const [value, setValue, searchTerm] = useDebouncedState("", DEBOUNCE);
|
|
42
|
+
const [value, setValue, searchTerm, setImmediate] = useDebouncedState("", DEBOUNCE);
|
|
27
43
|
// Search results
|
|
28
|
-
const
|
|
44
|
+
const effectiveWorkspace = useWorkspaceStrict(workspace);
|
|
45
|
+
const { searchStatus, searchResults, searchError, relationships } = useSemanticSearch({
|
|
29
46
|
backend,
|
|
30
|
-
workspace,
|
|
47
|
+
workspace: effectiveWorkspace,
|
|
31
48
|
searchTerm,
|
|
32
49
|
objectTypes,
|
|
33
50
|
deepSearch,
|
|
34
51
|
limit,
|
|
35
52
|
});
|
|
53
|
+
// Results wrapped into ListItems
|
|
54
|
+
const searchResultsItems = React.useMemo(() => searchResults.flatMap((item) => {
|
|
55
|
+
// Look up parent items if available
|
|
56
|
+
const parents = relationships.filter((rel) => rel.targetObjectId === item.id && rel.targetObjectType === item.type);
|
|
57
|
+
if (!parents.length)
|
|
58
|
+
return {
|
|
59
|
+
item,
|
|
60
|
+
url: getUIPath(item.type, item.id, effectiveWorkspace),
|
|
61
|
+
};
|
|
62
|
+
return parents.map((parent) => ({
|
|
63
|
+
item,
|
|
64
|
+
parentRef: parent,
|
|
65
|
+
url: getUIPath(parent.sourceObjectType, parent.sourceObjectId, effectiveWorkspace),
|
|
66
|
+
}));
|
|
67
|
+
}), [searchResults, effectiveWorkspace, relationships]);
|
|
68
|
+
// Search history
|
|
69
|
+
const [searchHistory, setSearchHistory] = useLocalStorage(SEARCH_HISTORY_KEY, SEARCH_HISTORY_EMPTY);
|
|
70
|
+
const onResultSelect = React.useCallback((item, e) => {
|
|
71
|
+
setSearchHistory([...new Set([searchTerm, ...searchHistory])].slice(0, MAX_SEARCH_HISTORY_LENGTH));
|
|
72
|
+
// Simulate browser behaviour - if user presses Ctrl or Cmd and clicks on the result, open it in a new tab
|
|
73
|
+
if (item.url && (e.ctrlKey || e.metaKey)) {
|
|
74
|
+
// Keyboard events do not navigate to the URL natively by the browser, do it artificially
|
|
75
|
+
if (e instanceof KeyboardEvent) {
|
|
76
|
+
window.open(item.url, "_blank");
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Call the onSelect callback
|
|
81
|
+
onSelect(item.item, e, item.url);
|
|
82
|
+
// If the default was not prevented - simulate browser navigation
|
|
83
|
+
if (item.url && e instanceof KeyboardEvent && !e.defaultPrevented) {
|
|
84
|
+
window.location.href = item.url;
|
|
85
|
+
}
|
|
86
|
+
}, [searchTerm, searchHistory, onSelect, setSearchHistory]);
|
|
87
|
+
const onHistorySelect = (item) => setImmediate(item.item);
|
|
88
|
+
const searchHistoryItems = React.useMemo(() => searchHistory.map((item) => ({ item })), [searchHistory]);
|
|
36
89
|
React.useEffect(() => {
|
|
37
90
|
if (searchStatus === "error") {
|
|
38
91
|
// Report error to the console
|
|
@@ -48,14 +101,21 @@ export const SearchOverlay = ({ onSelect, backend, workspace, objectTypes, deepS
|
|
|
48
101
|
return React.createElement(LoadingMask, { width: SEARCH_OVERLAY_WIDTH, height: LOADING_HEIGHT });
|
|
49
102
|
case "error":
|
|
50
103
|
return (React.createElement("div", { className: "gd-semantic-search__overlay-error" },
|
|
51
|
-
React.createElement(
|
|
104
|
+
React.createElement(Message, { type: "error" },
|
|
105
|
+
React.createElement(FormattedMessage, { tagName: "strong", id: "semantic-search.error.title" }),
|
|
106
|
+
" ",
|
|
107
|
+
React.createElement(FormattedMessage, { id: "semantic-search.error.text" }))));
|
|
52
108
|
case "success":
|
|
53
109
|
if (!searchResults.length) {
|
|
54
110
|
return (React.createElement("div", { className: "gd-semantic-search__overlay-no-results" },
|
|
55
111
|
React.createElement(FormattedMessage, { id: "semantic-search.no-results", values: { query: searchTerm } })));
|
|
56
112
|
}
|
|
57
|
-
return (React.createElement(
|
|
113
|
+
return (React.createElement(SearchList, { items: searchResultsItems, width: SEARCH_OVERLAY_WIDTH, onSelect: onResultSelect, ItemComponent: AnnotatedResultsItem }));
|
|
58
114
|
case "idle":
|
|
115
|
+
if (searchHistory.length) {
|
|
116
|
+
return (React.createElement(SearchList, { items: searchHistoryItems, width: SEARCH_OVERLAY_WIDTH, onSelect: onHistorySelect, ItemComponent: HistoryItem }));
|
|
117
|
+
}
|
|
118
|
+
// fallthrough
|
|
59
119
|
default:
|
|
60
120
|
return null;
|
|
61
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchOverlay.js","sourceRoot":"","sources":["../../src/internal/SearchOverlay.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchOver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EACxB,aAAa,EAAE,oBAAoB,GACrC,CACL,CAAC;gBACN,KAAK,MAAM;oBACP,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;wBACvB,OAAO,CACH,oBAAC,UAAU,IACP,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,oBAAoB,EAC3B,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,WAAW,GAC5B,CACL,CAAC;oBACN,CAAC;gBACL,cAAc;gBACd;oBACI,OAAO,IAAI,CAAC;YACpB,CAAC;QACL,CAAC,CAAC,EAAE,CACF,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ListItem } from "../types.js";
|
|
2
|
+
import { ISemanticSearchResultItem } from "@gooddata/sdk-model";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
type UpdateDateProps = {
|
|
5
|
+
listItem: ListItem<ISemanticSearchResultItem>;
|
|
6
|
+
timezone?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const UpdatedDate: React.NamedExoticComponent<UpdateDateProps>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=UpdateDate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateDate.d.ts","sourceRoot":"","sources":["../../src/internal/UpdateDate.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,KAAK,eAAe,GAAG;IACnB,QAAQ,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAQF,eAAO,MAAM,WAAW,6CA2BtB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// (C) 2024 GoodData Corporation
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { getDateTimeConfig } from "@gooddata/sdk-ui-kit";
|
|
4
|
+
import { defineMessages, FormattedDate, FormattedMessage, FormattedTime } from "react-intl";
|
|
5
|
+
const messages = defineMessages({
|
|
6
|
+
today: { id: "gs.date.today" },
|
|
7
|
+
yesterday: { id: "gs.date.yesterday" },
|
|
8
|
+
at: { id: "gs.date.at" },
|
|
9
|
+
});
|
|
10
|
+
export const UpdatedDate = React.memo(function UpdatedDate({ listItem: { item }, timezone, }) {
|
|
11
|
+
const timestamp = item.modifiedAt ?? item.createdAt;
|
|
12
|
+
if (!timestamp)
|
|
13
|
+
return null;
|
|
14
|
+
const config = getDateTimeConfig(timestamp, { dateTimezone: timezone });
|
|
15
|
+
const relativeDate = config.isToday ? messages.today.id : messages.yesterday.id;
|
|
16
|
+
if (config.isToday || config.isYesterday) {
|
|
17
|
+
return (React.createElement("span", null,
|
|
18
|
+
React.createElement(FormattedMessage, { id: relativeDate }),
|
|
19
|
+
"\u00A0",
|
|
20
|
+
React.createElement(FormattedMessage, { id: messages.at.id }),
|
|
21
|
+
"\u00A0",
|
|
22
|
+
React.createElement(FormattedTime, { value: config.date, hour: "numeric", minute: "2-digit" })));
|
|
23
|
+
}
|
|
24
|
+
else if (config.isCurrentYear) {
|
|
25
|
+
return React.createElement(FormattedDate, { value: config.date, day: "numeric", month: "short" });
|
|
26
|
+
}
|
|
27
|
+
return React.createElement(FormattedDate, { value: config.date, day: "numeric", month: "short", year: "numeric" });
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=UpdateDate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateDate.js","sourceRoot":"","sources":["../../src/internal/UpdateDate.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAIhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE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AC,KAAK,EAAC,OAAO,GAAG,CAAC;IAC7E,CAAC;IAED,OAAO,oBAAC,aAAa,IAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAC,SAAS,EAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,GAAG,CAAC;AAC5F,CAAC,CAAC,CAAC"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { GenAISemanticSearchType } from '@gooddata/sdk-model';
|
|
8
8
|
import { IAnalyticalBackend } from '@gooddata/sdk-backend-spi';
|
|
9
|
+
import { ISemanticSearchRelationship } from '@gooddata/sdk-model';
|
|
9
10
|
import { ISemanticSearchResultItem } from '@gooddata/sdk-model';
|
|
10
|
-
import { ISemanticSearchResultItemWithUrl } from '@gooddata/sdk-model';
|
|
11
11
|
import * as React_2 from 'react';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -113,7 +113,8 @@ export declare type SemanticSearchInputResult = {
|
|
|
113
113
|
/**
|
|
114
114
|
* The search results.
|
|
115
115
|
*/
|
|
116
|
-
searchResults:
|
|
116
|
+
searchResults: ISemanticSearchResultItem[];
|
|
117
|
+
relationships: ISemanticSearchRelationship[];
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
/**
|
|
@@ -129,7 +130,7 @@ export declare type SemanticSearchProps = SemanticSearchCoreProps & {
|
|
|
129
130
|
* calls the onSelect callback when Enter is pressed.
|
|
130
131
|
* @internal
|
|
131
132
|
*/
|
|
132
|
-
export declare const useListSelector: <T>(items: T[], onSelect: (item: T) => void) => [T, (item: T) => void];
|
|
133
|
+
export declare const useListSelector: <T>(items: T[], onSelect: (item: T, e: MouseEvent | KeyboardEvent) => void) => [T, (item: T) => void];
|
|
133
134
|
|
|
134
135
|
/**
|
|
135
136
|
* Hook to perform semantic search.
|
package/esm/types.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ISemanticSearchRelationship } from "@gooddata/sdk-model";
|
|
2
|
+
/**
|
|
3
|
+
* A wrapper type to handle search results rendering.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export type ListItem<T> = {
|
|
7
|
+
item: T;
|
|
8
|
+
url?: string;
|
|
9
|
+
parentRef?: ISemanticSearchRelationship;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Shared props definition for all list items components.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export type ListItemProps<T> = {
|
|
16
|
+
/**
|
|
17
|
+
* The item to render.
|
|
18
|
+
*/
|
|
19
|
+
listItem: ListItem<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the item is active.
|
|
22
|
+
*/
|
|
23
|
+
isActive: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Set itself as an active item.
|
|
26
|
+
*/
|
|
27
|
+
setActive: (item: ListItem<T>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Set itself as selected item.
|
|
30
|
+
*/
|
|
31
|
+
onSelect: (item: ListItem<T>, e: MouseEvent) => void;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IACtB,IAAI,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,2BAA2B,CAAC;CAC3C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC3B;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACvC;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CACxD,CAAC"}
|
package/esm/types.js
ADDED
package/esm/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,gCAAgC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ISemanticSearchResultItem, ITheme } from "@gooddata/sdk-model";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ListItem } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Render the details of the item in a bubble.
|
|
6
|
+
*/
|
|
7
|
+
export declare const renderDetails: (listItem: ListItem<ISemanticSearchResultItem>, theme?: ITheme) => React.JSX.Element;
|
|
8
|
+
//# sourceMappingURL=renderDetails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderDetails.d.ts","sourceRoot":"","sources":["../../src/utils/renderDetails.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA0CvC;;GAEG;AACH,eAAO,MAAM,aAAa,aAAc,SAAS,yBAAyB,CAAC,UAAU,MAAM,sBAsB1F,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// (C) 2024 GoodData Corporation
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { Bubble, BubbleHoverTrigger, EllipsisText, Icon, Typography } from "@gooddata/sdk-ui-kit";
|
|
5
|
+
/**
|
|
6
|
+
* Maximum number of lines for the description before ellipsis.
|
|
7
|
+
*/
|
|
8
|
+
const MAX_LINES = 7;
|
|
9
|
+
/**
|
|
10
|
+
* Align points for the details bubble.
|
|
11
|
+
*/
|
|
12
|
+
const BUBBLE_ALIGN_POINTS = [{ align: "bc tr", offset: { x: 2, y: -4 } }];
|
|
13
|
+
/**
|
|
14
|
+
* Arrow style for the details bubble.
|
|
15
|
+
*/
|
|
16
|
+
const ARROW_STYLE = { display: "none" };
|
|
17
|
+
/**
|
|
18
|
+
* Render the tags if there are any.
|
|
19
|
+
*/
|
|
20
|
+
const renderTags = (item) => {
|
|
21
|
+
if (item.tags?.some((tag) => tag !== item.title)) {
|
|
22
|
+
return (React.createElement(React.Fragment, null,
|
|
23
|
+
React.createElement(FormattedMessage, { tagName: "h4", id: "semantic-search.tags" }),
|
|
24
|
+
React.createElement(Typography, { tagName: "p" }, item.tags.join(", "))));
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Render the description if it is different from the title.
|
|
30
|
+
*/
|
|
31
|
+
const renderDescription = (item) => {
|
|
32
|
+
if (item.description && item.description !== item.title) {
|
|
33
|
+
return React.createElement(EllipsisText, { maxLines: MAX_LINES, text: item.description });
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Render the details of the item in a bubble.
|
|
39
|
+
*/
|
|
40
|
+
export const renderDetails = (listItem, theme) => {
|
|
41
|
+
return (React.createElement("span", { className: "gd-semantic-search__results-item__details" },
|
|
42
|
+
React.createElement(BubbleHoverTrigger, { eventsOnBubble: true },
|
|
43
|
+
React.createElement(Icon.QuestionMark, { color: theme?.palette?.complementary?.c7 ?? "#6D7680" }),
|
|
44
|
+
React.createElement(Bubble, { className: "bubble-light gd-semantic-search__bubble", alignPoints: BUBBLE_ALIGN_POINTS, arrowStyle: ARROW_STYLE },
|
|
45
|
+
React.createElement("div", { className: "gd-semantic-search__results-item__details__contents" },
|
|
46
|
+
React.createElement(Typography, { tagName: "h3" }, listItem.item.title),
|
|
47
|
+
renderDescription(listItem.item),
|
|
48
|
+
React.createElement(FormattedMessage, { tagName: "h4", id: "semantic-search.id" }),
|
|
49
|
+
React.createElement(Typography, { tagName: "p" }, listItem.item.id),
|
|
50
|
+
renderTags(listItem.item))))));
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=renderDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderDetails.js","sourceRoot":"","sources":["../../src/utils/renderDetails.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAGhC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlG;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1E;;GAEG;AACH,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,IAA+B,EAAE,EAAE;IACnD,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,CACH,oBAAC,KAAK,CAAC,QAAQ;YACX,oBAAC,gBAAgB,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAC,sBAAsB,GAAG;YAC3D,oBAAC,UAAU,IAAC,OAAO,EAAC,GAAG,IAAE,IAAI,CAAC,IAAI,CAAC,I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,9 @@
|
|
|
1
|
+
import { ISemanticSearchResultItem } from "@gooddata/sdk-model";
|
|
2
|
+
import { IIconProps } from "@gooddata/sdk-ui-kit";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { ListItem } from "../types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Pick an icon according to the item type.
|
|
7
|
+
*/
|
|
8
|
+
export declare const renderItemIcon: ({ item }: ListItem<ISemanticSearchResultItem>, props: IIconProps) => React.JSX.Element;
|
|
9
|
+
//# sourceMappingURL=renderItemIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderItemIcon.d.ts","sourceRoot":"","sources":["../../src/utils/renderItemIcon.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAqB,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,cAAc,aAAc,SAAS,yBAAyB,CAAC,SAAS,UAAU,sBAqB9F,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// (C) 2024 GoodData Corporation
|
|
2
|
+
import { Icon, InsightIcon } from "@gooddata/sdk-ui-kit";
|
|
3
|
+
import React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* Pick an icon according to the item type.
|
|
6
|
+
*/
|
|
7
|
+
export const renderItemIcon = ({ item }, props) => {
|
|
8
|
+
switch (item.type) {
|
|
9
|
+
case "dashboard":
|
|
10
|
+
return React.createElement(Icon.Dashboard, { ...props });
|
|
11
|
+
case "visualization":
|
|
12
|
+
return React.createElement(InsightIcon, { visualizationUrl: item.visualizationUrl, iconProps: props });
|
|
13
|
+
case "dataset":
|
|
14
|
+
return React.createElement(Icon.Dataset, { ...props });
|
|
15
|
+
case "attribute":
|
|
16
|
+
return React.createElement(Icon.Attribute, { ...props });
|
|
17
|
+
case "label":
|
|
18
|
+
return React.createElement(Icon.Label, { ...props });
|
|
19
|
+
case "fact":
|
|
20
|
+
return React.createElement(Icon.Fact, { ...props });
|
|
21
|
+
case "metric":
|
|
22
|
+
return React.createElement(Icon.Metric, { ...props });
|
|
23
|
+
case "date":
|
|
24
|
+
return React.createElement(Icon.Date, { ...props });
|
|
25
|
+
default:
|
|
26
|
+
return exhaustiveCheck(item.type);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const exhaustiveCheck = (type) => {
|
|
30
|
+
throw new Error(`Unknown item type: ${type}`);
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=renderItemIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderItemIcon.js","sourceRoot":"","sources":["../../src/utils/renderItemIcon.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAGhC,OAAO,EAAc,IAAI,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,IAAI,EAAuC,EAAE,KAAiB,EAAE,EAAE;IAC/F,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,WAAW;YACZ,OAAO,oBAAC,IAAI,CAAC,SAAS,OAAK,KAAK,GAAI,CAAC;QACzC,KAAK,eAAe;YAChB,OAAO,oBAAC,WAAW,IAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,EAAE,KAAK,GAAI,CAAC;QACtF,KAAK,SAAS;YACV,OAAO,oBAAC,IAAI,CAAC,OAAO,OAAK,KAAK,GAAI,CAAC;QACvC,KAAK,WAAW;YACZ,OAAO,oBAAC,IAAI,CAAC,SAAS,OAAK,KAAK,GAAI,CAAC;QACzC,KAAK,OAAO;YACR,OAAO,oBAAC,IAAI,CAAC,KAAK,OAAK,KAAK,GAAI,CAAC;QACrC,KAAK,MAAM;YACP,OAAO,oBAAC,IAAI,CAAC,IAAI,OAAK,KAAK,GAAI,CAAC;QACpC,KAAK,QAAQ;YACT,OAAO,oBAAC,IAAI,CAAC,MAAM,OAAK,KAAK,GAAI,CAAC;QACtC,KAAK,MAAM;YACP,OAAO,oBAAC,IAAI,CAAC,IAAI,OAAK,KAAK,GAAI,CAAC;QACpC;YACI,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAAW,EAAS,EAAE;IAC3C,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-ui-semantic-search",
|
|
3
|
-
"version": "10.8.0-
|
|
3
|
+
"version": "10.8.0-beta.0",
|
|
4
4
|
"description": "GoodData SDK TypeScript & React skeleton",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"react-intl": "^6.4.1",
|
|
38
38
|
"tslib": "^2.5.0",
|
|
39
39
|
"classnames": "^2.3.1",
|
|
40
|
-
"@gooddata/sdk-model": "10.8.0-
|
|
41
|
-
"@gooddata/sdk-ui": "10.8.0-
|
|
42
|
-
"@gooddata/sdk-
|
|
43
|
-
"@gooddata/sdk-
|
|
44
|
-
"@gooddata/sdk-ui-theme-provider": "10.8.0-
|
|
40
|
+
"@gooddata/sdk-model": "10.8.0-beta.0",
|
|
41
|
+
"@gooddata/sdk-ui": "10.8.0-beta.0",
|
|
42
|
+
"@gooddata/sdk-backend-spi": "10.8.0-beta.0",
|
|
43
|
+
"@gooddata/sdk-ui-kit": "10.8.0-beta.0",
|
|
44
|
+
"@gooddata/sdk-ui-theme-provider": "10.8.0-beta.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^16.10.0 || ^17.0.0 || ^18.0.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"stylelint": "^13.8.0",
|
|
84
84
|
"stylelint-checkstyle-formatter": "^0.1.2",
|
|
85
85
|
"stylelint-config-prettier": "^8.0.2",
|
|
86
|
-
"@gooddata/sdk-backend-mockingbird": "10.8.0-
|
|
86
|
+
"@gooddata/sdk-backend-mockingbird": "10.8.0-beta.0"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
89
|
"clean": "rm -rf ci dist esm coverage *.log styles/css tsconfig.tsbuildinfo",
|
package/styles/css/internal.css
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
1
2
|
/* allow vendor prefixes and disable max length */
|
|
2
3
|
/* allow vendor prefixes and disable max length */
|
|
3
4
|
.gd-semantic-search__results-item {
|
|
@@ -7,7 +8,10 @@
|
|
|
7
8
|
cursor: pointer;
|
|
8
9
|
gap: 1em;
|
|
9
10
|
padding: 0 1em;
|
|
10
|
-
height:
|
|
11
|
+
height: 50px;
|
|
12
|
+
text-decoration: none;
|
|
13
|
+
}
|
|
14
|
+
.gd-semantic-search__results-item:hover {
|
|
11
15
|
text-decoration: none;
|
|
12
16
|
}
|
|
13
17
|
.gd-semantic-search__results-item--active {
|
|
@@ -15,32 +19,65 @@
|
|
|
15
19
|
background: var(--gd-palette-complementary-2, #ebeff4);
|
|
16
20
|
}
|
|
17
21
|
.gd-semantic-search__results-item__icon {
|
|
18
|
-
width:
|
|
19
|
-
height:
|
|
22
|
+
width: 32px;
|
|
23
|
+
height: 32px;
|
|
20
24
|
display: flex;
|
|
21
25
|
align-items: center;
|
|
22
26
|
}
|
|
23
27
|
.gd-semantic-search__results-item__icon > svg {
|
|
24
|
-
width:
|
|
25
|
-
height:
|
|
28
|
+
width: 32px;
|
|
29
|
+
height: 32px;
|
|
30
|
+
}
|
|
31
|
+
.gd-semantic-search__results-item__icon--history {
|
|
32
|
+
width: 17px;
|
|
33
|
+
height: 17px;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
}
|
|
37
|
+
.gd-semantic-search__results-item__icon--history > svg {
|
|
38
|
+
width: 17px;
|
|
39
|
+
height: 17px;
|
|
26
40
|
}
|
|
27
41
|
.gd-semantic-search__results-item__text {
|
|
28
42
|
flex-grow: 1;
|
|
29
|
-
min-width: 0;
|
|
30
43
|
font-weight: 400;
|
|
31
|
-
line-height: 1.4rem;
|
|
32
44
|
color: var(--gd-palette-complementary-8, #464e56);
|
|
33
45
|
font-size: 14px;
|
|
46
|
+
}
|
|
47
|
+
.gd-semantic-search__results-item__text--history {
|
|
48
|
+
min-width: 0;
|
|
49
|
+
line-height: 1.4rem;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
text-overflow: ellipsis;
|
|
52
|
+
white-space: nowrap;
|
|
53
|
+
}
|
|
54
|
+
.gd-semantic-search__results-item__text--result {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
}
|
|
58
|
+
.gd-semantic-search__results-item__text__1 {
|
|
59
|
+
min-width: 0;
|
|
60
|
+
line-height: 20px;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
text-overflow: ellipsis;
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
}
|
|
65
|
+
.gd-semantic-search__results-item__text__2 {
|
|
66
|
+
min-width: 0;
|
|
67
|
+
line-height: 20px;
|
|
34
68
|
overflow: hidden;
|
|
35
69
|
text-overflow: ellipsis;
|
|
36
70
|
white-space: nowrap;
|
|
71
|
+
color: var(--gd-palette-complementary-6, #94a1ad);
|
|
37
72
|
}
|
|
38
73
|
.gd-semantic-search__results-item__details {
|
|
39
|
-
display: none;
|
|
40
74
|
width: 16px;
|
|
41
75
|
height: 16px;
|
|
42
76
|
align-items: center;
|
|
43
77
|
}
|
|
78
|
+
.gd-semantic-search__results-item__details .gd-ellipsis-text {
|
|
79
|
+
margin: 10px 0 0;
|
|
80
|
+
}
|
|
44
81
|
.gd-semantic-search__results-item__details__contents {
|
|
45
82
|
width: 190px;
|
|
46
83
|
padding: 5px;
|
|
@@ -48,25 +85,25 @@
|
|
|
48
85
|
display: flex;
|
|
49
86
|
flex-direction: column;
|
|
50
87
|
}
|
|
51
|
-
.gd-semantic-search__results-item__details__contents > * {
|
|
52
|
-
margin-bottom: 15px;
|
|
53
|
-
}
|
|
54
88
|
.gd-semantic-search__results-item__details__contents h3 {
|
|
55
89
|
font-size: 14px;
|
|
56
|
-
margin: 0
|
|
90
|
+
margin: 0;
|
|
57
91
|
}
|
|
58
92
|
.gd-semantic-search__results-item__details__contents .gd-ellipsis-text-content {
|
|
59
93
|
font-size: 12px;
|
|
60
94
|
}
|
|
61
95
|
.gd-semantic-search__results-item__details__contents h4 {
|
|
62
|
-
margin: 0;
|
|
96
|
+
margin: 10px 0 0;
|
|
63
97
|
text-transform: uppercase;
|
|
64
98
|
font-size: 10px;
|
|
65
99
|
font-weight: 400;
|
|
66
100
|
color: var(--gd-palette-complementary-6, #94a1ad);
|
|
67
101
|
}
|
|
68
|
-
.gd-semantic-search__results-
|
|
69
|
-
|
|
102
|
+
.gd-semantic-search__results-item__annotation:after {
|
|
103
|
+
content: " • ";
|
|
104
|
+
}
|
|
105
|
+
.gd-semantic-search__results-item__annotation:last-child:after {
|
|
106
|
+
content: "";
|
|
70
107
|
}
|
|
71
108
|
|
|
72
109
|
.gd-semantic-search__bubble.bubble.bubble-light {
|
|
@@ -82,12 +119,17 @@
|
|
|
82
119
|
margin: 0 10px;
|
|
83
120
|
}
|
|
84
121
|
.gd-semantic-search__overlay-error, .gd-semantic-search__overlay-no-results {
|
|
85
|
-
height: 100px;
|
|
86
122
|
display: flex;
|
|
87
123
|
justify-content: center;
|
|
88
124
|
align-items: center;
|
|
89
125
|
color: var(--gd-palette-complementary-6, #94a1ad);
|
|
90
126
|
}
|
|
127
|
+
.gd-semantic-search__overlay-error {
|
|
128
|
+
padding: 10px 10px 0;
|
|
129
|
+
}
|
|
130
|
+
.gd-semantic-search__overlay-no-results {
|
|
131
|
+
height: 100px;
|
|
132
|
+
}
|
|
91
133
|
|
|
92
134
|
.gd-header-search {
|
|
93
135
|
height: 100%;
|