@grafana/scenes 6.39.4--canary.1269.18370250318.0 → 6.39.4--canary.1269.18370736450.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.
@@ -22,10 +22,10 @@ class CustomVariable extends MultiValueVariable {
22
22
  }
23
23
  // We expose this publicly as we also need it outside the variable
24
24
  // The interpolate flag is needed since we don't always want to get the interpolated options
25
- transformQueryToOptions(interpolate = true) {
25
+ transformCsvStringToOptions(str, interpolate = true) {
26
26
  var _a;
27
- const query = interpolate ? sceneGraph.interpolate(this, this.state.query) : this.state.query;
28
- const match = (_a = query.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
27
+ str = interpolate ? sceneGraph.interpolate(this, str) : str;
28
+ const match = (_a = str.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
29
29
  return match.map((text) => {
30
30
  var _a2;
31
31
  text = text.replace(/\\,/g, ",");
@@ -39,7 +39,7 @@ class CustomVariable extends MultiValueVariable {
39
39
  });
40
40
  }
41
41
  getValueOptions(args) {
42
- const options = this.transformQueryToOptions();
42
+ const options = this.transformCsvStringToOptions(this.state.query);
43
43
  if (!options.length) {
44
44
  this.skipNextValidation = true;
45
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 // 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 transformQueryToOptions(interpolate = true): VariableValueOption[] {\n const query = interpolate ? sceneGraph.interpolate(this, this.state.query) : this.state.query;\n const match = query.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.transformQueryToOptions();\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,IAAM,EAAA,EAAA;AAAA,MACN,GAAG;AAAA,KACJ,CAAA;AAbH,IAAU,IAAA,CAAA,mBAAA,GAAsB,IAAI,wBAAA,CAAyB,IAAM,EAAA;AAAA,MACjE,UAAA,EAAY,CAAC,OAAO;AAAA,KACrB,CAAA;AAAA;AAYD;AAAA;AAAA,EAIO,uBAAA,CAAwB,cAAc,IAA6B,EAAA;AAlC5E,IAAA,IAAA,EAAA;AAmCI,IAAM,MAAA,KAAA,GAA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"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 <MultiOrSingleValueSelect model={model} />;\n };\n}\n"],"names":["_a"],"mappings":";;;;;;;AAeO,MAAM,uBAAuB,kBAAwC,CAAA;AAAA,EAKnE,YAAY,YAA4C,EAAA;AAC7D,IAAM,KAA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;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,7 +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
- transformQueryToOptions(interpolate?: boolean): VariableValueOption[];
1127
+ transformCsvStringToOptions(str: string, interpolate?: boolean): VariableValueOption[];
1128
1128
  getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]>;
1129
1129
  static Component: ({ model }: SceneComponentProps<MultiValueVariable>) => React__default.JSX.Element;
1130
1130
  }
package/dist/index.js CHANGED
@@ -11115,10 +11115,10 @@ class CustomVariable extends MultiValueVariable {
11115
11115
  }
11116
11116
  // We expose this publicly as we also need it outside the variable
11117
11117
  // The interpolate flag is needed since we don't always want to get the interpolated options
11118
- transformQueryToOptions(interpolate = true) {
11118
+ transformCsvStringToOptions(str, interpolate = true) {
11119
11119
  var _a;
11120
- const query = interpolate ? sceneGraph.interpolate(this, this.state.query) : this.state.query;
11121
- const match = (_a = query.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
11120
+ str = interpolate ? sceneGraph.interpolate(this, str) : str;
11121
+ const match = (_a = str.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
11122
11122
  return match.map((text) => {
11123
11123
  var _a2;
11124
11124
  text = text.replace(/\\,/g, ",");
@@ -11132,7 +11132,7 @@ class CustomVariable extends MultiValueVariable {
11132
11132
  });
11133
11133
  }
11134
11134
  getValueOptions(args) {
11135
- const options = this.transformQueryToOptions();
11135
+ const options = this.transformCsvStringToOptions(this.state.query);
11136
11136
  if (!options.length) {
11137
11137
  this.skipNextValidation = true;
11138
11138
  }