@grafana/scenes 6.43.0--canary.1278.19036459049.0 → 6.43.0--canary.1296.19132771015.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/dist/index.d.ts CHANGED
@@ -1094,6 +1094,10 @@ interface AdHocFiltersVariableState extends SceneVariableState {
1094
1094
  * Allows custom formatting of a value before saving to filter state
1095
1095
  */
1096
1096
  onAddCustomValue?: OnAddCustomValueFn;
1097
+ /**
1098
+ * @internal allows to focus the adhoc input through focusInput()
1099
+ */
1100
+ _shouldFocus?: boolean;
1097
1101
  }
1098
1102
  type AdHocVariableExpressionBuilderFn = (filters: AdHocFilterWithLabels[]) => string;
1099
1103
  type OnAddCustomValueFn = (item: SelectableValue<string> & {
@@ -1157,6 +1161,16 @@ declare class AdHocFiltersVariable extends SceneObjectBase<AdHocFiltersVariableS
1157
1161
  */
1158
1162
  _getValuesFor(filter: AdHocFilterWithLabels): Promise<Array<SelectableValue<string>>>;
1159
1163
  _addWip(): void;
1164
+ /**
1165
+ * Focus the filter input to start adding a new filter.
1166
+ * Works with both standard and combobox layouts.
1167
+ */
1168
+ focusInput(): void;
1169
+ /**
1170
+ * Reset the focus flag after focusing has completed
1171
+ * @internal
1172
+ */
1173
+ _resetFocusFlag(): void;
1160
1174
  _getOperators(): SelectableValue<string>[];
1161
1175
  }
1162
1176
  declare function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHocFiltersVariable>): React__default.JSX.Element;
@@ -1385,6 +1399,11 @@ interface GroupByVariableState extends MultiValueVariableState {
1385
1399
  * Holds the applicability for each of the selected keys
1386
1400
  */
1387
1401
  keysApplicability?: DrilldownsApplicability[];
1402
+ /**
1403
+ * @internal
1404
+ * Flag to trigger focus on the input
1405
+ */
1406
+ _shouldFocus?: boolean;
1388
1407
  }
1389
1408
  type getTagKeysProvider = (set: GroupByVariable, currentKey: string | null) => Promise<{
1390
1409
  replace?: boolean;
@@ -1415,6 +1434,10 @@ declare class GroupByVariable extends MultiValueVariable<GroupByVariableState> {
1415
1434
  value: VariableValueSingle[];
1416
1435
  text: string[];
1417
1436
  };
1437
+ /**
1438
+ * Focus the group by input to start selecting dimensions.
1439
+ */
1440
+ focusInput(): void;
1418
1441
  }
1419
1442
  declare function GroupByVariableRenderer({ model }: SceneComponentProps<GroupByVariable>): React__default.JSX.Element;
1420
1443
 
@@ -2466,6 +2489,7 @@ interface AdHocFiltersControllerState {
2466
2489
  onAddCustomValue?: OnAddCustomValueFn;
2467
2490
  wip?: AdHocFilterWithLabels;
2468
2491
  inputPlaceholder?: string;
2492
+ _shouldFocus?: boolean;
2469
2493
  }
2470
2494
  /**
2471
2495
  * Controller interface for adhoc filters combobox UI.
@@ -2525,6 +2549,15 @@ interface AdHocFiltersController {
2525
2549
  * @param filter - The filter to restore
2526
2550
  */
2527
2551
  restoreOriginalFilter(filter: AdHocFilterWithLabels): void;
2552
+ /**
2553
+ * Optional: Focus the filter input (for combobox layout).
2554
+ * This allows external code to programmatically focus the filter input.
2555
+ */
2556
+ focusInput?(): void;
2557
+ /**
2558
+ * Reset the focus flag.
2559
+ */
2560
+ resetFocusFlag?(): void;
2528
2561
  /**
2529
2562
  * Optional: Start profiling an interaction (for performance tracking).
2530
2563
  * @param name - The interaction name
@@ -2559,6 +2592,8 @@ declare class AdHocFiltersVariableController implements AdHocFiltersController {
2559
2592
  handleComboboxBackspace(filter: AdHocFilterWithLabels): void;
2560
2593
  addWip(): void;
2561
2594
  restoreOriginalFilter(filter: AdHocFilterWithLabels): void;
2595
+ focusInput(): void;
2596
+ resetFocusFlag(): void;
2562
2597
  startProfile(name: string): void;
2563
2598
  startInteraction(name: string): void;
2564
2599
  stopInteraction(): void;
package/dist/index.js CHANGED
@@ -3638,6 +3638,15 @@ class GroupByVariable extends MultiValueVariable {
3638
3638
  getDefaultMultiState(options) {
3639
3639
  return { value: [], text: [] };
3640
3640
  }
3641
+ /**
3642
+ * Focus the group by input to start selecting dimensions.
3643
+ */
3644
+ focusInput() {
3645
+ if (this.state.readOnly) {
3646
+ return;
3647
+ }
3648
+ this.setState({ _shouldFocus: true });
3649
+ }
3641
3650
  }
3642
3651
  GroupByVariable.Component = GroupByVariableRenderer;
3643
3652
  function GroupByVariableRenderer({ model }) {
@@ -3652,7 +3661,8 @@ function GroupByVariableRenderer({ model }) {
3652
3661
  includeAll,
3653
3662
  allowCustomValue = true,
3654
3663
  defaultValue,
3655
- keysApplicability
3664
+ keysApplicability,
3665
+ _shouldFocus
3656
3666
  } = model.useState();
3657
3667
  const values = React.useMemo(() => {
3658
3668
  const arrayValue = lodash.isArray(value) ? value : [value];
@@ -3671,6 +3681,14 @@ function GroupByVariableRenderer({ model }) {
3671
3681
  const [uncommittedValue, setUncommittedValue] = React.useState(values);
3672
3682
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
3673
3683
  const hasDefaultValue = defaultValue !== void 0;
3684
+ const selectRef = React.useRef(null);
3685
+ React.useEffect(() => {
3686
+ var _a, _b;
3687
+ if (_shouldFocus) {
3688
+ (_b = (_a = selectRef.current) == null ? void 0 : _a.focus) == null ? void 0 : _b.call(_a);
3689
+ model.setState({ _shouldFocus: false });
3690
+ }
3691
+ }, [_shouldFocus, model]);
3674
3692
  React.useEffect(() => {
3675
3693
  setUncommittedValue(values);
3676
3694
  }, [values]);
@@ -3695,6 +3713,7 @@ function GroupByVariableRenderer({ model }) {
3695
3713
  return isMulti ? /* @__PURE__ */ React__default.default.createElement(
3696
3714
  ui.MultiSelect,
3697
3715
  {
3716
+ selectRef,
3698
3717
  "aria-label": i18n.t(
3699
3718
  "grafana-scenes.variables.group-by-variable-renderer.aria-label-group-by-selector",
3700
3719
  "Group by selector"
@@ -3762,6 +3781,7 @@ function GroupByVariableRenderer({ model }) {
3762
3781
  ) : /* @__PURE__ */ React__default.default.createElement(
3763
3782
  ui.Select,
3764
3783
  {
3784
+ selectRef,
3765
3785
  "aria-label": i18n.t(
3766
3786
  "grafana-scenes.variables.group-by-variable-renderer.aria-label-group-by-selector",
3767
3787
  "Group by selector"
@@ -7614,9 +7634,16 @@ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwa
7614
7634
  });
7615
7635
 
7616
7636
  const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ controller }) {
7617
- const { originFilters, filters, readOnly } = controller.useState();
7637
+ const { originFilters, filters, readOnly, _shouldFocus } = controller.useState();
7618
7638
  const styles = ui.useStyles2(getStyles$9);
7619
7639
  const focusOnWipInputRef = React.useRef();
7640
+ React.useEffect(() => {
7641
+ var _a, _b;
7642
+ if (_shouldFocus) {
7643
+ (_a = focusOnWipInputRef.current) == null ? void 0 : _a.call(focusOnWipInputRef);
7644
+ (_b = controller.resetFocusFlag) == null ? void 0 : _b.call(controller);
7645
+ }
7646
+ }, [_shouldFocus, controller]);
7620
7647
  return /* @__PURE__ */ React__default.default.createElement(
7621
7648
  "div",
7622
7649
  {
@@ -7783,7 +7810,8 @@ class AdHocFiltersVariableController {
7783
7810
  allowCustomValue: state.allowCustomValue,
7784
7811
  supportsMultiValueOperators: state.supportsMultiValueOperators,
7785
7812
  onAddCustomValue: state.onAddCustomValue,
7786
- wip: state._wip
7813
+ wip: state._wip,
7814
+ _shouldFocus: state._shouldFocus
7787
7815
  };
7788
7816
  }
7789
7817
  async getKeys(currentKey) {
@@ -7816,6 +7844,12 @@ class AdHocFiltersVariableController {
7816
7844
  restoreOriginalFilter(filter) {
7817
7845
  this.model.restoreOriginalFilter(filter);
7818
7846
  }
7847
+ focusInput() {
7848
+ this.model.focusInput();
7849
+ }
7850
+ resetFocusFlag() {
7851
+ this.model._resetFocusFlag();
7852
+ }
7819
7853
  startProfile(name) {
7820
7854
  const queryController = getQueryController(this.model);
7821
7855
  queryController == null ? void 0 : queryController.startProfile(name);
@@ -8283,6 +8317,27 @@ class AdHocFiltersVariable extends SceneObjectBase {
8283
8317
  _wip: { key: "", value: "", operator: "=", condition: "" }
8284
8318
  });
8285
8319
  }
8320
+ /**
8321
+ * Focus the filter input to start adding a new filter.
8322
+ * Works with both standard and combobox layouts.
8323
+ */
8324
+ focusInput() {
8325
+ if (this.state.readOnly) {
8326
+ return;
8327
+ }
8328
+ if (this.state.layout === "combobox") {
8329
+ this.setState({ _shouldFocus: true });
8330
+ }
8331
+ }
8332
+ /**
8333
+ * Reset the focus flag after focusing has completed
8334
+ * @internal
8335
+ */
8336
+ _resetFocusFlag() {
8337
+ if (this.state._shouldFocus) {
8338
+ this.setState({ _shouldFocus: false });
8339
+ }
8340
+ }
8286
8341
  _getOperators() {
8287
8342
  const { supportsMultiValueOperators, allowCustomValue = true } = this.state;
8288
8343
  return OPERATORS.filter(({ isMulti, isRegex }) => {