@gooddata/sdk-ui-kit 11.62.0-alpha.1 → 11.62.0-alpha.2
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/UiAsyncTable/UiAsyncTable/UiAsyncTableHeader.d.ts.map +1 -1
- package/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableHeader.js +38 -5
- package/esm/@ui/UiAsyncTable/types.d.ts +4 -0
- package/esm/@ui/UiAsyncTable/types.d.ts.map +1 -1
- package/esm/@ui/UiChip/ChipActionButton.d.ts.map +1 -1
- package/esm/@ui/UiChip/ChipActionButton.js +5 -3
- package/esm/@ui/UiFocusManager/utils.js +2 -2
- package/esm/@ui/UiIcon/icons.d.ts.map +1 -1
- package/esm/@ui/UiIcon/icons.js +1 -1
- package/esm/@ui/UiResizableSidebar/UiResizableSidebarNavigation.d.ts +11 -5
- package/esm/@ui/UiResizableSidebar/UiResizableSidebarNavigation.d.ts.map +1 -1
- package/esm/@ui/UiResizableSidebar/UiResizableSidebarNavigation.js +257 -20
- package/esm/@ui/UiResizableSidebar/types.d.ts +15 -7
- package/esm/@ui/UiResizableSidebar/types.d.ts.map +1 -1
- package/esm/@ui/UiResizableSidebar/useUiResizableSidebarState.d.ts +1 -1
- package/esm/@ui/UiResizableSidebar/useUiResizableSidebarState.d.ts.map +1 -1
- package/esm/@ui/UiResizableSidebar/useUiResizableSidebarState.js +5 -4
- package/esm/Header/generateHeaderMenuItemsGroups.d.ts +1 -5
- package/esm/Header/generateHeaderMenuItemsGroups.d.ts.map +1 -1
- package/esm/Header/generateHeaderMenuItemsGroups.js +3 -21
- package/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/sdk-ui-kit.d.ts +32 -19
- package/package.json +11 -11
- package/src/@ui/UiResizableSidebar/UiResizableSidebarNavigation.scss +67 -40
- package/styles/css/main.css +46 -28
- package/styles/css/main.css.map +1 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2026 GoodData Corporation
|
|
3
|
-
import { useCallback, useId, useMemo, useRef, useState, } from "react";
|
|
3
|
+
import { useCallback, useId, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
4
|
+
import { FloatingFocusManager, FloatingPortal, safePolygon, useDismiss, useHover, useInteractions, } from "@floating-ui/react";
|
|
5
|
+
import cx from "classnames";
|
|
6
|
+
import { ConditionalScopedThemeProvider } from "@gooddata/sdk-ui-theme-provider";
|
|
4
7
|
import { accessibilityConfigToAttributes } from "../../typings/utilities.js";
|
|
5
8
|
import { bem } from "../@utils/bem.js";
|
|
6
|
-
import { makeGridKeyboardNavigation } from "../@utils/keyboardNavigation.js";
|
|
9
|
+
import { makeGridKeyboardNavigation, makeMenuKeyboardNavigation } from "../@utils/keyboardNavigation.js";
|
|
10
|
+
import { useFloatingPosition } from "../UiFloatingElement/useFloatingPosition.js";
|
|
7
11
|
import { iconPaths } from "../UiIcon/icons.js";
|
|
8
12
|
import { UiIcon } from "../UiIcon/UiIcon.js";
|
|
9
13
|
import { hasSystemModifier } from "../UiToolbar/rovingFocusUtils.js";
|
|
@@ -12,6 +16,7 @@ import { useOptionalUiResizableSidebar } from "./UiResizableSidebarContext.js";
|
|
|
12
16
|
const { b, e } = bem("gd-ui-kit-resizable-sidebar-navigation");
|
|
13
17
|
const ICON_SIZE = 18;
|
|
14
18
|
const CHEVRON_SIZE = 14;
|
|
19
|
+
const FLYOVER_OPEN_DELAY = 100;
|
|
15
20
|
function makeRow(item, parent) {
|
|
16
21
|
return { item, parent, key: JSON.stringify(parent ? [parent.id, item.id] : [item.id]) };
|
|
17
22
|
}
|
|
@@ -24,6 +29,10 @@ function getFirstGrapheme(label) {
|
|
|
24
29
|
function isLink(item) {
|
|
25
30
|
return item.href !== undefined;
|
|
26
31
|
}
|
|
32
|
+
// A modified click on a link is left to the browser: a new tab, a window or a download.
|
|
33
|
+
function isBrowserLinkClick(item, event) {
|
|
34
|
+
return isLink(item) && (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey);
|
|
35
|
+
}
|
|
27
36
|
function isIconType(icon) {
|
|
28
37
|
return typeof icon === "string" && icon in iconPaths;
|
|
29
38
|
}
|
|
@@ -33,6 +42,9 @@ function isGroup(item) {
|
|
|
33
42
|
function isActive(item) {
|
|
34
43
|
return !!item.isSelected || !!item.children?.some((child) => child.isSelected);
|
|
35
44
|
}
|
|
45
|
+
function hasGroupRow(items, rowKey) {
|
|
46
|
+
return items.some((item) => isGroup(item) && makeRow(item).key === rowKey);
|
|
47
|
+
}
|
|
36
48
|
function getSelectionKey(items) {
|
|
37
49
|
return items
|
|
38
50
|
.flatMap((item) => [makeRow(item), ...(item.children ?? []).map((child) => makeRow(child, item))])
|
|
@@ -52,12 +64,20 @@ function getSelectionKey(items) {
|
|
|
52
64
|
*
|
|
53
65
|
* @internal
|
|
54
66
|
*/
|
|
55
|
-
export function UiResizableSidebarNavigation({ items, onSelect, accessibilityConfig, isRail: isRailProp, dataTestId, }) {
|
|
67
|
+
export function UiResizableSidebarNavigation({ items, onSelect, accessibilityConfig, isRail: isRailProp, flyoverClassName, dataTestId, }) {
|
|
56
68
|
const sidebar = useOptionalUiResizableSidebar();
|
|
57
69
|
const isRail = isRailProp ?? (!!sidebar && sidebar.isCollapsed && sidebar.hasRail);
|
|
58
70
|
const idPrefix = useId();
|
|
59
71
|
const selectionKey = getSelectionKey(items);
|
|
60
72
|
const [expansion, setExpansion] = useState({ selectionKey, toggles: new Map() });
|
|
73
|
+
const [flyoverState, setFlyoverState] = useState(null);
|
|
74
|
+
const flyover = isRail ? flyoverState : null;
|
|
75
|
+
const flyoverFocusRef = useRef(null);
|
|
76
|
+
// A flyover left open must not open again, and take focus, when the list returns to the rail or
|
|
77
|
+
// its group comes back.
|
|
78
|
+
if (flyoverState && (!isRail || !hasGroupRow(items, flyoverState.rowKey))) {
|
|
79
|
+
setFlyoverState(null);
|
|
80
|
+
}
|
|
61
81
|
// A change of selection forgets the manual toggles, so the group of the new page always opens.
|
|
62
82
|
if (expansion.selectionKey !== selectionKey) {
|
|
63
83
|
setExpansion({ selectionKey, toggles: new Map() });
|
|
@@ -109,7 +129,11 @@ export function UiResizableSidebarNavigation({ items, onSelect, accessibilityCon
|
|
|
109
129
|
onFocusRight: (event) => {
|
|
110
130
|
const row = rows[getRowIndex(event.target)];
|
|
111
131
|
const item = row?.item;
|
|
112
|
-
if (!item || row.parent || !isGroup(item)
|
|
132
|
+
if (!item || row.parent || !isGroup(item)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (isRail) {
|
|
136
|
+
setFlyoverState({ rowKey: row.key, focusItems: true });
|
|
113
137
|
return;
|
|
114
138
|
}
|
|
115
139
|
if (isExpanded(item)) {
|
|
@@ -133,13 +157,29 @@ export function UiResizableSidebarNavigation({ items, onSelect, accessibilityCon
|
|
|
133
157
|
}
|
|
134
158
|
},
|
|
135
159
|
});
|
|
136
|
-
// Modified keys stay with the browser, e.g. Alt+Left for history navigation.
|
|
160
|
+
// Modified keys stay with the browser, e.g. Alt+Left for history navigation. Keys from a flyover
|
|
161
|
+
// reach the list through the React tree only, because the flyover renders in a portal.
|
|
137
162
|
return (event) => {
|
|
138
|
-
|
|
163
|
+
const isFromList = event.currentTarget.contains(event.target);
|
|
164
|
+
if (isFromList && !hasSystemModifier(event)) {
|
|
139
165
|
handleKey(event);
|
|
140
166
|
}
|
|
141
167
|
};
|
|
142
168
|
}, [rows, getRowIndex, focusRow, isExpanded, setExpanded, isRail]);
|
|
169
|
+
// Leaving the rail, or removing the open group, unmounts the flyover with focus inside. Focus goes
|
|
170
|
+
// back to the group row, or to the tab stop of the list when the group is gone.
|
|
171
|
+
useLayoutEffect(() => {
|
|
172
|
+
const focus = flyoverFocusRef.current;
|
|
173
|
+
if (!focus) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const hasGroup = hasGroupRow(items, focus.rowKey);
|
|
177
|
+
if (isRail && hasGroup) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
flyoverFocusRef.current = null;
|
|
181
|
+
focusRow(hasGroup ? focus.rowKey : (tabStopKey ?? undefined));
|
|
182
|
+
}, [isRail, items, tabStopKey, focusRow]);
|
|
143
183
|
const registerElement = useCallback((key, element) => {
|
|
144
184
|
if (element) {
|
|
145
185
|
elementsRef.current.set(key, element);
|
|
@@ -150,7 +190,13 @@ export function UiResizableSidebarNavigation({ items, onSelect, accessibilityCon
|
|
|
150
190
|
}, []);
|
|
151
191
|
const onActivate = useCallback((row, event) => {
|
|
152
192
|
const item = row.item;
|
|
153
|
-
if (
|
|
193
|
+
if (isBrowserLinkClick(item, event)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (isRail && !row.parent && isGroup(item)) {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
// A keyboard activation has no click count; it moves focus into the flyover.
|
|
199
|
+
setFlyoverState({ rowKey: row.key, focusItems: event.detail === 0 });
|
|
154
200
|
return;
|
|
155
201
|
}
|
|
156
202
|
if (row.parent || isRail || !isGroup(item)) {
|
|
@@ -170,43 +216,234 @@ export function UiResizableSidebarNavigation({ items, onSelect, accessibilityCon
|
|
|
170
216
|
const group = !row.parent && isGroup(item);
|
|
171
217
|
const expanded = isExpanded(item);
|
|
172
218
|
const childrenId = `${idPrefix}-${encodeURIComponent(item.id)}`;
|
|
173
|
-
// A collapsed group shows the
|
|
174
|
-
const
|
|
175
|
-
(group && !expanded
|
|
176
|
-
|
|
219
|
+
// A collapsed group shows the marker of a sub-page, so the marker stays visible from outside.
|
|
220
|
+
const actionRequired = item.actionRequired ??
|
|
221
|
+
(group && !expanded
|
|
222
|
+
? item.children?.find((child) => child.actionRequired)?.actionRequired
|
|
223
|
+
: undefined);
|
|
224
|
+
const isFlyoverOpen = flyover?.rowKey === row.key;
|
|
225
|
+
const element = (_jsx(NavigationRow, { item: item, actionRequired: actionRequired, rowKey: row.key, isChild: !!row.parent, isRail: isRail, isActive: !row.parent && isActive(item), isExpanded: group && !isRail ? expanded : undefined, isFlyoverOpen: group && isRail ? isFlyoverOpen : undefined, childrenId: group ? childrenId : undefined, tabIndex: row.key === tabStopKey ? 0 : -1, onFocus: () => setFocusedKey(row.key), onActivate: (event) => onActivate(row, event), registerElement: registerElement }));
|
|
226
|
+
if (isRail && group) {
|
|
227
|
+
const closeFlyover = () => setFlyoverState((current) => (current?.rowKey === row.key ? null : current));
|
|
228
|
+
// The pointer must not take over from the keyboard in the flyover of another group.
|
|
229
|
+
const hoverOpenFlyover = () => {
|
|
230
|
+
const focus = flyoverFocusRef.current;
|
|
231
|
+
if (focus?.source === "keyboard" && focus.rowKey !== row.key) {
|
|
232
|
+
if (isFocusInFlyover()) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
// The focused item was removed without a blur, so the record is stale.
|
|
236
|
+
flyoverFocusRef.current = null;
|
|
237
|
+
}
|
|
238
|
+
setFlyoverState({ rowKey: row.key, focusItems: false });
|
|
239
|
+
};
|
|
240
|
+
return (_jsx("li", { className: e("row", { rail: true }), children: _jsx(NavigationFlyover, { id: childrenId, className: flyoverClassName, label: item.label, anchor: _jsx(UiTooltip, { anchor: element, content: item.label, arrowPlacement: "left", triggerBy: ["focus"], disabled: isFlyoverOpen, accessibilityHidden: true }), isOpen: isFlyoverOpen, focusItems: isFlyoverOpen ? !!flyover?.focusItems : false, onOpenChange: (open) => (open ? hoverOpenFlyover() : closeFlyover()), onClose: closeFlyover, onReturnFocus: () => focusRow(row.key), onFocusChange: (source) => {
|
|
241
|
+
flyoverFocusRef.current = source ? { rowKey: row.key, source } : null;
|
|
242
|
+
}, children: item.children?.map((child) => {
|
|
243
|
+
const childRow = makeRow(child, item);
|
|
244
|
+
return (_jsx("li", { children: _jsx(NavigationRow, { item: child, actionRequired: child.actionRequired, rowKey: childRow.key, isChild: true, isFlyover: true, isRail: false, isActive: false, isExpanded: undefined, childrenId: undefined, tabIndex: -1, onActivate: (event) => {
|
|
245
|
+
onActivate(childRow, event);
|
|
246
|
+
// A new-tab click leaves the flyover open for more pages.
|
|
247
|
+
if (!isBrowserLinkClick(child, event)) {
|
|
248
|
+
closeFlyover();
|
|
249
|
+
}
|
|
250
|
+
} }) }, childRow.key));
|
|
251
|
+
}) }) }, row.key));
|
|
252
|
+
}
|
|
177
253
|
return (_jsxs("li", { className: e("row", { rail: isRail }), children: [isRail ? (_jsx(UiTooltip, { anchor: element, content: item.label, arrowPlacement: "left", triggerBy: ["hover", "focus"], accessibilityHidden: true, closeOnAnchorClick: true })) : (element), group && expanded ? (_jsx("ul", { id: childrenId, className: e("children"), children: item.children?.map((child) => renderRow(makeRow(child, item))) })) : null] }, row.key));
|
|
178
254
|
};
|
|
179
255
|
return (_jsx("nav", { className: b({ rail: isRail }), ...accessibilityConfigToAttributes(accessibilityConfig), "data-testid": dataTestId, onKeyDown: onKeyDown, children: _jsx("ul", { className: e("list"), children: items.map((item) => renderRow(makeRow(item))) }) }));
|
|
180
256
|
}
|
|
181
|
-
function NavigationRow({ item,
|
|
257
|
+
function NavigationRow({ item, actionRequired, rowKey, isChild, isFlyover = false, isRail, isActive, isExpanded, isFlyoverOpen, childrenId, tabIndex, onFocus, onActivate, registerElement, }) {
|
|
182
258
|
const showIcon = !isChild;
|
|
183
259
|
const showChevron = isExpanded !== undefined;
|
|
184
|
-
// A group whose current sub-page is not rendered (collapsed, or in
|
|
185
|
-
const
|
|
260
|
+
// A group whose current sub-page is not rendered (collapsed, or in a closed flyover) stands in for it.
|
|
261
|
+
const isSubPageShown = isExpanded === true || isFlyoverOpen === true;
|
|
262
|
+
const holdsHiddenCurrentPage = isActive && !item.isSelected && !isSubPageShown;
|
|
186
263
|
const ariaCurrent = item.isSelected
|
|
187
264
|
? "page"
|
|
188
265
|
: holdsHiddenCurrentPage
|
|
189
266
|
? "true"
|
|
190
267
|
: undefined;
|
|
191
|
-
const
|
|
192
|
-
const content = (_jsxs(_Fragment, { children: [showIcon ? (_jsx("span", { className: e("icon"), "aria-hidden": "true", children: isIconType(item.icon) ? (_jsx(UiIcon, { type: item.icon, size: ICON_SIZE, color: "currentColor", layout: "block" })) : ((item.icon ?? getFirstGrapheme(item.label))) })) : null, _jsx("span", { className: e(isRail ? "sr-only" : "label"), children: item.label }),
|
|
268
|
+
const actionRequiredElement = actionRequired ? (_jsx("span", { className: e("action-required"), children: _jsx("span", { className: e("sr-only"), children: actionRequired.label }) })) : null;
|
|
269
|
+
const content = (_jsxs(_Fragment, { children: [showIcon ? (_jsx("span", { className: e("icon"), "aria-hidden": "true", children: isIconType(item.icon) ? (_jsx(UiIcon, { type: item.icon, size: ICON_SIZE, color: "currentColor", layout: "block" })) : ((item.icon ?? getFirstGrapheme(item.label))) })) : null, _jsx("span", { className: e(isRail ? "sr-only" : "label"), children: item.label }), actionRequiredElement, showChevron ? (_jsx("span", { className: e("chevron", { expanded: !!isExpanded }), "aria-hidden": "true", children: _jsx(UiIcon, { type: "chevronRight", size: CHEVRON_SIZE, color: "currentColor", layout: "block" }) })) : null] }));
|
|
193
270
|
const sharedProps = {
|
|
194
271
|
className: e("item", {
|
|
195
272
|
selected: !!item.isSelected,
|
|
196
273
|
active: isActive,
|
|
197
274
|
child: isChild,
|
|
275
|
+
flyover: isFlyover,
|
|
198
276
|
rail: isRail,
|
|
277
|
+
open: !!isFlyoverOpen,
|
|
199
278
|
}),
|
|
200
279
|
tabIndex,
|
|
201
280
|
"aria-current": ariaCurrent,
|
|
202
|
-
"aria-expanded": isExpanded,
|
|
203
|
-
"aria-controls": isExpanded ? childrenId : undefined,
|
|
281
|
+
"aria-expanded": isExpanded ?? isFlyoverOpen,
|
|
282
|
+
"aria-controls": (isExpanded ?? isFlyoverOpen) ? childrenId : undefined,
|
|
204
283
|
"data-testid": item.dataTestId,
|
|
205
284
|
onFocus,
|
|
206
285
|
onClick: onActivate,
|
|
207
286
|
};
|
|
208
287
|
if (isLink(item)) {
|
|
209
|
-
return (_jsx("a", { ref: (element) => registerElement(rowKey, element), href: item.href, ...sharedProps, children: content }));
|
|
288
|
+
return (_jsx("a", { ref: (element) => registerElement?.(rowKey, element), href: item.href, ...sharedProps, children: content }));
|
|
210
289
|
}
|
|
211
|
-
return (_jsx("button", { ref: (element) => registerElement(rowKey, element), type: "button", ...sharedProps, children: content }));
|
|
290
|
+
return (_jsx("button", { ref: (element) => registerElement?.(rowKey, element), type: "button", ...sharedProps, children: content }));
|
|
291
|
+
}
|
|
292
|
+
// The flyover starts at the edge of the sidebar, not at the edge of the narrower item in the rail.
|
|
293
|
+
const flyoverOffset = ({ elements }) => {
|
|
294
|
+
const sidebar = elements.reference instanceof Element
|
|
295
|
+
? elements.reference.closest(".gd-ui-kit-resizable-sidebar")
|
|
296
|
+
: null;
|
|
297
|
+
return sidebar
|
|
298
|
+
? sidebar.getBoundingClientRect().right - elements.reference.getBoundingClientRect().right
|
|
299
|
+
: 0;
|
|
300
|
+
};
|
|
301
|
+
function isFocusInFlyover() {
|
|
302
|
+
return !!document.activeElement?.closest(`.${e("flyover")}`);
|
|
303
|
+
}
|
|
304
|
+
// Scrolls only the container. Element.scrollIntoView would also scroll the page under the flyover.
|
|
305
|
+
function scrollIntoContainer(container, element) {
|
|
306
|
+
const box = container.getBoundingClientRect();
|
|
307
|
+
const target = element.getBoundingClientRect();
|
|
308
|
+
if (target.bottom > box.bottom) {
|
|
309
|
+
container.scrollTop += target.bottom - box.bottom;
|
|
310
|
+
}
|
|
311
|
+
else if (target.top < box.top) {
|
|
312
|
+
container.scrollTop -= box.top - target.top;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function getFlyoverItems(container) {
|
|
316
|
+
return container ? [...container.querySelectorAll("a, button")] : [];
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Lists the sub-items of a group in the rail. Hover opens it without moving focus; the Right arrow key
|
|
320
|
+
* on the group opens it with focus on the current page or the first sub-item.
|
|
321
|
+
*/
|
|
322
|
+
function NavigationFlyover({ id, className, label, anchor, isOpen, focusItems, onOpenChange, onClose, onReturnFocus, onFocusChange, children, }) {
|
|
323
|
+
const focusSourceRef = useRef(null);
|
|
324
|
+
const isPointerDownRef = useRef(false);
|
|
325
|
+
const setFocusSource = (source) => {
|
|
326
|
+
focusSourceRef.current = source;
|
|
327
|
+
onFocusChange(source);
|
|
328
|
+
};
|
|
329
|
+
const { refs, floatingStyles, zIndex, context } = useFloatingPosition({
|
|
330
|
+
isOpen,
|
|
331
|
+
// The pointer can leave while the keyboard works in the flyover; that must not close it.
|
|
332
|
+
onOpenChange: (open, _event, reason) => {
|
|
333
|
+
const isHoverClose = reason === "hover" || reason === "safe-polygon";
|
|
334
|
+
if (!open && isHoverClose && focusSourceRef.current === "keyboard") {
|
|
335
|
+
if (refs.floating.current?.contains(document.activeElement)) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
// The focused item was removed without a blur, so nothing holds the flyover open.
|
|
339
|
+
setFocusSource(null);
|
|
340
|
+
}
|
|
341
|
+
onOpenChange(open);
|
|
342
|
+
},
|
|
343
|
+
placement: "right-start",
|
|
344
|
+
offset: flyoverOffset,
|
|
345
|
+
autoFlip: false,
|
|
346
|
+
// Only the height is limited, to the viewport space below the group, so a long list scrolls.
|
|
347
|
+
maxWidth: "none",
|
|
348
|
+
});
|
|
349
|
+
const hover = useHover(context, {
|
|
350
|
+
delay: { open: FLYOVER_OPEN_DELAY },
|
|
351
|
+
handleClose: safePolygon(),
|
|
352
|
+
});
|
|
353
|
+
const dismiss = useDismiss(context);
|
|
354
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([hover, dismiss]);
|
|
355
|
+
// The portal mounts the flyover after the first commit, so focus waits for the element.
|
|
356
|
+
const [flyoverElement, setFlyoverElement] = useState(null);
|
|
357
|
+
const setFloating = useCallback((element) => {
|
|
358
|
+
refs.setFloating(element);
|
|
359
|
+
setFlyoverElement(element);
|
|
360
|
+
}, [refs]);
|
|
361
|
+
useLayoutEffect(() => {
|
|
362
|
+
if (!focusItems) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
const items = getFlyoverItems(flyoverElement);
|
|
366
|
+
const current = items.find((item) => item.getAttribute("aria-current") === "page");
|
|
367
|
+
(current ?? items[0])?.focus({ preventScroll: true });
|
|
368
|
+
}, [focusItems, flyoverElement]);
|
|
369
|
+
// Removing the focused item, e.g. after a change of permissions, drops focus to the document. Focus
|
|
370
|
+
// goes back into the flyover, so its keys keep working.
|
|
371
|
+
useLayoutEffect(() => {
|
|
372
|
+
if (!focusSourceRef.current || !flyoverElement || document.activeElement !== document.body) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
// Focus from a press is not restored, or the flyover would count as keyboard focused.
|
|
376
|
+
if (focusSourceRef.current === "pointer") {
|
|
377
|
+
setFocusSource(null);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const items = getFlyoverItems(flyoverElement);
|
|
381
|
+
const current = items.find((item) => item.getAttribute("aria-current") === "page");
|
|
382
|
+
(current ?? items[0])?.focus({ preventScroll: true });
|
|
383
|
+
});
|
|
384
|
+
// The height limit applies once the flyover is positioned, so the focused item is revealed after it.
|
|
385
|
+
useLayoutEffect(() => {
|
|
386
|
+
const focused = document.activeElement;
|
|
387
|
+
if (focusItems && flyoverElement && focused && flyoverElement.contains(focused)) {
|
|
388
|
+
scrollIntoContainer(flyoverElement, focused);
|
|
389
|
+
}
|
|
390
|
+
}, [focusItems, flyoverElement, floatingStyles]);
|
|
391
|
+
// A flyover that closes with focus inside removes the focused item, so focus goes back to the group.
|
|
392
|
+
useLayoutEffect(() => {
|
|
393
|
+
if (!isOpen && focusSourceRef.current) {
|
|
394
|
+
// Focus from a press stays where the pointer goes, e.g. to the flyover of another group.
|
|
395
|
+
const isKeyboardFocus = focusSourceRef.current === "keyboard";
|
|
396
|
+
setFocusSource(null);
|
|
397
|
+
if (isKeyboardFocus) {
|
|
398
|
+
onReturnFocus();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
const moveFocus = (target, getIndex) => {
|
|
403
|
+
const items = getFlyoverItems(refs.floating.current);
|
|
404
|
+
const index = items.findIndex((item) => item.contains(target));
|
|
405
|
+
items[getIndex(index, items.length)]?.focus();
|
|
406
|
+
};
|
|
407
|
+
// Enter and Space stay unhandled, so links and buttons keep their native activation.
|
|
408
|
+
const handleKey = makeMenuKeyboardNavigation({
|
|
409
|
+
onFocusPrevious: (event) => moveFocus(event.target, (index) => Math.max(0, index - 1)),
|
|
410
|
+
onFocusNext: (event) => moveFocus(event.target, (index, count) => Math.min(count - 1, index + 1)),
|
|
411
|
+
onFocusFirst: (event) => moveFocus(event.target, () => 0),
|
|
412
|
+
onFocusLast: (event) => moveFocus(event.target, (_, count) => count - 1),
|
|
413
|
+
onLeaveLevel: onClose,
|
|
414
|
+
onClose,
|
|
415
|
+
});
|
|
416
|
+
// The navigation stops only the keys it handles, so page shortcuts such as Ctrl+K still work here.
|
|
417
|
+
const onKeyDown = (event) => {
|
|
418
|
+
isPointerDownRef.current = false;
|
|
419
|
+
if (!hasSystemModifier(event)) {
|
|
420
|
+
handleKey(event);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: e("flyover-anchor"), ref: refs.setReference, ...getReferenceProps(), children: anchor }), isOpen ? (_jsx(FloatingPortal, { children: _jsx(ConditionalScopedThemeProvider, { children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: -1, returnFocus: false, children: _jsx("div", { id: id, ref: setFloating, className: cx(e("flyover"), className), style: { ...floatingStyles, zIndex }, role: "group", "aria-label": label, ...getFloatingProps({
|
|
424
|
+
onKeyDown,
|
|
425
|
+
// A press focuses an item before the click, e.g. a right click for a
|
|
426
|
+
// new tab. That focus must not hold the flyover open like the keyboard.
|
|
427
|
+
onPointerDown: () => {
|
|
428
|
+
isPointerDownRef.current = true;
|
|
429
|
+
},
|
|
430
|
+
onPointerUp: () => {
|
|
431
|
+
isPointerDownRef.current = false;
|
|
432
|
+
},
|
|
433
|
+
onFocus: () => {
|
|
434
|
+
setFocusSource(isPointerDownRef.current ? "pointer" : "keyboard");
|
|
435
|
+
},
|
|
436
|
+
// A removed item can blur with no target; focus still has to go back.
|
|
437
|
+
onBlur: (event) => {
|
|
438
|
+
const target = event.relatedTarget;
|
|
439
|
+
if (target && !event.currentTarget.contains(target)) {
|
|
440
|
+
// Shift+Tab lands on the group, which keeps a non-modal flyover open.
|
|
441
|
+
const isKeyboardExit = focusSourceRef.current === "keyboard";
|
|
442
|
+
setFocusSource(null);
|
|
443
|
+
if (isKeyboardExit) {
|
|
444
|
+
onClose();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
}), children: _jsx("ul", { className: e("flyover-list"), children: children }) }) }) }) })) : null] }));
|
|
212
449
|
}
|
|
@@ -55,9 +55,14 @@ export interface IUiResizableSidebarStateOptions {
|
|
|
55
55
|
*/
|
|
56
56
|
hasRail?: boolean;
|
|
57
57
|
/**
|
|
58
|
-
* Width the sibling content must keep. Caps the maximum at the
|
|
58
|
+
* Width the sibling content must keep. Caps the maximum at the available width minus this value.
|
|
59
59
|
*/
|
|
60
60
|
minContentWidth?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Width the sidebar shares with its sibling content, e.g. their measured container when the host takes
|
|
63
|
+
* part of the window. Defaults to the viewport width.
|
|
64
|
+
*/
|
|
65
|
+
availableWidth?: number;
|
|
61
66
|
isResizable: boolean;
|
|
62
67
|
isCollapsible: boolean;
|
|
63
68
|
/**
|
|
@@ -81,10 +86,14 @@ export interface IUiResizableSidebarStateOptions {
|
|
|
81
86
|
onUserChange?: (property: "collapsed" | "width") => void;
|
|
82
87
|
}
|
|
83
88
|
/**
|
|
89
|
+
* Marks a page that needs an action from the user, e.g. a setting that is not complete.
|
|
90
|
+
*
|
|
84
91
|
* @internal
|
|
85
92
|
*/
|
|
86
|
-
export interface
|
|
87
|
-
|
|
93
|
+
export interface IUiResizableSidebarNavigationActionRequired {
|
|
94
|
+
/**
|
|
95
|
+
* Accessible text of the marker, e.g. "Action required".
|
|
96
|
+
*/
|
|
88
97
|
label: string;
|
|
89
98
|
}
|
|
90
99
|
/**
|
|
@@ -105,11 +114,10 @@ export interface IUiResizableSidebarNavigationSubItem {
|
|
|
105
114
|
*/
|
|
106
115
|
isSelected?: boolean;
|
|
107
116
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* first badged sub-page.
|
|
117
|
+
* Shows a dot next to the label: the page needs an action from the user. A collapsed group, and a
|
|
118
|
+
* group in the rail, shows the dot when one of its sub-pages requires an action.
|
|
111
119
|
*/
|
|
112
|
-
|
|
120
|
+
actionRequired?: IUiResizableSidebarNavigationActionRequired;
|
|
113
121
|
dataTestId?: string;
|
|
114
122
|
}
|
|
115
123
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiResizableSidebar/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACrC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC5C;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,KAAK,IAAI,CAAC;CAC5D;AAED
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiResizableSidebar/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACrC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC5C;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,KAAK,IAAI,CAAC;CAC5D;AAED;;;;GAIG;AACH,MAAM,WAAW,2CAA2C;IACxD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,oCAAoC;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,2CAA2C,CAAC;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iCAAkC,SAAQ,oCAAoC;IAC3F;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,oCAAoC,EAAE,CAAC;CACrD;AAED;;;;GAIG;AACH,MAAM,MAAM,wCAAwC,GAC9C;IACI,SAAS,EAAE,WAAW,CAAC,wBAAwB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9D,cAAc,CAAC,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;CAC/D,GACD;IACI,SAAS,CAAC,EAAE,wBAAwB,CAAC,WAAW,CAAC,CAAC;IAClD,cAAc,EAAE,WAAW,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,CAAC,CAAC;CAC3E,CAAC"}
|
|
@@ -15,5 +15,5 @@ export declare const UI_RESIZABLE_SIDEBAR_RAIL_WIDTH = 48;
|
|
|
15
15
|
*
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
|
-
export declare function useUiResizableSidebarState({ widthStorageKey, collapsedStorageKey, minWidth, maxWidth, hasRail, minContentWidth, isResizable, isCollapsible, collapsedOverride, widthOverride, onUserChange, }: IUiResizableSidebarStateOptions): IUiResizableSidebarState;
|
|
18
|
+
export declare function useUiResizableSidebarState({ widthStorageKey, collapsedStorageKey, minWidth, maxWidth, hasRail, minContentWidth, availableWidth, isResizable, isCollapsible, collapsedOverride, widthOverride, onUserChange, }: IUiResizableSidebarStateOptions): IUiResizableSidebarState;
|
|
19
19
|
//# sourceMappingURL=useUiResizableSidebarState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUiResizableSidebarState.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiResizableSidebar/useUiResizableSidebarState.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAIjG;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAsBlD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,EACvC,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,QAAQ,EACR,OAAe,EACf,eAAe,EACf,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,GACf,EAAE,+BAA+B,GAAG,wBAAwB,
|
|
1
|
+
{"version":3,"file":"useUiResizableSidebarState.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiResizableSidebar/useUiResizableSidebarState.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAIjG;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAsBlD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,EACvC,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,QAAQ,EACR,OAAe,EACf,eAAe,EACf,cAAc,EACd,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,GACf,EAAE,+BAA+B,GAAG,wBAAwB,CAiG5D"}
|
|
@@ -33,8 +33,9 @@ function useWindowWidth(active) {
|
|
|
33
33
|
*
|
|
34
34
|
* @internal
|
|
35
35
|
*/
|
|
36
|
-
export function useUiResizableSidebarState({ widthStorageKey, collapsedStorageKey, minWidth, maxWidth, hasRail = false, minContentWidth, isResizable, isCollapsible, collapsedOverride, widthOverride, onUserChange, }) {
|
|
37
|
-
const viewportWidth = useWindowWidth(isResizable && minContentWidth !== undefined);
|
|
36
|
+
export function useUiResizableSidebarState({ widthStorageKey, collapsedStorageKey, minWidth, maxWidth, hasRail = false, minContentWidth, availableWidth, isResizable, isCollapsible, collapsedOverride, widthOverride, onUserChange, }) {
|
|
37
|
+
const viewportWidth = useWindowWidth(isResizable && minContentWidth !== undefined && availableWidth === undefined);
|
|
38
|
+
const sharedWidth = availableWidth ?? viewportWidth;
|
|
38
39
|
const [storedWidth, setPersistedWidth] = useLocalStorage(widthStorageKey, null);
|
|
39
40
|
const [storedCollapsed, setPersistedCollapsed] = useLocalStorage(collapsedStorageKey, false);
|
|
40
41
|
// Anything may have written these keys, so only well-formed values are trusted; the overrides
|
|
@@ -51,7 +52,7 @@ export function useUiResizableSidebarState({ widthStorageKey, collapsedStorageKe
|
|
|
51
52
|
const collapsedWidth = hasRail ? UI_RESIZABLE_SIDEBAR_RAIL_WIDTH : 0;
|
|
52
53
|
const max = minContentWidth === undefined
|
|
53
54
|
? maxWidth
|
|
54
|
-
: clamp(
|
|
55
|
+
: clamp(sharedWidth - minContentWidth, minWidth, maxWidth);
|
|
55
56
|
const expandedWidth = isResizable ? clamp(preferredWidth, minWidth, max) : minWidth;
|
|
56
57
|
// Live setters announce the user change first so the caller can release an override of the property.
|
|
57
58
|
const setCollapsed = isCollapsible ? announceAndSetCollapsed : noop;
|
|
@@ -113,6 +114,6 @@ export function useUiResizableSidebarState({ widthStorageKey, collapsedStorageKe
|
|
|
113
114
|
preferredCollapsed,
|
|
114
115
|
preferredWidth,
|
|
115
116
|
setPersistedWidth,
|
|
116
|
-
|
|
117
|
+
sharedWidth,
|
|
117
118
|
]);
|
|
118
119
|
}
|
|
@@ -24,10 +24,6 @@ export declare const HEADER_ITEM_ID_ANALYZE: string;
|
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
26
|
export declare const HEADER_ITEM_ID_METRICS: string;
|
|
27
|
-
/**
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
export declare const HEADER_ITEM_ID_LOAD: string;
|
|
31
27
|
/**
|
|
32
28
|
* @internal
|
|
33
29
|
*/
|
|
@@ -43,5 +39,5 @@ export declare const HEADER_ITEM_ID_CATALOG: string;
|
|
|
43
39
|
/**
|
|
44
40
|
* @internal
|
|
45
41
|
*/
|
|
46
|
-
export declare function generateHeaderMenuItemsGroups(featureFlags: ISettings, workspacePermissions: IWorkspacePermissions, hasAnalyticalDashboards?: boolean, workspaceId?: string, hasNoDataSet?: boolean, backendSupportsDataItem?: boolean,
|
|
42
|
+
export declare function generateHeaderMenuItemsGroups(featureFlags: ISettings, workspacePermissions: IWorkspacePermissions, hasAnalyticalDashboards?: boolean, workspaceId?: string, hasNoDataSet?: boolean, backendSupportsDataItem?: boolean, hasMeasures?: boolean, hasManage?: boolean, baseUrl?: string): IHeaderMenuItem[][];
|
|
47
43
|
//# sourceMappingURL=generateHeaderMenuItemsGroups.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateHeaderMenuItemsGroups.d.ts","sourceRoot":"","sources":["../../src/Header/generateHeaderMenuItemsGroups.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"generateHeaderMenuItemsGroups.d.ts","sourceRoot":"","sources":["../../src/Header/generateHeaderMenuItemsGroups.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAmD,CAAC;AAC1F;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAgD,CAAC;AACpF;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAiD,CAAC;AACtF;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAA6C,CAAC;AAC9E;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAgD,CAAC;AACpF;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAgD,CAAC;AACpF;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAA6C,CAAC;AAC9E;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAA+C,CAAC;AAElF;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAgD,CAAC;AAEpF;;GAEG;AACH,wBAAgB,6BAA6B,CACzC,YAAY,EAAE,SAAS,EACvB,oBAAoB,EAAE,qBAAqB,EAC3C,uBAAuB,GAAE,OAAe,EACxC,WAAW,CAAC,EAAE,MAAM,EACpB,YAAY,GAAE,OAAe,EAC7B,uBAAuB,GAAE,OAAe,EACxC,WAAW,GAAE,OAAe,EAC5B,SAAS,GAAE,OAAc,EACzB,OAAO,GAAE,MAAW,GACrB,eAAe,EAAE,EAAE,CAqBrB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// (C) 2007-2026 GoodData Corporation
|
|
2
2
|
import { defineMessage } from "react-intl";
|
|
3
|
-
import { isFreemiumEdition } from "../utils/featureFlags.js";
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
@@ -25,10 +24,6 @@ export const HEADER_ITEM_ID_ANALYZE = defineMessage({ id: "gs.header.analyze" })
|
|
|
25
24
|
* @internal
|
|
26
25
|
*/
|
|
27
26
|
export const HEADER_ITEM_ID_METRICS = defineMessage({ id: "gs.header.metrics" }).id;
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export const HEADER_ITEM_ID_LOAD = defineMessage({ id: "gs.header.load" }).id;
|
|
32
27
|
/**
|
|
33
28
|
* @internal
|
|
34
29
|
*/
|
|
@@ -44,12 +39,12 @@ export const HEADER_ITEM_ID_CATALOG = defineMessage({ id: "gs.header.catalog" })
|
|
|
44
39
|
/**
|
|
45
40
|
* @internal
|
|
46
41
|
*/
|
|
47
|
-
export function generateHeaderMenuItemsGroups(featureFlags, workspacePermissions, hasAnalyticalDashboards = false, workspaceId, hasNoDataSet = false, backendSupportsDataItem = false,
|
|
42
|
+
export function generateHeaderMenuItemsGroups(featureFlags, workspacePermissions, hasAnalyticalDashboards = false, workspaceId, hasNoDataSet = false, backendSupportsDataItem = false, hasMeasures = false, hasManage = true, baseUrl = "") {
|
|
48
43
|
if (!workspaceId) {
|
|
49
44
|
return [];
|
|
50
45
|
}
|
|
51
46
|
const pixelPerfectItemsGroup = [];
|
|
52
|
-
const insightItemsGroup = createInsightsItemsGroup(featureFlags, workspaceId, workspacePermissions, hasAnalyticalDashboards, hasMeasures,
|
|
47
|
+
const insightItemsGroup = createInsightsItemsGroup(featureFlags, workspaceId, workspacePermissions, hasAnalyticalDashboards, hasMeasures, backendSupportsDataItem, hasNoDataSet, baseUrl);
|
|
53
48
|
const manageItemsGroup = createManageItemsGroup(workspacePermissions, workspaceId, hasManage);
|
|
54
49
|
return [pixelPerfectItemsGroup, insightItemsGroup, manageItemsGroup].filter((itemsGroup) => itemsGroup.length > 0);
|
|
55
50
|
}
|
|
@@ -60,8 +55,7 @@ function createManageItemsGroup(workspacePermissions, workspaceId, hasManage) {
|
|
|
60
55
|
pushConditionally(manageItemsGroup, createIHeaderMenuItem(HEADER_ITEM_ID_MANAGE, "s-menu-manage", manageUrl), canManageMetric && hasManage);
|
|
61
56
|
return manageItemsGroup;
|
|
62
57
|
}
|
|
63
|
-
function createInsightsItemsGroup(featureFlags, workspaceId, workspacePermissions, hasAnalyticalDashboards, hasMeasures,
|
|
64
|
-
const isFreemiumCustomer = isFreemiumEdition(featureFlags.platformEdition);
|
|
58
|
+
function createInsightsItemsGroup(featureFlags, workspaceId, workspacePermissions, hasAnalyticalDashboards, hasMeasures, backendSupportsDataItem, hasNoDataSet, baseUrl) {
|
|
65
59
|
const insightItemsGroup = [];
|
|
66
60
|
const kpisUrl = kpisItemUrl(baseUrl, workspaceId, Boolean(featureFlags.enableShellApplication_dashboards));
|
|
67
61
|
pushConditionally(insightItemsGroup, createIHeaderMenuItem(HEADER_ITEM_ID_KPIS_NEW, "s-menu-kpis", kpisUrl), canShowKpisItem(workspacePermissions, hasAnalyticalDashboards));
|
|
@@ -72,8 +66,6 @@ function createInsightsItemsGroup(featureFlags, workspaceId, workspacePermission
|
|
|
72
66
|
const dataUrl = dataItemUrl(workspaceId, workspacePermissions, backendSupportsDataItem, hasNoDataSet, baseUrl);
|
|
73
67
|
pushConditionally(insightItemsGroup, createIHeaderMenuItem(HEADER_ITEM_ID_DATA, "s-menu-data", dataUrl), canShowDataItem(featureFlags, workspacePermissions));
|
|
74
68
|
pushConditionally(insightItemsGroup, createIHeaderMenuItem(HEADER_ITEM_ID_CATALOG, "s-menu-workspace-catalog", catalogItemUrl(workspaceId, featureFlags), true), canShowCatalogItem(featureFlags, workspacePermissions));
|
|
75
|
-
const loadUrl = loadItemUrl(baseUrl, workspaceId);
|
|
76
|
-
pushConditionally(insightItemsGroup, createIHeaderMenuItem(HEADER_ITEM_ID_LOAD, "s-menu-load", loadUrl), canShowLoadItem(featureFlags, workspacePermissions, isFreemiumCustomer, backendSupportsCsvUploader));
|
|
77
69
|
return insightItemsGroup;
|
|
78
70
|
}
|
|
79
71
|
function createIHeaderMenuItem(key, className, href, isActiveByStartWith) {
|
|
@@ -139,13 +131,3 @@ function canShowDataItem(featureFlags, workspacePermissions) {
|
|
|
139
131
|
return Boolean(featureFlags.enableDataSection &&
|
|
140
132
|
(workspacePermissions.canInitData || workspacePermissions.canRefreshData));
|
|
141
133
|
}
|
|
142
|
-
function loadItemUrl(baseUrl, workspaceId) {
|
|
143
|
-
return withBaseUrl(baseUrl, `/data/#/workspaces/${workspaceId}/datasets`);
|
|
144
|
-
}
|
|
145
|
-
function canShowLoadItem(featureFlags, workspacePermissions, isFreemiumCustomer, backendSupportsCsvUploader) {
|
|
146
|
-
const canAccessLoadCsvPage = workspacePermissions.canUploadNonProductionCSV === true;
|
|
147
|
-
const canShowLoadCsvItem = featureFlags.enableDataSection
|
|
148
|
-
? !isFreemiumCustomer && canAccessLoadCsvPage
|
|
149
|
-
: canAccessLoadCsvPage;
|
|
150
|
-
return Boolean(canShowLoadCsvItem && backendSupportsCsvUploader);
|
|
151
|
-
}
|
package/esm/index.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export { generateHeaderCommonHelpMenuItems } from "./Header/generateHeaderCommon
|
|
|
88
88
|
export { generateHeaderStaticHelpMenuItems } from "./Header/generateHeaderStaticHelpMenuItems.js";
|
|
89
89
|
export { HeaderBadge, type IHeaderBadgeProps } from "./Header/HeaderBadge.js";
|
|
90
90
|
export { HeaderBadgeWithModal, type IHeaderBadgeWithModalProps } from "./Header/HeaderBadgeWithModal.js";
|
|
91
|
-
export { HEADER_ITEM_ID_DASHBOARDS, HEADER_ITEM_ID_REPORTS, HEADER_ITEM_ID_KPIS_NEW, HEADER_ITEM_ID_KPIS, HEADER_ITEM_ID_ANALYZE, HEADER_ITEM_ID_METRICS,
|
|
91
|
+
export { HEADER_ITEM_ID_DASHBOARDS, HEADER_ITEM_ID_REPORTS, HEADER_ITEM_ID_KPIS_NEW, HEADER_ITEM_ID_KPIS, HEADER_ITEM_ID_ANALYZE, HEADER_ITEM_ID_METRICS, HEADER_ITEM_ID_DATA, HEADER_ITEM_ID_MANAGE, HEADER_ITEM_ID_CATALOG, generateHeaderMenuItemsGroups, } from "./Header/generateHeaderMenuItemsGroups.js";
|
|
92
92
|
export { activateHeaderMenuItems } from "./Header/activateHeaderMenuItems.js";
|
|
93
93
|
export type { IHeaderMenuItem, IAppHeaderProps, IAppHeaderState, IHeaderAccountProps, IHeaderAccountState, IHeaderMenuProps, IHeaderUpsellButtonProps, TUTMContent, } from "./Header/typings.js";
|
|
94
94
|
export { type HeaderSearchContext, HeaderSearchProvider, useHeaderSearch, } from "./Header/headerSearchContext.js";
|
|
@@ -522,7 +522,7 @@ export { UiResizableSidebar, type IUiResizableSidebarProps, } from "./@ui/UiResi
|
|
|
522
522
|
export { UiResizableSidebarHandle, type IUiResizableSidebarHandleProps, } from "./@ui/UiResizableSidebar/UiResizableSidebarHandle.js";
|
|
523
523
|
export { UiResizableSidebarProvider, useUiResizableSidebar, type IUiResizableSidebarProviderProps, } from "./@ui/UiResizableSidebar/UiResizableSidebarContext.js";
|
|
524
524
|
export { useUiResizableSidebarState, UI_RESIZABLE_SIDEBAR_RAIL_WIDTH, } from "./@ui/UiResizableSidebar/useUiResizableSidebarState.js";
|
|
525
|
-
export { type IUiResizableSidebarState, type IUiResizableSidebarStateOptions, type
|
|
525
|
+
export { type IUiResizableSidebarState, type IUiResizableSidebarStateOptions, type IUiResizableSidebarNavigationActionRequired, type IUiResizableSidebarNavigationItem, type IUiResizableSidebarNavigationSubItem, type UiResizableSidebarNavigationNamingConfig, } from "./@ui/UiResizableSidebar/types.js";
|
|
526
526
|
export { UiResizableSidebarNavigation, type IUiResizableSidebarNavigationProps, type UiResizableSidebarNavigationItem, } from "./@ui/UiResizableSidebar/UiResizableSidebarNavigation.js";
|
|
527
527
|
export { UiResizableSidebarCollapseToggle, type IUiResizableSidebarCollapseToggleProps, } from "./@ui/UiResizableSidebar/UiResizableSidebarCollapseToggle.js";
|
|
528
528
|
export { UiResizableSidebarExpandTrigger, type IUiResizableSidebarExpandTriggerProps, } from "./@ui/UiResizableSidebar/UiResizableSidebarExpandTrigger.js";
|