@grafana/scenes 6.39.4--canary.1270.18376571635.0 → 6.39.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v6.39.4 (Fri Oct 10 2025)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - CustomVariable: Expose query parsing mechanism [#1269](https://github.com/grafana/scenes/pull/1269) ([@bfmatei](https://github.com/bfmatei))
6
+
7
+ #### Authors: 1
8
+
9
+ - Bogdan Matei ([@bfmatei](https://github.com/bfmatei))
10
+
11
+ ---
12
+
1
13
  # v6.39.3 (Thu Oct 09 2025)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -20,11 +20,13 @@ class CustomVariable extends MultiValueVariable {
20
20
  statePaths: ["query"]
21
21
  });
22
22
  }
23
- getValueOptions(args) {
23
+ // We expose this publicly as we also need it outside the variable
24
+ // The interpolate flag is needed since we don't always want to get the interpolated options
25
+ transformCsvStringToOptions(str, interpolate = true) {
24
26
  var _a;
25
- const interpolated = sceneGraph.interpolate(this, this.state.query);
26
- const match = (_a = interpolated.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
27
- const options = match.map((text) => {
27
+ str = interpolate ? sceneGraph.interpolate(this, str) : str;
28
+ const match = (_a = str.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
29
+ return match.map((text) => {
28
30
  var _a2;
29
31
  text = text.replace(/\\,/g, ",");
30
32
  const textMatch = (_a2 = /^\s*(.+)\s:\s(.+)$/g.exec(text)) != null ? _a2 : [];
@@ -35,6 +37,9 @@ class CustomVariable extends MultiValueVariable {
35
37
  return { label: text.trim(), value: text.trim() };
36
38
  }
37
39
  });
40
+ }
41
+ getValueOptions(args) {
42
+ const options = this.transformCsvStringToOptions(this.state.query);
38
43
  if (!options.length) {
39
44
  this.skipNextValidation = true;
40
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CustomVariable.js","sources":["../../../../src/variables/variants/CustomVariable.tsx"],"sourcesContent":["import { Observable, of } from 'rxjs';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { VariableDependencyConfig } from '../VariableDependencyConfig';\nimport { MultiOrSingleValueSelect } from '../components/VariableValueSelect';\nimport { VariableValueOption } from '../types';\n\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport React from 'react';\n\nexport interface CustomVariableState extends MultiValueVariableState {\n query: string;\n}\n\nexport class CustomVariable extends MultiValueVariable<CustomVariableState> {\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['query'],\n });\n\n public constructor(initialState: Partial<CustomVariableState>) {\n super({\n type: 'custom',\n query: '',\n value: '',\n text: '',\n options: [],\n name: '',\n ...initialState,\n });\n }\n\n public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {\n const interpolated = sceneGraph.interpolate(this, this.state.query);\n const match = interpolated.match(/(?:\\\\,|[^,])+/g) ?? [];\n\n const options = match.map((text) => {\n text = text.replace(/\\\\,/g, ',');\n const textMatch = /^\\s*(.+)\\s:\\s(.+)$/g.exec(text) ?? [];\n if (textMatch.length === 3) {\n const [, key, value] = textMatch;\n return { label: key.trim(), value: value.trim() };\n } else {\n return { label: text.trim(), value: text.trim() };\n }\n });\n\n if (!options.length) {\n this.skipNextValidation = true;\n }\n\n return of(options);\n }\n\n public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {\n return <MultiOrSingleValueSelect model={model} />;\n };\n}\n"],"names":["_a"],"mappings":";;;;;;;AAeO,MAAM,uBAAuB,kBAAwC,CAAA;AAAA,EAKnE,YAAY,YAA4C,EAAA;AAC7D,IAAM,KAAA,CAAA;AAAA,MACJ,IAAM,EAAA,QAAA;AAAA,MACN,KAAO,EAAA,EAAA;AAAA,MACP,KAAO,EAAA,EAAA;AAAA,MACP,IAAM,EAAA,EAAA;AAAA,MACN,SAAS,EAAC;AAAA,MACV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,GAAA,CAAC,EAAE,KAAA,EAAqD,KAAA;AAChF,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,4BAAyB,KAAc,EAAA,CAAA;AACjD,CAAA;;;;"}
1
+ {"version":3,"file":"CustomVariable.js","sources":["../../../../src/variables/variants/CustomVariable.tsx"],"sourcesContent":["import { Observable, of } from 'rxjs';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { VariableDependencyConfig } from '../VariableDependencyConfig';\nimport { MultiOrSingleValueSelect } from '../components/VariableValueSelect';\nimport { VariableValueOption } from '../types';\n\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport React from 'react';\n\nexport interface CustomVariableState extends MultiValueVariableState {\n query: string;\n}\n\nexport class CustomVariable extends MultiValueVariable<CustomVariableState> {\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['query'],\n });\n\n public constructor(initialState: Partial<CustomVariableState>) {\n super({\n type: 'custom',\n query: '',\n value: '',\n text: '',\n options: [],\n name: '',\n ...initialState,\n });\n }\n\n // We expose this publicly as we also need it outside the variable\n // The interpolate flag is needed since we don't always want to get the interpolated options\n public transformCsvStringToOptions(str: string, interpolate = true): VariableValueOption[] {\n str = interpolate ? sceneGraph.interpolate(this, str) : str;\n const match = str.match(/(?:\\\\,|[^,])+/g) ?? [];\n\n return match.map((text) => {\n text = text.replace(/\\\\,/g, ',');\n const textMatch = /^\\s*(.+)\\s:\\s(.+)$/g.exec(text) ?? [];\n if (textMatch.length === 3) {\n const [, key, value] = textMatch;\n return { label: key.trim(), value: value.trim() };\n } else {\n return { label: text.trim(), value: text.trim() };\n }\n });\n }\n\n public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {\n const options = this.transformCsvStringToOptions(this.state.query);\n\n if (!options.length) {\n this.skipNextValidation = true;\n }\n\n return of(options);\n }\n\n public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {\n return <Multi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,EAAA,KAAA,CAAM,MAAO,EAAA;AAAA,OAC3C,MAAA;AACL,QAAO,OAAA,EAAE,OAAO,IAAK,CAAA,IAAA,IAAQ,KAAO,EAAA,IAAA,CAAK,MAAO,EAAA;AAAA;AAClD,KACD,CAAA;AAAA;AACH,EAEO,gBAAgB,IAAiE,EAAA;AACtF,IAAA,MAAM,OAAU,GAAA,IAAA,CAAK,2BAA4B,CAAA,IAAA,CAAK,MAAM,KAAK,CAAA;AAEjE,IAAI,IAAA,CAAC,QAAQ,MAAQ,EAAA;AACnB,MAAA,IAAA,CAAK,kBAAqB,GAAA,IAAA;AAAA;AAG5B,IAAA,OAAO,GAAG,OAAO,CAAA;AAAA;AAMrB;AAhDa,cAAA,CA6CG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAqD,KAAA;AAChF,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,4BAAyB,KAAc,EAAA,CAAA;AACjD,CAAA;;;;"}
package/dist/index.d.ts CHANGED
@@ -1124,6 +1124,7 @@ interface CustomVariableState extends MultiValueVariableState {
1124
1124
  declare class CustomVariable extends MultiValueVariable<CustomVariableState> {
1125
1125
  protected _variableDependency: VariableDependencyConfig<CustomVariableState>;
1126
1126
  constructor(initialState: Partial<CustomVariableState>);
1127
+ transformCsvStringToOptions(str: string, interpolate?: boolean): VariableValueOption[];
1127
1128
  getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]>;
1128
1129
  static Component: ({ model }: SceneComponentProps<MultiValueVariable>) => React__default.JSX.Element;
1129
1130
  }
package/dist/index.js CHANGED
@@ -11113,11 +11113,13 @@ class CustomVariable extends MultiValueVariable {
11113
11113
  statePaths: ["query"]
11114
11114
  });
11115
11115
  }
11116
- getValueOptions(args) {
11116
+ // We expose this publicly as we also need it outside the variable
11117
+ // The interpolate flag is needed since we don't always want to get the interpolated options
11118
+ transformCsvStringToOptions(str, interpolate = true) {
11117
11119
  var _a;
11118
- const interpolated = sceneGraph.interpolate(this, this.state.query);
11119
- const match = (_a = interpolated.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
11120
- const options = match.map((text) => {
11120
+ str = interpolate ? sceneGraph.interpolate(this, str) : str;
11121
+ const match = (_a = str.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
11122
+ return match.map((text) => {
11121
11123
  var _a2;
11122
11124
  text = text.replace(/\\,/g, ",");
11123
11125
  const textMatch = (_a2 = /^\s*(.+)\s:\s(.+)$/g.exec(text)) != null ? _a2 : [];
@@ -11128,6 +11130,9 @@ class CustomVariable extends MultiValueVariable {
11128
11130
  return { label: text.trim(), value: text.trim() };
11129
11131
  }
11130
11132
  });
11133
+ }
11134
+ getValueOptions(args) {
11135
+ const options = this.transformCsvStringToOptions(this.state.query);
11131
11136
  if (!options.length) {
11132
11137
  this.skipNextValidation = true;
11133
11138
  }