@gooddata/sdk-ui-metric-component 11.68.0-alpha.8 → 11.68.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/NOTICE +55 -386
- package/esm/MaqlEditor/codemirror/baseExtensions.d.ts +0 -8
- package/esm/MaqlEditor/codemirror/baseExtensions.d.ts.map +1 -1
- package/esm/MaqlEditor/codemirror/baseExtensions.js +13 -25
- package/esm/MaqlEditor/maql/extensions/completion.d.ts +13 -3
- package/esm/MaqlEditor/maql/extensions/completion.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/extensions/completion.js +69 -36
- package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorHeader.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorHeader.js +8 -6
- package/esm/MetricComponent/Form/MaqlResult/components/AttributesSelect.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlResult/components/AttributesSelect.js +2 -3
- package/esm/MetricComponent/Form/PartHeader/PartHeader.d.ts +16 -1
- package/esm/MetricComponent/Form/PartHeader/PartHeader.d.ts.map +1 -1
- package/esm/MetricComponent/Form/PartHeader/PartHeader.js +97 -21
- package/esm/MetricComponent/MetricsState.d.ts.map +1 -1
- package/esm/MetricComponent/MetricsState.js +1 -0
- package/esm/MetricComponent/MinimizedMetricComponent/MinimizedMetricComponent.d.ts.map +1 -1
- package/esm/MetricComponent/MinimizedMetricComponent/MinimizedMetricComponent.js +25 -4
- package/esm/MetricComponent/MultipleMetricsState.d.ts.map +1 -1
- package/esm/MetricComponent/MultipleMetricsState.js +5 -2
- package/esm/shared/Tabs/Tab.d.ts +5 -1
- package/esm/shared/Tabs/Tab.d.ts.map +1 -1
- package/esm/shared/Tabs/Tab.js +3 -3
- package/esm/shared/Tabs/Tabs.d.ts.map +1 -1
- package/esm/shared/Tabs/Tabs.data.d.ts +8 -0
- package/esm/shared/Tabs/Tabs.data.d.ts.map +1 -1
- package/esm/shared/Tabs/Tabs.js +88 -9
- package/esm/shared/Tabs/hooks/useScrollByButtons.d.ts +2 -0
- package/esm/shared/Tabs/hooks/useScrollByButtons.d.ts.map +1 -1
- package/esm/shared/Tabs/hooks/useScrollByButtons.js +3 -1
- package/esm/shared/Tabs/hooks/useTabsLabels.d.ts +21 -0
- package/esm/shared/Tabs/hooks/useTabsLabels.d.ts.map +1 -0
- package/esm/shared/Tabs/hooks/useTabsLabels.js +29 -0
- package/esm/shared/focusHandoff.d.ts +33 -0
- package/esm/shared/focusHandoff.d.ts.map +1 -0
- package/esm/shared/focusHandoff.js +44 -0
- package/esm/shared/metrics/useMetricListData.d.ts.map +1 -1
- package/esm/shared/metrics/useMetricListData.events.d.ts.map +1 -1
- package/esm/shared/metrics/useMetricListData.events.js +2 -3
- package/esm/shared/metrics/useMetricListData.js +2 -2
- package/esm/translations/de-DE.json +1 -1
- package/esm/translations/en-US.json +46 -6
- package/esm/translations/translations.d.ts.map +1 -1
- package/esm/translations/translations.js +2 -3
- package/package.json +17 -17
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2021-2026 GoodData Corporation
|
|
3
|
-
import { createContext } from "react";
|
|
3
|
+
import { createContext, useState } from "react";
|
|
4
|
+
import { FocusHandoffContext, createFocusHandoff } from "../shared/focusHandoff.js";
|
|
4
5
|
import { CloseAllStatus, } from "./MetricState/metricState.data.js";
|
|
5
6
|
import { useMetricState } from "./MetricState/useMetricState.js";
|
|
6
7
|
export const MultipleMetricsContext = createContext({
|
|
@@ -52,5 +53,7 @@ export function MultipleMetricsState({ children, active, metrics = [], permissio
|
|
|
52
53
|
onClose,
|
|
53
54
|
onCancel,
|
|
54
55
|
});
|
|
55
|
-
|
|
56
|
+
// one per editor instance: it wraps both the editor and its minimized chip
|
|
57
|
+
const [focusHandoff] = useState(createFocusHandoff);
|
|
58
|
+
return (_jsx(MultipleMetricsContext.Provider, { value: metricStateProps, children: _jsx(FocusHandoffContext.Provider, { value: focusHandoff, children: children }) }));
|
|
56
59
|
}
|
package/esm/shared/Tabs/Tab.d.ts
CHANGED
|
@@ -24,8 +24,12 @@ export interface ITabProps<T = undefined> {
|
|
|
24
24
|
beforeActive?: boolean;
|
|
25
25
|
afterActive?: boolean;
|
|
26
26
|
last?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Accessible name of the tab's close button; gets the tab title (or the placeholder) as `title`.
|
|
29
|
+
*/
|
|
30
|
+
closeLabel?: (title: string) => string;
|
|
27
31
|
onActive: (tab: ITab<T>) => void;
|
|
28
32
|
onClose: (tab: ITab<T>) => void;
|
|
29
33
|
}
|
|
30
|
-
export declare function Tab({ tab, placeholder, last, active, afterActive, onActive, onClose }: ITabProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare function Tab({ tab, placeholder, last, active, afterActive, closeLabel, onActive, onClose, }: ITabProps): import("react/jsx-runtime").JSX.Element;
|
|
31
35
|
//# sourceMappingURL=Tab.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/shared/Tabs/Tab.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,UAAU,SAAS,CAAC;AACjC,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,OAAO,aAAa,CAAC;AAClC,eAAO,MAAM,QAAQ,cAAc,CAAC;AACpC,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAiJhD,oBAAY,QAAQ;IAChB,OAAO,YAAY;IACnB,KAAK,UAAU;CAClB;AAED,MAAM,WAAW,IAAI,CAAC,CAAC,GAAG,SAAS;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE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,GAAG,SAAS;IACpC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACjC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CACnC;AAED,wBAAgB,GAAG,CAAC,EAChB,GAAG,EACH,WAAW,EACX,IAAI,EACJ,MAAM,EACN,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,GACV,EAAE,SAAS,2CA4DX"}
|
package/esm/shared/Tabs/Tab.js
CHANGED
|
@@ -151,13 +151,13 @@ export var TabState;
|
|
|
151
151
|
TabState["Invalid"] = "invalid";
|
|
152
152
|
TabState["Dirty"] = "dirty";
|
|
153
153
|
})(TabState || (TabState = {}));
|
|
154
|
-
export function Tab({ tab, placeholder, last, active, afterActive, onActive, onClose }) {
|
|
154
|
+
export function Tab({ tab, placeholder, last, active, afterActive, closeLabel, onActive, onClose, }) {
|
|
155
155
|
const { states, options, title } = tab;
|
|
156
156
|
const { classes, cx } = useStyles();
|
|
157
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { className: cx(classes.space, active && classes.spaceActive, afterActive && classes.spaceAfterActive, TabSpace) }), _jsxs("div", { role: "tab", className: cx(classes.root, TabRoot, active && classes.active, active && TabActive, TabsClasses.Tab), onClick: () => onActive(tab), children: [_jsx("div", { className: cx(classes.dirty, states?.dirty && classes.dirtyActive, states?.dirty && TabsClasses.TabDirty, states?.invalid && classes.dirtyInvalid, states?.invalid && TabsClasses.TabInvalid) }), _jsx("div", { className: cx(classes.title), children: _jsx("div", { className: cx(classes.inner, TitleText), children: _jsx(Title, { title: title, placeholder: placeholder }) }) }), options && options.closeable && (_jsx("button", { className: cx(classes.close, NameButton, TabsClasses.ButtonCloseTab), onClick: (e) => {
|
|
157
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: cx(classes.space, active && classes.spaceActive, afterActive && classes.spaceAfterActive, TabSpace) }), _jsxs("div", { role: "tab", tabIndex: active ? 0 : -1, "aria-selected": active, className: cx(classes.root, TabRoot, active && classes.active, active && TabActive, TabsClasses.Tab), onClick: () => onActive(tab), children: [_jsx("div", { className: cx(classes.dirty, states?.dirty && classes.dirtyActive, states?.dirty && TabsClasses.TabDirty, states?.invalid && classes.dirtyInvalid, states?.invalid && TabsClasses.TabInvalid) }), _jsx("div", { className: cx(classes.title), children: _jsx("div", { className: cx(classes.inner, TitleText), children: _jsx(Title, { title: title, placeholder: placeholder }) }) }), options && options.closeable && (_jsx("button", { type: "button", className: cx(classes.close, NameButton, TabsClasses.ButtonCloseTab), "aria-label": closeLabel?.(title || placeholder || ""), onClick: (e) => {
|
|
158
158
|
e.stopPropagation();
|
|
159
159
|
onClose(tab);
|
|
160
|
-
}, children: _jsx(IconClose, { width: 9, height: 9 }) }))] }), last && _jsx("div", { className: cx(classes.space, active && classes.spaceActive, TabSpace) })] }));
|
|
160
|
+
}, children: _jsx(IconClose, { width: 9, height: 9, ariaHidden: true }) }))] }), last && _jsx("div", { className: cx(classes.space, active && classes.spaceActive, TabSpace) })] }));
|
|
161
161
|
}
|
|
162
162
|
function Title({ title, placeholder }) {
|
|
163
163
|
const { classes, cx } = useStyles();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/shared/Tabs/Tabs.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/shared/Tabs/Tabs.tsx"],"names":[],"mappings":"AAmCA,OAAO,EAAyB,KAAK,UAAU,EAA6B,MAAM,gBAAgB,CAAC;AAEnG,eAAO,MAAM,aAAa,YAAY,CAAC;AAuKvC,wBAAgB,IAAI,CAAC,EACjB,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,SAAS,EACT,SAAiB,EACjB,WAAmB,EACnB,WAAmB,EACnB,SAAiB,EACjB,SAAiB,EACjB,WAAsB,EACtB,aAAwB,EACxB,UAAqB,EACrB,cAAyB,EACzB,iBAA4B,EAC5B,WAAsB,EACtB,OAAY,EACZ,OAAY,GACf,EAAE,UAAU,2CA+IZ"}
|
|
@@ -32,6 +32,14 @@ export interface ITabsProps<T = undefined> {
|
|
|
32
32
|
locales?: {
|
|
33
33
|
createTooltip?: string;
|
|
34
34
|
titlePlaceholder?: string;
|
|
35
|
+
minimize?: string;
|
|
36
|
+
maximize?: string;
|
|
37
|
+
exitMaximize?: string;
|
|
38
|
+
close?: string;
|
|
39
|
+
closeTab?: (title: string) => string;
|
|
40
|
+
tabList?: string;
|
|
41
|
+
scrollLeft?: string;
|
|
42
|
+
scrollRight?: string;
|
|
35
43
|
};
|
|
36
44
|
}
|
|
37
45
|
//# sourceMappingURL=Tabs.data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.data.d.ts","sourceRoot":"","sources":["../../../src/shared/Tabs/Tabs.data.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,WAAW,MAAM,CAAC;AAE/B,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,SAAS;IAC3C,GAAG,EAAE,IAAI,CAAC,CAAC,CA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AAK,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAE7C,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,OAAO,CAAC,EAAE;QACN,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAE1B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;QACrC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACL"}
|
package/esm/shared/Tabs/Tabs.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2022-2026 GoodData Corporation
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useEffect, useRef, useState, } from "react";
|
|
4
4
|
import { Bubble, BubbleHoverTrigger, Button, IconClose, IconContract, IconExpand, IconMinimize, } from "@gooddata/sdk-ui-kit";
|
|
5
|
+
import { handOffFocusDuring, useFocusHandoff } from "../focusHandoff.js";
|
|
5
6
|
import { makeStyles } from "../theme/index.js";
|
|
6
7
|
import { useChangeScroll } from "./hooks/useChangeScroll.js";
|
|
7
8
|
import { useScrollByButtons } from "./hooks/useScrollByButtons.js";
|
|
8
9
|
import { useScrollToActive } from "./hooks/useScrollToActive.js";
|
|
9
10
|
import { useTabCallbacks } from "./hooks/useTabCallbacks.js";
|
|
10
11
|
import { useTabsCallbacks } from "./hooks/useTabsCallbacks.js";
|
|
11
|
-
import {
|
|
12
|
+
import { useTabsLabels } from "./hooks/useTabsLabels.js";
|
|
13
|
+
import { NameButton, Tab, TabActive, TabRoot, TitleText } from "./Tab.js";
|
|
12
14
|
import { TabsClasses } from "./Tabs.classes.js";
|
|
13
15
|
import { TabMaxWidth, TabsIconSize } from "./Tabs.data.js";
|
|
14
16
|
export const ButtonDivider = "divider";
|
|
@@ -166,25 +168,102 @@ export function Tabs({ tabs, active, render, content, className, closeable = fal
|
|
|
166
168
|
}
|
|
167
169
|
const { classes, cx } = useStyles();
|
|
168
170
|
const { scrollToTabSpace = 3, scrollByArrowsRepeat = 150, scrollByArrowsStep = 100 } = options;
|
|
171
|
+
const labels = useTabsLabels(locales);
|
|
169
172
|
const [tabsElement, setTabsElement] = useState(null);
|
|
170
|
-
const
|
|
173
|
+
const editorRoot = useRef(null);
|
|
174
|
+
const { enabled, canLeft, canRight, onLeft, onRight, stepLeft, stepRight } = useScrollByButtons(tabsElement, scrollByArrowsRepeat, scrollByArrowsStep);
|
|
171
175
|
useChangeScroll(tabsElement);
|
|
172
176
|
useScrollToActive(tabsElement, active, enabled, scrollToTabSpace);
|
|
173
177
|
const { onTabsMinimizeHandler, onTabsCloseHandler, onTabCreateHandler, onTabsMaximizeHandler } = useTabsCallbacks(onTabCreate, onTabsMinimize, onTabsMaximizable, onTabsClose);
|
|
174
178
|
const { onTabActiveHandler, onTabCloseHandler } = useTabCallbacks(tabs, onTabActivate, onTabClose, onTabsClose);
|
|
179
|
+
const onTabListKeyDown = useTabListKeyboard(tabsElement, tabs, active, onTabActiveHandler);
|
|
175
180
|
const Content = content;
|
|
176
|
-
return (_jsxs("div", { className: cx(classes.root, className), children: [_jsxs("div", { className: cx(classes.tabs), children: [enabled && (_jsx("button", { className: cx(classes.leftButton, !canLeft && classes.disabled, TabsClasses.ButtonLeft), onMouseDown: onLeft, children: _jsx("span", { className: "gd-icon-navigateleft" }) })), _jsx("div", { className: cx(classes.tabsList, {
|
|
181
|
+
return (_jsxs("div", { ref: editorRoot, className: cx(classes.root, className), children: [_jsxs("div", { className: cx(classes.tabs), children: [enabled && (_jsx("button", { type: "button", "aria-label": labels.scrollLeft, "aria-disabled": !canLeft, className: cx(classes.leftButton, !canLeft && classes.disabled, TabsClasses.ButtonLeft), onMouseDown: onLeft, onClick: (event) => onScrollButtonClick(event, stepLeft), children: _jsx("span", { className: "gd-icon-navigateleft", "aria-hidden": "true" }) })), _jsx("div", { role: "tablist", "aria-label": labels.tabList, onKeyDown: onTabListKeyDown, className: cx(classes.tabsList, {
|
|
177
182
|
minimizable: minimizable,
|
|
178
183
|
closeable: closeable,
|
|
179
184
|
scrollable: enabled,
|
|
180
|
-
}), style: { width: TabMaxWidth * tabs.length }, ref: setTabsElement, children: tabs.map((tab, i) => (_jsx(Tab, { tab: tab, placeholder: locales.titlePlaceholder, active: active === i, last: i === tabs.length - 1, beforeActive: active - 1 === i, afterActive: active + 1 === i, onActive: onTabActiveHandler, onClose: onTabCloseHandler }, tab.id))) }), enabled && (_jsx("button", { className: cx(classes.rightButton, !canRight && classes.disabled, TabsClasses.ButtonRight), onMouseDown: onRight, children: _jsx("span", { className: "gd-icon-navigateright" }) })), creatable && (_jsxs(BubbleHoverTrigger, { showDelay: 0, hideDelay: 100, eventsOnBubble: true, className: classes.trigger, children: [_jsx("div", { className: cx(classes.controls), children: _jsx(Button, { iconLeft: "gd-icon-add", onClick: onTabCreateHandler, className: cx(classes.create, "gd-button-action", TabsClasses.ButtonNewTab)
|
|
185
|
+
}), style: { width: TabMaxWidth * tabs.length }, ref: setTabsElement, children: tabs.map((tab, i) => (_jsx(Tab, { tab: tab, placeholder: locales.titlePlaceholder, active: active === i, last: i === tabs.length - 1, beforeActive: active - 1 === i, afterActive: active + 1 === i, closeLabel: labels.closeTab, onActive: onTabActiveHandler, onClose: onTabCloseHandler }, tab.id))) }), enabled && (_jsx("button", { type: "button", "aria-label": labels.scrollRight, "aria-disabled": !canRight, className: cx(classes.rightButton, !canRight && classes.disabled, TabsClasses.ButtonRight), onMouseDown: onRight, onClick: (event) => onScrollButtonClick(event, stepRight), children: _jsx("span", { className: "gd-icon-navigateright", "aria-hidden": "true" }) })), creatable && (_jsxs(BubbleHoverTrigger, { showDelay: 0, hideDelay: 100, eventsOnBubble: true, className: classes.trigger, children: [_jsx("div", { className: cx(classes.controls), children: _jsx(Button, { iconLeft: "gd-icon-add", onClick: onTabCreateHandler, className: cx(classes.create, "gd-button-action", TabsClasses.ButtonNewTab),
|
|
186
|
+
// the same text as the hover tooltip, so the name matches what is seen
|
|
187
|
+
accessibilityConfig: { ariaLabel: labels.create } }) }), locales.createTooltip && (_jsx(Bubble, { className: cx("bubble-dark", "s-tabs-create-tooltip"), alignPoints: [{ align: "bc tr", offset: { x: 0, y: -5 } }], children: locales.createTooltip }))] })), _jsx("div", { className: cx(classes.filler) }), _jsx("div", { className: cx(classes.controls), children: _jsx(TabsControls, { maximized: maximized, minimizable: minimizable, maximizable: maximizable, closeable: closeable,
|
|
188
|
+
// closing asks first only when a metric has unsaved changes
|
|
189
|
+
closeOpensDialog: tabs.some((tab) => tab.states?.dirty), labels: labels, onTabsClose: onTabsCloseHandler, onTabsMinimize: onTabsMinimizeHandler, editorRoot: editorRoot, onTabsMaximize: onTabsMaximizeHandler }) })] }), Content && tabs[active] && _jsx(Content, { tab: tabs[active] }), render && tabs[active] && render({ tab: tabs[active] })] }));
|
|
181
190
|
}
|
|
182
|
-
|
|
191
|
+
/**
|
|
192
|
+
* A click with no pointer behind it (`detail` 0) comes from Enter, Space or assistive technology, and
|
|
193
|
+
* scrolls one step. A mouse click (`detail` 1 and up) was already handled by its mousedown, which
|
|
194
|
+
* keeps scrolling while the button is held, so it does not scroll a second time.
|
|
195
|
+
*/
|
|
196
|
+
function onScrollButtonClick(event, step) {
|
|
197
|
+
if (event.detail === 0) {
|
|
198
|
+
step();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The arrow keys, Home and End of the tab list, the way the ARIA tabs pattern has them: they select
|
|
203
|
+
* the tab (selection follows the focus) and move the focus to it once it is active, and the active
|
|
204
|
+
* tab scrolls into view as it does for a mouse selection.
|
|
205
|
+
*/
|
|
206
|
+
function useTabListKeyboard(tabsElement, tabs, active, onActivate) {
|
|
207
|
+
const isFocusPending = useRef(false);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (!isFocusPending.current) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
isFocusPending.current = false;
|
|
213
|
+
// The key's activation may never have completed (a caller can hold it back), and the change
|
|
214
|
+
// of the active tab then comes from elsewhere; follow it only while the keyboard is still in
|
|
215
|
+
// the tab list, never pull the focus back from a field the user went to in the meantime.
|
|
216
|
+
if (!tabsElement?.contains(document.activeElement)) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
// the scroll to the active tab is smooth, a focus scroll would jump ahead of it
|
|
220
|
+
tabsElement.querySelector(`.${TabRoot}.${TabActive}`)?.focus({ preventScroll: true });
|
|
221
|
+
}, [active, tabsElement]);
|
|
222
|
+
return (event) => {
|
|
223
|
+
// the keys of the close button inside a tab are its own
|
|
224
|
+
if (!(event.target instanceof HTMLElement) || event.target.getAttribute("role") !== "tab") {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const last = tabs.length - 1;
|
|
228
|
+
const targets = {
|
|
229
|
+
ArrowLeft: active > 0 ? active - 1 : last,
|
|
230
|
+
ArrowRight: active < last ? active + 1 : 0,
|
|
231
|
+
Home: 0,
|
|
232
|
+
End: last,
|
|
233
|
+
};
|
|
234
|
+
const target = targets[event.key];
|
|
235
|
+
if (target === undefined) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
if (target !== active && tabs[target]) {
|
|
240
|
+
isFocusPending.current = true;
|
|
241
|
+
onActivate(tabs[target]);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function TabsControls({ minimizable, maximizable, maximized, closeable, closeOpensDialog, labels, onTabsMinimize, onTabsMaximize, onTabsClose, editorRoot, }) {
|
|
183
246
|
const { classes, cx } = useStyles();
|
|
247
|
+
const minimizeButton = useRef(null);
|
|
248
|
+
const focusHandoff = useFocusHandoff();
|
|
249
|
+
// Restoring from the chip drops the focus to the page (see focusHandoff). Put it back on the
|
|
250
|
+
// minimize button, where it was before minimizing, only when this editor's chip handed it off,
|
|
251
|
+
// and only if nothing inside the editor has taken it in the meantime.
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
const isHandedOff = focusHandoff?.take("editor") ?? false;
|
|
254
|
+
const isFocusDropped = !document.activeElement || document.activeElement === document.body;
|
|
255
|
+
if (isHandedOff && isFocusDropped) {
|
|
256
|
+
minimizeButton.current?.focus();
|
|
257
|
+
}
|
|
258
|
+
// only on mount, which is when the chip has just handed off
|
|
259
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
260
|
+
}, []);
|
|
261
|
+
// minimizing unmounts the editor, so the chip catches the focus if the editor held it
|
|
262
|
+
const minimizeHandler = () => handOffFocusDuring(focusHandoff, "chip", !!editorRoot.current?.contains(document.activeElement), onTabsMinimize, () => editorRoot.current !== null);
|
|
184
263
|
const controls = [
|
|
185
|
-
minimizable && (_jsx("button", { className: cx(classes.button, TabsClasses.ButtonMinimize), onClick:
|
|
186
|
-
maximizable && (_jsx("button", { className: cx(classes.button, TabsClasses.ButtonMaximize), onClick: () => onTabsMaximize?.(!maximized), children: maximized ? (_jsx(IconContract, { width: TabsIconSize, height: TabsIconSize })) : (_jsx(IconExpand, { width: TabsIconSize, height: TabsIconSize })) }, "maximize")),
|
|
187
|
-
closeable && (_jsx("button", { className: cx(classes.button, TabsClasses.ButtonCloseTabs), onClick: onTabsClose, children: _jsx(IconClose, { width: TabsIconSize, height: TabsIconSize }) }, "close")),
|
|
264
|
+
minimizable && (_jsx("button", { ref: minimizeButton, type: "button", className: cx(classes.button, TabsClasses.ButtonMinimize), "aria-label": labels.minimize, onClick: minimizeHandler, children: _jsx(IconMinimize, { width: TabsIconSize, height: TabsIconSize, ariaHidden: true }) }, "minimize")),
|
|
265
|
+
maximizable && (_jsx("button", { type: "button", className: cx(classes.button, TabsClasses.ButtonMaximize), "aria-label": maximized ? labels.exitMaximize : labels.maximize, onClick: () => onTabsMaximize?.(!maximized), children: maximized ? (_jsx(IconContract, { width: TabsIconSize, height: TabsIconSize, ariaHidden: true })) : (_jsx(IconExpand, { width: TabsIconSize, height: TabsIconSize, ariaHidden: true })) }, "maximize")),
|
|
266
|
+
closeable && (_jsx("button", { type: "button", className: cx(classes.button, TabsClasses.ButtonCloseTabs), "aria-label": labels.close, "aria-haspopup": closeOpensDialog ? "dialog" : undefined, onClick: onTabsClose, children: _jsx(IconClose, { width: TabsIconSize, height: TabsIconSize, ariaHidden: true }) }, "close")),
|
|
188
267
|
];
|
|
189
268
|
return (_jsx(_Fragment, { children: controls.filter(Boolean).reduce((prev, current, i) => {
|
|
190
269
|
if (i !== 0) {
|
|
@@ -5,5 +5,7 @@ export declare function useScrollByButtons(element: HTMLElement | null, timeout?
|
|
|
5
5
|
canRight: boolean;
|
|
6
6
|
onLeft: (e: MouseEvent) => void;
|
|
7
7
|
onRight: (e: MouseEvent) => void;
|
|
8
|
+
stepLeft: () => void;
|
|
9
|
+
stepRight: () => void;
|
|
8
10
|
};
|
|
9
11
|
//# sourceMappingURL=useScrollByButtons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollByButtons.d.ts","sourceRoot":"","sources":["../../../../src/shared/Tabs/hooks/useScrollByButtons.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAA6C,MAAM,OAAO,CAAC;AAInF,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,OAAO,SAAM,EACb,IAAI,SAAM,GACX;IACC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"useScrollByButtons.d.ts","sourceRoot":"","sources":["../../../../src/shared/Tabs/hooks/useScrollByButtons.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAA6C,MAAM,OAAO,CAAC;AAInF,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,OAAO,SAAM,EACb,IAAI,SAAM,GACX;IACC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAEjC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;CACzB,CAuBA"}
|
|
@@ -14,9 +14,11 @@ export function useScrollByButtons(element, timeout = 150, step = 100) {
|
|
|
14
14
|
canRight,
|
|
15
15
|
onLeft,
|
|
16
16
|
onRight,
|
|
17
|
+
stepLeft: onLeftHandler,
|
|
18
|
+
stepRight: onRightHandler,
|
|
17
19
|
}),
|
|
18
20
|
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
-
[enabled, canLeft, canRight, onLeft, onRight, changed]);
|
|
21
|
+
[enabled, canLeft, canRight, onLeft, onRight, onLeftHandler, onRightHandler, changed]);
|
|
20
22
|
}
|
|
21
23
|
function useScroll(element) {
|
|
22
24
|
const [changed, setChanged] = useState("");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ITabsProps } from "../Tabs.data.js";
|
|
2
|
+
/**
|
|
3
|
+
* The accessible names of the tab strip's controls.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITabsLabels {
|
|
6
|
+
tabList: string;
|
|
7
|
+
create: string;
|
|
8
|
+
minimize: string;
|
|
9
|
+
maximize: string;
|
|
10
|
+
exitMaximize: string;
|
|
11
|
+
close: string;
|
|
12
|
+
closeTab: (title: string) => string;
|
|
13
|
+
scrollLeft: string;
|
|
14
|
+
scrollRight: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Every icon-only control needs an accessible name, so each one has a localized default; a label in
|
|
18
|
+
* `locales` overrides it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useTabsLabels(locales: NonNullable<ITabsProps["locales"]>): ITabsLabels;
|
|
21
|
+
//# sourceMappingURL=useTabsLabels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTabsLabels.d.ts","sourceRoot":"","sources":["../../../../src/shared/Tabs/hooks/useTabsLabels.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACvB;AAUD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,GAAG,WAAW,CAgBtF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { IntlContext, createIntl } from "react-intl";
|
|
4
|
+
import { DEFAULT_LANGUAGE, DEFAULT_MESSAGES } from "../../../translations/translations.js";
|
|
5
|
+
let fallbackIntl;
|
|
6
|
+
// Outside an IntlProvider (a bare render) the names still come from the default messages.
|
|
7
|
+
function getFallbackIntl() {
|
|
8
|
+
fallbackIntl ??= createIntl({ locale: DEFAULT_LANGUAGE, messages: DEFAULT_MESSAGES[DEFAULT_LANGUAGE] });
|
|
9
|
+
return fallbackIntl;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Every icon-only control needs an accessible name, so each one has a localized default; a label in
|
|
13
|
+
* `locales` overrides it.
|
|
14
|
+
*/
|
|
15
|
+
export function useTabsLabels(locales) {
|
|
16
|
+
const intl = useContext(IntlContext) ?? getFallbackIntl();
|
|
17
|
+
return {
|
|
18
|
+
tabList: locales.tabList ?? intl.formatMessage({ id: "metricComponent.tabs.tabList" }),
|
|
19
|
+
create: locales.createTooltip ?? intl.formatMessage({ id: "metricComponent.createMetric.title" }),
|
|
20
|
+
minimize: locales.minimize ?? intl.formatMessage({ id: "metricComponent.tabs.minimize" }),
|
|
21
|
+
maximize: locales.maximize ?? intl.formatMessage({ id: "metricComponent.tabs.maximize" }),
|
|
22
|
+
exitMaximize: locales.exitMaximize ?? intl.formatMessage({ id: "metricComponent.tabs.exitMaximize" }),
|
|
23
|
+
close: locales.close ?? intl.formatMessage({ id: "metricComponent.tabs.close" }),
|
|
24
|
+
closeTab: locales.closeTab ??
|
|
25
|
+
((title) => intl.formatMessage({ id: "metricComponent.tabs.closeTab" }, { title })),
|
|
26
|
+
scrollLeft: locales.scrollLeft ?? intl.formatMessage({ id: "metricComponent.tabs.scrollLeft" }),
|
|
27
|
+
scrollRight: locales.scrollRight ?? intl.formatMessage({ id: "metricComponent.tabs.scrollRight" }),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the focus goes when the metric editor is minimized into the chip, or restored from it.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Minimizing unmounts the editor and mounts the chip, restoring the other way round; the focus is
|
|
6
|
+
* dropped to the page either way. The side that unmounts records that it held the focus, and the
|
|
7
|
+
* side that mounts takes the record and catches the focus. Without a record the mounting side leaves
|
|
8
|
+
* the focus alone, so a chip or an editor that appears for any other reason never takes it.
|
|
9
|
+
*
|
|
10
|
+
* The record belongs to one editor instance (one `MultipleMetricsState`), so the chip of another
|
|
11
|
+
* editor never takes it, and the side that made it cancels it when the transition did not happen.
|
|
12
|
+
*/
|
|
13
|
+
export type FocusHandoffTarget = "chip" | "editor";
|
|
14
|
+
export interface IFocusHandoff {
|
|
15
|
+
handOff(target: FocusHandoffTarget): void;
|
|
16
|
+
/**
|
|
17
|
+
* True once after `handOff(target)`, false otherwise; the record is gone after it.
|
|
18
|
+
*/
|
|
19
|
+
take(target: FocusHandoffTarget): boolean;
|
|
20
|
+
cancel(target: FocusHandoffTarget): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createFocusHandoff(): IFocusHandoff;
|
|
23
|
+
/**
|
|
24
|
+
* The handoff of the editor instance around; null outside one, where the focus is never moved.
|
|
25
|
+
*/
|
|
26
|
+
export declare const FocusHandoffContext: import("react").Context<IFocusHandoff | null>;
|
|
27
|
+
export declare function useFocusHandoff(): IFocusHandoff | null;
|
|
28
|
+
/**
|
|
29
|
+
* Runs the transition and cancels the record if, a task later, the side that made it is still
|
|
30
|
+
* mounted: the transition did not happen, and nothing is coming to take the record.
|
|
31
|
+
*/
|
|
32
|
+
export declare function handOffFocusDuring(handoff: IFocusHandoff | null, target: FocusHandoffTarget, isFocusHeld: boolean, transition: (() => void) | undefined, isStillMounted: () => boolean): void;
|
|
33
|
+
//# sourceMappingURL=focusHandoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusHandoff.d.ts","sourceRoot":"","sources":["../../src/shared/focusHandoff.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC1B,OAAO,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1C;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAC1C,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC5C;AAED,wBAAgB,kBAAkB,IAAI,aAAa,CAoBlD;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,+CAA4C,CAAC;AAE7E,wBAAgB,eAAe,IAAI,aAAa,GAAG,IAAI,CAEtD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,aAAa,GAAG,IAAI,EAC7B,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,OAAO,EACpB,UAAU,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EACpC,cAAc,EAAE,MAAM,OAAO,GAC9B,IAAI,CAUN"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
export function createFocusHandoff() {
|
|
4
|
+
let pending = null;
|
|
5
|
+
return {
|
|
6
|
+
handOff: (target) => {
|
|
7
|
+
pending = target;
|
|
8
|
+
},
|
|
9
|
+
take: (target) => {
|
|
10
|
+
if (pending !== target) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
pending = null;
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
cancel: (target) => {
|
|
17
|
+
if (pending === target) {
|
|
18
|
+
pending = null;
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The handoff of the editor instance around; null outside one, where the focus is never moved.
|
|
25
|
+
*/
|
|
26
|
+
export const FocusHandoffContext = createContext(null);
|
|
27
|
+
export function useFocusHandoff() {
|
|
28
|
+
return useContext(FocusHandoffContext);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Runs the transition and cancels the record if, a task later, the side that made it is still
|
|
32
|
+
* mounted: the transition did not happen, and nothing is coming to take the record.
|
|
33
|
+
*/
|
|
34
|
+
export function handOffFocusDuring(handoff, target, isFocusHeld, transition, isStillMounted) {
|
|
35
|
+
if (handoff && isFocusHeld) {
|
|
36
|
+
handoff.handOff(target);
|
|
37
|
+
window.setTimeout(() => {
|
|
38
|
+
if (isStillMounted()) {
|
|
39
|
+
handoff.cancel(target);
|
|
40
|
+
}
|
|
41
|
+
}, 0);
|
|
42
|
+
}
|
|
43
|
+
transition?.();
|
|
44
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMetricListData.d.ts","sourceRoot":"","sources":["../../../src/shared/metrics/useMetricListData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMetricListData.d.ts","sourceRoot":"","sources":["../../../src/shared/metrics/useMetricListData.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAWlE,UAAU,aAAa;IACnB,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,iBAAiB,YAEb,kBAAkB,eACd,MAAM,gBACL,CAAC,IAAI,EAAE,sBAAsB,EAAE,KAAK,IAAI,gCAEvD,mBAqBF,CAAC;AAEN;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,0BAE3B,yBAAyB,KAAQ,cAoCnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMetricListData.events.d.ts","sourceRoot":"","sources":["../../../src/shared/metrics/useMetricListData.events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMetricListData.events.d.ts","sourceRoot":"","sources":["../../../src/shared/metrics/useMetricListData.events.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAG1D,MAAM,MAAM,oBAAoB,GAAG;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uBAAuB,EAAE,MAAM,CAAC;CACnC,CAAC;AAmBF,iBAAS,wBAAwB,CAAC,IAAI,EAAE,sBAAsB,EAAE,GAAG,MAAM,GAAG,IAAI,CAO/E;AAED,eAAO,MAAM,MAAM;;CAElB,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// (C) 2021-2026 GoodData Corporation
|
|
2
|
-
import {
|
|
3
|
-
import { _isEqual } from "@gooddata/util";
|
|
2
|
+
import { _groupBy, _isEqual } from "@gooddata/util";
|
|
4
3
|
import { EventCategories, Events } from "../eventing/events.js";
|
|
5
4
|
function getSameItemNumber(collection, iteratee) {
|
|
6
|
-
const groups =
|
|
5
|
+
const groups = _groupBy(collection, iteratee);
|
|
7
6
|
return Object.values(groups).filter((group) => group.length > 1).length;
|
|
8
7
|
}
|
|
9
8
|
function calculateWorkspaceMetricStats(data) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// (C) 2021-2026 GoodData Corporation
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
-
import { debounce } from "lodash-es";
|
|
4
3
|
import { useBackendStrict, useCancelablePromise, useWorkspaceStrict } from "@gooddata/sdk-ui";
|
|
4
|
+
import { _debounce } from "@gooddata/util";
|
|
5
5
|
import { useEvents } from "../eventing/useEvents.js";
|
|
6
6
|
import { getFilteredItems } from "./functions/metricListData.js";
|
|
7
7
|
import { events } from "./useMetricListData.events.js";
|
|
@@ -32,7 +32,7 @@ export const useMetricListData = ({ loadPermissions = false, } = {}) => {
|
|
|
32
32
|
const [sort, setSort] = useState({ type: "title", direction: "asc" });
|
|
33
33
|
const [search, setSearch] = useState("");
|
|
34
34
|
const { workspaceMetricDataEvent } = useEvents(events);
|
|
35
|
-
const debouncedTrackWorkspace =
|
|
35
|
+
const debouncedTrackWorkspace = _debounce(workspaceMetricDataEvent, 500);
|
|
36
36
|
const workspaceId = useWorkspaceStrict();
|
|
37
37
|
const backend = useBackendStrict();
|
|
38
38
|
const { metricReloadRequest } = useReloadMetrics();
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"metricComponent.editMetric.metric.result.context.displayTop": "Oben",
|
|
65
65
|
"metricComponent.editMetric.metric.result.context.displayBottom": "Unten",
|
|
66
66
|
"metricComponent.editMetric.metric.result": "Ergebnis",
|
|
67
|
-
"metricComponent.editMetric.metric.result.tooltip": "Die Metrik gibt eine Zahl zurück und kann wiederverwendet werden, wenn sie mit Attributen und Filtern kombiniert wird, um einen Report zu erstellen. Fügen Sie „Anzeigen nach“ hinzu, um einen
|
|
67
|
+
"metricComponent.editMetric.metric.result.tooltip": "Die Metrik gibt eine Zahl zurück und kann wiederverwendet werden, wenn sie mit Attributen und Filtern kombiniert wird, um einen Report zu erstellen. Fügen Sie „Anzeigen nach“ hinzu, um einen Vorschaureport zu erstellen.",
|
|
68
68
|
"metricComponent.editMetric.metric.result.computing": "Wird berechnet...",
|
|
69
69
|
"metricComponent.editMetric.metric.result.error.title": "Fehler beim Berechnen des Ergebnisses",
|
|
70
70
|
"metricComponent.editMetric.metric.result.error": "Das Ergebnis kann nicht berechnet werden, da die Metrikdefinition unvollständig oder ungültig ist.",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"crowdinContext": "Text on a button to automatically apply formatting rules on a MAQL metric"
|
|
33
33
|
},
|
|
34
34
|
"metricComponent.editMetric.autoFormatBubble": {
|
|
35
|
-
"text": "Format metric expression (Shift+
|
|
35
|
+
"text": "Format metric expression (Shift+Alt+F)",
|
|
36
36
|
"crowdinContext": "Tooltip for auto-format button with keyboard shortcut"
|
|
37
37
|
},
|
|
38
38
|
"metricComponent.editMetric.autoFormatBubbleMac": {
|
|
@@ -69,11 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"metricComponent.editMetric.decoratorsShow": {
|
|
71
71
|
"text": "Show names",
|
|
72
|
-
"crowdinContext": "
|
|
73
|
-
},
|
|
74
|
-
"metricComponent.editMetric.decoratorsHide": {
|
|
75
|
-
"text": "Hide names",
|
|
76
|
-
"crowdinContext": "Button to hide element names in metric editor"
|
|
72
|
+
"crowdinContext": "Menu item with a check mark that turns the display of element names in the metric editor on and off"
|
|
77
73
|
},
|
|
78
74
|
"metricComponent.editMetric.descriptionPlaceholder": {
|
|
79
75
|
"text": "Add description here...",
|
|
@@ -223,6 +219,14 @@
|
|
|
223
219
|
"text": "Create a MAQL statement to query your data.",
|
|
224
220
|
"crowdinContext": "Tooltip explaining metric definition functionality"
|
|
225
221
|
},
|
|
222
|
+
"metricComponent.editMetric.metric.definition.moreActions": {
|
|
223
|
+
"text": "More actions for the metric definition",
|
|
224
|
+
"crowdinContext": "Accessible name of the '...' button that opens the menu of the metric definition section (auto format, show or hide titles)"
|
|
225
|
+
},
|
|
226
|
+
"metricComponent.partHeader.moreActions": {
|
|
227
|
+
"text": "More actions",
|
|
228
|
+
"crowdinContext": "Accessible name of a '...' button that opens a menu of more actions for a section of the metric editor"
|
|
229
|
+
},
|
|
226
230
|
"metricComponent.editMetric.metric.result.context": {
|
|
227
231
|
"text": "View by",
|
|
228
232
|
"crowdinContext": "Label for result context section"
|
|
@@ -495,6 +499,42 @@
|
|
|
495
499
|
"text": "Save all",
|
|
496
500
|
"crowdinContext": "Button to save all unsaved changes"
|
|
497
501
|
},
|
|
502
|
+
"metricComponent.minimize.restore": {
|
|
503
|
+
"text": "Restore editor",
|
|
504
|
+
"crowdinContext": "Accessible name of the icon button that reopens the minimized metric editor"
|
|
505
|
+
},
|
|
506
|
+
"metricComponent.tabs.minimize": {
|
|
507
|
+
"text": "Minimize editor",
|
|
508
|
+
"crowdinContext": "Accessible name of the icon button that minimizes the metric editor into a small bar"
|
|
509
|
+
},
|
|
510
|
+
"metricComponent.tabs.maximize": {
|
|
511
|
+
"text": "Full screen",
|
|
512
|
+
"crowdinContext": "Accessible name of the icon button that expands the metric editor to full screen"
|
|
513
|
+
},
|
|
514
|
+
"metricComponent.tabs.exitMaximize": {
|
|
515
|
+
"text": "Exit full screen",
|
|
516
|
+
"crowdinContext": "Accessible name of the icon button that returns the full-screen metric editor to its normal size"
|
|
517
|
+
},
|
|
518
|
+
"metricComponent.tabs.close": {
|
|
519
|
+
"text": "Close editor",
|
|
520
|
+
"crowdinContext": "Accessible name of the icon button that closes the metric editor with all its open metrics"
|
|
521
|
+
},
|
|
522
|
+
"metricComponent.tabs.tabList": {
|
|
523
|
+
"text": "Open metrics",
|
|
524
|
+
"crowdinContext": "Accessible name of the row of tabs in the metric editor, one tab per metric being edited"
|
|
525
|
+
},
|
|
526
|
+
"metricComponent.tabs.scrollLeft": {
|
|
527
|
+
"text": "Scroll tabs left",
|
|
528
|
+
"crowdinContext": "Accessible name of the arrow button that scrolls the metric editor tabs to the left"
|
|
529
|
+
},
|
|
530
|
+
"metricComponent.tabs.scrollRight": {
|
|
531
|
+
"text": "Scroll tabs right",
|
|
532
|
+
"crowdinContext": "Accessible name of the arrow button that scrolls the metric editor tabs to the right"
|
|
533
|
+
},
|
|
534
|
+
"metricComponent.tabs.closeTab": {
|
|
535
|
+
"text": "Close {title}",
|
|
536
|
+
"crowdinContext": "Accessible name of the icon button that closes one metric tab in the metric editor. {title} is the metric name"
|
|
537
|
+
},
|
|
498
538
|
"metricComponent.minimize.editing": {
|
|
499
539
|
"text": "Editing:",
|
|
500
540
|
"crowdinContext": "Status label when metric is in editing mode"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../src/translations/translations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../src/translations/translations.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,aAAa,EAGrB,MAAM,kBAAkB,CAAC;AAc1B;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAiB,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAM1D,CAAC;AA2DF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAqC,CAAC;AAE7G;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CACxC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAChD,MAAM,EAAE,MAAM,GACf,MAAM,CAER"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// (C) 2021-2026 GoodData Corporation
|
|
2
|
-
import { memoize } from "lodash-es";
|
|
3
2
|
import { DEFAULT_MESSAGES as SDK_DEFAULT_MESSAGES, resolveMessages as resolveSdkMessages, } from "@gooddata/sdk-ui";
|
|
4
3
|
// The share dialog's `objectShare.*` ids live in sdk-ui-ext, not the sdk-ui layer.
|
|
5
4
|
import { DEFAULT_MESSAGES as EXT_DEFAULT_MESSAGES, resolveMessages as resolveExtMessages, } from "@gooddata/sdk-ui-ext/internal";
|
|
6
|
-
import { removeMetadata } from "@gooddata/util";
|
|
5
|
+
import { _memoize, removeMetadata } from "@gooddata/util";
|
|
7
6
|
import en_US from "./en-US.json" with { type: "json" };
|
|
8
7
|
// English (default) app messages, used as the fallback for locales that are missing keys.
|
|
9
8
|
// The composed sdk layer already falls back to English for its own keys.
|
|
@@ -80,7 +79,7 @@ const resolveMessagesInternal = async (locale) => {
|
|
|
80
79
|
*
|
|
81
80
|
* @internal
|
|
82
81
|
*/
|
|
83
|
-
export const resolveMessages =
|
|
82
|
+
export const resolveMessages = _memoize(resolveMessagesInternal);
|
|
84
83
|
/**
|
|
85
84
|
* Validates if a locale has translations available in the messages map.
|
|
86
85
|
* Falls back to DEFAULT_LANGUAGE if the locale is not found.
|