@grafana/scenes 6.39.4--canary.1269.18370250318.0 → 6.39.4--canary.1270.18376571635.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.
@@ -20,13 +20,11 @@ class CustomVariable extends MultiValueVariable {
|
|
20
20
|
statePaths: ["query"]
|
21
21
|
});
|
22
22
|
}
|
23
|
-
|
24
|
-
// The interpolate flag is needed since we don't always want to get the interpolated options
|
25
|
-
transformQueryToOptions(interpolate = true) {
|
23
|
+
getValueOptions(args) {
|
26
24
|
var _a;
|
27
|
-
const
|
28
|
-
const match = (_a =
|
29
|
-
|
25
|
+
const interpolated = sceneGraph.interpolate(this, this.state.query);
|
26
|
+
const match = (_a = interpolated.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
|
27
|
+
const options = match.map((text) => {
|
30
28
|
var _a2;
|
31
29
|
text = text.replace(/\\,/g, ",");
|
32
30
|
const textMatch = (_a2 = /^\s*(.+)\s:\s(.+)$/g.exec(text)) != null ? _a2 : [];
|
@@ -37,9 +35,6 @@ class CustomVariable extends MultiValueVariable {
|
|
37
35
|
return { label: text.trim(), value: text.trim() };
|
38
36
|
}
|
39
37
|
});
|
40
|
-
}
|
41
|
-
getValueOptions(args) {
|
42
|
-
const options = this.transformQueryToOptions();
|
43
38
|
if (!options.length) {
|
44
39
|
this.skipNextValidation = true;
|
45
40
|
}
|
@@ -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
|
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":["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OAAO,IAAK,CAAA,IAAA,IAAQ,KAAO,EAAA,IAAA,CAAK,MAAO,EAAA;AAAA;AAClD,KACD,CAAA;AAED,IAAI,IAAA,CAAC,QAAQ,MAAQ,EAAA;AACnB,MAAA,IAAA,CAAK,kBAAqB,GAAA,IAAA;AAAA;AAG5B,IAAA,OAAO,GAAG,OAAO,CAAA;AAAA;AAMrB;AA1Ca,cAAA,CAuCG,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,6 @@ 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[];
|
1128
1127
|
getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]>;
|
1129
1128
|
static Component: ({ model }: SceneComponentProps<MultiValueVariable>) => React__default.JSX.Element;
|
1130
1129
|
}
|
package/dist/index.js
CHANGED
@@ -11113,13 +11113,11 @@ class CustomVariable extends MultiValueVariable {
|
|
11113
11113
|
statePaths: ["query"]
|
11114
11114
|
});
|
11115
11115
|
}
|
11116
|
-
|
11117
|
-
// The interpolate flag is needed since we don't always want to get the interpolated options
|
11118
|
-
transformQueryToOptions(interpolate = true) {
|
11116
|
+
getValueOptions(args) {
|
11119
11117
|
var _a;
|
11120
|
-
const
|
11121
|
-
const match = (_a =
|
11122
|
-
|
11118
|
+
const interpolated = sceneGraph.interpolate(this, this.state.query);
|
11119
|
+
const match = (_a = interpolated.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
|
11120
|
+
const options = match.map((text) => {
|
11123
11121
|
var _a2;
|
11124
11122
|
text = text.replace(/\\,/g, ",");
|
11125
11123
|
const textMatch = (_a2 = /^\s*(.+)\s:\s(.+)$/g.exec(text)) != null ? _a2 : [];
|
@@ -11130,9 +11128,6 @@ class CustomVariable extends MultiValueVariable {
|
|
11130
11128
|
return { label: text.trim(), value: text.trim() };
|
11131
11129
|
}
|
11132
11130
|
});
|
11133
|
-
}
|
11134
|
-
getValueOptions(args) {
|
11135
|
-
const options = this.transformQueryToOptions();
|
11136
11131
|
if (!options.length) {
|
11137
11132
|
this.skipNextValidation = true;
|
11138
11133
|
}
|