@grafana/scenes 6.28.0 → 6.28.1
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.28.1 (Thu Jul 24 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Custom variable: support newline separated options [#1191](https://github.com/grafana/scenes/pull/1191) ([@domasx2](https://github.com/domasx2))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Domas ([@domasx2](https://github.com/domasx2))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v6.28.0 (Wed Jul 23 2025)
|
|
2
14
|
|
|
3
15
|
#### 🚀 Enhancement
|
|
@@ -27,7 +27,7 @@ class CustomVariable extends MultiValueVariable {
|
|
|
27
27
|
const options = match.map((text) => {
|
|
28
28
|
var _a2;
|
|
29
29
|
text = text.replace(/\\,/g, ",");
|
|
30
|
-
const textMatch = (_a2 =
|
|
30
|
+
const textMatch = (_a2 = /^\s*(.+)\s:\s(.+)$/g.exec(text)) != null ? _a2 : [];
|
|
31
31
|
if (textMatch.length === 3) {
|
|
32
32
|
const [, key, value] = textMatch;
|
|
33
33
|
return { label: key.trim(), value: value.trim() };
|
|
@@ -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 =
|
|
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,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,EAEO,gBAAgB,IAAiE,EAAA;AAhC1F,IAAA,IAAA,EAAA;AAiCI,IAAA,MAAM,eAAe,UAAW,CAAA,WAAA,CAAY,IAAM,EAAA,IAAA,CAAK,MAAM,KAAK,CAAA;AAClE,IAAA,MAAM,SAAQ,EAAa,GAAA,YAAA,CAAA,KAAA,CAAM,gBAAgB,CAAA,KAAnC,YAAwC,EAAC;AAEvD,IAAA,MAAM,OAAU,GAAA,KAAA,CAAM,GAAI,CAAA,CAAC,IAAS,KAAA;AApCxC,MAAAA,IAAAA,GAAAA;AAqCM,MAAO,IAAA,GAAA,IAAA,CAAK,OAAQ,CAAA,MAAA,EAAQ,GAAG,CAAA;AAC/B,MAAM,MAAA,SAAA,GAAA,CAAYA,MAAA,qBAAsB,CAAA,IAAA,CAAK,IAAI,CAA/B,KAAA,IAAA,GAAAA,MAAoC,EAAC;AACvD,MAAI,IAAA,SAAA,CAAU,WAAW,CAAG,EAAA;AAC1B,QAAA,MAAM,GAAG,GAAK,EAAA,KAAK,CAAI,GAAA,SAAA;AACvB,QAAO,OAAA,EAAE,OAAO,GAAI,CAAA,IAAA,IAAQ,KAAO,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;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.js
CHANGED
|
@@ -10238,7 +10238,7 @@ class CustomVariable extends MultiValueVariable {
|
|
|
10238
10238
|
const options = match.map((text) => {
|
|
10239
10239
|
var _a2;
|
|
10240
10240
|
text = text.replace(/\\,/g, ",");
|
|
10241
|
-
const textMatch = (_a2 =
|
|
10241
|
+
const textMatch = (_a2 = /^\s*(.+)\s:\s(.+)$/g.exec(text)) != null ? _a2 : [];
|
|
10242
10242
|
if (textMatch.length === 3) {
|
|
10243
10243
|
const [, key, value] = textMatch;
|
|
10244
10244
|
return { label: key.trim(), value: value.trim() };
|