@gooddata/sdk-ui-metric-component 11.68.0-alpha.9 → 11.69.0-alpha.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.
Files changed (61) hide show
  1. package/NOTICE +55 -386
  2. package/esm/MaqlEditor/codemirror/baseExtensions.d.ts +0 -8
  3. package/esm/MaqlEditor/codemirror/baseExtensions.d.ts.map +1 -1
  4. package/esm/MaqlEditor/codemirror/baseExtensions.js +13 -25
  5. package/esm/MaqlEditor/maql/extensions/completion.d.ts +13 -3
  6. package/esm/MaqlEditor/maql/extensions/completion.d.ts.map +1 -1
  7. package/esm/MaqlEditor/maql/extensions/completion.js +69 -36
  8. package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorHeader.d.ts.map +1 -1
  9. package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorHeader.js +8 -6
  10. package/esm/MetricComponent/Form/PartHeader/PartHeader.d.ts +16 -1
  11. package/esm/MetricComponent/Form/PartHeader/PartHeader.d.ts.map +1 -1
  12. package/esm/MetricComponent/Form/PartHeader/PartHeader.js +97 -21
  13. package/esm/MetricComponent/MetricsState.d.ts.map +1 -1
  14. package/esm/MetricComponent/MetricsState.js +1 -0
  15. package/esm/MetricComponent/MinimizedMetricComponent/MinimizedMetricComponent.d.ts.map +1 -1
  16. package/esm/MetricComponent/MinimizedMetricComponent/MinimizedMetricComponent.js +25 -4
  17. package/esm/MetricComponent/MultipleMetricsState.d.ts.map +1 -1
  18. package/esm/MetricComponent/MultipleMetricsState.js +5 -2
  19. package/esm/shared/Tabs/Tab.d.ts +5 -1
  20. package/esm/shared/Tabs/Tab.d.ts.map +1 -1
  21. package/esm/shared/Tabs/Tab.js +3 -3
  22. package/esm/shared/Tabs/Tabs.d.ts.map +1 -1
  23. package/esm/shared/Tabs/Tabs.data.d.ts +8 -0
  24. package/esm/shared/Tabs/Tabs.data.d.ts.map +1 -1
  25. package/esm/shared/Tabs/Tabs.js +88 -9
  26. package/esm/shared/Tabs/hooks/useScrollByButtons.d.ts +2 -0
  27. package/esm/shared/Tabs/hooks/useScrollByButtons.d.ts.map +1 -1
  28. package/esm/shared/Tabs/hooks/useScrollByButtons.js +3 -1
  29. package/esm/shared/Tabs/hooks/useTabsLabels.d.ts +21 -0
  30. package/esm/shared/Tabs/hooks/useTabsLabels.d.ts.map +1 -0
  31. package/esm/shared/Tabs/hooks/useTabsLabels.js +29 -0
  32. package/esm/shared/focusHandoff.d.ts +33 -0
  33. package/esm/shared/focusHandoff.d.ts.map +1 -0
  34. package/esm/shared/focusHandoff.js +44 -0
  35. package/esm/translations/de-DE.json +10 -1
  36. package/esm/translations/en-AU.json +9 -0
  37. package/esm/translations/en-GB.json +9 -0
  38. package/esm/translations/en-US.json +46 -6
  39. package/esm/translations/es-419.json +9 -0
  40. package/esm/translations/es-ES.json +9 -0
  41. package/esm/translations/fi-FI.json +9 -0
  42. package/esm/translations/fr-CA.json +9 -0
  43. package/esm/translations/fr-FR.json +9 -0
  44. package/esm/translations/id-ID.json +9 -0
  45. package/esm/translations/it-IT.json +9 -0
  46. package/esm/translations/ja-JP.json +9 -0
  47. package/esm/translations/ko-KR.json +9 -0
  48. package/esm/translations/nl-NL.json +9 -0
  49. package/esm/translations/pl-PL.json +9 -0
  50. package/esm/translations/pt-BR.json +9 -0
  51. package/esm/translations/pt-PT.json +9 -0
  52. package/esm/translations/ru-RU.json +9 -0
  53. package/esm/translations/sl-SI.json +9 -0
  54. package/esm/translations/th-TH.json +9 -0
  55. package/esm/translations/tr-TR.json +9 -0
  56. package/esm/translations/uk-UA.json +9 -0
  57. package/esm/translations/vi-VN.json +9 -0
  58. package/esm/translations/zh-HK.json +9 -0
  59. package/esm/translations/zh-Hans.json +9 -0
  60. package/esm/translations/zh-Hant.json +9 -0
  61. package/package.json +17 -17
@@ -1,6 +1,6 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  import { closeBrackets, closeBracketsKeymap } from "@codemirror/autocomplete";
3
- import { defaultKeymap, history, historyKeymap, indentLess, indentMore } from "@codemirror/commands";
3
+ import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
4
4
  import { bracketMatching, indentUnit } from "@codemirror/language";
5
5
  import { highlightSelectionMatches, search, searchKeymap } from "@codemirror/search";
6
6
  import { EditorState } from "@codemirror/state";
@@ -31,27 +31,13 @@ function windowSpace() {
31
31
  return { top: 0, left: 0, right: window.innerWidth, bottom: window.innerHeight };
32
32
  }
33
33
  /**
34
- * Tab the way Monaco handled it: it inserts the indentation at the cursor, and indents the lines
35
- * of a selection. It does nothing in a read-only editor, nor while an input method composes text
36
- * (the Vietnamese keyboard, for one): an edit of the text the input method still owns ends up with
37
- * the typed letters twice.
34
+ * Tab and Shift-Tab move the focus out of the editor, as in any other text field, so the editor is
35
+ * no keyboard trap (WCAG 2.1.2); indentation is on Mod-] and Mod-[ of the standard bindings, and an
36
+ * open suggestion list takes Tab to accept a suggestion. The one thing kept is the input method:
37
+ * while it composes text (the Vietnamese keyboard, for one), Tab is held, because leaving the text it
38
+ * still owns ends up with the typed letters twice.
38
39
  */
39
- export const insertIndent = (view) => {
40
- if (view.state.readOnly) {
41
- return false;
42
- }
43
- if (view.compositionStarted) {
44
- return true;
45
- }
46
- if (view.state.selection.ranges.some((range) => !range.empty)) {
47
- return indentMore(view);
48
- }
49
- view.dispatch(view.state.replaceSelection(view.state.facet(indentUnit)), {
50
- scrollIntoView: true,
51
- userEvent: "input",
52
- });
53
- return true;
54
- };
40
+ const holdTabWhileComposing = (view) => view.compositionStarted;
55
41
  /**
56
42
  * The editing behaviour every editor of this package shares: undo history, bracket pairing and
57
43
  * matching, the standard key bindings, two-space indentation, and the find and replace panel at
@@ -72,7 +58,7 @@ export function baseExtensions() {
72
58
  ...defaultKeymap,
73
59
  ...historyKeymap,
74
60
  ...searchKeymap,
75
- { key: "Tab", run: insertIndent, shift: indentLess },
61
+ { key: "Tab", run: holdTabWhileComposing, shift: holdTabWhileComposing },
76
62
  { key: "Mod-F2", run: changeAllOccurrences },
77
63
  ]),
78
64
  indentUnit.of(" ".repeat(TAB_SIZE)),
@@ -88,8 +74,10 @@ export function readOnlyExtension(readOnly) {
88
74
  return [
89
75
  EditorState.readOnly.of(readOnly),
90
76
  EditorView.editable.of(!readOnly),
91
- // The content of a read-only editor is not editable, so the browser does not let the
92
- // keyboard reach it on its own; the tab index keeps it in the focus order of the dialog.
93
- readOnly ? EditorView.contentAttributes.of({ tabindex: "0" }) : [],
77
+ // A read-only content is not editable, so the browser does not let the keyboard reach it on
78
+ // its own. An editable one is, but reports tabIndex -1, and a focus trap that reads the
79
+ // tabIndex (the dialog's) skips it. The explicit tab index keeps either in the focus order,
80
+ // at its place, so Tab moves into the editor and out of it to the next control.
81
+ EditorView.contentAttributes.of({ tabindex: "0" }),
94
82
  ];
95
83
  }
@@ -24,10 +24,20 @@ export interface IMaqlCompletionOptions {
24
24
  */
25
25
  export declare function completionType(kind: CompletionItemKind | undefined): string;
26
26
  /**
27
- * The protocol writes tab stops as `$1` and the final cursor as `$0`; CodeMirror wants them in braces,
28
- * with the final cursor as an unnamed field.
27
+ * A snippet of the protocol (`SUM($1)$0`, `BY ${1:attribute}`) as plain text, with the selection to
28
+ * leave: the placeholder of the first tab stop (or the cursor there), else the final cursor (`$0`),
29
+ * else the end.
30
+ *
31
+ * @remarks
32
+ * The text goes in without an active snippet on purpose. A snippet's fields take Tab and Shift-Tab
33
+ * to move between them, so right after a function went in, Tab would only jump past its closing
34
+ * parenthesis instead of moving the focus out of the editor (WCAG 2.1.2).
29
35
  */
30
- export declare function toCodeMirrorSnippet(text: string): string;
36
+ export declare function expandSnippet(snippetText: string): {
37
+ text: string;
38
+ from: number;
39
+ to: number;
40
+ };
31
41
  /**
32
42
  * The text a completion replaces. The language service computed its edit for the document it was
33
43
  * asked about; the list stays open while the user types on, so the typed characters are taken in
@@ -1 +1 @@
1
- {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../../../src/MaqlEditor/maql/extensions/completion.ts"],"names":[],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AE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAoC5E;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,SAAS,MAAM,EAAE,GAC3B,MAAM,EAAE,CA+BV;AA8CD;;GAEG;AACH,UAAU,eAAgB,SAAQ,UAAU;IACxC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD;;GAEG;AACH,KAAK,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAuBvC;;;GAGG;AACH,wBAAgB,WAAW,CACvB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,mBAAmB,EACpC,MAAM,GAAE,MAAuB,GAChC,eAAe,EAAE,CAsCnB;AAMD;;;GAGG;AACH,eAAO,MAAM,cAAc,sDAAgC,CAAC;AAoG5D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC3B,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,YAAY,GACf,EAAE,sBAAsB,GAAG,SAAS,CAgGpC"}
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../../../src/MaqlEditor/maql/extensions/completion.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,UAAU,EAQlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAmB,KAAK,SAAS,EAAiC,MAAM,mBAAmB,CAAC;AACnG,OAAO,EAAE,UAAU,EAAU,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACH,KAAK,cAAc,EACnB,kBAAkB,EAClB,KAAK,cAAc,EAItB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAc9E,MAAM,WAAW,sBAAsB;IACnC,eAAe,E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C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD;;GAEG;AACH,KAAK,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAuBvC;;;GAGG;AACH,wBAAgB,WAAW,CACvB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,mBAAmB,EACpC,MAAM,GAAE,MAAuB,GAChC,eAAe,EAAE,CAsCnB;AAMD;;;GAGG;AACH,eAAO,MAAM,cAAc,sDAAgC,CAAC;AAyH5D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC3B,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,YAAY,GACf,EAAE,sBAAsB,GAAG,SAAS,CA6FpC"}
@@ -1,5 +1,5 @@
1
1
  // (C) 2021-2026 GoodData Corporation
2
- import { acceptCompletion, autocompletion, completionStatus, pickedCompletion, snippet, startCompletion, } from "@codemirror/autocomplete";
2
+ import { autocompletion, completionStatus, pickedCompletion, startCompletion, } from "@codemirror/autocomplete";
3
3
  import { Prec, StateEffect, StateField } from "@codemirror/state";
4
4
  import { EditorView, keymap } from "@codemirror/view";
5
5
  import { CompletionItemKind, InsertTextFormat, TextEdit, } from "vscode-languageserver-types";
@@ -43,11 +43,35 @@ export function completionType(kind) {
43
43
  }
44
44
  }
45
45
  /**
46
- * The protocol writes tab stops as `$1` and the final cursor as `$0`; CodeMirror wants them in braces,
47
- * with the final cursor as an unnamed field.
46
+ * A snippet of the protocol (`SUM($1)$0`, `BY ${1:attribute}`) as plain text, with the selection to
47
+ * leave: the placeholder of the first tab stop (or the cursor there), else the final cursor (`$0`),
48
+ * else the end.
49
+ *
50
+ * @remarks
51
+ * The text goes in without an active snippet on purpose. A snippet's fields take Tab and Shift-Tab
52
+ * to move between them, so right after a function went in, Tab would only jump past its closing
53
+ * parenthesis instead of moving the focus out of the editor (WCAG 2.1.2).
48
54
  */
49
- export function toCodeMirrorSnippet(text) {
50
- return text.replace(/\$(\d+)/g, (_match, index) => (index === "0" ? "${}" : `\${${index}}`));
55
+ export function expandSnippet(snippetText) {
56
+ const fields = [];
57
+ let text = "";
58
+ let last = 0;
59
+ for (const match of snippetText.matchAll(/\$\{(\d+)(?::([^}]*))?\}|\$(\d+)/g)) {
60
+ text += snippetText.slice(last, match.index);
61
+ const placeholder = match[2] ?? "";
62
+ fields.push({
63
+ index: Number(match[1] ?? match[3]),
64
+ from: text.length,
65
+ to: text.length + placeholder.length,
66
+ });
67
+ text += placeholder;
68
+ last = match.index + match[0].length;
69
+ }
70
+ text += snippetText.slice(last);
71
+ // the first tab stop, else the final cursor ($0), else the end
72
+ const target = fields.filter((field) => field.index > 0).sort((a, b) => a.index - b.index)[0] ??
73
+ fields.find((field) => field.index === 0);
74
+ return target ? { text, from: target.from, to: target.to } : { text, from: text.length, to: text.length };
51
75
  }
52
76
  /**
53
77
  * The text a completion replaces. The language service computed its edit for the document it was
@@ -161,31 +185,22 @@ function applyCompletion(view, completion, item, from, to) {
161
185
  const doc = view.state.doc;
162
186
  const edit = TextEdit.is(item.textEdit) ? item.textEdit : undefined;
163
187
  const span = completionSpan(edit ? rangeToSpan(doc, edit.range) : undefined, from, to);
164
- const text = edit?.newText ?? item.insertText ?? item.label;
188
+ const rawText = edit?.newText ?? item.insertText ?? item.label;
165
189
  const additional = item.additionalTextEdits ? textEditsToChanges(doc, item.additionalTextEdits) : [];
166
- if (item.insertTextFormat === InsertTextFormat.Snippet) {
167
- // The snippet is placed after the additional edits moved the text, so its span is mapped
168
- // through them.
169
- let snippetFrom = span.from;
170
- let snippetTo = span.to;
171
- if (additional.length) {
172
- const changes = view.state.changes(additional);
173
- view.dispatch({ changes });
174
- snippetFrom = changes.mapPos(span.from, 1);
175
- snippetTo = Math.max(snippetFrom, changes.mapPos(span.to, -1));
176
- }
177
- snippet(toCodeMirrorSnippet(text))(view, completion, snippetFrom, snippetTo);
178
- }
179
- else {
180
- const specs = [{ from: span.from, to: span.to, insert: text }, ...additional];
181
- const changes = view.state.changes(specs);
182
- view.dispatch({
183
- changes,
184
- // The cursor goes after the inserted text, wherever the additional edits moved it.
185
- selection: { anchor: changes.mapPos(span.to, 1) },
186
- annotations: pickedCompletion.of(completion),
187
- });
188
- }
190
+ // A snippet goes in as plain text with the selection at its first tab stop (see expandSnippet);
191
+ // any other text with the cursor after it.
192
+ const { text, from: selectFrom, to: selectTo, } = item.insertTextFormat === InsertTextFormat.Snippet
193
+ ? expandSnippet(rawText)
194
+ : { text: rawText, from: rawText.length, to: rawText.length };
195
+ const specs = [{ from: span.from, to: span.to, insert: text }, ...additional];
196
+ const changes = view.state.changes(specs);
197
+ // where the inserted text starts, wherever the additional edits moved it
198
+ const start = changes.mapPos(span.from, -1);
199
+ view.dispatch({
200
+ changes,
201
+ selection: { anchor: start + selectFrom, head: start + selectTo },
202
+ annotations: pickedCompletion.of(completion),
203
+ });
189
204
  // An accepted reference may open a longer one, so the suggestions reopen right away.
190
205
  startCompletion(view);
191
206
  }
@@ -278,9 +293,27 @@ function viewOf(element) {
278
293
  * The `?` on the selected row: it opens and closes the documentation. The row itself accepts the
279
294
  * completion on mousedown, so the event stops here.
280
295
  */
296
+ const FOCUSABLE_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])';
297
+ /**
298
+ * Takes the element and its focusable content out of the Tab order. The suggestion popup is
299
+ * rendered inside the editor, so the next Tab from the editor would otherwise land on its controls
300
+ * instead of the next control of the page; the popup is used through the editor (the arrow keys,
301
+ * Enter and Escape) and with the mouse, which a tab index of -1 keeps working.
302
+ */
303
+ function removeFromTabOrder(element) {
304
+ if (element.matches(FOCUSABLE_SELECTOR)) {
305
+ element.tabIndex = -1;
306
+ }
307
+ element.querySelectorAll(FOCUSABLE_SELECTOR).forEach((focusable) => {
308
+ focusable.tabIndex = -1;
309
+ });
310
+ return element;
311
+ }
281
312
  function renderDocsToggle(view) {
282
313
  const button = document.createElement("button");
283
314
  button.type = "button";
315
+ // out of the Tab order, see removeFromTabOrder
316
+ button.tabIndex = -1;
284
317
  button.className = DOCS_TOGGLE_CLASS;
285
318
  button.setAttribute("aria-label", view.state.phrase("Documentation"));
286
319
  button.textContent = "?";
@@ -323,7 +356,8 @@ function renderDocsPane(detail, markdown, phrase) {
323
356
  if (rendered) {
324
357
  pane.appendChild(rendered.dom);
325
358
  }
326
- return { dom: pane, destroy: () => rendered?.destroy() };
359
+ // the close button and the links of the documentation (rendered synchronously, so all there)
360
+ return { dom: removeFromTabOrder(pane), destroy: () => rendered?.destroy() };
327
361
  }
328
362
  async function resolveInfo(item, languageService, phrase) {
329
363
  const resolved = await languageService.doCompletionResolve(item);
@@ -409,12 +443,11 @@ export function maqlCompletion({ languageService, triggerCharacters, onList, onD
409
443
  { render: (_completion, _state, view) => renderDocsToggle(view), position: 90 },
410
444
  ],
411
445
  }),
412
- // Above the standard bindings: Mod-i selects the enclosing syntax there, and Tab indents.
413
- // While an input method composes text, Tab is left to the base binding, which ignores it.
414
- Prec.high(keymap.of([
415
- { key: "Mod-i", run: startCompletion },
416
- { key: "Tab", run: (view) => (view.compositionStarted ? false : acceptCompletion(view)) },
417
- ])),
446
+ // Above the standard bindings: Mod-i selects the enclosing syntax there. Tab does not accept a
447
+ // suggestion: Enter does, Escape closes the list, and Tab and Shift-Tab leave the editor
448
+ // with the text as typed (the list closes as the editor loses the focus), so leaving never
449
+ // changes the formula unasked.
450
+ Prec.high(keymap.of([{ key: "Mod-i", run: startCompletion }])),
418
451
  listener,
419
452
  ];
420
453
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MaqlEditorHeader.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/MaqlEditorField/MaqlEditorHeader.tsx"],"names":[],"mappings":"AAWA,oBAAY,YAAY;IACpB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC7C;AAmDD,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CAuDhG"}
1
+ {"version":3,"file":"MaqlEditorHeader.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/MaqlEditorField/MaqlEditorHeader.tsx"],"names":[],"mappings":"AAWA,oBAAY,YAAY;IACpB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC7C;AAoDD,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CA0DhG"}
@@ -53,15 +53,15 @@ const messages = defineMessages({
53
53
  decoratorsShow: {
54
54
  id: "metricComponent.editMetric.decoratorsShow",
55
55
  },
56
- decoratorsHide: {
57
- id: "metricComponent.editMetric.decoratorsHide",
56
+ moreActions: {
57
+ id: "metricComponent.editMetric.metric.definition.moreActions",
58
58
  },
59
59
  });
60
60
  export function MaqlEditorHeader({ areTitles, isMaqlDefined, isSQL, onAction }) {
61
61
  const intl = useIntl();
62
62
  const { classes } = useStyles();
63
63
  const { canShowResults, canShowSql } = useFeaturesAndSettings();
64
- return (_jsx(PartHeader, { className: "s-maql_definition_header", TitleContent: _jsx(FormattedMessage, { id: "metricComponent.editMetric.metric.definition" }), TitleTooltip: _jsx(FormattedMessage, { id: "metricComponent.editMetric.metric.definition.tooltip" }), buttons: [
64
+ return (_jsx(PartHeader, { className: "s-maql_definition_header", TitleContent: _jsx(FormattedMessage, { id: "metricComponent.editMetric.metric.definition" }), TitleTooltip: _jsx(FormattedMessage, { id: "metricComponent.editMetric.metric.definition.tooltip" }), dropdownLabel: intl.formatMessage(messages.moreActions), buttons: [
65
65
  canShowResults && (_jsx(PartHeaderButton, { disabledTooltip: intl.formatMessage(messages.runBubbleDisabled), tooltip: intl.formatMessage(messages.runBubble), tooltipMac: intl.formatMessage(messages.runBubbleMac), value: intl.formatMessage(messages.run), elementIconLeft: _jsx(IconRun, {}), disabled: !isMaqlDefined, onClick: () => onAction?.(HeaderAction.Run), sClassName: "s-run-button", className: classes.run }, 0)),
66
66
  canShowSql && !isSQL && (_jsx(PartHeaderButton, { disabledTooltip: intl.formatMessage(messages.sqlBubbleDisabled), value: intl.formatMessage(messages.sql), disabled: !isMaqlDefined, onClick: () => onAction?.(HeaderAction.SQL), sClassName: "s-show-sql-button" }, 1)),
67
67
  ], dropdown: [
@@ -70,14 +70,16 @@ export function MaqlEditorHeader({ areTitles, isMaqlDefined, isSQL, onAction })
70
70
  title: intl.formatMessage(messages.autoFormat),
71
71
  tooltip: intl.formatMessage(messages.autoFormatBubble),
72
72
  tooltipMac: intl.formatMessage(messages.autoFormatBubbleMac),
73
+ // the formatting keymap's Shift-Alt-f, on every platform
74
+ keyShortcuts: "Shift+Alt+F",
73
75
  onClick: () => onAction?.(HeaderAction.Format),
74
76
  },
75
77
  { type: "separator" },
76
78
  {
79
+ // a toggle, read with its state ("Show names, checked")
77
80
  type: "link",
78
- title: areTitles
79
- ? intl.formatMessage(messages.decoratorsHide)
80
- : intl.formatMessage(messages.decoratorsShow),
81
+ title: intl.formatMessage(messages.decoratorsShow),
82
+ checked: areTitles,
81
83
  onClick: () => onAction?.(HeaderAction.Titles),
82
84
  },
83
85
  ] }));
@@ -1,9 +1,20 @@
1
1
  import { type ReactElement } from "react";
2
2
  interface IDropdownItem {
3
3
  type: "separator" | "link";
4
+ /**
5
+ * What the item does, read as its description (aria-describedby); on macOS `tooltipMac` if given.
6
+ */
4
7
  tooltip?: string;
5
8
  tooltipMac?: string;
6
9
  title?: string;
10
+ /**
11
+ * The keys of the item, in the `aria-keyshortcuts` form ("Shift+Alt+F"); shown at its right too.
12
+ */
13
+ keyShortcuts?: string;
14
+ /**
15
+ * Set for a toggle: the item is a menu checkbox, checked when the option is on.
16
+ */
17
+ checked?: boolean;
7
18
  onClick?: () => void;
8
19
  }
9
20
  export interface IPartHeader {
@@ -12,9 +23,13 @@ export interface IPartHeader {
12
23
  className?: string;
13
24
  buttons?: Array<ReactElement | false | undefined>;
14
25
  dropdown?: Array<IDropdownItem>;
26
+ /**
27
+ * Accessible name of the dropdown's "⋯" button; a generic "More actions" when not given.
28
+ */
29
+ dropdownLabel?: string;
15
30
  after?: ReactElement | false | undefined;
16
31
  }
17
32
  export declare function PartDivider(): import("react/jsx-runtime").JSX.Element;
18
- export declare function PartHeader({ TitleContent, TitleTooltip, buttons, dropdown, after, className, }: IPartHeader): import("react/jsx-runtime").JSX.Element;
33
+ export declare function PartHeader({ TitleContent, TitleTooltip, buttons, dropdown, dropdownLabel, after, className, }: IPartHeader): import("react/jsx-runtime").JSX.Element;
19
34
  export {};
20
35
  //# sourceMappingURL=PartHeader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PartHeader.d.ts","sourceRoot":"","sources":["../../../../src/MetricComponent/Form/PartHeader/PartHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAiF1C,UAAU,aAAa;IACnB,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAC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AC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAChC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,YAAY,GAAG,KAAK,GAAG,SAAS,CAAC;CAC5C;AAED,wBAAgB,WAAW,4CAI1B;AAED,wBAAgB,UAAU,CAAC,EACvB,YAAY,EACZ,YAAY,EACZ,OAAY,EACZ,QAAa,EACb,aAAa,EACb,KAAK,EACL,SAAS,GACZ,EAAE,WAAW,2CAiHb"}
@@ -1,5 +1,9 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Bubble, BubbleHoverTrigger, Dropdown, DropdownList, IconQuestionMark, Separator, SingleSelectListItem, } from "@gooddata/sdk-ui-kit";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // (C) 2021-2026 GoodData Corporation
3
+ import { useId, useRef } from "react";
4
+ import { useIntl } from "react-intl";
5
+ import { Bubble, BubbleHoverTrigger, IconQuestionMark, UiDropdown, UiMenu, getFocusableElements, } from "@gooddata/sdk-ui-kit";
6
+ import { simplifyText } from "@gooddata/util";
3
7
  import { isMac } from "../../../shared/platform.js";
4
8
  import { makeStyles } from "../../../shared/theme/index.js";
5
9
  const useStyles = makeStyles()((theme) => ({
@@ -61,30 +65,102 @@ const useStyles = makeStyles()((theme) => ({
61
65
  color: theme.globals.colors.defaultText,
62
66
  background: theme.globals.colors.dropdownButtonMoreHover,
63
67
  },
68
+ "&:focus-visible": {
69
+ outline: `2px solid ${theme.globals.colors.defaultText}`,
70
+ outlineOffset: -2,
71
+ },
72
+ },
73
+ shortcut: {
74
+ marginLeft: 16,
75
+ color: theme.globals.colors.defaultGreyedText,
64
76
  },
65
- dropdownList: {},
66
77
  }));
67
- const getItemHeight = (item) => {
68
- return item.type === "separator" ? 10 : 28;
69
- };
78
+ function getDescription(item) {
79
+ return isMac() ? item.tooltipMac || item.tooltip : item.tooltip;
80
+ }
81
+ // "Shift+Alt+F" as macOS shows it ("⇧⌥F"), and as it is elsewhere
82
+ function formatShortcut(keyShortcuts) {
83
+ const macSymbols = { Shift: "⇧", Alt: "⌥", Meta: "⌘", Control: "⌃" };
84
+ return isMac()
85
+ ? keyShortcuts
86
+ .split("+")
87
+ .map((key) => macSymbols[key] ?? key)
88
+ .join("")
89
+ : keyShortcuts;
90
+ }
91
+ /**
92
+ * The menu items. No item has a tooltip: the menu's tooltip takes the first Escape for itself, so the
93
+ * menu would need two to close. What a tooltip said is the item's description instead, its keys are
94
+ * in aria-keyshortcuts and shown at its right, hidden from assistive technology, which has them.
95
+ */
96
+ function toMenuItems(dropdown, descriptionId, shortcutClassName) {
97
+ return dropdown.map((item, index) => {
98
+ if (item.type === "separator") {
99
+ return { type: "separator", id: `separator-${index}` };
100
+ }
101
+ const title = item.title ?? "";
102
+ const isToggle = item.checked !== undefined;
103
+ return {
104
+ type: "interactive",
105
+ id: `${index}-${title}`,
106
+ stringTitle: title,
107
+ selectionRole: isToggle ? "checkbox" : undefined,
108
+ isSelected: item.checked,
109
+ iconRight: item.keyShortcuts ? (_jsx("span", { className: shortcutClassName, "aria-hidden": "true", children: formatShortcut(item.keyShortcuts) })) : undefined,
110
+ ariaAttributes: {
111
+ "aria-describedby": getDescription(item) ? descriptionId(index) : undefined,
112
+ "aria-keyshortcuts": item.keyShortcuts,
113
+ },
114
+ data: item.onClick,
115
+ };
116
+ });
117
+ }
118
+ // The test hook of each item ("s-auto_format", the class the former list items had), which the e2e
119
+ // helpers select by; UiMenu takes it as the item's data-testid.
120
+ function getItemDataTestId(item) {
121
+ return item.type === "interactive" ? `s-${simplifyText(item.stringTitle)}` : undefined;
122
+ }
123
+ function stopPropagation(event) {
124
+ event.stopPropagation();
125
+ }
70
126
  export function PartDivider() {
71
127
  const { classes, cx } = useStyles();
72
128
  return _jsx("div", { className: cx(classes.afterLine) });
73
129
  }
74
- export function PartHeader({ TitleContent, TitleTooltip, buttons = [], dropdown = [], after, className, }) {
130
+ export function PartHeader({ TitleContent, TitleTooltip, buttons = [], dropdown = [], dropdownLabel, after, className, }) {
75
131
  const { classes, cx } = useStyles();
76
- return (_jsxs("div", { className: cx(classes.root, className), children: [_jsxs("div", { className: cx(classes.header), children: [_jsx("div", { className: cx(classes.title), children: TitleContent }), TitleTooltip && (_jsxs(BubbleHoverTrigger, { showDelay: 500, className: cx(classes.help), children: [_jsx(IconQuestionMark, {}), _jsx(Bubble, { className: "bubble-primary", alignPoints: [{ align: "bc tc" }], children: TitleTooltip })] }))] }), _jsxs("div", { className: cx(classes.toolbar), children: [buttons, dropdown.length > 0 && (_jsx(Dropdown, { enableEventPropagation: true, className: classes.dropdownRoot, alignPoints: [{ align: "br tr" }, { align: "tr br" }], renderBody: ({ closeDropdown, isMobile }) => (_jsx(DropdownList, { height: dropdown.reduce((accumulator, item) => accumulator + getItemHeight(item), 0), itemHeightGetter: (index) => getItemHeight(dropdown[index]), items: dropdown, isMobile: isMobile, className: classes.dropdownList, renderItem: ({ item }) => (_jsx(_Fragment, { children: item.type === "separator" ? (_jsx(Separator, {})) : (_jsxs(BubbleHoverTrigger, { showDelay: 500, children: [_jsx(SingleSelectListItem, { title: item.title, onClick: (e) => {
77
- if (item.onClick) {
78
- item.onClick();
79
- }
80
- closeDropdown();
81
- e.stopPropagation();
82
- }, isSelected: false }), Boolean(item.tooltip) && (_jsx(Bubble, { className: "bubble-primary", alignPoints: [{ align: "bc tc" }], children: isMac()
83
- ? item.tooltipMac || item.tooltip
84
- : item.tooltip }))] })) })) })), renderButton: ({ toggleDropdown, isOpen }) => (_jsx("button", { type: "button", className: cx(classes.dropdownButton, "s-part_header_dropdown", [
85
- { "is-open": isOpen },
86
- ]), onClick: (e) => {
87
- toggleDropdown();
88
- e.stopPropagation();
89
- }, children: "\u22EF" })) })), Boolean(after) && (_jsxs("div", { className: cx(classes.after), children: [_jsx(PartDivider, {}), after] }))] })] }));
132
+ const intl = useIntl();
133
+ const dropdownRoot = useRef(null);
134
+ const idBase = useId();
135
+ const descriptionId = (index) => `${idBase}-description-${index}`;
136
+ // The menu renders in a portal at the end of the page, so the browser would continue the Tab order
137
+ // from there (past Save). As in the menu button pattern, Tab closes the menu and moves on from the
138
+ // "⋯" button, Shift+Tab closes it and goes back to the button.
139
+ const onMenuKeyDownCapture = (event, closeDropdown) => {
140
+ if (event.key !== "Tab") {
141
+ return;
142
+ }
143
+ event.preventDefault();
144
+ event.stopPropagation();
145
+ closeDropdown();
146
+ const trigger = dropdownRoot.current?.querySelector(".s-part_header_dropdown");
147
+ if (!trigger) {
148
+ return;
149
+ }
150
+ if (event.shiftKey) {
151
+ trigger.focus();
152
+ return;
153
+ }
154
+ // the next control after the button, in the order of the dialog around it (its focus trap's)
155
+ const scope = trigger.closest('[role="dialog"]') ?? document.body;
156
+ const { focusableElements } = getFocusableElements(scope);
157
+ (focusableElements[focusableElements.indexOf(trigger) + 1] ?? trigger).focus();
158
+ };
159
+ return (_jsxs("div", { className: cx(classes.root, className), children: [_jsxs("div", { className: cx(classes.header), children: [_jsx("div", { className: cx(classes.title), children: TitleContent }), TitleTooltip && (_jsxs(BubbleHoverTrigger, { showDelay: 500, className: cx(classes.help), children: [_jsx(IconQuestionMark, {}), _jsx(Bubble, { className: "bubble-primary", alignPoints: [{ align: "bc tc" }], children: TitleTooltip })] }))] }), _jsxs("div", { className: cx(classes.toolbar), children: [buttons, dropdown.length > 0 && (_jsx("div", { ref: dropdownRoot, className: classes.dropdownRoot, onClick: stopPropagation, children: _jsx(UiDropdown, { alignPoints: [{ align: "br tr" }, { align: "tr br" }], autofocusOnOpen: true, closeOnEscape: true, closeOnOutsideClick: true, enableFocusTrap: false, accessibilityConfig: { triggerRole: "button", popupRole: "menu" }, renderButton: ({ ref, toggleDropdown, isOpen, ariaAttributes }) => (_jsx("button", { ref: ref, type: "button", className: cx(classes.dropdownButton, "s-part_header_dropdown", {
160
+ "is-open": isOpen,
161
+ }), "aria-label": dropdownLabel ??
162
+ intl.formatMessage({ id: "metricComponent.partHeader.moreActions" }), onClick: toggleDropdown, ...ariaAttributes, children: _jsx("span", { "aria-hidden": "true", children: "\u22EF" }) })), renderBody: ({ ariaAttributes, closeDropdown, triggerId }) => (_jsxs("div", { style: { display: "contents" }, onKeyDownCapture: (event) => onMenuKeyDownCapture(event, closeDropdown), children: [_jsx(UiMenu, { items: toMenuItems(dropdown, descriptionId, classes.shortcut), onSelect: (item) => item.data?.(), onClose: closeDropdown, ariaAttributes: { ...ariaAttributes, "aria-labelledby": triggerId }, size: "small", containerTopPadding: "small", containerBottomPadding: "small", itemDataTestId: getItemDataTestId }), dropdown.map((item, index) => {
163
+ const description = getDescription(item);
164
+ return description ? (_jsx("span", { id: descriptionId(index), hidden: true, children: description }, index)) : null;
165
+ })] })) }) })), Boolean(after) && (_jsxs("div", { className: cx(classes.after), children: [_jsx(PartDivider, {}), after] }))] })] }));
90
166
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MetricsState.d.ts","sourceRoot":"","sources":["../../src/MetricComponent/MetricsState.tsx"],"names":[],"mappings":"AAMA,OAAO,EACH,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAyB,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAOrF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAwBrE,MAAM,WAAW,iBAAiB;IAC9B,WAAW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AAa,EACb,sBAAsB,EACtB,2BAA2B,GAC9B,EAAE,iBAAiB,2CAyGnB"}
@@ -68,6 +68,7 @@ export function MetricsState({ permissions, prefixes, tabsProps, updateTab, upda
68
68
  titlePlaceholder: intl.formatMessage({
69
69
  id: "metricComponent.editMetricForm.namePlaceholder",
70
70
  }),
71
+ // the accessible names of the controls are the tabs' own localized defaults
71
72
  }), [intl]);
72
73
  return (_jsx(_Fragment, { children: tabsProps.tabs.length > 0 && (_jsx(MetricTabs, { ...tabsProps, className: cx(classes.root, maximized && classes.maximized), minimizable: true, maximizable: canMaximize, closeable: true, onTabCreate: createTab, onTabsMinimize: handleMinimize, maximized: maximized, onTabsMaximizable: handleMaximize, onTabsClose: closeAllTabs, render: renderTab, locales: locales })) }));
73
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MinimizedMetricComponent.d.ts","sourceRoot":"","sources":["../../../src/MetricComponent/MinimizedMetricComponent/MinimizedMetricComponent.tsx"],"names":[],"mappings":"AA8GA,MAAM,WAAW,8BAA8B;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,aAAa,GAAG,QAAQ,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,wBAAwB,CAAC,EACrC,QAAe,EACf,OAAc,EACd,KAAgB,EAChB,MAAU,EACV,QAAQ,EACR,OAAO,EACP,KAAa,EACb,OAAe,GAClB,EAAE,8BAA8B,kDA2ChC"}
1
+ {"version":3,"file":"MinimizedMetricComponent.d.ts","sourceRoot":"","sources":["../../../src/MetricComponent/MinimizedMetricComponent/MinimizedMetricComponent.tsx"],"names":[],"mappings":"AA+GA,MAAM,WAAW,8BAA8B;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,aAAa,GAAG,QAAQ,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,wBAAwB,CAAC,EACrC,QAAe,EACf,OAAc,EACd,KAAgB,EAChB,MAAU,EACV,QAAQ,EACR,OAAO,EACP,KAAa,EACb,OAAe,GAClB,EAAE,8BAA8B,kDAkFhC"}
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // (C) 2022-2026 GoodData Corporation
3
- import { useState } from "react";
4
- import { FormattedMessage } from "react-intl";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { FormattedMessage, useIntl } from "react-intl";
5
5
  import { IconClose, IconExpand } from "@gooddata/sdk-ui-kit";
6
+ import { handOffFocusDuring, useFocusHandoff } from "../../shared/focusHandoff.js";
6
7
  import { makeStyles } from "../../shared/theme/index.js";
7
8
  const useStyles = makeStyles()((theme) => {
8
9
  return {
@@ -102,9 +103,29 @@ const useStyles = makeStyles()((theme) => {
102
103
  });
103
104
  export function MinimizedMetricComponent({ editable = true, visible = true, where = "inline", edited = 0, onExpand, onClose, dirty = false, invalid = false, }) {
104
105
  const { classes, cx } = useStyles();
106
+ const intl = useIntl();
105
107
  const [over, setOver] = useState(false);
106
- if (edited === 0 || !visible) {
108
+ const chip = useRef(null);
109
+ const expandButton = useRef(null);
110
+ const isShown = edited > 0 && visible;
111
+ const focusHandoff = useFocusHandoff();
112
+ // Catch the focus only when minimizing this chip's editor dropped it (see focusHandoff). The
113
+ // record is taken in any case, so it cannot move the focus later; and should something have taken
114
+ // the focus in the meantime, it keeps it.
115
+ useEffect(() => {
116
+ if (!isShown) {
117
+ return;
118
+ }
119
+ const isHandedOff = focusHandoff?.take("chip") ?? false;
120
+ const isFocusDropped = !document.activeElement || document.activeElement === document.body;
121
+ if (isHandedOff && isFocusDropped) {
122
+ expandButton.current?.focus();
123
+ }
124
+ }, [isShown, focusHandoff]);
125
+ // restoring unmounts the chip, so the editor catches the focus if the chip held it
126
+ const expandHandler = () => handOffFocusDuring(focusHandoff, "editor", !!chip.current?.contains(document.activeElement), onExpand, () => chip.current !== null);
127
+ if (!isShown) {
107
128
  return null;
108
129
  }
109
- return (_jsxs("div", { className: cx(classes.root, where, "s-edit_dialog-minimized"), children: [_jsxs("div", { className: cx(classes.info), onClick: onExpand, onMouseEnter: () => setOver(true), onMouseLeave: () => setOver(false), children: [_jsx("label", { className: cx(classes.editing), children: editable ? (_jsx(FormattedMessage, { id: "metricComponent.minimize.editing" })) : (_jsx(FormattedMessage, { id: "metricComponent.minimize.viewing" })) }), invalid && _jsx("div", { className: cx(classes.indicator, classes.invalid) }), dirty && !invalid && _jsx("div", { className: cx(classes.indicator, classes.dirty) }), _jsx("div", { className: cx(classes.count, "s-edit_dialog-minimized-counter"), children: _jsx(FormattedMessage, { id: "metricComponent.minimize.metrics", values: { edited } }) })] }), _jsxs("div", { className: cx(classes.controls), children: [_jsx("button", { className: cx(classes.button, over && "hover", "s-edit_dialog-minimized-expand"), onClick: onExpand, children: _jsx(IconExpand, {}) }), _jsx("div", { className: cx(classes.divider) }), _jsx("button", { className: cx(classes.button, "s-edit_dialog-minimized-close"), onClick: onClose, children: _jsx(IconClose, {}) })] })] }));
130
+ return (_jsxs("div", { ref: chip, className: cx(classes.root, where, "s-edit_dialog-minimized"), children: [_jsxs("div", { className: cx(classes.info), onClick: expandHandler, onMouseEnter: () => setOver(true), onMouseLeave: () => setOver(false), children: [_jsx("label", { className: cx(classes.editing), children: editable ? (_jsx(FormattedMessage, { id: "metricComponent.minimize.editing" })) : (_jsx(FormattedMessage, { id: "metricComponent.minimize.viewing" })) }), invalid && _jsx("div", { className: cx(classes.indicator, classes.invalid) }), dirty && !invalid && _jsx("div", { className: cx(classes.indicator, classes.dirty) }), _jsx("div", { className: cx(classes.count, "s-edit_dialog-minimized-counter"), children: _jsx(FormattedMessage, { id: "metricComponent.minimize.metrics", values: { edited } }) })] }), _jsxs("div", { className: cx(classes.controls), children: [_jsx("button", { ref: expandButton, type: "button", className: cx(classes.button, over && "hover", "s-edit_dialog-minimized-expand"), "aria-label": intl.formatMessage({ id: "metricComponent.minimize.restore" }), onClick: expandHandler, children: _jsx(IconExpand, { ariaHidden: true }) }), _jsx("div", { className: cx(classes.divider) }), _jsx("button", { type: "button", className: cx(classes.button, "s-edit_dialog-minimized-close"), "aria-label": intl.formatMessage({ id: "metricComponent.tabs.close" }), onClick: onClose, children: _jsx(IconClose, { ariaHidden: true }) })] })] }));
110
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MultipleMetricsState.d.ts","sourceRoot":"","sources":["../../src/MetricComponent/MultipleMetricsState.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAiB,MAAM,OAAO,CAAC;AAEhE,OAAO,EACH,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAA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c,EACd,OAAO,EACP,QAAQ,GACX,EAAE,qBAAqB,2CA4BvB"}
@@ -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
- return (_jsx(MultipleMetricsContext.Provider, { value: metricStateProps, children: children }));
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
  }
@@ -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