@grafana/scenes 5.3.6 → 5.4.0--canary.813.9776503756.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +0 -24
- package/dist/esm/components/SceneRefreshPicker.js +5 -5
- package/dist/esm/components/SceneRefreshPicker.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +9 -24
- package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +23 -9
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +36 -72
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/variables/adhoc/getAdhocOptionSearcher.js +0 -40
- package/dist/esm/variables/adhoc/getAdhocOptionSearcher.js.map +0 -1
package/dist/index.js
CHANGED
@@ -3409,61 +3409,13 @@ const getStyles$9 = (theme) => ({
|
|
3409
3409
|
})
|
3410
3410
|
});
|
3411
3411
|
|
3412
|
-
function
|
3413
|
-
|
3414
|
-
|
3415
|
-
|
3416
|
-
|
3417
|
-
var _a;
|
3418
|
-
if (search === "") {
|
3419
|
-
if (options.length > limit) {
|
3420
|
-
return options.slice(0, limit);
|
3421
|
-
} else {
|
3422
|
-
return options;
|
3423
|
-
}
|
3424
|
-
}
|
3425
|
-
if (haystack.length === 0) {
|
3426
|
-
for (let i = 0; i < options.length; i++) {
|
3427
|
-
haystack.push((_a = options[i].label) != null ? _a : String(options[i].value));
|
3428
|
-
}
|
3429
|
-
}
|
3430
|
-
const idxs = ufuzzy.filter(haystack, search);
|
3431
|
-
const filteredOptions = [];
|
3432
|
-
if (idxs) {
|
3433
|
-
for (let i = 0; i < idxs.length; i++) {
|
3434
|
-
filteredOptions.push(options[idxs[i]]);
|
3435
|
-
if (filteredOptions.length > limit) {
|
3436
|
-
return filteredOptions;
|
3437
|
-
}
|
3438
|
-
}
|
3439
|
-
return filteredOptions;
|
3440
|
-
}
|
3441
|
-
if (options.length > limit) {
|
3442
|
-
return options.slice(0, limit);
|
3443
|
-
}
|
3444
|
-
return options;
|
3412
|
+
function selectableValueToVariableValueOption(value) {
|
3413
|
+
var _a;
|
3414
|
+
return {
|
3415
|
+
label: (_a = value.label) != null ? _a : String(value.value),
|
3416
|
+
value: value.value
|
3445
3417
|
};
|
3446
3418
|
}
|
3447
|
-
|
3448
|
-
function handleOptionGroups(values) {
|
3449
|
-
const result = [];
|
3450
|
-
const groupedResults = /* @__PURE__ */ new Map();
|
3451
|
-
for (const value of values) {
|
3452
|
-
const groupLabel = value.group;
|
3453
|
-
if (groupLabel) {
|
3454
|
-
let group = groupedResults.get(groupLabel);
|
3455
|
-
if (!group) {
|
3456
|
-
group = [];
|
3457
|
-
groupedResults.set(groupLabel, group);
|
3458
|
-
result.push({ label: groupLabel, options: group });
|
3459
|
-
}
|
3460
|
-
group.push(value);
|
3461
|
-
} else {
|
3462
|
-
result.push(value);
|
3463
|
-
}
|
3464
|
-
}
|
3465
|
-
return result;
|
3466
|
-
}
|
3467
3419
|
function keyLabelToOption(key, label) {
|
3468
3420
|
return key !== "" ? {
|
3469
3421
|
value: key,
|
@@ -3485,7 +3437,7 @@ function AdHocFilterRenderer({ filter, model }) {
|
|
3485
3437
|
const keyValue = keyLabelToOption(filter.key, filter.keyLabel);
|
3486
3438
|
const valueValue = keyLabelToOption(filter.value, filter.valueLabel);
|
3487
3439
|
const optionSearcher = React.useMemo(
|
3488
|
-
() =>
|
3440
|
+
() => getOptionSearcher(values.map(selectableValueToVariableValueOption), void 0),
|
3489
3441
|
[values]
|
3490
3442
|
);
|
3491
3443
|
const onValueInputChange = (value, { action }) => {
|
@@ -3494,10 +3446,7 @@ function AdHocFilterRenderer({ filter, model }) {
|
|
3494
3446
|
}
|
3495
3447
|
return value;
|
3496
3448
|
};
|
3497
|
-
const filteredValueOptions =
|
3498
|
-
() => handleOptionGroups(optionSearcher(valueInputValue)),
|
3499
|
-
[optionSearcher, valueInputValue]
|
3500
|
-
);
|
3449
|
+
const filteredValueOptions = optionSearcher(valueInputValue);
|
3501
3450
|
const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, {
|
3502
3451
|
virtualized: true,
|
3503
3452
|
allowCustomValue: true,
|
@@ -3874,7 +3823,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
3874
3823
|
var _a, _b, _c;
|
3875
3824
|
const override = await ((_b = (_a = this.state).getTagValuesProvider) == null ? void 0 : _b.call(_a, this, filter));
|
3876
3825
|
if (override && override.replace) {
|
3877
|
-
return dataFromResponse(override.values)
|
3826
|
+
return handleOptionGroups(dataFromResponse(override.values));
|
3878
3827
|
}
|
3879
3828
|
const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);
|
3880
3829
|
if (!ds || !ds.getTagValues) {
|
@@ -3896,7 +3845,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
3896
3845
|
if (override) {
|
3897
3846
|
values = values.concat(dataFromResponse(override.values));
|
3898
3847
|
}
|
3899
|
-
return values
|
3848
|
+
return handleOptionGroups(values);
|
3900
3849
|
}
|
3901
3850
|
_addWip() {
|
3902
3851
|
this.setState({
|
@@ -3943,20 +3892,34 @@ const getStyles$7 = (theme) => ({
|
|
3943
3892
|
paddingRight: theme.spacing(0.5)
|
3944
3893
|
})
|
3945
3894
|
});
|
3946
|
-
function toSelectableValue(
|
3947
|
-
|
3948
|
-
const result = {
|
3895
|
+
function toSelectableValue({ text, value }) {
|
3896
|
+
return {
|
3949
3897
|
label: text,
|
3950
3898
|
value: String(value != null ? value : text)
|
3951
3899
|
};
|
3952
|
-
if ("group" in input) {
|
3953
|
-
result.group = input.group;
|
3954
|
-
}
|
3955
|
-
return result;
|
3956
3900
|
}
|
3957
3901
|
function isFilterComplete(filter) {
|
3958
3902
|
return filter.key !== "" && filter.operator !== "" && filter.value !== "";
|
3959
3903
|
}
|
3904
|
+
function handleOptionGroups(values) {
|
3905
|
+
const result = [];
|
3906
|
+
const groupedResults = /* @__PURE__ */ new Map();
|
3907
|
+
for (const value of values) {
|
3908
|
+
const groupLabel = value.group;
|
3909
|
+
if (groupLabel) {
|
3910
|
+
let group = groupedResults.get(groupLabel);
|
3911
|
+
if (!group) {
|
3912
|
+
group = [];
|
3913
|
+
groupedResults.set(groupLabel, group);
|
3914
|
+
result.push({ label: groupLabel, options: group });
|
3915
|
+
}
|
3916
|
+
group.push(toSelectableValue(value));
|
3917
|
+
} else {
|
3918
|
+
result.push(toSelectableValue(value));
|
3919
|
+
}
|
3920
|
+
}
|
3921
|
+
return result;
|
3922
|
+
}
|
3960
3923
|
|
3961
3924
|
class DataLayersMerger {
|
3962
3925
|
constructor() {
|
@@ -9195,15 +9158,15 @@ class SceneRefreshPicker extends SceneObjectBase {
|
|
9195
9158
|
}
|
9196
9159
|
getUrlState() {
|
9197
9160
|
return {
|
9198
|
-
refresh: this.state.refresh
|
9161
|
+
refresh: this.state.refresh !== "" ? this.state.refresh : void 0
|
9199
9162
|
};
|
9200
9163
|
}
|
9201
9164
|
updateFromUrl(values) {
|
9202
9165
|
const refresh = values.refresh;
|
9203
|
-
if (
|
9204
|
-
this.setState({
|
9205
|
-
|
9206
|
-
});
|
9166
|
+
if (typeof refresh === "string") {
|
9167
|
+
this.setState({ refresh });
|
9168
|
+
} else if (refresh == null) {
|
9169
|
+
this.setState({ refresh: "" });
|
9207
9170
|
}
|
9208
9171
|
}
|
9209
9172
|
}
|
@@ -11514,6 +11477,7 @@ const sceneUtils = {
|
|
11514
11477
|
syncStateFromSearchParams,
|
11515
11478
|
getUrlState,
|
11516
11479
|
renderPrometheusLabelFilters,
|
11480
|
+
safeStringifyValue,
|
11517
11481
|
isAdHocVariable,
|
11518
11482
|
isConstantVariable,
|
11519
11483
|
isCustomVariable,
|