@gooddata/sdk-ui-semantic-search 10.8.0-alpha.8 → 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 +2 -32
- package/esm/ResultsItem.d.ts.map +1 -1
- package/esm/ResultsItem.js +13 -44
- package/esm/ResultsItem.js.map +1 -1
- package/esm/SearchResultsDropdownList.d.ts +2 -1
- package/esm/SearchResultsDropdownList.d.ts.map +1 -1
- package/esm/SearchResultsDropdownList.js +6 -6
- package/esm/SearchResultsDropdownList.js.map +1 -1
- package/esm/SemanticSearch.d.ts.map +1 -1
- package/esm/SemanticSearch.js +32 -13
- 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 +11 -10
- package/esm/hooks/useListSelector.js.map +1 -1
- package/esm/hooks/useSemanticSearch.d.ts +2 -1
- package/esm/hooks/useSemanticSearch.d.ts.map +1 -1
- package/esm/hooks/useSemanticSearch.js +4 -2
- 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 +17 -0
- package/esm/internal/HeaderSearchButton.d.ts.map +1 -0
- package/esm/internal/HeaderSearchButton.js +39 -0
- package/esm/internal/HeaderSearchButton.js.map +1 -0
- 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/{SemanticSearchOverlay.d.ts → SearchOverlay.d.ts} +6 -5
- package/esm/internal/SearchOverlay.d.ts.map +1 -0
- package/esm/internal/SearchOverlay.js +124 -0
- package/esm/internal/SearchOverlay.js.map +1 -0
- 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/internal.d.ts +1 -1
- package/esm/internal.d.ts.map +1 -1
- package/esm/internal.js +1 -1
- package/esm/internal.js.map +1 -1
- package/esm/sdk-ui-semantic-search.d.ts +3 -1
- 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/getUIPath.d.ts +14 -0
- package/esm/utils/getUIPath.d.ts.map +1 -0
- package/esm/utils/getUIPath.js +37 -0
- package/esm/utils/getUIPath.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 -6
- package/styles/css/internal.css +159 -9
- package/styles/css/internal.css.map +1 -1
- package/styles/css/main.css +84 -7
- package/styles/css/main.css.map +1 -1
- package/styles/scss/internal.scss +85 -3
- package/styles/scss/main.scss +99 -16
- package/esm/internal/SearchResultsList.d.ts +0 -26
- package/esm/internal/SearchResultsList.d.ts.map +0 -1
- package/esm/internal/SearchResultsList.js +0 -18
- package/esm/internal/SearchResultsList.js.map +0 -1
- package/esm/internal/SemanticSearchOverlay.d.ts.map +0 -1
- package/esm/internal/SemanticSearchOverlay.js +0 -60
- package/esm/internal/SemanticSearchOverlay.js.map +0 -1
|
@@ -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,15 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { WrappedComponentProps } from "react-intl";
|
|
3
3
|
import { GenAISemanticSearchType, ISemanticSearchResultItem } from "@gooddata/sdk-model";
|
|
4
|
+
import { IAnalyticalBackend } from "@gooddata/sdk-backend-spi";
|
|
4
5
|
/**
|
|
5
6
|
* Props for the SemanticSearchOverlay component.
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
8
|
-
export type
|
|
9
|
+
export type SearchOverlayProps = WrappedComponentProps & {
|
|
9
10
|
/**
|
|
10
11
|
* A function called when the user selects an item from the search results.
|
|
11
12
|
*/
|
|
12
|
-
onSelect: (item: ISemanticSearchResultItem) => void;
|
|
13
|
+
onSelect: (item: ISemanticSearchResultItem, e: MouseEvent | KeyboardEvent, itemUrl?: string) => void;
|
|
13
14
|
/**
|
|
14
15
|
* An analytical backend to use for the search. Can be omitted and taken from context.
|
|
15
16
|
*/
|
|
@@ -36,5 +37,5 @@ export type SemanticSearchOverlayProps = {
|
|
|
36
37
|
* The internal version is meant to be used in an overlay inside the Header.
|
|
37
38
|
* @internal
|
|
38
39
|
*/
|
|
39
|
-
export declare const
|
|
40
|
-
//# sourceMappingURL=
|
|
40
|
+
export declare const SearchOverlay: React.FC<SearchOverlayProps>;
|
|
41
|
+
//# sourceMappingURL=SearchOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// (C) 2024 GoodData Corporation
|
|
2
|
+
import * as React from "react";
|
|
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";
|
|
11
|
+
/**
|
|
12
|
+
* A time in milliseconds to wait before sending a search request after the user stops typing.
|
|
13
|
+
*/
|
|
14
|
+
const DEBOUNCE = 300;
|
|
15
|
+
/**
|
|
16
|
+
* A height of the loading mask.
|
|
17
|
+
*/
|
|
18
|
+
const LOADING_HEIGHT = 100;
|
|
19
|
+
/**
|
|
20
|
+
* A width of the search drop-down.
|
|
21
|
+
*/
|
|
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 = [];
|
|
35
|
+
/**
|
|
36
|
+
* A component that allows users to search for insights, metrics, attributes, and other objects using semantic search.
|
|
37
|
+
* The internal version is meant to be used in an overlay inside the Header.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export const SearchOverlay = ({ onSelect, backend, workspace, objectTypes, deepSearch, limit = 6, intl, }) => {
|
|
41
|
+
// Input value handling
|
|
42
|
+
const [value, setValue, searchTerm, setImmediate] = useDebouncedState("", DEBOUNCE);
|
|
43
|
+
// Search results
|
|
44
|
+
const effectiveWorkspace = useWorkspaceStrict(workspace);
|
|
45
|
+
const { searchStatus, searchResults, searchError, relationships } = useSemanticSearch({
|
|
46
|
+
backend,
|
|
47
|
+
workspace: effectiveWorkspace,
|
|
48
|
+
searchTerm,
|
|
49
|
+
objectTypes,
|
|
50
|
+
deepSearch,
|
|
51
|
+
limit,
|
|
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]);
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
if (searchStatus === "error") {
|
|
91
|
+
// Report error to the console
|
|
92
|
+
// UI will display a generic error message
|
|
93
|
+
console.error(searchError);
|
|
94
|
+
}
|
|
95
|
+
}, [searchStatus, searchError]);
|
|
96
|
+
return (React.createElement("div", { className: "gd-semantic-search__overlay" },
|
|
97
|
+
React.createElement(Input, { className: "gd-semantic-search__overlay-input", autofocus: true, placeholder: intl.formatMessage({ id: "semantic-search.placeholder" }), isSearch: true, clearOnEsc: true, value: value, onChange: (e) => setValue(String(e)) }),
|
|
98
|
+
(() => {
|
|
99
|
+
switch (searchStatus) {
|
|
100
|
+
case "loading":
|
|
101
|
+
return React.createElement(LoadingMask, { width: SEARCH_OVERLAY_WIDTH, height: LOADING_HEIGHT });
|
|
102
|
+
case "error":
|
|
103
|
+
return (React.createElement("div", { className: "gd-semantic-search__overlay-error" },
|
|
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" }))));
|
|
108
|
+
case "success":
|
|
109
|
+
if (!searchResults.length) {
|
|
110
|
+
return (React.createElement("div", { className: "gd-semantic-search__overlay-no-results" },
|
|
111
|
+
React.createElement(FormattedMessage, { id: "semantic-search.no-results", values: { query: searchTerm } })));
|
|
112
|
+
}
|
|
113
|
+
return (React.createElement(SearchList, { items: searchResultsItems, width: SEARCH_OVERLAY_WIDTH, onSelect: onResultSelect, ItemComponent: AnnotatedResultsItem }));
|
|
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
|
|
119
|
+
default:
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
})()));
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=SearchOverlay.js.map
|
|
@@ -0,0 +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,gBAAgB,EAAyB,MAAM,YAAY,CAAC;AAGrE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,E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anticSearchResultItem } 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,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAO5F,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC5B,KAAK,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE;IAC9B,SAAS,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE;IACtC,EAAE,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,WAAW,CAAC,EACvD,QAAQ,EAAE,EAAE,IAAI,EAAE,EAClB,QAAQ,GACM;IACd,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC;IAEpD,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5B,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC;IAExE,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;IAEhF,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvC,OAAO,CACH;YACI,oBAAC,gBAAgB,IAAC,EAAE,EAAE,YAAY,GAAI;;YAEtC,oBAAC,gBAAgB,IAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAI;;YAExC,oBAAC,aAAa,IAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAC,SAAS,EAAC,MAAM,EAAC,SAAS,GAAG,CAClE,CACV,CAAC;IACN,CAAC;SAAM,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;QAC9B,OAAO,oBAAC,aAAa,IAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAC,SAAS,EAAC,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"}
|
package/esm/internal.d.ts
CHANGED
package/esm/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,cAAc,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,cAAc,kCAAkC,CAAC"}
|
package/esm/internal.js
CHANGED
package/esm/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC;;;;;GAKG;AAEH,cAAc,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC;;;;;GAKG;AAEH,cAAc,kCAAkC,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
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
11
|
import * as React_2 from 'react';
|
|
11
12
|
|
|
@@ -113,6 +114,7 @@ export declare type SemanticSearchInputResult = {
|
|
|
113
114
|
* The search results.
|
|
114
115
|
*/
|
|
115
116
|
searchResults: ISemanticSearchResultItem[];
|
|
117
|
+
relationships: ISemanticSearchRelationship[];
|
|
116
118
|
};
|
|
117
119
|
|
|
118
120
|
/**
|
|
@@ -128,7 +130,7 @@ export declare type SemanticSearchProps = SemanticSearchCoreProps & {
|
|
|
128
130
|
* calls the onSelect callback when Enter is pressed.
|
|
129
131
|
* @internal
|
|
130
132
|
*/
|
|
131
|
-
export declare const useListSelector: <T>(items: T[], onSelect: (item: T) => void) => [
|
|
133
|
+
export declare const useListSelector: <T>(items: T[], onSelect: (item: T, e: MouseEvent | KeyboardEvent) => void) => [T, (item: T) => void];
|
|
132
134
|
|
|
133
135
|
/**
|
|
134
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,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of objects that we can navigate to in UI.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export type UIPathObjectTypes = "dashboard" | "visualization" | "metric" | "dataset" | "date" | "fact" | "attribute" | "label";
|
|
6
|
+
/**
|
|
7
|
+
* Get the UI path for the given object type, object ID, and workspace ID.
|
|
8
|
+
* TODO - this logic should live in gdc-ui repo, would require refactoring of the sdk-ui-semantic-search
|
|
9
|
+
* - ui components need URL right away to be able to render native anchor tags
|
|
10
|
+
* - gdc-ui would need to inject the URL between the data is loaded and the render
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const getUIPath: (objectType: UIPathObjectTypes, objectId: string, workspaceId: string) => string;
|
|
14
|
+
//# sourceMappingURL=getUIPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUIPath.d.ts","sourceRoot":"","sources":["../../src/utils/getUIPath.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACvB,WAAW,GACX,eAAe,GACf,QAAQ,GACR,SAAS,GACT,MAAM,GACN,MAAM,GACN,WAAW,GACX,OAAO,CAAC;AAEd;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,eAAgB,iBAAiB,YAAY,MAAM,eAAe,MAAM,KAAG,MAqBhG,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// (C) 2024 GoodData Corporation
|
|
2
|
+
/**
|
|
3
|
+
* Get the UI path for the given object type, object ID, and workspace ID.
|
|
4
|
+
* TODO - this logic should live in gdc-ui repo, would require refactoring of the sdk-ui-semantic-search
|
|
5
|
+
* - ui components need URL right away to be able to render native anchor tags
|
|
6
|
+
* - gdc-ui would need to inject the URL between the data is loaded and the render
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const getUIPath = (objectType, objectId, workspaceId) => {
|
|
10
|
+
switch (objectType) {
|
|
11
|
+
case "dashboard":
|
|
12
|
+
return `/dashboards/#/workspace/${workspaceId}/dashboard/${objectId}`;
|
|
13
|
+
case "visualization":
|
|
14
|
+
return `/analyze/#/${workspaceId}/${objectId}/edit`;
|
|
15
|
+
case "metric":
|
|
16
|
+
return `/metrics/#/${workspaceId}/metric/${objectId}`;
|
|
17
|
+
case "dataset":
|
|
18
|
+
return `/modeler/#/${workspaceId}`; // TODO - deep links
|
|
19
|
+
case "attribute":
|
|
20
|
+
return `/modeler/#/${workspaceId}`; // TODO - deep links
|
|
21
|
+
case "label":
|
|
22
|
+
return `/modeler/#/${workspaceId}`; // TODO - deep links
|
|
23
|
+
case "fact":
|
|
24
|
+
return `/modeler/#/${workspaceId}`; // TODO - deep links
|
|
25
|
+
case "date":
|
|
26
|
+
return `/modeler/#/${workspaceId}`; // TODO - deep links
|
|
27
|
+
default:
|
|
28
|
+
return exhaustiveCheck(objectType);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Ensure exhaustive switch to prevent missing cases.
|
|
33
|
+
*/
|
|
34
|
+
const exhaustiveCheck = (x) => {
|
|
35
|
+
throw new Error(`Unknown item type ${x}`);
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=getUIPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUIPath.js","sourceRoot":"","sources":["../../src/utils/getUIPath.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAgBhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,UAA6B,EAAE,QAAgB,EAAE,WAAmB,EAAU,EAAE;IACtG,QAAQ,UAAU,EAAE,CAAC;QACjB,KAAK,WAAW;YACZ,OAAO,2BAA2B,WAAW,cAAc,QAAQ,EAAE,CAAC;QAC1E,KAAK,eAAe;YAChB,OAAO,cAAc,WAAW,IAAI,QAAQ,OAAO,CAAC;QACxD,KAAK,QAAQ;YACT,OAAO,cAAc,WAAW,WAAW,QAAQ,EAAE,CAAC;QAC1D,KAAK,SAAS;YACV,OAAO,cAAc,WAAW,EAAE,CAAC,CAAC,oBAAoB;QAC5D,KAAK,WAAW;YACZ,OAAO,cAAc,WAAW,EAAE,CAAC,CAAC,oBAAoB;QAC5D,KAAK,OAAO;YACR,OAAO,cAAc,WAAW,EAAE,CAAC,CAAC,oBAAoB;QAC5D,KAAK,MAAM;YACP,OAAO,cAAc,WAAW,EAAE,CAAC,CAAC,oBAAoB;QAC5D,KAAK,MAAM;YACP,OAAO,cAAc,WAAW,EAAE,CAAC,CAAC,oBAAoB;QAC5D;YACI,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;AACL,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,CAAQ,EAAS,EAAE;IACxC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC"}
|
|
@@ -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,GAA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AC,YAAY,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,SAAS,GAAI;YAC5E,oBAAC,MAAM,IACH,SAAS,EAAC,yCAAyC,EACnD,WAAW,EAAE,mBAAmB,EAChC,UAAU,EAAE,WAAW;gBAGvB,6BAAK,SAAS,EAAC,qDAAqD;oBAChE,oBAAC,UAAU,IAAC,OAAO,EAAC,IAAI,IAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAc;oBAC1D,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACjC,oBAAC,gBAAgB,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAC,oBAAoB,GAAG;oBACzD,oBAAC,UAAU,IAAC,OAAO,EAAE,GAAG,IAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAc;oBACxD,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CACxB,CACD,CACQ,CAClB,CACV,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,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,EAA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|
3
|
+
"version": "10.8.0-beta.0",
|
|
4
4
|
"description": "GoodData SDK TypeScript & React skeleton",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,10 +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-backend-spi": "10.8.0-
|
|
43
|
-
"@gooddata/sdk-ui-kit": "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"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
47
|
"react": "^16.10.0 || ^17.0.0 || ^18.0.0",
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
"stylelint": "^13.8.0",
|
|
83
84
|
"stylelint-checkstyle-formatter": "^0.1.2",
|
|
84
85
|
"stylelint-config-prettier": "^8.0.2",
|
|
85
|
-
"@gooddata/sdk-backend-mockingbird": "10.8.0-
|
|
86
|
+
"@gooddata/sdk-backend-mockingbird": "10.8.0-beta.0"
|
|
86
87
|
},
|
|
87
88
|
"scripts": {
|
|
88
89
|
"clean": "rm -rf ci dist esm coverage *.log styles/css tsconfig.tsbuildinfo",
|