@grafana/scenes 4.13.0--canary.705.8847545922.0 → 4.13.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.
- package/CHANGELOG.md +12 -0
- package/dist/esm/core/sceneGraph/sceneGraph.js +2 -2
- package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js +30 -6
- package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +10 -24
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/interpolation/sceneInterpolator.js +9 -2
- package/dist/esm/variables/interpolation/sceneInterpolator.js.map +1 -1
- package/dist/esm/variables/utils.js +1 -27
- package/dist/esm/variables/utils.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +50 -109
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/variables/groupby/GroupByVariableUrlSyncHandler.js +0 -58
- package/dist/esm/variables/groupby/GroupByVariableUrlSyncHandler.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1304,7 +1304,7 @@ function lookupVariable(name, sceneObject) {
|
|
|
1304
1304
|
return null;
|
|
1305
1305
|
}
|
|
1306
1306
|
|
|
1307
|
-
function sceneInterpolator(sceneObject, target, scopedVars, format) {
|
|
1307
|
+
function sceneInterpolator(sceneObject, target, scopedVars, format, interpolations) {
|
|
1308
1308
|
if (!target) {
|
|
1309
1309
|
return target != null ? target : "";
|
|
1310
1310
|
}
|
|
@@ -1314,9 +1314,16 @@ function sceneInterpolator(sceneObject, target, scopedVars, format) {
|
|
|
1314
1314
|
const fmt = fmt2 || fmt3 || format;
|
|
1315
1315
|
const variable = lookupFormatVariable(variableName, match, scopedVars, sceneObject);
|
|
1316
1316
|
if (!variable) {
|
|
1317
|
+
if (interpolations) {
|
|
1318
|
+
interpolations.push({ match, variableName, fieldPath, format: fmt, value: match, found: false });
|
|
1319
|
+
}
|
|
1317
1320
|
return match;
|
|
1318
1321
|
}
|
|
1319
|
-
|
|
1322
|
+
const value = formatValue(variable, variable.getValue(fieldPath), fmt);
|
|
1323
|
+
if (interpolations) {
|
|
1324
|
+
interpolations.push({ match, variableName, fieldPath, format: fmt, value, found: value !== match });
|
|
1325
|
+
}
|
|
1326
|
+
return value;
|
|
1320
1327
|
});
|
|
1321
1328
|
}
|
|
1322
1329
|
function lookupFormatVariable(name, match, scopedVars, sceneObject) {
|
|
@@ -1455,11 +1462,11 @@ function getLayout(scene) {
|
|
|
1455
1462
|
}
|
|
1456
1463
|
return null;
|
|
1457
1464
|
}
|
|
1458
|
-
function interpolate(sceneObject, value, scopedVars, format) {
|
|
1465
|
+
function interpolate(sceneObject, value, scopedVars, format, interpolations) {
|
|
1459
1466
|
if (value === "" || value == null) {
|
|
1460
1467
|
return "";
|
|
1461
1468
|
}
|
|
1462
|
-
return sceneInterpolator(sceneObject, value, scopedVars, format);
|
|
1469
|
+
return sceneInterpolator(sceneObject, value, scopedVars, format, interpolations);
|
|
1463
1470
|
}
|
|
1464
1471
|
function hasVariableDependencyInLoadingState(sceneObject) {
|
|
1465
1472
|
if (!sceneObject.variableDependency) {
|
|
@@ -2840,59 +2847,6 @@ class CustomAllValue {
|
|
|
2840
2847
|
}
|
|
2841
2848
|
}
|
|
2842
2849
|
|
|
2843
|
-
class GroupByVariableUrlSyncHandler {
|
|
2844
|
-
constructor(_sceneObject) {
|
|
2845
|
-
this._sceneObject = _sceneObject;
|
|
2846
|
-
}
|
|
2847
|
-
getKey() {
|
|
2848
|
-
return `var-${this._sceneObject.state.name}`;
|
|
2849
|
-
}
|
|
2850
|
-
getKeys() {
|
|
2851
|
-
if (this._sceneObject.state.skipUrlSync) {
|
|
2852
|
-
return [];
|
|
2853
|
-
}
|
|
2854
|
-
return [this.getKey()];
|
|
2855
|
-
}
|
|
2856
|
-
getUrlState() {
|
|
2857
|
-
if (this._sceneObject.state.skipUrlSync) {
|
|
2858
|
-
return {};
|
|
2859
|
-
}
|
|
2860
|
-
let { value: values, text: texts } = this._sceneObject.state;
|
|
2861
|
-
values = Array.isArray(values) ? values : [values];
|
|
2862
|
-
texts = Array.isArray(texts) ? texts : [texts];
|
|
2863
|
-
const urlValue = lodash.zip(values, texts).map(toUrlValues);
|
|
2864
|
-
return { [this.getKey()]: urlValue };
|
|
2865
|
-
}
|
|
2866
|
-
updateFromUrl(values) {
|
|
2867
|
-
let urlValue = values[this.getKey()];
|
|
2868
|
-
if (urlValue != null) {
|
|
2869
|
-
if (!this._sceneObject.isActive) {
|
|
2870
|
-
this._sceneObject.skipNextValidation = true;
|
|
2871
|
-
}
|
|
2872
|
-
urlValue = Array.isArray(urlValue) ? urlValue : [urlValue];
|
|
2873
|
-
const valuesLabelsPairs = urlValue.map((value) => value ? value.split(",") : [value]);
|
|
2874
|
-
let [values2, labels] = lodash.unzip(valuesLabelsPairs);
|
|
2875
|
-
values2 = (values2 != null ? values2 : []).map(unescapeUrlDelimiters);
|
|
2876
|
-
labels = (labels != null ? labels : []).map(unescapeUrlDelimiters);
|
|
2877
|
-
this._sceneObject.setState({
|
|
2878
|
-
urlOptions: values2.map((value, idx) => ({
|
|
2879
|
-
value,
|
|
2880
|
-
text: labels[idx]
|
|
2881
|
-
}))
|
|
2882
|
-
});
|
|
2883
|
-
this._sceneObject.changeValueTo(values2, labels);
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
}
|
|
2887
|
-
function toUrlValues([value, label]) {
|
|
2888
|
-
if (value === void 0 || value === null) {
|
|
2889
|
-
return "";
|
|
2890
|
-
}
|
|
2891
|
-
value = String(value);
|
|
2892
|
-
label = label === void 0 || label === null ? value : String(label);
|
|
2893
|
-
return toUrlCommaDelimitedString(value, label);
|
|
2894
|
-
}
|
|
2895
|
-
|
|
2896
2850
|
var __defProp$z = Object.defineProperty;
|
|
2897
2851
|
var __defProps$n = Object.defineProperties;
|
|
2898
2852
|
var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
|
|
@@ -2929,7 +2883,6 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
2929
2883
|
noValueOnClear: true
|
|
2930
2884
|
}));
|
|
2931
2885
|
this.isLazy = true;
|
|
2932
|
-
this._urlSync = new GroupByVariableUrlSyncHandler(this);
|
|
2933
2886
|
this._getKeys = async (ds) => {
|
|
2934
2887
|
var _a, _b, _c;
|
|
2935
2888
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, null));
|
|
@@ -2979,11 +2932,9 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
2979
2932
|
this.setState(stateUpdate);
|
|
2980
2933
|
}
|
|
2981
2934
|
getValueOptions(args) {
|
|
2982
|
-
var _a;
|
|
2983
|
-
const urlOptions = (_a = this.state.urlOptions) != null ? _a : [];
|
|
2984
2935
|
if (this.state.defaultOptions) {
|
|
2985
2936
|
return rxjs.of(
|
|
2986
|
-
|
|
2937
|
+
this.state.defaultOptions.map((o) => ({
|
|
2987
2938
|
label: o.text,
|
|
2988
2939
|
value: String(o.value)
|
|
2989
2940
|
}))
|
|
@@ -2999,7 +2950,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
2999
2950
|
return rxjs.from(this._getKeys(ds)).pipe(
|
|
3000
2951
|
rxjs.take(1),
|
|
3001
2952
|
rxjs.mergeMap((data) => {
|
|
3002
|
-
const a =
|
|
2953
|
+
const a = data.map((i) => {
|
|
3003
2954
|
return {
|
|
3004
2955
|
label: i.text,
|
|
3005
2956
|
value: i.value ? String(i.value) : i.text
|
|
@@ -3017,24 +2968,14 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3017
2968
|
}
|
|
3018
2969
|
GroupByVariable.Component = GroupByVariableRenderer;
|
|
3019
2970
|
function GroupByVariableRenderer({ model }) {
|
|
3020
|
-
const { value,
|
|
3021
|
-
const
|
|
3022
|
-
const arrayValue = lodash.isArray(value) ? value : [value];
|
|
3023
|
-
const arrayText = lodash.isArray(text) ? text : [text];
|
|
3024
|
-
return arrayValue.map((value2, idx) => {
|
|
3025
|
-
var _a;
|
|
3026
|
-
return {
|
|
3027
|
-
value: value2,
|
|
3028
|
-
label: String((_a = arrayText[idx]) != null ? _a : value2)
|
|
3029
|
-
};
|
|
3030
|
-
});
|
|
3031
|
-
}, [value, text]);
|
|
2971
|
+
const { value, key, maxVisibleValues, noValueOnClear } = model.useState();
|
|
2972
|
+
const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
|
|
3032
2973
|
const [isFetchingOptions, setIsFetchingOptions] = React.useState(false);
|
|
3033
2974
|
const [isOptionsOpen, setIsOptionsOpen] = React.useState(false);
|
|
3034
|
-
const [uncommittedValue, setUncommittedValue] = React.useState(
|
|
2975
|
+
const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
|
|
3035
2976
|
React.useEffect(() => {
|
|
3036
|
-
setUncommittedValue(
|
|
3037
|
-
}, [
|
|
2977
|
+
setUncommittedValue(arrayValue);
|
|
2978
|
+
}, [arrayValue]);
|
|
3038
2979
|
const onInputChange = model.onSearchChange ? (value2, meta) => {
|
|
3039
2980
|
if (meta.action === "input-change") {
|
|
3040
2981
|
model.onSearchChange(value2);
|
|
@@ -3059,13 +3000,13 @@ function GroupByVariableRenderer({ model }) {
|
|
|
3059
3000
|
isLoading: isFetchingOptions,
|
|
3060
3001
|
onInputChange,
|
|
3061
3002
|
onBlur: () => {
|
|
3062
|
-
model.changeValueTo(uncommittedValue
|
|
3003
|
+
model.changeValueTo(uncommittedValue);
|
|
3063
3004
|
},
|
|
3064
3005
|
onChange: (newValue, action) => {
|
|
3065
3006
|
if (action.action === "clear" && noValueOnClear) {
|
|
3066
3007
|
model.changeValueTo([]);
|
|
3067
3008
|
}
|
|
3068
|
-
setUncommittedValue(newValue);
|
|
3009
|
+
setUncommittedValue(newValue.map((x) => x.value));
|
|
3069
3010
|
},
|
|
3070
3011
|
onOpenMenu: async () => {
|
|
3071
3012
|
setIsFetchingOptions(true);
|
|
@@ -3388,7 +3329,7 @@ class AdHocFiltersVariableUrlSyncHandler {
|
|
|
3388
3329
|
if (filters.length === 0) {
|
|
3389
3330
|
return { [this.getKey()]: [""] };
|
|
3390
3331
|
}
|
|
3391
|
-
const value = filters.map((filter) => toArray(filter).map(
|
|
3332
|
+
const value = filters.map((filter) => toArray(filter).map(escapePipeDelimiters).join("|"));
|
|
3392
3333
|
return { [this.getKey()]: value };
|
|
3393
3334
|
}
|
|
3394
3335
|
updateFromUrl(values) {
|
|
@@ -3408,13 +3349,39 @@ function deserializeUrlToFilters(value) {
|
|
|
3408
3349
|
const filter = toFilter(value);
|
|
3409
3350
|
return filter === null ? [] : [filter];
|
|
3410
3351
|
}
|
|
3352
|
+
function escapePipeDelimiters(value) {
|
|
3353
|
+
if (value === null || value === void 0) {
|
|
3354
|
+
return "";
|
|
3355
|
+
}
|
|
3356
|
+
return value = /\|/g[Symbol.replace](value, "__gfp__");
|
|
3357
|
+
}
|
|
3358
|
+
function escapeCommaDelimiters(value) {
|
|
3359
|
+
if (value === null || value === void 0) {
|
|
3360
|
+
return "";
|
|
3361
|
+
}
|
|
3362
|
+
return /,/g[Symbol.replace](value, "__gfc__");
|
|
3363
|
+
}
|
|
3364
|
+
function unescapeDelimiters(value) {
|
|
3365
|
+
if (value === null || value === void 0) {
|
|
3366
|
+
return "";
|
|
3367
|
+
}
|
|
3368
|
+
value = /__gfp__/g[Symbol.replace](value, "|");
|
|
3369
|
+
value = /__gfc__/g[Symbol.replace](value, ",");
|
|
3370
|
+
return value;
|
|
3371
|
+
}
|
|
3411
3372
|
function toArray(filter) {
|
|
3412
3373
|
return [
|
|
3413
|
-
|
|
3374
|
+
toCommaDelimitedString(filter.key, filter.keyLabel),
|
|
3414
3375
|
filter.operator,
|
|
3415
|
-
|
|
3376
|
+
toCommaDelimitedString(filter.value, filter.valueLabel)
|
|
3416
3377
|
];
|
|
3417
3378
|
}
|
|
3379
|
+
function toCommaDelimitedString(key, label) {
|
|
3380
|
+
if (!label || key === label) {
|
|
3381
|
+
return escapeCommaDelimiters(key);
|
|
3382
|
+
}
|
|
3383
|
+
return [key, label].map(escapeCommaDelimiters).join(",");
|
|
3384
|
+
}
|
|
3418
3385
|
function toFilter(urlValue) {
|
|
3419
3386
|
if (typeof urlValue !== "string" || urlValue.length === 0) {
|
|
3420
3387
|
return null;
|
|
@@ -3423,7 +3390,7 @@ function toFilter(urlValue) {
|
|
|
3423
3390
|
const [key2, label] = v.split(",");
|
|
3424
3391
|
acc.push(key2, label != null ? label : key2);
|
|
3425
3392
|
return acc;
|
|
3426
|
-
}, []).map(
|
|
3393
|
+
}, []).map(unescapeDelimiters);
|
|
3427
3394
|
return {
|
|
3428
3395
|
key,
|
|
3429
3396
|
keyLabel,
|
|
@@ -4133,32 +4100,6 @@ function filterOutInactiveRunnerDuplicates(runners) {
|
|
|
4133
4100
|
return activeItems;
|
|
4134
4101
|
});
|
|
4135
4102
|
}
|
|
4136
|
-
function escapeUrlPipeDelimiters(value) {
|
|
4137
|
-
if (value === null || value === void 0) {
|
|
4138
|
-
return "";
|
|
4139
|
-
}
|
|
4140
|
-
return value = /\|/g[Symbol.replace](value, "__gfp__");
|
|
4141
|
-
}
|
|
4142
|
-
function escapeUrlCommaDelimiters(value) {
|
|
4143
|
-
if (value === null || value === void 0) {
|
|
4144
|
-
return "";
|
|
4145
|
-
}
|
|
4146
|
-
return /,/g[Symbol.replace](value, "__gfc__");
|
|
4147
|
-
}
|
|
4148
|
-
function unescapeUrlDelimiters(value) {
|
|
4149
|
-
if (value === null || value === void 0) {
|
|
4150
|
-
return "";
|
|
4151
|
-
}
|
|
4152
|
-
value = /__gfp__/g[Symbol.replace](value, "|");
|
|
4153
|
-
value = /__gfc__/g[Symbol.replace](value, ",");
|
|
4154
|
-
return value;
|
|
4155
|
-
}
|
|
4156
|
-
function toUrlCommaDelimitedString(key, label) {
|
|
4157
|
-
if (!label || key === label) {
|
|
4158
|
-
return escapeUrlCommaDelimiters(key);
|
|
4159
|
-
}
|
|
4160
|
-
return [key, label].map(escapeUrlCommaDelimiters).join(",");
|
|
4161
|
-
}
|
|
4162
4103
|
|
|
4163
4104
|
function isAdHocVariable(variable) {
|
|
4164
4105
|
return variable.state.type === "adhoc";
|