@gooddata/sdk-ui-kit 11.64.0-alpha.6 → 11.64.1
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/@ui/@types/icon.d.ts +1 -1
- package/esm/@ui/@types/icon.d.ts.map +1 -1
- package/esm/@ui/@utils/matchesSearchQuery.d.ts +8 -0
- package/esm/@ui/@utils/matchesSearchQuery.d.ts.map +1 -0
- package/esm/@ui/@utils/matchesSearchQuery.js +18 -0
- package/esm/@ui/@utils/scrollIntoView.d.ts +13 -0
- package/esm/@ui/@utils/scrollIntoView.d.ts.map +1 -0
- package/esm/@ui/@utils/scrollIntoView.js +22 -0
- package/esm/@ui/UiIcon/icons.d.ts.map +1 -1
- package/esm/@ui/UiIcon/icons.js +1 -0
- package/esm/@ui/UiListbox/UiListbox.d.ts +15 -2
- package/esm/@ui/UiListbox/UiListbox.d.ts.map +1 -1
- package/esm/@ui/UiListbox/UiListbox.js +76 -9
- package/esm/@ui/UiListbox/types.d.ts +32 -0
- package/esm/@ui/UiListbox/types.d.ts.map +1 -1
- package/esm/@ui/UiSearchResultsAnnouncement/UiSearchResultsAnnouncement.d.ts +5 -1
- package/esm/@ui/UiSearchResultsAnnouncement/UiSearchResultsAnnouncement.d.ts.map +1 -1
- package/esm/@ui/UiSearchResultsAnnouncement/UiSearchResultsAnnouncement.js +4 -4
- package/esm/@ui/UiSearchableSelect/UiSearchableSelect.d.ts +28 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelect.d.ts.map +1 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelect.js +106 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectContext.d.ts +24 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectContext.d.ts.map +1 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectContext.js +10 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectDivider.d.ts +7 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectDivider.d.ts.map +1 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectDivider.js +9 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectItem.d.ts +29 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectItem.d.ts.map +1 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectItem.js +18 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectList.d.ts +18 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectList.d.ts.map +1 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectList.js +60 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectSearch.d.ts +13 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectSearch.d.ts.map +1 -0
- package/esm/@ui/UiSearchableSelect/UiSearchableSelectSearch.js +82 -0
- package/esm/@ui/UiSearchableSelect/searchableSelectBem.d.ts +2 -0
- package/esm/@ui/UiSearchableSelect/searchableSelectBem.d.ts.map +1 -0
- package/esm/@ui/UiSearchableSelect/searchableSelectBem.js +3 -0
- package/esm/@ui/UiTextInput/UiTextInput.d.ts +8 -2
- package/esm/@ui/UiTextInput/UiTextInput.d.ts.map +1 -1
- package/esm/@ui/UiTextInput/UiTextInput.js +3 -3
- package/esm/Header/Header.d.ts.map +1 -1
- package/esm/Header/Header.js +11 -2
- package/esm/Header/Header.test.helpers.d.ts +2 -1
- package/esm/Header/Header.test.helpers.d.ts.map +1 -1
- package/esm/Header/Header.test.helpers.js +34 -26
- package/esm/Header/HeaderAccount.js +5 -2
- package/esm/Header/generateHeaderAccountMenuItems.d.ts +10 -2
- package/esm/Header/generateHeaderAccountMenuItems.d.ts.map +1 -1
- package/esm/Header/generateHeaderAccountMenuItems.js +6 -1
- package/esm/index.d.ts +7 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +7 -1
- package/esm/sdk-ui-kit.d.ts +148 -6
- package/package.json +11 -11
- package/src/@ui/UiChip/UiChip.scss +2 -3
- package/src/@ui/UiFloatingPanel/UiFloatingPanel.scss +1 -0
- package/src/@ui/UiListbox/UiListbox.scss +15 -4
- package/src/@ui/UiModalDialog/UiModalDialog.scss +1 -0
- package/src/@ui/UiSearchableSelect/UiSearchableSelect.scss +118 -0
- package/src/@ui/UiTextInput/UiTextInput.scss +36 -5
- package/src/@ui/index.scss +1 -0
- package/styles/css/header.css +35 -0
- package/styles/css/header.css.map +1 -1
- package/styles/css/main.css +158 -7
- package/styles/css/main.css.map +1 -1
- package/styles/scss/header.scss +45 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// (C) 2026 GoodData Corporation
|
|
3
|
+
import { Children, Fragment, isValidElement, useId, useState } from "react";
|
|
4
|
+
import { accessibilityConfigToAttributes } from "../../typings/utilities.js";
|
|
5
|
+
import { matchesSearchQuery } from "../@utils/matchesSearchQuery.js";
|
|
6
|
+
import { UiDropdown } from "../UiDropdown/UiDropdown.js";
|
|
7
|
+
import { UiIcon } from "../UiIcon/UiIcon.js";
|
|
8
|
+
import { getNextFocusableItemId } from "../UiListbox/UiListbox.js";
|
|
9
|
+
import { e } from "./searchableSelectBem.js";
|
|
10
|
+
import { UiSearchableSelectContext } from "./UiSearchableSelectContext.js";
|
|
11
|
+
import { UiSearchableSelectDivider } from "./UiSearchableSelectDivider.js";
|
|
12
|
+
import { getUiSearchableSelectItemDescriptor } from "./UiSearchableSelectItem.js";
|
|
13
|
+
import { findUiSearchableSelectListRenderItem } from "./UiSearchableSelectList.js";
|
|
14
|
+
const BODY_WIDTH = 300;
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export function UiSearchableSelect({ accessibilityConfig, children, items, filter, placeholder, defaultOpen = false, value, onChange, }) {
|
|
19
|
+
const buttonId = useId();
|
|
20
|
+
// the button's name is its value followed by its label ("Item 12 Language"), like in React Aria's Select
|
|
21
|
+
const valueId = useId();
|
|
22
|
+
// shared, so that the search can point at the highlighted option (aria-activedescendant)
|
|
23
|
+
const listboxId = useId();
|
|
24
|
+
const [query, setQuery] = useState("");
|
|
25
|
+
// built here, where the items are typed, also to show the selected item while the list is not rendered
|
|
26
|
+
const renderItem = findUiSearchableSelectListRenderItem(children);
|
|
27
|
+
// one group per item: the item and the dividers rendered with it
|
|
28
|
+
const listboxItemGroups = items.map((item) => renderItem ? getListboxItems(renderItem(item), item) : []);
|
|
29
|
+
const selectedItem = listboxItemGroups
|
|
30
|
+
.flat()
|
|
31
|
+
.find((item) => item.type === "interactive" && item.id === value);
|
|
32
|
+
const filterListboxItems = (searchQuery) => listboxItemGroups
|
|
33
|
+
.filter((group) => !searchQuery ||
|
|
34
|
+
group.some((item) => item.type === "interactive" &&
|
|
35
|
+
(filter
|
|
36
|
+
? filter(item.data, searchQuery)
|
|
37
|
+
: matchesSearchQuery(item.stringTitle, searchQuery))))
|
|
38
|
+
.flat();
|
|
39
|
+
const filteredListboxItems = filterListboxItems(query);
|
|
40
|
+
// the highlight the search moves and the list shows; each opening starts on the selected item
|
|
41
|
+
const [focusedItemId, setFocusedItemId] = useState(value);
|
|
42
|
+
// the highlight shows right away, but the search points at it only after the first arrow key or hover, so
|
|
43
|
+
// that screen readers announce the search on open (see the tests)
|
|
44
|
+
const [isActiveDescendantShown, setIsActiveDescendantShown] = useState(false);
|
|
45
|
+
// while searching, the highlight moves to the first match, like in React Aria; without a query, it goes
|
|
46
|
+
// back to the selected item
|
|
47
|
+
const changeQuery = (nextQuery) => {
|
|
48
|
+
setQuery(nextQuery);
|
|
49
|
+
setFocusedItemId(nextQuery
|
|
50
|
+
? getNextFocusableItemId({
|
|
51
|
+
items: filterListboxItems(nextQuery),
|
|
52
|
+
focusedItemId: null,
|
|
53
|
+
direction: "down",
|
|
54
|
+
})
|
|
55
|
+
: value);
|
|
56
|
+
};
|
|
57
|
+
return (_jsx(UiDropdown, { width: BODY_WIDTH, fullWidthButton: true, autofocusOnOpen: true,
|
|
58
|
+
// like a native <select>, tab closes the popup and moves on from the button: the tab out focuses
|
|
59
|
+
// the button (returnFocusTo) before the browser moves the focus
|
|
60
|
+
enableFocusTrap: false, returnFocusTo: buttonId, offset: 4, openOnInit: defaultOpen, accessibilityConfig: { popupRole: "listbox" },
|
|
61
|
+
// a new opening starts with all items, like TimezoneSelect
|
|
62
|
+
onOpen: () => {
|
|
63
|
+
setFocusedItemId(value);
|
|
64
|
+
setIsActiveDescendantShown(false);
|
|
65
|
+
}, onClose: () => setQuery(""), renderButton: ({ ref, isOpen, toggleDropdown, ariaAttributes }) => (_jsxs("button", { className: e("button"),
|
|
66
|
+
// UiDropdown types its ref as RefObject<HTMLElement>, which a <button> doesn't accept;
|
|
67
|
+
// a callback ref assigns the mounted button to it without a cast
|
|
68
|
+
ref: (button) => {
|
|
69
|
+
if (button) {
|
|
70
|
+
ref.current = button;
|
|
71
|
+
}
|
|
72
|
+
}, type: "button", onClick: toggleDropdown, ...ariaAttributes, ...accessibilityConfigToAttributes(accessibilityConfig), id: buttonId, "aria-controls": isOpen ? listboxId : undefined, "aria-labelledby": `${valueId} ${accessibilityConfig.ariaLabelledBy ?? buttonId}`, children: [_jsx("span", { id: valueId, className: e("button-title"), children: selectedItem?.stringTitle ?? placeholder }), _jsx("div", { className: e("button-icon"), children: _jsx(UiIcon, { type: isOpen ? "navigateUp" : "navigateDown", size: 14, disableAnimation: true }) })] })), renderBody: ({ ariaAttributes, closeDropdown }) => (_jsx(UiSearchableSelectContext.Provider, { value: {
|
|
73
|
+
listboxItems: filteredListboxItems,
|
|
74
|
+
query,
|
|
75
|
+
setQuery: changeQuery,
|
|
76
|
+
buttonId,
|
|
77
|
+
listboxId,
|
|
78
|
+
focusedItemId,
|
|
79
|
+
setFocusedItemId,
|
|
80
|
+
isActiveDescendantShown,
|
|
81
|
+
setIsActiveDescendantShown,
|
|
82
|
+
value,
|
|
83
|
+
onChange,
|
|
84
|
+
closeDropdown,
|
|
85
|
+
}, children: _jsx("div", { className: e("body"), ...ariaAttributes, children: children }) })) }));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Reads what the item render function returned: an item alone, or an item in a fragment with dividers
|
|
89
|
+
* (`<><UiSearchableSelectItem … /><UiSearchableSelectDivider /></>`), in the order they were written.
|
|
90
|
+
*/
|
|
91
|
+
function getListboxItems(node, data) {
|
|
92
|
+
const nodes = isValidElement(node) && node.type === Fragment
|
|
93
|
+
? Children.toArray(node.props.children)
|
|
94
|
+
: [node];
|
|
95
|
+
const listboxItems = nodes.flatMap((child) => {
|
|
96
|
+
const descriptor = getUiSearchableSelectItemDescriptor(child);
|
|
97
|
+
if (descriptor) {
|
|
98
|
+
return [{ type: "interactive", ...descriptor, data }];
|
|
99
|
+
}
|
|
100
|
+
return isValidElement(child) && child.type === UiSearchableSelectDivider
|
|
101
|
+
? [{ type: "separator" }]
|
|
102
|
+
: [];
|
|
103
|
+
});
|
|
104
|
+
// dividers belong to an item, so without exactly one item there is nothing to show
|
|
105
|
+
return listboxItems.filter((item) => item.type === "interactive").length === 1 ? listboxItems : [];
|
|
106
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type IUiListboxItem } from "../UiListbox/types.js";
|
|
2
|
+
interface IUiSearchableSelectContext {
|
|
3
|
+
/** The items matching the search query, with the dividers rendered with them. */
|
|
4
|
+
listboxItems: IUiListboxItem<unknown>[];
|
|
5
|
+
query: string;
|
|
6
|
+
setQuery: (query: string) => void;
|
|
7
|
+
/** The id of the trigger button, which labels the listbox. */
|
|
8
|
+
buttonId: string;
|
|
9
|
+
/** The id of the listbox, which the search points into with aria-activedescendant. */
|
|
10
|
+
listboxId: string;
|
|
11
|
+
/** The highlighted option: the search moves it, the list shows it. */
|
|
12
|
+
focusedItemId: string | null;
|
|
13
|
+
setFocusedItemId: (focusedItemId: string | null) => void;
|
|
14
|
+
/** Whether the search points at the highlighted option (aria-activedescendant). */
|
|
15
|
+
isActiveDescendantShown: boolean;
|
|
16
|
+
setIsActiveDescendantShown: (isActiveDescendantShown: boolean) => void;
|
|
17
|
+
value: string | null;
|
|
18
|
+
onChange: (value: string) => void;
|
|
19
|
+
closeDropdown: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const UiSearchableSelectContext: import("react").Context<IUiSearchableSelectContext | null>;
|
|
22
|
+
export declare function useUiSearchableSelectContext(): IUiSearchableSelectContext;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=UiSearchableSelectContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiSearchableSelectContext.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiSearchableSelect/UiSearchableSelectContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,UAAU,0BAA0B;IAChC,iFAAiF;IACjF,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB,EAAE,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzD,mFAAmF;IACnF,uBAAuB,EAAE,OAAO,CAAC;IACjC,0BAA0B,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,IAAI,CAAC;IACvE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,aAAa,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,eAAO,MAAM,yBAAyB,4DAAyD,CAAC;AAEhG,wBAAgB,4BAA4B,IAAI,0BAA0B,CAMzE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
export const UiSearchableSelectContext = createContext(null);
|
|
4
|
+
export function useUiSearchableSelectContext() {
|
|
5
|
+
const context = useContext(UiSearchableSelectContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error("`useUiSearchableSelectContext` must be used within `UiSearchableSelect`");
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiSearchableSelectDivider.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiSearchableSelect/UiSearchableSelectDivider.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,yBAAyB,SAExC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface IUiSearchableSelectItemProps {
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* The language of the item's text when it differs from the page, e.g. "de" for "Deutsch". Set as the
|
|
9
|
+
* option's `lang` attribute, like on a native `<option>`.
|
|
10
|
+
*/
|
|
11
|
+
lang?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The option's title, shown in the list and the button and matched by the search.
|
|
14
|
+
*/
|
|
15
|
+
children: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Describes an option and renders nothing: UiSearchableSelectList reads its props and UiListbox renders
|
|
19
|
+
* the option, like the `Item` of React Stately collections.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function UiSearchableSelectItem(_props: IUiSearchableSelectItemProps): null;
|
|
24
|
+
export declare function getUiSearchableSelectItemDescriptor(node: ReactNode): {
|
|
25
|
+
id: string;
|
|
26
|
+
stringTitle: string;
|
|
27
|
+
lang?: string;
|
|
28
|
+
} | undefined;
|
|
29
|
+
//# sourceMappingURL=UiSearchableSelectItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiSearchableSelectItem.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiSearchableSelect/UiSearchableSelectItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,4BAA4B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,4BAA4B,QAE1E;AAED,wBAAgB,mCAAmC,CAC/C,IAAI,EAAE,SAAS,GAChB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAOhE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { isValidElement } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Describes an option and renders nothing: UiSearchableSelectList reads its props and UiListbox renders
|
|
5
|
+
* the option, like the `Item` of React Stately collections.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function UiSearchableSelectItem(_props) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
export function getUiSearchableSelectItemDescriptor(node) {
|
|
13
|
+
if (!isValidElement(node) || node.type !== UiSearchableSelectItem) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const { id, lang, children } = node.props;
|
|
17
|
+
return { id, lang, stringTitle: children };
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface IUiSearchableSelectListProps<T> {
|
|
6
|
+
children: (item: T) => ReactNode;
|
|
7
|
+
noItemsText?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function UiSearchableSelectList<T>({ noItemsText }: IUiSearchableSelectListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* Finds the item render function of the UiSearchableSelectList among the select's children. The root needs it
|
|
15
|
+
* to show the selected item on the button while the list is not rendered (the dropdown is closed).
|
|
16
|
+
*/
|
|
17
|
+
export declare function findUiSearchableSelectListRenderItem(children: ReactNode): ((item: unknown) => ReactNode) | undefined;
|
|
18
|
+
//# sourceMappingURL=UiSearchableSelectList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiSearchableSelectList.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiSearchableSelect/UiSearchableSelectList.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AAiBjE;;GAEG;AACH,MAAM,WAAW,4BAA4B,CAAC,CAAC;IAC3C,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,4BAA4B,CAAC,CAAC,CAAC,2CA4DzF;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAChD,QAAQ,EAAE,SAAS,GACpB,CAAC,CAAC,IAAI,EAAE,OAAO,KAAK,SAAS,CAAC,GAAG,SAAS,CAgB5C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// (C) 2026 GoodData Corporation
|
|
3
|
+
import { Fragment, isValidElement } from "react";
|
|
4
|
+
import { defineMessages, useIntl } from "react-intl";
|
|
5
|
+
import { UiListbox } from "../UiListbox/UiListbox.js";
|
|
6
|
+
import { UiSearchResultsAnnouncement } from "../UiSearchResultsAnnouncement/UiSearchResultsAnnouncement.js";
|
|
7
|
+
import { e } from "./searchableSelectBem.js";
|
|
8
|
+
import { useUiSearchableSelectContext } from "./UiSearchableSelectContext.js";
|
|
9
|
+
const messages = defineMessages({
|
|
10
|
+
noItems: { id: "uiKit.searchableSelect.noItems" },
|
|
11
|
+
});
|
|
12
|
+
const LIST_MAX_HEIGHT = 280;
|
|
13
|
+
// `children` is read by UiSearchableSelect (findUiSearchableSelectListRenderItem), which builds the items
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export function UiSearchableSelectList({ noItemsText }) {
|
|
18
|
+
const intl = useIntl();
|
|
19
|
+
const { listboxItems, query, buttonId, listboxId, focusedItemId, setFocusedItemId, setIsActiveDescendantShown, value, onChange, closeDropdown, } = useUiSearchableSelectContext();
|
|
20
|
+
const noItemsMessage = noItemsText ?? intl.formatMessage(messages.noItems);
|
|
21
|
+
// the results of the search, without the dividers
|
|
22
|
+
const options = listboxItems.filter((item) => item.type === "interactive");
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsx(UiSearchResultsAnnouncement, { totalResults: query ? options.length : undefined, resultValues: options.map((option) => option.stringTitle), noResultsText: noItemsMessage }), _jsx(UiListbox, { items: listboxItems, selectedItemId: value ?? undefined, onSelect: (item) => {
|
|
24
|
+
// like a native <select>, picking the already selected item only closes the list
|
|
25
|
+
if (item.id !== value) {
|
|
26
|
+
onChange(item.id);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
// UiListbox closes after a selection (shouldCloseOnSelect defaults to true) through onClose
|
|
30
|
+
onClose: closeDropdown,
|
|
31
|
+
// selects on clicks on the option element itself too (tests, assistive technologies)
|
|
32
|
+
shouldSelectOnOptionClick: true,
|
|
33
|
+
// the highlight is moved by the search, which keeps focus (virtual focus)
|
|
34
|
+
focusedItemId: focusedItemId,
|
|
35
|
+
// hovering moves the same highlight, so keyboard and mouse don't highlight two rows, and like
|
|
36
|
+
// an arrow key, it lets the search point at it
|
|
37
|
+
onFocusedItemIdChange: (itemId) => {
|
|
38
|
+
setFocusedItemId(itemId);
|
|
39
|
+
setIsActiveDescendantShown(true);
|
|
40
|
+
}, isCompact: true, padding: "none", maxHeight: LIST_MAX_HEIGHT, ariaAttributes: { id: listboxId, "aria-labelledby": buttonId }, supportedViews: ["desktop"] }), listboxItems.length ? null : _jsx("div", { className: e("no-items"), children: noItemsMessage })] }));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Finds the item render function of the UiSearchableSelectList among the select's children. The root needs it
|
|
44
|
+
* to show the selected item on the button while the list is not rendered (the dropdown is closed).
|
|
45
|
+
*/
|
|
46
|
+
export function findUiSearchableSelectListRenderItem(children) {
|
|
47
|
+
for (const child of Array.isArray(children) ? children : [children]) {
|
|
48
|
+
if (isValidElement(child) &&
|
|
49
|
+
child.type === UiSearchableSelectList) {
|
|
50
|
+
return child.props.children;
|
|
51
|
+
}
|
|
52
|
+
if (isValidElement(child) && child.type === Fragment) {
|
|
53
|
+
const renderItem = findUiSearchableSelectListRenderItem(child.props.children);
|
|
54
|
+
if (renderItem) {
|
|
55
|
+
return renderItem;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type IAccessibilityConfigBase } from "../../typings/accessibility.js";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface IUiSearchableSelectSearchProps {
|
|
6
|
+
accessibilityConfig?: IAccessibilityConfigBase;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function UiSearchableSelectSearch({ accessibilityConfig, placeholder, }: IUiSearchableSelectSearchProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=UiSearchableSelectSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiSearchableSelectSearch.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiSearchableSelect/UiSearchableSelectSearch.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAa/E;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC3C,mBAAmB,CAAC,EAAE,wBAAwB,CAAC;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,EACrC,mBAAwB,EACxB,WAAW,GACd,EAAE,8BAA8B,2CA8FhC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// (C) 2026 GoodData Corporation
|
|
3
|
+
import { defineMessages, useIntl } from "react-intl";
|
|
4
|
+
import { useDebounce } from "@gooddata/sdk-ui";
|
|
5
|
+
import { getNextFocusableItemId, makeItemId } from "../UiListbox/UiListbox.js";
|
|
6
|
+
import { UiTextInput } from "../UiTextInput/UiTextInput.js";
|
|
7
|
+
import { e } from "./searchableSelectBem.js";
|
|
8
|
+
import { useUiSearchableSelectContext } from "./UiSearchableSelectContext.js";
|
|
9
|
+
const messages = defineMessages({
|
|
10
|
+
searchPlaceholder: { id: "uiKit.searchableSelect.searchPlaceholder" },
|
|
11
|
+
searchAriaLabel: { id: "uiKit.searchableSelect.searchAriaLabel" },
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function UiSearchableSelectSearch({ accessibilityConfig = {}, placeholder, }) {
|
|
17
|
+
const intl = useIntl();
|
|
18
|
+
const { query, setQuery, listboxItems, listboxId, focusedItemId, setFocusedItemId, isActiveDescendantShown, setIsActiveDescendantShown, value, onChange, closeDropdown, } = useUiSearchableSelectContext();
|
|
19
|
+
// while typing, the search points at the highlight only a moment after the last key, like in React Aria,
|
|
20
|
+
// so that screen readers read the typed letter first
|
|
21
|
+
const showActiveDescendantLater = useDebounce(() => setIsActiveDescendantShown(true), 300);
|
|
22
|
+
const changeQuery = (nextQuery) => {
|
|
23
|
+
setQuery(nextQuery);
|
|
24
|
+
setIsActiveDescendantShown(false);
|
|
25
|
+
// without a query, it's like a fresh opening again: the search points at nothing until an arrow key
|
|
26
|
+
if (nextQuery) {
|
|
27
|
+
showActiveDescendantLater();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
showActiveDescendantLater.cancel();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
// focus stays in the search, which moves the highlight that the list shows (virtual focus)
|
|
34
|
+
const activeItem = listboxItems.find((item) => item.type === "interactive" && item.id === focusedItemId);
|
|
35
|
+
return (_jsx("div", { className: e("search"), children: _jsx(UiTextInput, { value: query, onChange: changeQuery, onKeyDown: (event) => {
|
|
36
|
+
// while an input method composes text (e.g. Japanese), the keys are its own; Safari reports
|
|
37
|
+
// the key that ends the composition after it, with only the keyCode 229 left
|
|
38
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
42
|
+
// keeps the caret where it is
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
const direction = event.key === "ArrowDown" ? "down" : "up";
|
|
45
|
+
setIsActiveDescendantShown(true);
|
|
46
|
+
setFocusedItemId(getNextFocusableItemId({ items: listboxItems, focusedItemId, direction }));
|
|
47
|
+
}
|
|
48
|
+
else if (event.key === "Enter" && activeItem) {
|
|
49
|
+
// like escape, the event ends here, so that e.g. a surrounding dialog doesn't submit
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
event.stopPropagation();
|
|
52
|
+
// like a native <select>, picking the already selected item only closes the list
|
|
53
|
+
if (activeItem.id !== value) {
|
|
54
|
+
onChange(activeItem.id);
|
|
55
|
+
}
|
|
56
|
+
closeDropdown();
|
|
57
|
+
}
|
|
58
|
+
else if (event.key === "Escape") {
|
|
59
|
+
// the first escape clears the query, the next one closes the list; the event ends here,
|
|
60
|
+
// so that e.g. a surrounding dialog doesn't close too
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
if (query) {
|
|
64
|
+
changeQuery("");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
closeDropdown();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, placeholder: placeholder ?? intl.formatMessage(messages.searchPlaceholder), iconBefore: "search", size: "small", accessibilityConfig: {
|
|
71
|
+
ariaLabel: intl.formatMessage(messages.searchAriaLabel),
|
|
72
|
+
...accessibilityConfig,
|
|
73
|
+
// a combobox that filters the list it controls; the list is shown while the search is
|
|
74
|
+
role: "combobox",
|
|
75
|
+
ariaExpanded: true,
|
|
76
|
+
ariaControls: listboxId,
|
|
77
|
+
ariaAutocomplete: "list",
|
|
78
|
+
ariaActiveDescendant: isActiveDescendantShown
|
|
79
|
+
? makeItemId(listboxId, activeItem)
|
|
80
|
+
: undefined,
|
|
81
|
+
} }) }));
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchableSelectBem.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiSearchableSelect/searchableSelectBem.ts"],"names":[],"mappings":"AAIA,eAAO,MAAQ,CAAC,6DAAE,CAAC,4EAAuC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type FocusEventHandler, type KeyboardEventHandler, type MouseEventHandler, type Ref } from "react";
|
|
2
2
|
import { type IAccessibilityConfigBase } from "../../typings/accessibility.js";
|
|
3
3
|
import { type IconType } from "../@types/icon.js";
|
|
4
|
+
import { type SizeMedium, type SizeSmall } from "../@types/size.js";
|
|
4
5
|
/**
|
|
5
6
|
* Clickable trailing icon button (e.g. a clear button). Bundles its own
|
|
6
7
|
* accessible name so the button can never be rendered unnamed.
|
|
@@ -27,6 +28,11 @@ export interface IUiTextInputProps {
|
|
|
27
28
|
onChange: (next: string) => void;
|
|
28
29
|
/** Optional label rendered above the input. */
|
|
29
30
|
label?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Height of the field: `"medium"` is 32px, `"small"` is 27px with smaller text.
|
|
33
|
+
* Defaults to `"medium"`.
|
|
34
|
+
*/
|
|
35
|
+
size?: SizeSmall | SizeMedium;
|
|
30
36
|
/** Placeholder shown when the input is empty. */
|
|
31
37
|
placeholder?: string;
|
|
32
38
|
/** Optional icon rendered inside the input at the start. */
|
|
@@ -69,10 +75,10 @@ export interface IUiTextInputProps {
|
|
|
69
75
|
}
|
|
70
76
|
/**
|
|
71
77
|
* Single-line text input with optional label and leading / trailing icons.
|
|
72
|
-
* The kit's canonical text-field rendering: 32px height, 1px
|
|
78
|
+
* The kit's canonical text-field rendering: 32px height (27px when `size` is `"small"`), 1px
|
|
73
79
|
* complementary-4 border, inset shadow, primary-blue focus state.
|
|
74
80
|
*
|
|
75
81
|
* @internal
|
|
76
82
|
*/
|
|
77
|
-
export declare function UiTextInput({ type, value, onChange, label, placeholder, iconBefore, iconAfter, onIconAfter, accessibilityConfig, isError, disabled, autoFocus, onKeyDown, onFocus, onBlur, onClick, dataTestId, inputRef, wrapperRef, name, autoComplete, autoCapitalize, autoCorrect, }: IUiTextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
export declare function UiTextInput({ type, value, onChange, label, size, placeholder, iconBefore, iconAfter, onIconAfter, accessibilityConfig, isError, disabled, autoFocus, onKeyDown, onFocus, onBlur, onClick, dataTestId, inputRef, wrapperRef, name, autoComplete, autoCapitalize, autoCorrect, }: IUiTextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
78
84
|
//# sourceMappingURL=UiTextInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiTextInput.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiTextInput/UiTextInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,GAAG,EAEX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"UiTextInput.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiTextInput/UiTextInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,GAAG,EAEX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOpE;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IACxC,uCAAuC;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf,sBAAsB;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;IAC3C,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9B,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB,mFAAmF;IACnF,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,2BAA2B,CAAC;IAC1C,2DAA2D;IAC3D,mBAAmB,CAAC,EAAE,wBAAwB,CAAC;IAC/C,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gFAAgF;IAChF,SAAS,CAAC,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACnD,sCAAsC;IACtC,OAAO,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,sCAAsC;IACtC,MAAM,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC7C,sCAAsC;IACtC,OAAO,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACjC,yFAAyF;IACzF,UAAU,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EACxB,IAAa,EACb,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAe,EACf,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,OAAe,EACf,QAAgB,EAChB,SAAiB,EACjB,SAAS,EACT,OAAO,EACP,MAAM,EACN,OAAO,EACP,UAAU,EACV,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,WAAW,GACd,EAAE,iBAAiB,2CA6DnB"}
|
|
@@ -8,16 +8,16 @@ import { UiIconButton } from "../UiIconButton/UiIconButton.js";
|
|
|
8
8
|
const { b, e } = bem("gd-ui-kit-text-input");
|
|
9
9
|
/**
|
|
10
10
|
* Single-line text input with optional label and leading / trailing icons.
|
|
11
|
-
* The kit's canonical text-field rendering: 32px height, 1px
|
|
11
|
+
* The kit's canonical text-field rendering: 32px height (27px when `size` is `"small"`), 1px
|
|
12
12
|
* complementary-4 border, inset shadow, primary-blue focus state.
|
|
13
13
|
*
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
export function UiTextInput({ type = "text", value, onChange, label, placeholder, iconBefore, iconAfter, onIconAfter, accessibilityConfig, isError = false, disabled = false, autoFocus = false, onKeyDown, onFocus, onBlur, onClick, dataTestId, inputRef, wrapperRef, name, autoComplete, autoCapitalize, autoCorrect, }) {
|
|
16
|
+
export function UiTextInput({ type = "text", value, onChange, label, size = "medium", placeholder, iconBefore, iconAfter, onIconAfter, accessibilityConfig, isError = false, disabled = false, autoFocus = false, onKeyDown, onFocus, onBlur, onClick, dataTestId, inputRef, wrapperRef, name, autoComplete, autoCapitalize, autoCorrect, }) {
|
|
17
17
|
const id = useId();
|
|
18
18
|
const { ariaLabel, ...restA11y } = accessibilityConfig ?? {};
|
|
19
19
|
// When a visible <label> is present, the label provides the accessible name;
|
|
20
20
|
// forwarding aria-label would override it (WCAG name-in-name mismatch).
|
|
21
21
|
const inputA11y = label ? restA11y : { ...restA11y, ariaLabel };
|
|
22
|
-
return (_jsxs("div", { ref: wrapperRef, className: b(), children: [label ? (_jsx("label", { className: e("label"), htmlFor: id, children: label })) : null, _jsxs("div", { className: e("field", { disabled, error: isError }), children: [iconBefore ? (_jsx("span", { className: e("icon-before"), children: _jsx(UiIcon, { type: iconBefore, size: 14
|
|
22
|
+
return (_jsxs("div", { ref: wrapperRef, className: b(), children: [label ? (_jsx("label", { className: e("label"), htmlFor: id, children: label })) : null, _jsxs("div", { className: e("field", { disabled, error: isError, size }), children: [iconBefore ? (_jsx("span", { className: e("icon-before"), children: _jsx(UiIcon, { type: iconBefore, size: 14 }) })) : null, _jsx("input", { ref: inputRef, id: id, name: name, type: type, className: e("input"), value: value, placeholder: placeholder, disabled: disabled, autoFocus: autoFocus, autoComplete: autoComplete, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, "data-testid": dataTestId, onChange: (event) => onChange(event.target.value), onKeyDown: onKeyDown, onFocus: onFocus, onBlur: onBlur, onClick: onClick, "aria-invalid": isError || undefined, ...accessibilityConfigToAttributes(inputA11y) }), onIconAfter ? (_jsx("span", { className: e("icon-after"), children: _jsx(UiIconButton, { icon: onIconAfter.icon, size: "xxsmall", variant: "tertiary", onClick: onIconAfter.onClick, isDisabled: disabled, label: onIconAfter.ariaLabel, iconColor: "complementary-6" }) })) : iconAfter ? (_jsx("span", { className: e("icon-after"), children: _jsx(UiIcon, { type: iconAfter, size: 14 }) })) : null] })] }));
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/Header/Header.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/Header/Header.tsx"],"names":[],"mappings":"AA4BA,OAAO,EAAE,KAAK,eAAe,EAA8C,MAAM,cAAc,CAAC;AAyBhG;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACtB,QAAc,EACd,gBAAqB,EACrB,aAAkB,EAClB,eAAoB,EACpB,MAAM,EACN,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,EACN,kBAAkB,EAClB,QAAQ,EACR,2BAA2B,EAAE,iBAAiB,EAC9C,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,UAAU,EACV,eAAe,EACf,WAAW,EACX,eAAe,GAClB,EAAE,eAAe,2CA6jBjB"}
|
package/esm/Header/Header.js
CHANGED
|
@@ -7,12 +7,13 @@ import { debounce } from "lodash-es";
|
|
|
7
7
|
import { FormattedMessage, defineMessage, defineMessages, useIntl } from "react-intl";
|
|
8
8
|
import { v4 as uuid } from "uuid";
|
|
9
9
|
import { useTheme } from "@gooddata/sdk-ui-theme-provider";
|
|
10
|
+
import { UiIcon } from "../@ui/UiIcon/UiIcon.js";
|
|
10
11
|
import { Icon } from "../Icon/Icon.js";
|
|
11
12
|
import { Overlay } from "../Overlay/Overlay.js";
|
|
12
13
|
import { Typography } from "../Typography/Typography.js";
|
|
13
14
|
import { removeFromDom } from "../utils/domUtilities.js";
|
|
14
15
|
import { addCssToStylesheet } from "./addCssToStylesheet.js";
|
|
15
|
-
import { LOGOUT_MENU_ITEM_ID } from "./generateHeaderAccountMenuItems.js";
|
|
16
|
+
import { LANGUAGE_MENU_ITEM_ID, LOGOUT_MENU_ITEM_ID } from "./generateHeaderAccountMenuItems.js";
|
|
16
17
|
import { HeaderAccount } from "./HeaderAccount.js";
|
|
17
18
|
import { HeaderChatButton } from "./HeaderChatButton.js";
|
|
18
19
|
import { createHeaderCssRules } from "./headerCss.js";
|
|
@@ -299,13 +300,21 @@ export function AppHeader({ logoHref = "/", accountMenuItems = [], helpMenuItems
|
|
|
299
300
|
onMenuItemClick?.(logoutMenuItem, e);
|
|
300
301
|
}, children: [_jsx(LogoutIcon, { className: "gd-icon-logout", color: theme?.palette?.complementary?.c0 }), _jsx("span", { className: "gd-button-text", children: _jsx(FormattedMessage, { id: "gs.header.logout" }) })] })) : (false);
|
|
301
302
|
};
|
|
303
|
+
const renderLanguageButton = () => {
|
|
304
|
+
const languageMenuItem = accountMenuItems.find((item) => item.key === LANGUAGE_MENU_ITEM_ID);
|
|
305
|
+
return languageMenuItem ? (_jsxs("button", { type: "button", className: "gd-header-menu-vertical-bottom-item gd-header-language-button s-language", "aria-haspopup": "dialog", onClick: (e) => {
|
|
306
|
+
// the menu closes first, so that the dialog the item opens isn't under it
|
|
307
|
+
setOverlayMenu(false);
|
|
308
|
+
onMenuItemClick?.(languageMenuItem, e);
|
|
309
|
+
}, children: [_jsx(UiIcon, { type: "globe", size: 20, color: "currentColor" }), _jsx("span", { className: "gd-header-language-label", children: _jsx(FormattedMessage, { id: languageMenuItem.key }) }), _jsx(UiIcon, { type: "navigateRight", size: 12, color: "currentColor" })] })) : null;
|
|
310
|
+
};
|
|
302
311
|
const renderVerticalMenu = () => {
|
|
303
312
|
const menuItemsGroupsToRender = state.isHelpMenuOpen
|
|
304
313
|
? [[getHelpMenuLink("gd-icon-header-help-back"), ...helpMenuItems]]
|
|
305
314
|
: showStaticHelpMenu
|
|
306
315
|
? [[getHelpMenuLink()]]
|
|
307
316
|
: addHelpItemGroup(addAdditionalItems(menuItemsGroups));
|
|
308
|
-
return (_jsxs("div", { className: "gd-header-menu-vertical-wrapper", children: [_jsx("div", { className: "gd-header-menu-vertical-header", children: _jsx(FormattedMessage, { id: "gs.header.menu" }) }), _jsxs("div", { className: "gd-header-menu-vertical-content", children: [_jsx(HeaderMenu, { onMenuItemClick: handleMenuItemClick, sections: menuItemsGroupsToRender, className: "gd-header-menu-vertical" }), renderTrialItems()] }), _jsxs("div", { className: "gd-header-menu-vertical-footer", children: [!!badges && _jsx("div", { className: "gd-header-vertical-badges", children: badges }), _jsx("div", { className: "gd-header-menu-vertical-bottom-item", children: _jsx("span", { className: "gd-header-username gd-icon-user", children: userName }) }), _jsx("div", { children: renderLogoutButton() })] })] }, "overlay-menu"));
|
|
317
|
+
return (_jsxs("div", { className: "gd-header-menu-vertical-wrapper", children: [_jsx("div", { className: "gd-header-menu-vertical-header", children: _jsx(FormattedMessage, { id: "gs.header.menu" }) }), _jsxs("div", { className: "gd-header-menu-vertical-content", children: [_jsx(HeaderMenu, { onMenuItemClick: handleMenuItemClick, sections: menuItemsGroupsToRender, className: "gd-header-menu-vertical" }), renderTrialItems()] }), _jsxs("div", { className: "gd-header-menu-vertical-footer", children: [!!badges && _jsx("div", { className: "gd-header-vertical-badges", children: badges }), _jsx("div", { className: "gd-header-menu-vertical-bottom-item", children: _jsx("span", { className: "gd-header-username gd-icon-user", children: userName }) }), renderLanguageButton(), _jsx("div", { children: renderLogoutButton() })] })] }, "overlay-menu"));
|
|
309
318
|
};
|
|
310
319
|
const renderOverlayMenu = () => {
|
|
311
320
|
let content = renderVerticalMenu();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ISettings, type IWorkspacePermissions, type PlatformEdition } from "@gooddata/sdk-model";
|
|
2
2
|
export declare const getHelpMenuFeatureFlagsMock: (enableUniversityHelpMenuItem: boolean, enableCommunityHelpMenuItem: boolean) => ISettings;
|
|
3
3
|
export declare const getAccountMenuFeatureFlagsMock: (enableDataSection: boolean, platformEdition: PlatformEdition) => ISettings;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const makeWorkspacePermissions: (permissions?: Partial<IWorkspacePermissions>) => IWorkspacePermissions;
|
|
5
|
+
export declare const makeFullWorkspacePermissions: (permissions?: Partial<IWorkspacePermissions>) => IWorkspacePermissions;
|
|
5
6
|
//# sourceMappingURL=Header.test.helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.test.helpers.d.ts","sourceRoot":"","sources":["../../src/Header/Header.test.helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Header.test.helpers.d.ts","sourceRoot":"","sources":["../../src/Header/Header.test.helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEvG,eAAO,MAAM,2BAA2B,iCACN,OAAO,+BACR,OAAO,KACrC,SAKF,CAAC;AAEF,eAAO,MAAM,8BAA8B,sBACpB,OAAO,mBACT,eAAe,KACjC,SAKF,CAAC;AAEF,eAAO,MAAM,wBAAwB,iBACpB,OAAO,CAAC,qBAAqB,CAAC,KAC5C,qBAgCF,CAAC;AAEF,eAAO,MAAM,4BAA4B,iBACxB,OAAO,CAAC,qBAAqB,CAAC,KAC5C,qBAKF,CAAC"}
|