@grafana/scenes 5.14.1--canary.889.10722729172.0 → 5.14.1
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/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +2 -7
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +54 -245
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js +4 -40
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/useFloatingInteractions.js +2 -8
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/useFloatingInteractions.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +2 -6
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +2 -2
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/components/VariableValueInput.js +1 -1
- package/dist/esm/variables/components/VariableValueInput.js.map +1 -1
- package/dist/esm/variables/variants/TextBoxVariable.js +1 -3
- package/dist/esm/variables/variants/TextBoxVariable.js.map +1 -1
- package/dist/index.js +60 -303
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
@@ -45,12 +45,10 @@ class TextBoxVariable extends SceneObjectBase {
|
|
45
45
|
return { [this.getKey()]: this.state.value };
|
46
46
|
}
|
47
47
|
updateFromUrl(values) {
|
48
|
-
const update = {};
|
49
48
|
const val = values[this.getKey()];
|
50
49
|
if (typeof val === "string") {
|
51
|
-
|
50
|
+
this.setValue(val);
|
52
51
|
}
|
53
|
-
this.setState(update);
|
54
52
|
}
|
55
53
|
}
|
56
54
|
TextBoxVariable.Component = ({ model }) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextBoxVariable.js","sources":["../../../../src/variables/variants/TextBoxVariable.tsx"],"sourcesContent":["import React from 'react';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObjectUrlValues } from '../../core/types';\nimport { SceneObjectUrlSyncConfig } from '../../services/SceneObjectUrlSyncConfig';\nimport { VariableValueInput } from '../components/VariableValueInput';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\n\nexport interface TextBoxVariableState extends SceneVariableState {\n value: string;\n}\n\nexport class TextBoxVariable\n extends SceneObjectBase<TextBoxVariableState>\n implements SceneVariable<TextBoxVariableState>\n{\n public constructor(initialState: Partial<TextBoxVariableState>) {\n super({\n type: 'textbox',\n value: '',\n name: '',\n ...initialState,\n });\n\n this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () => [this.getKey()] });\n }\n\n public getValue(): VariableValue {\n return this.state.value;\n }\n\n public setValue(newValue: string) {\n if (newValue !== this.state.value) {\n this.setState({ value: newValue });\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n private getKey(): string {\n return `var-${this.state.name}`;\n }\n\n public getUrlState() {\n return { [this.getKey()]: this.state.value };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const
|
1
|
+
{"version":3,"file":"TextBoxVariable.js","sources":["../../../../src/variables/variants/TextBoxVariable.tsx"],"sourcesContent":["import React from 'react';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObjectUrlValues } from '../../core/types';\nimport { SceneObjectUrlSyncConfig } from '../../services/SceneObjectUrlSyncConfig';\nimport { VariableValueInput } from '../components/VariableValueInput';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\n\nexport interface TextBoxVariableState extends SceneVariableState {\n value: string;\n}\n\nexport class TextBoxVariable\n extends SceneObjectBase<TextBoxVariableState>\n implements SceneVariable<TextBoxVariableState>\n{\n public constructor(initialState: Partial<TextBoxVariableState>) {\n super({\n type: 'textbox',\n value: '',\n name: '',\n ...initialState,\n });\n\n this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () => [this.getKey()] });\n }\n\n public getValue(): VariableValue {\n return this.state.value;\n }\n\n public setValue(newValue: string) {\n if (newValue !== this.state.value) {\n this.setState({ value: newValue });\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n private getKey(): string {\n return `var-${this.state.name}`;\n }\n\n public getUrlState() {\n return { [this.getKey()]: this.state.value };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const val = values[this.getKey()];\n\n if (typeof val === 'string') {\n this.setValue(val);\n }\n }\n\n public static Component = ({ model }: SceneComponentProps<TextBoxVariable>) => {\n return <VariableValueInput model={model} />;\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,wBACH,eAEV,CAAA;AAAA,EACS,YAAY,YAA6C,EAAA;AAC9D,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,SAAA;AAAA,MACN,KAAO,EAAA,EAAA;AAAA,MACP,IAAM,EAAA,EAAA;AAAA,KAAA,EACH,YACJ,CAAA,CAAA,CAAA;AAED,IAAA,IAAA,CAAK,QAAW,GAAA,IAAI,wBAAyB,CAAA,IAAA,EAAM,EAAE,IAAA,EAAM,MAAM,CAAC,IAAK,CAAA,MAAA,EAAQ,CAAA,EAAG,CAAA,CAAA;AAAA,GACpF;AAAA,EAEO,QAA0B,GAAA;AAC/B,IAAA,OAAO,KAAK,KAAM,CAAA,KAAA,CAAA;AAAA,GACpB;AAAA,EAEO,SAAS,QAAkB,EAAA;AAChC,IAAI,IAAA,QAAA,KAAa,IAAK,CAAA,KAAA,CAAM,KAAO,EAAA;AACjC,MAAA,IAAA,CAAK,QAAS,CAAA,EAAE,KAAO,EAAA,QAAA,EAAU,CAAA,CAAA;AACjC,MAAA,IAAA,CAAK,YAAa,CAAA,IAAI,8BAA+B,CAAA,IAAI,GAAG,IAAI,CAAA,CAAA;AAAA,KAClE;AAAA,GACF;AAAA,EAEQ,MAAiB,GAAA;AACvB,IAAO,OAAA,CAAA,IAAA,EAAO,KAAK,KAAM,CAAA,IAAA,CAAA,CAAA,CAAA;AAAA,GAC3B;AAAA,EAEO,WAAc,GAAA;AACnB,IAAA,OAAO,EAAE,CAAC,IAAA,CAAK,QAAW,GAAA,IAAA,CAAK,MAAM,KAAM,EAAA,CAAA;AAAA,GAC7C;AAAA,EAEO,cAAc,MAA8B,EAAA;AACjD,IAAM,MAAA,GAAA,GAAM,MAAO,CAAA,IAAA,CAAK,MAAO,EAAA,CAAA,CAAA;AAE/B,IAAI,IAAA,OAAO,QAAQ,QAAU,EAAA;AAC3B,MAAA,IAAA,CAAK,SAAS,GAAG,CAAA,CAAA;AAAA,KACnB;AAAA,GACF;AAKF,CAAA;AA7Ca,eAAA,CA0CG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAkD,KAAA;AAC7E,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,kBAAA,EAAA;AAAA,IAAmB,KAAA;AAAA,GAAc,CAAA,CAAA;AAC3C,CAAA;;;;"}
|
package/dist/index.js
CHANGED
@@ -3636,7 +3636,7 @@ var __objRest$3 = (source, exclude) => {
|
|
3636
3636
|
};
|
3637
3637
|
const DropdownItem = React.forwardRef(
|
3638
3638
|
function DropdownItem2(_a, ref) {
|
3639
|
-
var _b = _a, { children, active, addGroupBottomBorder
|
3639
|
+
var _b = _a, { children, active, addGroupBottomBorder } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder"]);
|
3640
3640
|
const styles = ui.useStyles2(getStyles$c);
|
3641
3641
|
const id = React.useId();
|
3642
3642
|
return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
|
@@ -3648,11 +3648,7 @@ const DropdownItem = React.forwardRef(
|
|
3648
3648
|
}, rest), /* @__PURE__ */ React__default["default"].createElement("div", {
|
3649
3649
|
className: styles.optionBody,
|
3650
3650
|
"data-testid": `data-testid ad hoc filter option value ${children}`
|
3651
|
-
}, /* @__PURE__ */ React__default["default"].createElement("span", null,
|
3652
|
-
tabIndex: -1,
|
3653
|
-
checked,
|
3654
|
-
className: styles.checkbox
|
3655
|
-
}) : null, children)));
|
3651
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", null, children)));
|
3656
3652
|
}
|
3657
3653
|
);
|
3658
3654
|
const getStyles$c = (theme) => ({
|
@@ -3692,22 +3688,6 @@ const getStyles$c = (theme) => ({
|
|
3692
3688
|
}),
|
3693
3689
|
groupBottomBorder: css.css({
|
3694
3690
|
borderBottom: `1px solid ${theme.colors.border.weak}`
|
3695
|
-
}),
|
3696
|
-
checkbox: css.css({
|
3697
|
-
paddingRight: theme.spacing(0.5)
|
3698
|
-
}),
|
3699
|
-
multiValueApply: css.css({
|
3700
|
-
position: "absolute",
|
3701
|
-
top: 0,
|
3702
|
-
left: 0,
|
3703
|
-
display: "flex"
|
3704
|
-
}),
|
3705
|
-
dropdownWrapper: css.css({
|
3706
|
-
backgroundColor: theme.colors.background.primary,
|
3707
|
-
color: theme.colors.text.primary,
|
3708
|
-
boxShadow: theme.shadows.z2,
|
3709
|
-
overflowY: "auto",
|
3710
|
-
zIndex: theme.zIndex.dropdown
|
3711
3691
|
})
|
3712
3692
|
});
|
3713
3693
|
const LoadingOptionsPlaceholder = () => {
|
@@ -3725,28 +3705,11 @@ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
|
|
3725
3705
|
onClick: handleFetchOptions
|
3726
3706
|
}, "An error has occurred fetching labels. Click to retry");
|
3727
3707
|
};
|
3728
|
-
const MultiValueApplyButton = ({ onClick, floatingElement, maxOptionWidth }) => {
|
3729
|
-
const styles = ui.useStyles2(getStyles$c);
|
3730
|
-
const floatingElementRect = floatingElement == null ? void 0 : floatingElement.getBoundingClientRect();
|
3731
|
-
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
3732
|
-
className: css.cx(styles.dropdownWrapper, styles.multiValueApply),
|
3733
|
-
style: {
|
3734
|
-
width: `${maxOptionWidth}px`,
|
3735
|
-
transform: `translate(${floatingElementRect == null ? void 0 : floatingElementRect.left}px,${floatingElementRect == null ? void 0 : floatingElementRect.bottom}px)`
|
3736
|
-
}
|
3737
|
-
}, /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
|
3738
|
-
onClick,
|
3739
|
-
fill: "text",
|
3740
|
-
fullWidth: true,
|
3741
|
-
tabIndex: -1
|
3742
|
-
}, "Apply"));
|
3743
|
-
};
|
3744
3708
|
|
3745
3709
|
const VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 8;
|
3746
3710
|
const VIRTUAL_LIST_PADDING = 8;
|
3747
3711
|
const VIRTUAL_LIST_OVERSCAN = 5;
|
3748
3712
|
const VIRTUAL_LIST_ITEM_HEIGHT = 38;
|
3749
|
-
const VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;
|
3750
3713
|
const ERROR_STATE_DROPDOWN_WIDTH = 366;
|
3751
3714
|
function fuzzySearchOptions(options) {
|
3752
3715
|
const ufuzzy = new uFuzzy__default["default"]();
|
@@ -3797,7 +3760,7 @@ function fuzzySearchOptions(options) {
|
|
3797
3760
|
}
|
3798
3761
|
const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
|
3799
3762
|
const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
|
3800
|
-
var _a, _b, _c
|
3763
|
+
var _a, _b, _c;
|
3801
3764
|
let maxOptionWidth = 182;
|
3802
3765
|
const listRefArr = [];
|
3803
3766
|
const disabledIndices = [];
|
@@ -3807,9 +3770,6 @@ const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
|
|
3807
3770
|
disabledIndices.push(i);
|
3808
3771
|
}
|
3809
3772
|
let label = (_c = (_b = options[i].label) != null ? _b : options[i].value) != null ? _c : "";
|
3810
|
-
if (label.length < (((_d = options[i].description) == null ? void 0 : _d.length) || 0)) {
|
3811
|
-
label = options[i].description;
|
3812
|
-
}
|
3813
3773
|
const widthEstimate = (options[i].isCustom ? label.length + 18 : label.length) * VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER + VIRTUAL_LIST_PADDING * 2;
|
3814
3774
|
if (widthEstimate > maxOptionWidth) {
|
3815
3775
|
maxOptionWidth = widthEstimate;
|
@@ -3859,7 +3819,7 @@ const useFloatingInteractions = ({
|
|
3859
3819
|
onOpenChange,
|
3860
3820
|
activeIndex,
|
3861
3821
|
setActiveIndex,
|
3862
|
-
|
3822
|
+
operatorIdentifier,
|
3863
3823
|
listRef,
|
3864
3824
|
disabledIndicesRef
|
3865
3825
|
}) => {
|
@@ -3883,13 +3843,7 @@ const useFloatingInteractions = ({
|
|
3883
3843
|
const role = react.useRole(context, { role: "listbox" });
|
3884
3844
|
const dismiss = react.useDismiss(context, {
|
3885
3845
|
outsidePress: (event) => {
|
3886
|
-
|
3887
|
-
const target = event.currentTarget || event.target;
|
3888
|
-
let idToCompare = (target == null ? void 0 : target.id) || "";
|
3889
|
-
if ((target == null ? void 0 : target.nodeName) === "path") {
|
3890
|
-
idToCompare = ((_a = target.parentElement) == null ? void 0 : _a.id) || "";
|
3891
|
-
}
|
3892
|
-
if (outsidePressIdsToIgnore.includes(idToCompare)) {
|
3846
|
+
if (event.currentTarget instanceof HTMLElement && event.currentTarget.id === operatorIdentifier) {
|
3893
3847
|
return false;
|
3894
3848
|
}
|
3895
3849
|
return true;
|
@@ -3943,14 +3897,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3943
3897
|
const [activeIndex, setActiveIndex] = React.useState(null);
|
3944
3898
|
const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
|
3945
3899
|
const styles = ui.useStyles2(getStyles$b);
|
3946
|
-
const [filterMultiValues, setFilterMultiValues] = React.useState([]);
|
3947
|
-
const [_, setForceRefresh] = React.useState({});
|
3948
|
-
const multiValueOperators = React.useMemo(
|
3949
|
-
() => OPERATORS.reduce((acc, operator) => operator.isMulti ? [...acc, operator.value] : acc, []),
|
3950
|
-
[]
|
3951
|
-
);
|
3952
|
-
const hasMultiValueOperator = multiValueOperators.includes((filter == null ? void 0 : filter.operator) || "");
|
3953
|
-
const isMultiValueEdit = hasMultiValueOperator && filterInputType === "value";
|
3954
3900
|
const operatorIdentifier = React.useId();
|
3955
3901
|
const listRef = React.useRef([]);
|
3956
3902
|
const disabledIndicesRef = React.useRef([]);
|
@@ -3962,70 +3908,22 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3962
3908
|
setInputValue("");
|
3963
3909
|
}
|
3964
3910
|
}, [model, isAlwaysWip]);
|
3965
|
-
const handleMultiValueFilterCommit = React.useCallback(
|
3966
|
-
(model2, filter2, filterMultiValues2, preventFocus) => {
|
3967
|
-
if (filterMultiValues2.length) {
|
3968
|
-
const valueLabels = [];
|
3969
|
-
const values = [];
|
3970
|
-
filterMultiValues2.forEach((item) => {
|
3971
|
-
var _a2;
|
3972
|
-
valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
|
3973
|
-
values.push(item.value);
|
3974
|
-
});
|
3975
|
-
model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
|
3976
|
-
setFilterMultiValues([]);
|
3977
|
-
}
|
3978
|
-
if (!preventFocus) {
|
3979
|
-
setTimeout(() => {
|
3980
|
-
var _a2;
|
3981
|
-
return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
3982
|
-
});
|
3983
|
-
}
|
3984
|
-
},
|
3985
|
-
[]
|
3986
|
-
);
|
3987
|
-
const handleLocalMultiValueChange = React.useCallback((selectedItem) => {
|
3988
|
-
setFilterMultiValues((items) => {
|
3989
|
-
if (items.some((item) => item.value === selectedItem.value)) {
|
3990
|
-
return items.filter((item) => item.value !== selectedItem.value);
|
3991
|
-
}
|
3992
|
-
return [...items, selectedItem];
|
3993
|
-
});
|
3994
|
-
}, []);
|
3995
|
-
const handleRemoveMultiValue = React.useCallback(
|
3996
|
-
(item) => setFilterMultiValues((selected) => selected.filter((option) => option.value !== item.value)),
|
3997
|
-
[]
|
3998
|
-
);
|
3999
3911
|
const onOpenChange = React.useCallback(
|
4000
|
-
(nextOpen,
|
3912
|
+
(nextOpen, _, reason) => {
|
4001
3913
|
setOpen(nextOpen);
|
4002
3914
|
if (reason && ["outside-press", "escape-key"].includes(reason)) {
|
4003
|
-
if (isMultiValueEdit) {
|
4004
|
-
handleMultiValueFilterCommit(model, filter, filterMultiValues);
|
4005
|
-
}
|
4006
3915
|
handleResetWip();
|
4007
3916
|
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
4008
3917
|
}
|
4009
3918
|
},
|
4010
|
-
[
|
4011
|
-
filter,
|
4012
|
-
filterMultiValues,
|
4013
|
-
handleChangeViewMode,
|
4014
|
-
handleMultiValueFilterCommit,
|
4015
|
-
handleResetWip,
|
4016
|
-
isMultiValueEdit,
|
4017
|
-
model
|
4018
|
-
]
|
3919
|
+
[handleChangeViewMode, handleResetWip]
|
4019
3920
|
);
|
4020
|
-
const outsidePressIdsToIgnore = React.useMemo(() => {
|
4021
|
-
return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
|
4022
|
-
}, [operatorIdentifier, filterMultiValues]);
|
4023
3921
|
const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
|
4024
3922
|
open,
|
4025
3923
|
onOpenChange,
|
4026
3924
|
activeIndex,
|
4027
3925
|
setActiveIndex,
|
4028
|
-
|
3926
|
+
operatorIdentifier,
|
4029
3927
|
listRef,
|
4030
3928
|
disabledIndicesRef
|
4031
3929
|
});
|
@@ -4076,89 +3974,43 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4076
3974
|
const rowVirtualizer = reactVirtual.useVirtualizer({
|
4077
3975
|
count: filteredDropDownItems.length,
|
4078
3976
|
getScrollElement: () => refs.floating.current,
|
4079
|
-
estimateSize: (
|
3977
|
+
estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,
|
4080
3978
|
overscan: VIRTUAL_LIST_OVERSCAN
|
4081
3979
|
});
|
4082
3980
|
const handleBackspaceInput = React.useCallback(
|
4083
|
-
(event
|
4084
|
-
if (event.key === "Backspace" && !inputValue) {
|
4085
|
-
|
4086
|
-
|
4087
|
-
const updated = [...items];
|
4088
|
-
updated.splice(-1, 1);
|
4089
|
-
return updated;
|
4090
|
-
});
|
4091
|
-
} else if (filterInputType === "key") {
|
4092
|
-
model._removeLastFilter();
|
4093
|
-
handleFetchOptions(filterInputType);
|
4094
|
-
}
|
4095
|
-
}
|
4096
|
-
},
|
4097
|
-
[inputValue, filterInputType, model, handleFetchOptions]
|
4098
|
-
);
|
4099
|
-
const handleTabInput = React.useCallback(
|
4100
|
-
(event, multiValueEdit) => {
|
4101
|
-
var _a2;
|
4102
|
-
if (event.key === "Tab" && !event.shiftKey) {
|
4103
|
-
if (multiValueEdit) {
|
4104
|
-
event.preventDefault();
|
4105
|
-
handleMultiValueFilterCommit(model, filter, filterMultiValues);
|
4106
|
-
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
4107
|
-
}
|
4108
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
4109
|
-
handleResetWip();
|
4110
|
-
}
|
4111
|
-
},
|
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();
|
3981
|
+
(event) => {
|
3982
|
+
if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
|
3983
|
+
model._removeLastFilter();
|
3984
|
+
handleFetchOptions(filterInputType);
|
4131
3985
|
}
|
4132
3986
|
},
|
4133
|
-
[
|
3987
|
+
[inputValue, filterInputType]
|
4134
3988
|
);
|
3989
|
+
const handleTabInput = React.useCallback((event) => {
|
3990
|
+
if (event.key === "Tab" && !event.shiftKey) {
|
3991
|
+
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
3992
|
+
handleResetWip();
|
3993
|
+
}
|
3994
|
+
}, []);
|
3995
|
+
const handleShiftTabInput = React.useCallback((event) => {
|
3996
|
+
if (event.key === "Tab" && event.shiftKey) {
|
3997
|
+
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
3998
|
+
handleResetWip();
|
3999
|
+
}
|
4000
|
+
}, []);
|
4135
4001
|
const handleEnterInput = React.useCallback(
|
4136
|
-
(event
|
4002
|
+
(event) => {
|
4137
4003
|
if (event.key === "Enter" && activeIndex != null) {
|
4138
4004
|
if (!filteredDropDownItems[activeIndex]) {
|
4139
4005
|
return;
|
4140
4006
|
}
|
4141
|
-
|
4142
|
-
if (multiValueEdit) {
|
4143
|
-
handleLocalMultiValueChange(selectedItem);
|
4144
|
-
} else {
|
4145
|
-
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, selectedItem));
|
4146
|
-
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
|
4147
|
-
setActiveIndex(0);
|
4148
|
-
}
|
4007
|
+
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, filteredDropDownItems[activeIndex]));
|
4149
4008
|
setInputValue("");
|
4009
|
+
setActiveIndex(0);
|
4010
|
+
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
|
4150
4011
|
}
|
4151
4012
|
},
|
4152
|
-
[
|
4153
|
-
activeIndex,
|
4154
|
-
filter,
|
4155
|
-
filterInputType,
|
4156
|
-
filteredDropDownItems,
|
4157
|
-
handleLocalMultiValueChange,
|
4158
|
-
handleChangeViewMode,
|
4159
|
-
model,
|
4160
|
-
refs.domReference
|
4161
|
-
]
|
4013
|
+
[activeIndex, filter, filterInputType, filteredDropDownItems, model]
|
4162
4014
|
);
|
4163
4015
|
React.useEffect(() => {
|
4164
4016
|
if (open) {
|
@@ -4166,34 +4018,13 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4166
4018
|
}
|
4167
4019
|
}, [open, filterInputType]);
|
4168
4020
|
React.useEffect(() => {
|
4169
|
-
var _a2
|
4021
|
+
var _a2;
|
4170
4022
|
if (!isAlwaysWip) {
|
4171
4023
|
setInputType("value");
|
4172
4024
|
setInputValue("");
|
4173
|
-
|
4174
|
-
const multiValueOptions = filter.values.reduce(
|
4175
|
-
(acc, value, i) => {
|
4176
|
-
var _a3;
|
4177
|
-
return [
|
4178
|
-
...acc,
|
4179
|
-
{
|
4180
|
-
label: ((_a3 = filter.valueLabels) == null ? void 0 : _a3[i]) || value,
|
4181
|
-
value
|
4182
|
-
}
|
4183
|
-
];
|
4184
|
-
},
|
4185
|
-
[]
|
4186
|
-
);
|
4187
|
-
setFilterMultiValues(multiValueOptions);
|
4188
|
-
}
|
4189
|
-
(_b2 = refs.domReference.current) == null ? void 0 : _b2.focus();
|
4025
|
+
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
4190
4026
|
}
|
4191
4027
|
}, []);
|
4192
|
-
React.useEffect(() => {
|
4193
|
-
if (isMultiValueEdit && filterMultiValues) {
|
4194
|
-
setTimeout(() => setForceRefresh({}));
|
4195
|
-
}
|
4196
|
-
}, [filterMultiValues, isMultiValueEdit]);
|
4197
4028
|
React.useLayoutEffect(() => {
|
4198
4029
|
var _a2, _b2;
|
4199
4030
|
if (activeIndex !== null && rowVirtualizer.range && (activeIndex > ((_a2 = rowVirtualizer.range) == null ? void 0 : _a2.endIndex) || activeIndex < ((_b2 = rowVirtualizer.range) == null ? void 0 : _b2.startIndex))) {
|
@@ -4219,17 +4050,14 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4219
4050
|
switchInputType("operator", setInputType, void 0, refs.domReference.current);
|
4220
4051
|
},
|
4221
4052
|
onKeyDown: (event) => {
|
4222
|
-
handleShiftTabInput(event
|
4053
|
+
handleShiftTabInput(event);
|
4223
4054
|
if (event.key === "Enter") {
|
4224
4055
|
switchInputType("operator", setInputType, void 0, refs.domReference.current);
|
4225
4056
|
}
|
4226
4057
|
}
|
4227
|
-
}, filter.operator) : null,
|
4228
|
-
|
4229
|
-
|
4230
|
-
index: i,
|
4231
|
-
handleRemoveMultiValue
|
4232
|
-
})) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$n(__spreadValues$A({}, getReferenceProps({
|
4058
|
+
}, filter.operator) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && (filter == null ? void 0 : filter.value) && !["operator", "value"].includes(filterInputType) ? /* @__PURE__ */ React__default["default"].createElement("div", {
|
4059
|
+
className: css.cx(styles.basePill, styles.valuePill)
|
4060
|
+
}, valueLabel) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$n(__spreadValues$A({}, getReferenceProps({
|
4233
4061
|
ref: refs.setReference,
|
4234
4062
|
onChange,
|
4235
4063
|
value: inputValue,
|
@@ -4243,9 +4071,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4243
4071
|
if (filterInputType === "operator") {
|
4244
4072
|
handleShiftTabInput(event);
|
4245
4073
|
}
|
4246
|
-
handleBackspaceInput(event
|
4247
|
-
handleTabInput(event
|
4248
|
-
handleEnterInput(event
|
4074
|
+
handleBackspaceInput(event);
|
4075
|
+
handleTabInput(event);
|
4076
|
+
handleEnterInput(event);
|
4249
4077
|
}
|
4250
4078
|
})), {
|
4251
4079
|
className: css.cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading }),
|
@@ -4265,7 +4093,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4265
4093
|
initialFocus: -1,
|
4266
4094
|
visuallyHiddenDismiss: true,
|
4267
4095
|
modal: false
|
4268
|
-
}, /* @__PURE__ */ React__default["default"].createElement(
|
4096
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
4269
4097
|
style: __spreadProps$n(__spreadValues$A({}, floatingStyles), {
|
4270
4098
|
width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`
|
4271
4099
|
}),
|
@@ -4306,24 +4134,17 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4306
4134
|
listRef.current[index] = node;
|
4307
4135
|
},
|
4308
4136
|
onClick(event) {
|
4309
|
-
var _a3;
|
4310
4137
|
if (filterInputType !== "value") {
|
4311
4138
|
event.stopPropagation();
|
4312
4139
|
}
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
|
4321
|
-
filterInputType,
|
4322
|
-
setInputType,
|
4323
|
-
handleChangeViewMode,
|
4324
|
-
refs.domReference.current
|
4325
|
-
);
|
4326
|
-
}
|
4140
|
+
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
|
4141
|
+
setInputValue("");
|
4142
|
+
switchToNextInputType(
|
4143
|
+
filterInputType,
|
4144
|
+
setInputType,
|
4145
|
+
handleChangeViewMode,
|
4146
|
+
refs.domReference.current
|
4147
|
+
);
|
4327
4148
|
}
|
4328
4149
|
})), {
|
4329
4150
|
active: activeIndex === index,
|
@@ -4333,56 +4154,19 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4333
4154
|
transform: `translateY(${virtualItem.start}px)`
|
4334
4155
|
},
|
4335
4156
|
"aria-setsize": filteredDropDownItems.length,
|
4336
|
-
"aria-posinset": virtualItem.index + 1
|
4337
|
-
|
4338
|
-
|
4339
|
-
}), /* @__PURE__ */ React__default["default"].createElement("span", null, item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value), item.description ? /* @__PURE__ */ React__default["default"].createElement("div", {
|
4340
|
-
className: styles.descriptionText
|
4341
|
-
}, item.description) : null);
|
4342
|
-
}))), isMultiValueEdit && !optionsLoading && !optionsError && filteredDropDownItems.length ? /* @__PURE__ */ React__default["default"].createElement(MultiValueApplyButton, {
|
4343
|
-
onClick: () => handleMultiValueFilterCommit(model, filter, filterMultiValues),
|
4344
|
-
floatingElement: refs.floating.current,
|
4345
|
-
maxOptionWidth
|
4346
|
-
}) : null))));
|
4157
|
+
"aria-posinset": virtualItem.index + 1
|
4158
|
+
}), item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value);
|
4159
|
+
}))))));
|
4347
4160
|
});
|
4348
|
-
const MultiValuePill = ({ item, handleRemoveMultiValue, index }) => {
|
4349
|
-
var _a, _b;
|
4350
|
-
const styles = ui.useStyles2(getStyles$b);
|
4351
|
-
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
4352
|
-
className: css.cx(styles.basePill, styles.valuePill)
|
4353
|
-
}, /* @__PURE__ */ React__default["default"].createElement("span", null, " ", (_a = item.label) != null ? _a : item.value), /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
|
4354
|
-
onClick: (e) => {
|
4355
|
-
e.stopPropagation();
|
4356
|
-
e.preventDefault();
|
4357
|
-
handleRemoveMultiValue(item);
|
4358
|
-
},
|
4359
|
-
onKeyDownCapture: (e) => {
|
4360
|
-
if (e.key === "Enter") {
|
4361
|
-
e.preventDefault();
|
4362
|
-
e.stopPropagation();
|
4363
|
-
handleRemoveMultiValue(item);
|
4364
|
-
}
|
4365
|
-
},
|
4366
|
-
fill: "text",
|
4367
|
-
size: "sm",
|
4368
|
-
variant: "secondary",
|
4369
|
-
className: styles.removeButton,
|
4370
|
-
tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
|
4371
|
-
}, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
|
4372
|
-
name: "times",
|
4373
|
-
size: "md",
|
4374
|
-
id: `${item.value}-${index}`
|
4375
|
-
})));
|
4376
|
-
};
|
4377
4161
|
const getStyles$b = (theme) => ({
|
4378
4162
|
comboboxWrapper: css.css({
|
4379
4163
|
display: "flex",
|
4380
|
-
flexWrap: "
|
4164
|
+
flexWrap: "nowrap"
|
4381
4165
|
}),
|
4382
4166
|
pillWrapper: css.css({
|
4383
4167
|
display: "flex",
|
4384
4168
|
alignItems: "center",
|
4385
|
-
|
4169
|
+
whiteSpace: "nowrap"
|
4386
4170
|
}),
|
4387
4171
|
basePill: css.css(__spreadProps$n(__spreadValues$A({
|
4388
4172
|
display: "flex",
|
@@ -4407,8 +4191,7 @@ const getStyles$b = (theme) => ({
|
|
4407
4191
|
}
|
4408
4192
|
}),
|
4409
4193
|
valuePill: css.css({
|
4410
|
-
background: theme.colors.action.selected
|
4411
|
-
padding: theme.spacing(0.125, 0, 0.125, 1)
|
4194
|
+
background: theme.colors.action.selected
|
4412
4195
|
}),
|
4413
4196
|
dropdownWrapper: css.css({
|
4414
4197
|
backgroundColor: theme.colors.background.primary,
|
@@ -4441,25 +4224,6 @@ const getStyles$b = (theme) => ({
|
|
4441
4224
|
"&:not(:first-child)": {
|
4442
4225
|
borderTop: `1px solid ${theme.colors.border.weak}`
|
4443
4226
|
}
|
4444
|
-
}),
|
4445
|
-
removeButton: css.css({
|
4446
|
-
marginInline: theme.spacing(0.5),
|
4447
|
-
height: "100%",
|
4448
|
-
padding: 0,
|
4449
|
-
cursor: "pointer",
|
4450
|
-
"&:hover": {
|
4451
|
-
color: theme.colors.text.primary
|
4452
|
-
}
|
4453
|
-
}),
|
4454
|
-
descriptionText: css.css(__spreadProps$n(__spreadValues$A({}, theme.typography.bodySmall), {
|
4455
|
-
color: theme.colors.text.secondary,
|
4456
|
-
paddingTop: theme.spacing(0.5)
|
4457
|
-
})),
|
4458
|
-
multiValueApply: css.css({
|
4459
|
-
position: "absolute",
|
4460
|
-
top: 0,
|
4461
|
-
left: 0,
|
4462
|
-
display: "flex"
|
4463
4227
|
})
|
4464
4228
|
});
|
4465
4229
|
|
@@ -4489,7 +4253,7 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
4489
4253
|
const [shouldFocus, setShouldFocus] = React.useState(false);
|
4490
4254
|
const pillWrapperRef = React.useRef(null);
|
4491
4255
|
const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
|
4492
|
-
const valueLabel = ((_b = filter.valueLabels) == null ? void 0 : _b
|
4256
|
+
const valueLabel = (_c = (_b = filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter.value;
|
4493
4257
|
const handleChangeViewMode = React.useCallback(
|
4494
4258
|
(event) => {
|
4495
4259
|
event == null ? void 0 : event.stopPropagation();
|
@@ -4521,9 +4285,7 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
4521
4285
|
"aria-label": `Edit filter with key ${keyLabel}`,
|
4522
4286
|
tabIndex: 0,
|
4523
4287
|
ref: pillWrapperRef
|
4524
|
-
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
4525
|
-
className: styles.pillText
|
4526
|
-
}, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
|
4288
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", null, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
|
4527
4289
|
onClick: (e) => {
|
4528
4290
|
e.stopPropagation();
|
4529
4291
|
model._removeFilter(filter);
|
@@ -4579,9 +4341,6 @@ const getStyles$a = (theme) => ({
|
|
4579
4341
|
"&:hover": {
|
4580
4342
|
color: theme.colors.text.primary
|
4581
4343
|
}
|
4582
|
-
}),
|
4583
|
-
pillText: css.css({
|
4584
|
-
whiteSpace: "break-spaces"
|
4585
4344
|
})
|
4586
4345
|
});
|
4587
4346
|
|
@@ -4847,7 +4606,7 @@ function renderExpression(builder, filters) {
|
|
4847
4606
|
function AdHocFiltersVariableRenderer({ model }) {
|
4848
4607
|
const { filters, readOnly, addFilterButtonText } = model.useState();
|
4849
4608
|
const styles = ui.useStyles2(getStyles$8);
|
4850
|
-
if (model.state.layout === "combobox") {
|
4609
|
+
if (!model.state.supportsMultiValueOperators && model.state.layout === "combobox") {
|
4851
4610
|
return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
|
4852
4611
|
model
|
4853
4612
|
});
|
@@ -9054,7 +8813,7 @@ function VariableValueInput({ model }) {
|
|
9054
8813
|
id: key,
|
9055
8814
|
placeholder: "Enter value",
|
9056
8815
|
minWidth: 15,
|
9057
|
-
|
8816
|
+
value,
|
9058
8817
|
loading,
|
9059
8818
|
onBlur,
|
9060
8819
|
onKeyDown
|
@@ -9102,12 +8861,10 @@ class TextBoxVariable extends SceneObjectBase {
|
|
9102
8861
|
return { [this.getKey()]: this.state.value };
|
9103
8862
|
}
|
9104
8863
|
updateFromUrl(values) {
|
9105
|
-
const update = {};
|
9106
8864
|
const val = values[this.getKey()];
|
9107
8865
|
if (typeof val === "string") {
|
9108
|
-
|
8866
|
+
this.setValue(val);
|
9109
8867
|
}
|
9110
|
-
this.setState(update);
|
9111
8868
|
}
|
9112
8869
|
}
|
9113
8870
|
TextBoxVariable.Component = ({ model }) => {
|