@grafana/scenes 4.30.0--canary.781.9444216593.0 → 4.30.0--canary.785.9463381206.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/variables/components/VariableValueSelect.js +10 -6
- package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
- package/dist/esm/variables/interpolation/sceneInterpolator.js +8 -5
- package/dist/esm/variables/interpolation/sceneInterpolator.js.map +1 -1
- package/dist/esm/variables/macros/index.js +19 -19
- package/dist/esm/variables/macros/index.js.map +1 -1
- package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
- package/dist/index.d.ts +1 -15
- package/dist/index.js +439 -504
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/variables/variants/SnapshotVariable.js +0 -79
- package/dist/esm/variables/variants/SnapshotVariable.js.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@grafana/scenes",
|
3
|
-
"version": "4.30.0--canary.
|
3
|
+
"version": "4.30.0--canary.785.9463381206.0",
|
4
4
|
"description": "Grafana framework for building dynamic dashboards",
|
5
5
|
"author": "Grafana Labs",
|
6
6
|
"license": "AGPL-3.0-only",
|
@@ -113,5 +113,5 @@
|
|
113
113
|
"prettier --write"
|
114
114
|
]
|
115
115
|
},
|
116
|
-
"gitHead": "
|
116
|
+
"gitHead": "4e5e12cceb8471c8055d611bca3ca95ee7b9461e"
|
117
117
|
}
|
@@ -1,79 +0,0 @@
|
|
1
|
-
import { of, map } from 'rxjs';
|
2
|
-
import { VariableDependencyConfig } from '../VariableDependencyConfig.js';
|
3
|
-
import { renderSelectForVariable } from '../components/VariableValueSelect.js';
|
4
|
-
import { MultiValueVariable } from './MultiValueVariable.js';
|
5
|
-
import { sceneGraph } from '../../core/sceneGraph/index.js';
|
6
|
-
|
7
|
-
var __defProp = Object.defineProperty;
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
12
|
-
var __spreadValues = (a, b) => {
|
13
|
-
for (var prop in b || (b = {}))
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
16
|
-
if (__getOwnPropSymbols)
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
18
|
-
if (__propIsEnum.call(b, prop))
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
20
|
-
}
|
21
|
-
return a;
|
22
|
-
};
|
23
|
-
class SnapshotVariable extends MultiValueVariable {
|
24
|
-
constructor(initialState) {
|
25
|
-
super(__spreadValues({
|
26
|
-
type: "custom",
|
27
|
-
isReadOnly: true,
|
28
|
-
query: "",
|
29
|
-
value: "",
|
30
|
-
text: "",
|
31
|
-
options: [],
|
32
|
-
name: ""
|
33
|
-
}, initialState));
|
34
|
-
this._variableDependency = new VariableDependencyConfig(this, {
|
35
|
-
statePaths: ["query"]
|
36
|
-
});
|
37
|
-
}
|
38
|
-
getValueOptions(args) {
|
39
|
-
var _a;
|
40
|
-
const interpolated = sceneGraph.interpolate(this, this.state.query);
|
41
|
-
const match = (_a = interpolated.match(/(?:\\,|[^,])+/g)) != null ? _a : [];
|
42
|
-
const options = match.map((text) => {
|
43
|
-
var _a2;
|
44
|
-
text = text.replace(/\\,/g, ",");
|
45
|
-
const textMatch = (_a2 = /^(.+)\s:\s(.+)$/g.exec(text)) != null ? _a2 : [];
|
46
|
-
if (textMatch.length === 3) {
|
47
|
-
const [, key, value] = textMatch;
|
48
|
-
return { label: key.trim(), value: value.trim() };
|
49
|
-
} else {
|
50
|
-
return { label: text.trim(), value: text.trim() };
|
51
|
-
}
|
52
|
-
});
|
53
|
-
return of(options);
|
54
|
-
}
|
55
|
-
validateAndUpdate() {
|
56
|
-
return this.getValueOptions({}).pipe(
|
57
|
-
map((options) => {
|
58
|
-
this._updateValueGivenNewOptions(options);
|
59
|
-
return {};
|
60
|
-
})
|
61
|
-
);
|
62
|
-
}
|
63
|
-
_updateValueGivenNewOptions(options) {
|
64
|
-
const { value: currentValue, text: currentText } = this.state;
|
65
|
-
const stateUpdate = {
|
66
|
-
options,
|
67
|
-
loading: false,
|
68
|
-
value: currentValue != null ? currentValue : [],
|
69
|
-
text: currentText != null ? currentText : []
|
70
|
-
};
|
71
|
-
this.setState(stateUpdate);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
SnapshotVariable.Component = ({ model }) => {
|
75
|
-
return renderSelectForVariable(model);
|
76
|
-
};
|
77
|
-
|
78
|
-
export { SnapshotVariable };
|
79
|
-
//# sourceMappingURL=SnapshotVariable.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SnapshotVariable.js","sources":["../../../../src/variables/variants/SnapshotVariable.tsx"],"sourcesContent":["import { Observable, of, map } from 'rxjs';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { VariableDependencyConfig } from '../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../components/VariableValueSelect';\nimport { VariableValueOption, ValidateAndUpdateResult } from '../types';\n\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable';\nimport { sceneGraph } from '../../core/sceneGraph';\n\nexport interface SnapshotVariableState extends MultiValueVariableState {\n query: string;\n isReadOnly: boolean;\n}\n\nexport class SnapshotVariable extends MultiValueVariable<SnapshotVariableState> {\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['query'],\n });\n\n public constructor(initialState: Partial<SnapshotVariableState>) {\n //TODO: Add new `snapshot` type to Variable Type\n super({\n type: 'custom',\n isReadOnly: true,\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(.+)$/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 return of(options);\n }\n\n public validateAndUpdate(): Observable<ValidateAndUpdateResult> {\n return this.getValueOptions({}).pipe(\n map((options) => {\n this._updateValueGivenNewOptions(options);\n return {};\n })\n );\n }\n\n public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {\n return renderSelectForVariable(model);\n };\n // we will always preserve the current value and text for snapshots\n private _updateValueGivenNewOptions(options: VariableValueOption[]) {\n const { value: currentValue, text: currentText } = this.state;\n\n const stateUpdate: Partial<MultiValueVariableState> = {\n options,\n loading: false,\n value: currentValue ?? [],\n text: currentText ?? [],\n };\n\n this.setState(stateUpdate);\n }\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeO,MAAM,yBAAyB,kBAA0C,CAAA;AAAA,EAKvE,YAAY,YAA8C,EAAA;AAE/D,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,QAAA;AAAA,MACN,UAAY,EAAA,IAAA;AAAA,MACZ,KAAO,EAAA,EAAA;AAAA,MACP,KAAO,EAAA,EAAA;AAAA,MACP,IAAM,EAAA,EAAA;AAAA,MACN,SAAS,EAAC;AAAA,MACV,IAAM,EAAA,EAAA;AAAA,KAAA,EACH,YACJ,CAAA,CAAA,CAAA;AAfH,IAAU,IAAA,CAAA,mBAAA,GAAsB,IAAI,wBAAA,CAAyB,IAAM,EAAA;AAAA,MACjE,UAAA,EAAY,CAAC,OAAO,CAAA;AAAA,KACrB,CAAA,CAAA;AAAA,GAcD;AAAA,EAEO,gBAAgB,IAAiE,EAAA;AAlC1F,IAA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