@grafana/scenes 8.1.3 → 8.2.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 +8 -2
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +33 -13
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/useFreeFormExpression.js +4 -5
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/useFreeFormExpression.js.map +1 -1
- package/dist/index.js +36 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6678,10 +6678,7 @@ function useFreeFormExpression({
|
|
|
6678
6678
|
isGroupBy,
|
|
6679
6679
|
populateInputOnEdit
|
|
6680
6680
|
}) {
|
|
6681
|
-
const operatorValues =
|
|
6682
|
-
() => controller.getOperators().map((o) => o.value).filter((v) => Boolean(v)),
|
|
6683
|
-
[controller]
|
|
6684
|
-
);
|
|
6681
|
+
const operatorValues = controller.getOperators().map((o) => o.value).filter((v) => Boolean(v));
|
|
6685
6682
|
const expressionInputEnabled = allowCustomValue && !isGroupBy && filterInputType !== "value" && !populateInputOnEdit;
|
|
6686
6683
|
const parseExpression = React.useCallback(
|
|
6687
6684
|
(input) => {
|
|
@@ -6701,6 +6698,7 @@ function useFreeFormExpression({
|
|
|
6701
6698
|
);
|
|
6702
6699
|
const parsedExpression = React.useMemo(() => parseExpression(inputValue), [parseExpression, inputValue]);
|
|
6703
6700
|
const canCommitExpressionUpdate = parsedExpression !== null;
|
|
6701
|
+
const canCommitFullExpression = Boolean(parsedExpression == null ? void 0 : parsedExpression.value);
|
|
6704
6702
|
const commitExpressionUpdate = React.useCallback(() => {
|
|
6705
6703
|
var _a;
|
|
6706
6704
|
if (!parsedExpression || !filter) {
|
|
@@ -6732,6 +6730,7 @@ function useFreeFormExpression({
|
|
|
6732
6730
|
return {
|
|
6733
6731
|
parseExpression,
|
|
6734
6732
|
canCommitExpressionUpdate,
|
|
6733
|
+
canCommitFullExpression,
|
|
6735
6734
|
commitExpressionUpdate
|
|
6736
6735
|
};
|
|
6737
6736
|
}
|
|
@@ -6874,7 +6873,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
6874
6873
|
const disabledIndicesRef = React.useRef([]);
|
|
6875
6874
|
const filterInputTypeRef = React.useRef(initialInputType);
|
|
6876
6875
|
const optionsSearcher = React.useMemo(() => getAdhocOptionSearcher(options), [options]);
|
|
6877
|
-
const { canCommitExpressionUpdate, parseExpression, commitExpressionUpdate } = useFreeFormExpression({
|
|
6876
|
+
const { canCommitExpressionUpdate, canCommitFullExpression, parseExpression, commitExpressionUpdate } = useFreeFormExpression({
|
|
6878
6877
|
controller,
|
|
6879
6878
|
filter,
|
|
6880
6879
|
inputValue,
|
|
@@ -7154,6 +7153,25 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7154
7153
|
handleResetWip
|
|
7155
7154
|
]
|
|
7156
7155
|
);
|
|
7156
|
+
const commitFullParsedExpression = React.useCallback(
|
|
7157
|
+
(parsed) => {
|
|
7158
|
+
var _a2;
|
|
7159
|
+
if (!filter || !parsed.value) {
|
|
7160
|
+
return false;
|
|
7161
|
+
}
|
|
7162
|
+
(_a2 = controller.startProfile) == null ? void 0 : _a2.call(controller, FILTER_CHANGED_INTERACTION);
|
|
7163
|
+
const isMultiValueCommit = Boolean(parsed.operator && isMultiValueOperator(parsed.operator));
|
|
7164
|
+
if (!isMultiValueCommit && onAddCustomValue) {
|
|
7165
|
+
const custom = onAddCustomValue({ label: parsed.value, value: parsed.value, isCustom: true }, filter);
|
|
7166
|
+
parsed.value = custom.value;
|
|
7167
|
+
parsed.valueLabels = custom.valueLabels;
|
|
7168
|
+
}
|
|
7169
|
+
controller.updateFilter(filter, parsed);
|
|
7170
|
+
setActiveIndex(null);
|
|
7171
|
+
return isMultiValueCommit;
|
|
7172
|
+
},
|
|
7173
|
+
[controller, filter, onAddCustomValue]
|
|
7174
|
+
);
|
|
7157
7175
|
const handleTabInput = React.useCallback(
|
|
7158
7176
|
(event, multiValueEdit) => {
|
|
7159
7177
|
var _a2;
|
|
@@ -7162,6 +7180,11 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7162
7180
|
event.preventDefault();
|
|
7163
7181
|
handleMultiValueFilterCommit(controller, filter, filterMultiValues);
|
|
7164
7182
|
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
|
7183
|
+
} else if (canCommitFullExpression && filter) {
|
|
7184
|
+
const parsed = commitExpressionUpdate();
|
|
7185
|
+
if (parsed == null ? void 0 : parsed.value) {
|
|
7186
|
+
commitFullParsedExpression(parsed);
|
|
7187
|
+
}
|
|
7165
7188
|
}
|
|
7166
7189
|
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
|
7167
7190
|
handleResetWip();
|
|
@@ -7173,6 +7196,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7173
7196
|
handleChangeViewMode,
|
|
7174
7197
|
handleMultiValueFilterCommit,
|
|
7175
7198
|
handleResetWip,
|
|
7199
|
+
canCommitFullExpression,
|
|
7200
|
+
commitExpressionUpdate,
|
|
7201
|
+
commitFullParsedExpression,
|
|
7176
7202
|
controller,
|
|
7177
7203
|
refs.domReference
|
|
7178
7204
|
]
|
|
@@ -7192,7 +7218,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7192
7218
|
);
|
|
7193
7219
|
const handleEnterInput = React.useCallback(
|
|
7194
7220
|
(event, multiValueEdit) => {
|
|
7195
|
-
var _a2, _b2
|
|
7221
|
+
var _a2, _b2;
|
|
7196
7222
|
if (event.key === "Enter" && canCommitExpressionUpdate && filter) {
|
|
7197
7223
|
const parsed = commitExpressionUpdate();
|
|
7198
7224
|
if (parsed) {
|
|
@@ -7204,14 +7230,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7204
7230
|
setActiveIndex(null);
|
|
7205
7231
|
return;
|
|
7206
7232
|
}
|
|
7207
|
-
|
|
7208
|
-
const isMultiValueCommit = Boolean(parsed.operator && isMultiValueOperator(parsed.operator));
|
|
7209
|
-
if (!isMultiValueCommit && onAddCustomValue) {
|
|
7210
|
-
const custom = onAddCustomValue({ label: parsed.value, value: parsed.value, isCustom: true }, filter);
|
|
7211
|
-
parsed.value = custom.value;
|
|
7212
|
-
parsed.valueLabels = custom.valueLabels;
|
|
7213
|
-
}
|
|
7214
|
-
controller.updateFilter(filter, parsed);
|
|
7233
|
+
const isMultiValueCommit = commitFullParsedExpression(parsed);
|
|
7215
7234
|
if (isAlwaysWip) {
|
|
7216
7235
|
handleResetWip();
|
|
7217
7236
|
setTimeout(() => {
|
|
@@ -7225,7 +7244,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7225
7244
|
if (isMultiValueCommit) {
|
|
7226
7245
|
setOpen(false);
|
|
7227
7246
|
}
|
|
7228
|
-
setActiveIndex(null);
|
|
7229
7247
|
return;
|
|
7230
7248
|
}
|
|
7231
7249
|
}
|
|
@@ -7236,7 +7254,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7236
7254
|
const selectedItem = filteredDropDownItems[activeIndex];
|
|
7237
7255
|
if (isGroupBy) {
|
|
7238
7256
|
if (isAlwaysWip) {
|
|
7239
|
-
(
|
|
7257
|
+
(_a2 = controller.addGroupByFilter) == null ? void 0 : _a2.call(controller, selectedItem);
|
|
7240
7258
|
handleResetWip();
|
|
7241
7259
|
} else {
|
|
7242
7260
|
controller.updateFilter(filter, {
|
|
@@ -7260,7 +7278,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7260
7278
|
onAddCustomValue
|
|
7261
7279
|
});
|
|
7262
7280
|
if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
|
|
7263
|
-
(
|
|
7281
|
+
(_b2 = controller.startProfile) == null ? void 0 : _b2.call(controller, FILTER_CHANGED_INTERACTION);
|
|
7264
7282
|
}
|
|
7265
7283
|
controller.updateFilter(filter, payload);
|
|
7266
7284
|
populateInputValueOnInputTypeSwitch({
|
|
@@ -7294,6 +7312,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
|
|
|
7294
7312
|
filterInputType,
|
|
7295
7313
|
canCommitExpressionUpdate,
|
|
7296
7314
|
commitExpressionUpdate,
|
|
7315
|
+
commitFullParsedExpression,
|
|
7297
7316
|
populateInputOnEdit,
|
|
7298
7317
|
handleChangeViewMode,
|
|
7299
7318
|
refs.domReference,
|