@grafana/scenes 5.13.1--canary.889.10720020573.0 → 5.14.1--canary.889.10722729172.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +12 -0
- package/dist/esm/core/SceneObjectBase.js +8 -0
- package/dist/esm/core/SceneObjectBase.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +47 -22
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +55 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -241,6 +241,7 @@ class SceneObjectBase {
|
|
241
241
|
this._deactivationHandlers = /* @__PURE__ */ new Map();
|
242
242
|
this._subs = new rxjs.Subscription();
|
243
243
|
this._refCount = 0;
|
244
|
+
this._UNSAFE_PARENT_ACTIVATION = false;
|
244
245
|
if (!state.key) {
|
245
246
|
state.key = uuid.v4();
|
246
247
|
}
|
@@ -397,12 +398,19 @@ class SceneObjectBase {
|
|
397
398
|
}
|
398
399
|
}
|
399
400
|
activate() {
|
401
|
+
let parentDeactivate;
|
402
|
+
if (this.parent && !this.parent.isActive && this._UNSAFE_PARENT_ACTIVATION) {
|
403
|
+
parentDeactivate = this.parent.activate();
|
404
|
+
}
|
400
405
|
if (!this.isActive) {
|
401
406
|
this._internalActivate();
|
402
407
|
}
|
403
408
|
this._refCount++;
|
404
409
|
let called = false;
|
405
410
|
return () => {
|
411
|
+
if (parentDeactivate) {
|
412
|
+
parentDeactivate();
|
413
|
+
}
|
406
414
|
this._refCount--;
|
407
415
|
if (called) {
|
408
416
|
const msg = `SceneObject cancelation handler returned by activate() called a second time`;
|
@@ -3954,8 +3962,8 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3954
3962
|
setInputValue("");
|
3955
3963
|
}
|
3956
3964
|
}, [model, isAlwaysWip]);
|
3957
|
-
const
|
3958
|
-
(model2, filter2, filterMultiValues2) => {
|
3965
|
+
const handleMultiValueFilterCommit = React.useCallback(
|
3966
|
+
(model2, filter2, filterMultiValues2, preventFocus) => {
|
3959
3967
|
if (filterMultiValues2.length) {
|
3960
3968
|
const valueLabels = [];
|
3961
3969
|
const values = [];
|
@@ -3967,14 +3975,16 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3967
3975
|
model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
|
3968
3976
|
setFilterMultiValues([]);
|
3969
3977
|
}
|
3970
|
-
|
3971
|
-
|
3972
|
-
|
3973
|
-
|
3978
|
+
if (!preventFocus) {
|
3979
|
+
setTimeout(() => {
|
3980
|
+
var _a2;
|
3981
|
+
return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
3982
|
+
});
|
3983
|
+
}
|
3974
3984
|
},
|
3975
3985
|
[]
|
3976
3986
|
);
|
3977
|
-
const
|
3987
|
+
const handleLocalMultiValueChange = React.useCallback((selectedItem) => {
|
3978
3988
|
setFilterMultiValues((items) => {
|
3979
3989
|
if (items.some((item) => item.value === selectedItem.value)) {
|
3980
3990
|
return items.filter((item) => item.value !== selectedItem.value);
|
@@ -3991,13 +4001,21 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3991
4001
|
setOpen(nextOpen);
|
3992
4002
|
if (reason && ["outside-press", "escape-key"].includes(reason)) {
|
3993
4003
|
if (isMultiValueEdit) {
|
3994
|
-
|
4004
|
+
handleMultiValueFilterCommit(model, filter, filterMultiValues);
|
3995
4005
|
}
|
3996
4006
|
handleResetWip();
|
3997
4007
|
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
3998
4008
|
}
|
3999
4009
|
},
|
4000
|
-
[
|
4010
|
+
[
|
4011
|
+
filter,
|
4012
|
+
filterMultiValues,
|
4013
|
+
handleChangeViewMode,
|
4014
|
+
handleMultiValueFilterCommit,
|
4015
|
+
handleResetWip,
|
4016
|
+
isMultiValueEdit,
|
4017
|
+
model
|
4018
|
+
]
|
4001
4019
|
);
|
4002
4020
|
const outsidePressIdsToIgnore = React.useMemo(() => {
|
4003
4021
|
return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
|
@@ -4084,21 +4102,36 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4084
4102
|
if (event.key === "Tab" && !event.shiftKey) {
|
4085
4103
|
if (multiValueEdit) {
|
4086
4104
|
event.preventDefault();
|
4087
|
-
|
4105
|
+
handleMultiValueFilterCommit(model, filter, filterMultiValues);
|
4088
4106
|
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
4089
4107
|
}
|
4090
4108
|
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
4091
4109
|
handleResetWip();
|
4092
4110
|
}
|
4093
4111
|
},
|
4094
|
-
[
|
4112
|
+
[
|
4113
|
+
filter,
|
4114
|
+
filterMultiValues,
|
4115
|
+
handleChangeViewMode,
|
4116
|
+
handleMultiValueFilterCommit,
|
4117
|
+
handleResetWip,
|
4118
|
+
model,
|
4119
|
+
refs.domReference
|
4120
|
+
]
|
4121
|
+
);
|
4122
|
+
const handleShiftTabInput = React.useCallback(
|
4123
|
+
(event, multiValueEdit) => {
|
4124
|
+
if (event.key === "Tab" && event.shiftKey) {
|
4125
|
+
if (multiValueEdit) {
|
4126
|
+
event.preventDefault();
|
4127
|
+
handleMultiValueFilterCommit(model, filter, filterMultiValues, true);
|
4128
|
+
}
|
4129
|
+
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
4130
|
+
handleResetWip();
|
4131
|
+
}
|
4132
|
+
},
|
4133
|
+
[filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, model]
|
4095
4134
|
);
|
4096
|
-
const handleShiftTabInput = React.useCallback((event) => {
|
4097
|
-
if (event.key === "Tab" && event.shiftKey) {
|
4098
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
4099
|
-
handleResetWip();
|
4100
|
-
}
|
4101
|
-
}, []);
|
4102
4135
|
const handleEnterInput = React.useCallback(
|
4103
4136
|
(event, multiValueEdit) => {
|
4104
4137
|
if (event.key === "Enter" && activeIndex != null) {
|
@@ -4107,7 +4140,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4107
4140
|
}
|
4108
4141
|
const selectedItem = filteredDropDownItems[activeIndex];
|
4109
4142
|
if (multiValueEdit) {
|
4110
|
-
|
4143
|
+
handleLocalMultiValueChange(selectedItem);
|
4111
4144
|
} else {
|
4112
4145
|
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, selectedItem));
|
4113
4146
|
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
|
@@ -4121,7 +4154,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4121
4154
|
filter,
|
4122
4155
|
filterInputType,
|
4123
4156
|
filteredDropDownItems,
|
4124
|
-
|
4157
|
+
handleLocalMultiValueChange,
|
4125
4158
|
handleChangeViewMode,
|
4126
4159
|
model,
|
4127
4160
|
refs.domReference
|
@@ -4186,7 +4219,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4186
4219
|
switchInputType("operator", setInputType, void 0, refs.domReference.current);
|
4187
4220
|
},
|
4188
4221
|
onKeyDown: (event) => {
|
4189
|
-
handleShiftTabInput(event);
|
4222
|
+
handleShiftTabInput(event, hasMultiValueOperator);
|
4190
4223
|
if (event.key === "Enter") {
|
4191
4224
|
switchInputType("operator", setInputType, void 0, refs.domReference.current);
|
4192
4225
|
}
|
@@ -4279,7 +4312,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4279
4312
|
}
|
4280
4313
|
if (isMultiValueEdit) {
|
4281
4314
|
event.stopPropagation();
|
4282
|
-
|
4315
|
+
handleLocalMultiValueChange(item);
|
4283
4316
|
(_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
|
4284
4317
|
} else {
|
4285
4318
|
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
|
@@ -4307,7 +4340,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4307
4340
|
className: styles.descriptionText
|
4308
4341
|
}, item.description) : null);
|
4309
4342
|
}))), isMultiValueEdit && !optionsLoading && !optionsError && filteredDropDownItems.length ? /* @__PURE__ */ React__default["default"].createElement(MultiValueApplyButton, {
|
4310
|
-
onClick: () =>
|
4343
|
+
onClick: () => handleMultiValueFilterCommit(model, filter, filterMultiValues),
|
4311
4344
|
floatingElement: refs.floating.current,
|
4312
4345
|
maxOptionWidth
|
4313
4346
|
}) : null))));
|