@grafana/scenes 4.27.0--canary.776.9400928706.0 → 4.28.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +29 -0
- package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +39 -3
- package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
- package/dist/esm/variables/components/VariableValueControl.js.map +1 -1
- package/dist/esm/variables/components/VariableValueSelect.js +15 -7
- package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
- package/dist/esm/variables/components/VariableValueSelectors.js +7 -5
- package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
- package/dist/esm/variables/components/getOptionSearcher.js +1 -7
- package/dist/esm/variables/components/getOptionSearcher.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +2 -2
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +66 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -2765,7 +2765,7 @@ class CustomAllValue {
|
|
2765
2765
|
}
|
2766
2766
|
}
|
2767
2767
|
|
2768
|
-
function getOptionSearcher(options, includeAll
|
2768
|
+
function getOptionSearcher(options, includeAll) {
|
2769
2769
|
const ufuzzy = new uFuzzy__default["default"]();
|
2770
2770
|
let allOptions = options;
|
2771
2771
|
const haystack = [];
|
@@ -2773,12 +2773,6 @@ function getOptionSearcher(options, includeAll, value, text) {
|
|
2773
2773
|
if (includeAll) {
|
2774
2774
|
allOptions = [{ value: ALL_VARIABLE_VALUE, label: ALL_VARIABLE_TEXT }, ...allOptions];
|
2775
2775
|
}
|
2776
|
-
if (!Array.isArray(value)) {
|
2777
|
-
const current = options.find((x) => x.value === value);
|
2778
|
-
if (!current) {
|
2779
|
-
allOptions = [{ value, label: String(text) }, ...allOptions];
|
2780
|
-
}
|
2781
|
-
}
|
2782
2776
|
return (search) => {
|
2783
2777
|
if (search === "") {
|
2784
2778
|
if (allOptions.length > limit) {
|
@@ -2841,14 +2835,21 @@ var __objRest$3 = (source, exclude) => {
|
|
2841
2835
|
}
|
2842
2836
|
return target;
|
2843
2837
|
};
|
2844
|
-
const filterNoOp$
|
2838
|
+
const filterNoOp$2 = () => true;
|
2839
|
+
function toSelectableValue$1(value, label) {
|
2840
|
+
return {
|
2841
|
+
value,
|
2842
|
+
label: label != null ? label : String(value)
|
2843
|
+
};
|
2844
|
+
}
|
2845
2845
|
function VariableValueSelect({ model }) {
|
2846
2846
|
const { value, text, key, options, includeAll } = model.useState();
|
2847
2847
|
const [inputValue, setInputValue] = React.useState("");
|
2848
2848
|
const [hasCustomValue, setHasCustomValue] = React.useState(false);
|
2849
|
+
const selectValue = toSelectableValue$1(value, String(text));
|
2849
2850
|
const optionSearcher = React.useMemo(
|
2850
|
-
() => getOptionSearcher(options, includeAll
|
2851
|
-
[options, includeAll
|
2851
|
+
() => getOptionSearcher(options, includeAll),
|
2852
|
+
[options, includeAll]
|
2852
2853
|
);
|
2853
2854
|
const onInputChange = (value2, { action }) => {
|
2854
2855
|
if (action === "input-change") {
|
@@ -2871,13 +2872,14 @@ function VariableValueSelect({ model }) {
|
|
2871
2872
|
};
|
2872
2873
|
return /* @__PURE__ */ React__default["default"].createElement(ui.Select, {
|
2873
2874
|
id: key,
|
2875
|
+
isValidNewOption: (inputValue2) => inputValue2.trim().length > 0,
|
2874
2876
|
placeholder: "Select value",
|
2875
2877
|
width: "auto",
|
2876
|
-
value,
|
2878
|
+
value: selectValue,
|
2877
2879
|
inputValue,
|
2878
2880
|
allowCustomValue: true,
|
2879
2881
|
virtualized: true,
|
2880
|
-
filterOption: filterNoOp$
|
2882
|
+
filterOption: filterNoOp$2,
|
2881
2883
|
tabSelectsValue: false,
|
2882
2884
|
onInputChange,
|
2883
2885
|
onOpenMenu,
|
@@ -2893,13 +2895,13 @@ function VariableValueSelect({ model }) {
|
|
2893
2895
|
});
|
2894
2896
|
}
|
2895
2897
|
function VariableValueSelectMulti({ model }) {
|
2896
|
-
const { value,
|
2898
|
+
const { value, options, key, maxVisibleValues, noValueOnClear, includeAll } = model.useState();
|
2897
2899
|
const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
|
2898
2900
|
const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
|
2899
2901
|
const [inputValue, setInputValue] = React.useState("");
|
2900
2902
|
const optionSearcher = React.useMemo(
|
2901
|
-
() => getOptionSearcher(options, includeAll
|
2902
|
-
[options, includeAll
|
2903
|
+
() => getOptionSearcher(options, includeAll),
|
2904
|
+
[options, includeAll]
|
2903
2905
|
);
|
2904
2906
|
React.useEffect(() => {
|
2905
2907
|
setUncommittedValue(arrayValue);
|
@@ -2940,7 +2942,7 @@ function VariableValueSelectMulti({ model }) {
|
|
2940
2942
|
onBlur: () => {
|
2941
2943
|
model.changeValueTo(uncommittedValue);
|
2942
2944
|
},
|
2943
|
-
filterOption: filterNoOp$
|
2945
|
+
filterOption: filterNoOp$2,
|
2944
2946
|
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
|
2945
2947
|
onChange: (newValue, action) => {
|
2946
2948
|
if (action.action === "clear" && noValueOnClear) {
|
@@ -3197,8 +3199,8 @@ function GroupByVariableRenderer({ model }) {
|
|
3197
3199
|
const [inputValue, setInputValue] = React.useState("");
|
3198
3200
|
const [uncommittedValue, setUncommittedValue] = React.useState(values);
|
3199
3201
|
const optionSearcher = React.useMemo(
|
3200
|
-
() => getOptionSearcher(options, includeAll
|
3201
|
-
[options, includeAll
|
3202
|
+
() => getOptionSearcher(options, includeAll),
|
3203
|
+
[options, includeAll]
|
3202
3204
|
);
|
3203
3205
|
React.useEffect(() => {
|
3204
3206
|
setUncommittedValue(values);
|
@@ -3230,7 +3232,7 @@ function GroupByVariableRenderer({ model }) {
|
|
3230
3232
|
tabSelectsValue: false,
|
3231
3233
|
virtualized: true,
|
3232
3234
|
options: filteredOptions,
|
3233
|
-
filterOption: filterNoOp,
|
3235
|
+
filterOption: filterNoOp$1,
|
3234
3236
|
closeMenuOnSelect: false,
|
3235
3237
|
isOpen: isOptionsOpen,
|
3236
3238
|
isClearable: true,
|
@@ -3261,7 +3263,7 @@ function GroupByVariableRenderer({ model }) {
|
|
3261
3263
|
}
|
3262
3264
|
});
|
3263
3265
|
}
|
3264
|
-
const filterNoOp = () => true;
|
3266
|
+
const filterNoOp$1 = () => true;
|
3265
3267
|
|
3266
3268
|
function LoadingIndicator(props) {
|
3267
3269
|
return /* @__PURE__ */ React__default["default"].createElement(ui.Tooltip, {
|
@@ -3376,12 +3378,20 @@ const getStyles$9 = (theme) => ({
|
|
3376
3378
|
})
|
3377
3379
|
});
|
3378
3380
|
|
3381
|
+
function selectableValueToVariableValueOption(value) {
|
3382
|
+
var _a;
|
3383
|
+
return {
|
3384
|
+
label: (_a = value.label) != null ? _a : String(value.value),
|
3385
|
+
value: value.value
|
3386
|
+
};
|
3387
|
+
}
|
3379
3388
|
function keyLabelToOption(key, label) {
|
3380
3389
|
return key !== "" ? {
|
3381
3390
|
value: key,
|
3382
3391
|
label: label || key
|
3383
3392
|
} : null;
|
3384
3393
|
}
|
3394
|
+
const filterNoOp = () => true;
|
3385
3395
|
function AdHocFilterRenderer({ filter, model }) {
|
3386
3396
|
var _a, _b;
|
3387
3397
|
const styles = ui.useStyles2(getStyles$8);
|
@@ -3391,9 +3401,23 @@ function AdHocFilterRenderer({ filter, model }) {
|
|
3391
3401
|
const [isValuesLoading, setIsValuesLoading] = React.useState(false);
|
3392
3402
|
const [isKeysOpen, setIsKeysOpen] = React.useState(false);
|
3393
3403
|
const [isValuesOpen, setIsValuesOpen] = React.useState(false);
|
3404
|
+
const [valueInputValue, setValueInputValue] = React.useState("");
|
3405
|
+
const [valueHasCustomValue, setValueHasCustomValue] = React.useState(false);
|
3394
3406
|
const keyValue = keyLabelToOption(filter.key, filter.keyLabel);
|
3395
3407
|
const valueValue = keyLabelToOption(filter.value, filter.valueLabel);
|
3408
|
+
const optionSearcher = React.useMemo(
|
3409
|
+
() => getOptionSearcher(values.map(selectableValueToVariableValueOption), void 0),
|
3410
|
+
[values]
|
3411
|
+
);
|
3412
|
+
const onValueInputChange = (value, { action }) => {
|
3413
|
+
if (action === "input-change") {
|
3414
|
+
setValueInputValue(value);
|
3415
|
+
}
|
3416
|
+
return value;
|
3417
|
+
};
|
3418
|
+
const filteredValueOptions = optionSearcher(valueInputValue);
|
3396
3419
|
const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, {
|
3420
|
+
virtualized: true,
|
3397
3421
|
allowCustomValue: true,
|
3398
3422
|
isValidNewOption: (inputValue) => inputValue.trim().length > 0,
|
3399
3423
|
allowCreateWhileLoading: true,
|
@@ -3402,22 +3426,35 @@ function AdHocFilterRenderer({ filter, model }) {
|
|
3402
3426
|
className: css.cx(styles.value, isKeysOpen ? styles.widthWhenOpen : void 0),
|
3403
3427
|
width: "auto",
|
3404
3428
|
value: valueValue,
|
3429
|
+
filterOption: filterNoOp,
|
3405
3430
|
placeholder: "Select value",
|
3406
|
-
options:
|
3407
|
-
|
3431
|
+
options: filteredValueOptions,
|
3432
|
+
inputValue: valueInputValue,
|
3433
|
+
onInputChange: onValueInputChange,
|
3434
|
+
onChange: (v) => {
|
3435
|
+
model._updateFilter(filter, "value", v);
|
3436
|
+
if (valueHasCustomValue !== v.__isNew__) {
|
3437
|
+
setValueHasCustomValue(v.__isNew__);
|
3438
|
+
}
|
3439
|
+
},
|
3408
3440
|
isOpen: isValuesOpen && !isValuesLoading,
|
3409
3441
|
isLoading: isValuesLoading,
|
3410
3442
|
autoFocus: filter.key !== "" && filter.value === "",
|
3411
3443
|
openMenuOnFocus: true,
|
3412
3444
|
onOpenMenu: async () => {
|
3445
|
+
var _a2;
|
3413
3446
|
setIsValuesLoading(true);
|
3414
3447
|
setIsValuesOpen(true);
|
3415
3448
|
const values2 = await model._getValuesFor(filter);
|
3416
3449
|
setIsValuesLoading(false);
|
3417
3450
|
setValues(values2);
|
3451
|
+
if (valueHasCustomValue) {
|
3452
|
+
setValueInputValue((_a2 = valueValue == null ? void 0 : valueValue.label) != null ? _a2 : "");
|
3453
|
+
}
|
3418
3454
|
},
|
3419
3455
|
onCloseMenu: () => {
|
3420
3456
|
setIsValuesOpen(false);
|
3457
|
+
setValueInputValue("");
|
3421
3458
|
}
|
3422
3459
|
});
|
3423
3460
|
const keySelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, {
|
@@ -6378,7 +6415,7 @@ function VariableValueSelectorsRenderer({ model }) {
|
|
6378
6415
|
layout: model.state.layout
|
6379
6416
|
})));
|
6380
6417
|
}
|
6381
|
-
function VariableValueSelectWrapper({ variable, layout, showAlways }) {
|
6418
|
+
function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel }) {
|
6382
6419
|
const state = useSceneObjectState(variable, { shouldActivateOrKeepAlive: true });
|
6383
6420
|
if (state.hide === data.VariableHide.hideVariable && !showAlways) {
|
6384
6421
|
return null;
|
@@ -6389,7 +6426,8 @@ function VariableValueSelectWrapper({ variable, layout, showAlways }) {
|
|
6389
6426
|
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItem
|
6390
6427
|
}, /* @__PURE__ */ React__default["default"].createElement(VariableLabel, {
|
6391
6428
|
variable,
|
6392
|
-
layout
|
6429
|
+
layout,
|
6430
|
+
hideLabel
|
6393
6431
|
}), /* @__PURE__ */ React__default["default"].createElement(variable.Component, {
|
6394
6432
|
model: variable
|
6395
6433
|
}));
|
@@ -6398,15 +6436,16 @@ function VariableValueSelectWrapper({ variable, layout, showAlways }) {
|
|
6398
6436
|
className: containerStyle,
|
6399
6437
|
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItem
|
6400
6438
|
}, /* @__PURE__ */ React__default["default"].createElement(VariableLabel, {
|
6401
|
-
variable
|
6439
|
+
variable,
|
6440
|
+
hideLabel
|
6402
6441
|
}), /* @__PURE__ */ React__default["default"].createElement(variable.Component, {
|
6403
6442
|
model: variable
|
6404
6443
|
}));
|
6405
6444
|
}
|
6406
|
-
function VariableLabel({ variable, layout }) {
|
6445
|
+
function VariableLabel({ variable, layout, hideLabel }) {
|
6407
6446
|
var _a, _b;
|
6408
6447
|
const { state } = variable;
|
6409
|
-
if (variable.state.hide === data.VariableHide.hideLabel) {
|
6448
|
+
if (variable.state.hide === data.VariableHide.hideLabel || hideLabel) {
|
6410
6449
|
return null;
|
6411
6450
|
}
|
6412
6451
|
const elementId = `var-${state.key}`;
|