@grafana/scenes 5.13.0--canary.878.10702174754.0 → 5.13.1--canary.889.10720020573.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +26 -0
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +7 -2
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +213 -47
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js +40 -4
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/useFloatingInteractions.js +8 -2
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/useFloatingInteractions.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +6 -2
- 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/index.js +267 -51
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -3628,7 +3628,7 @@ var __objRest$3 = (source, exclude) => {
|
|
3628
3628
|
};
|
3629
3629
|
const DropdownItem = React.forwardRef(
|
3630
3630
|
function DropdownItem2(_a, ref) {
|
3631
|
-
var _b = _a, { children, active, addGroupBottomBorder } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder"]);
|
3631
|
+
var _b = _a, { children, active, addGroupBottomBorder, isMultiValueEdit, checked } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder", "isMultiValueEdit", "checked"]);
|
3632
3632
|
const styles = ui.useStyles2(getStyles$c);
|
3633
3633
|
const id = React.useId();
|
3634
3634
|
return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
|
@@ -3640,7 +3640,11 @@ const DropdownItem = React.forwardRef(
|
|
3640
3640
|
}, rest), /* @__PURE__ */ React__default["default"].createElement("div", {
|
3641
3641
|
className: styles.optionBody,
|
3642
3642
|
"data-testid": `data-testid ad hoc filter option value ${children}`
|
3643
|
-
}, /* @__PURE__ */ React__default["default"].createElement("span", null,
|
3643
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", null, isMultiValueEdit ? /* @__PURE__ */ React__default["default"].createElement(ui.Checkbox, {
|
3644
|
+
tabIndex: -1,
|
3645
|
+
checked,
|
3646
|
+
className: styles.checkbox
|
3647
|
+
}) : null, children)));
|
3644
3648
|
}
|
3645
3649
|
);
|
3646
3650
|
const getStyles$c = (theme) => ({
|
@@ -3680,6 +3684,22 @@ const getStyles$c = (theme) => ({
|
|
3680
3684
|
}),
|
3681
3685
|
groupBottomBorder: css.css({
|
3682
3686
|
borderBottom: `1px solid ${theme.colors.border.weak}`
|
3687
|
+
}),
|
3688
|
+
checkbox: css.css({
|
3689
|
+
paddingRight: theme.spacing(0.5)
|
3690
|
+
}),
|
3691
|
+
multiValueApply: css.css({
|
3692
|
+
position: "absolute",
|
3693
|
+
top: 0,
|
3694
|
+
left: 0,
|
3695
|
+
display: "flex"
|
3696
|
+
}),
|
3697
|
+
dropdownWrapper: css.css({
|
3698
|
+
backgroundColor: theme.colors.background.primary,
|
3699
|
+
color: theme.colors.text.primary,
|
3700
|
+
boxShadow: theme.shadows.z2,
|
3701
|
+
overflowY: "auto",
|
3702
|
+
zIndex: theme.zIndex.dropdown
|
3683
3703
|
})
|
3684
3704
|
});
|
3685
3705
|
const LoadingOptionsPlaceholder = () => {
|
@@ -3697,11 +3717,28 @@ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
|
|
3697
3717
|
onClick: handleFetchOptions
|
3698
3718
|
}, "An error has occurred fetching labels. Click to retry");
|
3699
3719
|
};
|
3720
|
+
const MultiValueApplyButton = ({ onClick, floatingElement, maxOptionWidth }) => {
|
3721
|
+
const styles = ui.useStyles2(getStyles$c);
|
3722
|
+
const floatingElementRect = floatingElement == null ? void 0 : floatingElement.getBoundingClientRect();
|
3723
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
3724
|
+
className: css.cx(styles.dropdownWrapper, styles.multiValueApply),
|
3725
|
+
style: {
|
3726
|
+
width: `${maxOptionWidth}px`,
|
3727
|
+
transform: `translate(${floatingElementRect == null ? void 0 : floatingElementRect.left}px,${floatingElementRect == null ? void 0 : floatingElementRect.bottom}px)`
|
3728
|
+
}
|
3729
|
+
}, /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
|
3730
|
+
onClick,
|
3731
|
+
fill: "text",
|
3732
|
+
fullWidth: true,
|
3733
|
+
tabIndex: -1
|
3734
|
+
}, "Apply"));
|
3735
|
+
};
|
3700
3736
|
|
3701
3737
|
const VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 8;
|
3702
3738
|
const VIRTUAL_LIST_PADDING = 8;
|
3703
3739
|
const VIRTUAL_LIST_OVERSCAN = 5;
|
3704
3740
|
const VIRTUAL_LIST_ITEM_HEIGHT = 38;
|
3741
|
+
const VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;
|
3705
3742
|
const ERROR_STATE_DROPDOWN_WIDTH = 366;
|
3706
3743
|
function fuzzySearchOptions(options) {
|
3707
3744
|
const ufuzzy = new uFuzzy__default["default"]();
|
@@ -3752,7 +3789,7 @@ function fuzzySearchOptions(options) {
|
|
3752
3789
|
}
|
3753
3790
|
const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
|
3754
3791
|
const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
|
3755
|
-
var _a, _b, _c;
|
3792
|
+
var _a, _b, _c, _d;
|
3756
3793
|
let maxOptionWidth = 182;
|
3757
3794
|
const listRefArr = [];
|
3758
3795
|
const disabledIndices = [];
|
@@ -3762,6 +3799,9 @@ const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
|
|
3762
3799
|
disabledIndices.push(i);
|
3763
3800
|
}
|
3764
3801
|
let label = (_c = (_b = options[i].label) != null ? _b : options[i].value) != null ? _c : "";
|
3802
|
+
if (label.length < (((_d = options[i].description) == null ? void 0 : _d.length) || 0)) {
|
3803
|
+
label = options[i].description;
|
3804
|
+
}
|
3765
3805
|
const widthEstimate = (options[i].isCustom ? label.length + 18 : label.length) * VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER + VIRTUAL_LIST_PADDING * 2;
|
3766
3806
|
if (widthEstimate > maxOptionWidth) {
|
3767
3807
|
maxOptionWidth = widthEstimate;
|
@@ -3811,7 +3851,7 @@ const useFloatingInteractions = ({
|
|
3811
3851
|
onOpenChange,
|
3812
3852
|
activeIndex,
|
3813
3853
|
setActiveIndex,
|
3814
|
-
|
3854
|
+
outsidePressIdsToIgnore,
|
3815
3855
|
listRef,
|
3816
3856
|
disabledIndicesRef
|
3817
3857
|
}) => {
|
@@ -3835,7 +3875,13 @@ const useFloatingInteractions = ({
|
|
3835
3875
|
const role = react.useRole(context, { role: "listbox" });
|
3836
3876
|
const dismiss = react.useDismiss(context, {
|
3837
3877
|
outsidePress: (event) => {
|
3838
|
-
|
3878
|
+
var _a;
|
3879
|
+
const target = event.currentTarget || event.target;
|
3880
|
+
let idToCompare = (target == null ? void 0 : target.id) || "";
|
3881
|
+
if ((target == null ? void 0 : target.nodeName) === "path") {
|
3882
|
+
idToCompare = ((_a = target.parentElement) == null ? void 0 : _a.id) || "";
|
3883
|
+
}
|
3884
|
+
if (outsidePressIdsToIgnore.includes(idToCompare)) {
|
3839
3885
|
return false;
|
3840
3886
|
}
|
3841
3887
|
return true;
|
@@ -3889,6 +3935,14 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3889
3935
|
const [activeIndex, setActiveIndex] = React.useState(null);
|
3890
3936
|
const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
|
3891
3937
|
const styles = ui.useStyles2(getStyles$b);
|
3938
|
+
const [filterMultiValues, setFilterMultiValues] = React.useState([]);
|
3939
|
+
const [_, setForceRefresh] = React.useState({});
|
3940
|
+
const multiValueOperators = React.useMemo(
|
3941
|
+
() => OPERATORS.reduce((acc, operator) => operator.isMulti ? [...acc, operator.value] : acc, []),
|
3942
|
+
[]
|
3943
|
+
);
|
3944
|
+
const hasMultiValueOperator = multiValueOperators.includes((filter == null ? void 0 : filter.operator) || "");
|
3945
|
+
const isMultiValueEdit = hasMultiValueOperator && filterInputType === "value";
|
3892
3946
|
const operatorIdentifier = React.useId();
|
3893
3947
|
const listRef = React.useRef([]);
|
3894
3948
|
const disabledIndicesRef = React.useRef([]);
|
@@ -3900,22 +3954,60 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3900
3954
|
setInputValue("");
|
3901
3955
|
}
|
3902
3956
|
}, [model, isAlwaysWip]);
|
3957
|
+
const handleMultiValueUpdate = React.useCallback(
|
3958
|
+
(model2, filter2, filterMultiValues2) => {
|
3959
|
+
if (filterMultiValues2.length) {
|
3960
|
+
const valueLabels = [];
|
3961
|
+
const values = [];
|
3962
|
+
filterMultiValues2.forEach((item) => {
|
3963
|
+
var _a2;
|
3964
|
+
valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
|
3965
|
+
values.push(item.value);
|
3966
|
+
});
|
3967
|
+
model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
|
3968
|
+
setFilterMultiValues([]);
|
3969
|
+
}
|
3970
|
+
setTimeout(() => {
|
3971
|
+
var _a2;
|
3972
|
+
return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
3973
|
+
});
|
3974
|
+
},
|
3975
|
+
[]
|
3976
|
+
);
|
3977
|
+
const handleAddMultiValue = React.useCallback((selectedItem) => {
|
3978
|
+
setFilterMultiValues((items) => {
|
3979
|
+
if (items.some((item) => item.value === selectedItem.value)) {
|
3980
|
+
return items.filter((item) => item.value !== selectedItem.value);
|
3981
|
+
}
|
3982
|
+
return [...items, selectedItem];
|
3983
|
+
});
|
3984
|
+
}, []);
|
3985
|
+
const handleRemoveMultiValue = React.useCallback(
|
3986
|
+
(item) => setFilterMultiValues((selected) => selected.filter((option) => option.value !== item.value)),
|
3987
|
+
[]
|
3988
|
+
);
|
3903
3989
|
const onOpenChange = React.useCallback(
|
3904
|
-
(nextOpen,
|
3990
|
+
(nextOpen, _2, reason) => {
|
3905
3991
|
setOpen(nextOpen);
|
3906
3992
|
if (reason && ["outside-press", "escape-key"].includes(reason)) {
|
3993
|
+
if (isMultiValueEdit) {
|
3994
|
+
handleMultiValueUpdate(model, filter, filterMultiValues);
|
3995
|
+
}
|
3907
3996
|
handleResetWip();
|
3908
3997
|
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
3909
3998
|
}
|
3910
3999
|
},
|
3911
|
-
[handleChangeViewMode, handleResetWip]
|
4000
|
+
[filter, filterMultiValues, handleChangeViewMode, handleMultiValueUpdate, handleResetWip, isMultiValueEdit, model]
|
3912
4001
|
);
|
4002
|
+
const outsidePressIdsToIgnore = React.useMemo(() => {
|
4003
|
+
return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
|
4004
|
+
}, [operatorIdentifier, filterMultiValues]);
|
3913
4005
|
const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
|
3914
4006
|
open,
|
3915
4007
|
onOpenChange,
|
3916
4008
|
activeIndex,
|
3917
4009
|
setActiveIndex,
|
3918
|
-
|
4010
|
+
outsidePressIdsToIgnore,
|
3919
4011
|
listRef,
|
3920
4012
|
disabledIndicesRef
|
3921
4013
|
});
|
@@ -3966,24 +4058,41 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3966
4058
|
const rowVirtualizer = reactVirtual.useVirtualizer({
|
3967
4059
|
count: filteredDropDownItems.length,
|
3968
4060
|
getScrollElement: () => refs.floating.current,
|
3969
|
-
estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,
|
4061
|
+
estimateSize: (index) => filteredDropDownItems[index].description ? VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION : VIRTUAL_LIST_ITEM_HEIGHT,
|
3970
4062
|
overscan: VIRTUAL_LIST_OVERSCAN
|
3971
4063
|
});
|
3972
4064
|
const handleBackspaceInput = React.useCallback(
|
3973
|
-
(event) => {
|
3974
|
-
if (event.key === "Backspace" && !inputValue
|
3975
|
-
|
3976
|
-
|
4065
|
+
(event, multiValueEdit) => {
|
4066
|
+
if (event.key === "Backspace" && !inputValue) {
|
4067
|
+
if (multiValueEdit) {
|
4068
|
+
setFilterMultiValues((items) => {
|
4069
|
+
const updated = [...items];
|
4070
|
+
updated.splice(-1, 1);
|
4071
|
+
return updated;
|
4072
|
+
});
|
4073
|
+
} else if (filterInputType === "key") {
|
4074
|
+
model._removeLastFilter();
|
4075
|
+
handleFetchOptions(filterInputType);
|
4076
|
+
}
|
3977
4077
|
}
|
3978
4078
|
},
|
3979
|
-
[inputValue, filterInputType]
|
4079
|
+
[inputValue, filterInputType, model, handleFetchOptions]
|
4080
|
+
);
|
4081
|
+
const handleTabInput = React.useCallback(
|
4082
|
+
(event, multiValueEdit) => {
|
4083
|
+
var _a2;
|
4084
|
+
if (event.key === "Tab" && !event.shiftKey) {
|
4085
|
+
if (multiValueEdit) {
|
4086
|
+
event.preventDefault();
|
4087
|
+
handleMultiValueUpdate(model, filter, filterMultiValues);
|
4088
|
+
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
4089
|
+
}
|
4090
|
+
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
4091
|
+
handleResetWip();
|
4092
|
+
}
|
4093
|
+
},
|
4094
|
+
[filter, filterMultiValues, handleChangeViewMode, handleMultiValueUpdate, handleResetWip, model, refs.domReference]
|
3980
4095
|
);
|
3981
|
-
const handleTabInput = React.useCallback((event) => {
|
3982
|
-
if (event.key === "Tab" && !event.shiftKey) {
|
3983
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
3984
|
-
handleResetWip();
|
3985
|
-
}
|
3986
|
-
}, []);
|
3987
4096
|
const handleShiftTabInput = React.useCallback((event) => {
|
3988
4097
|
if (event.key === "Tab" && event.shiftKey) {
|
3989
4098
|
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
@@ -3991,18 +4100,32 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3991
4100
|
}
|
3992
4101
|
}, []);
|
3993
4102
|
const handleEnterInput = React.useCallback(
|
3994
|
-
(event) => {
|
4103
|
+
(event, multiValueEdit) => {
|
3995
4104
|
if (event.key === "Enter" && activeIndex != null) {
|
3996
4105
|
if (!filteredDropDownItems[activeIndex]) {
|
3997
4106
|
return;
|
3998
4107
|
}
|
3999
|
-
|
4108
|
+
const selectedItem = filteredDropDownItems[activeIndex];
|
4109
|
+
if (multiValueEdit) {
|
4110
|
+
handleAddMultiValue(selectedItem);
|
4111
|
+
} else {
|
4112
|
+
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, selectedItem));
|
4113
|
+
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
|
4114
|
+
setActiveIndex(0);
|
4115
|
+
}
|
4000
4116
|
setInputValue("");
|
4001
|
-
setActiveIndex(0);
|
4002
|
-
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
|
4003
4117
|
}
|
4004
4118
|
},
|
4005
|
-
[
|
4119
|
+
[
|
4120
|
+
activeIndex,
|
4121
|
+
filter,
|
4122
|
+
filterInputType,
|
4123
|
+
filteredDropDownItems,
|
4124
|
+
handleAddMultiValue,
|
4125
|
+
handleChangeViewMode,
|
4126
|
+
model,
|
4127
|
+
refs.domReference
|
4128
|
+
]
|
4006
4129
|
);
|
4007
4130
|
React.useEffect(() => {
|
4008
4131
|
if (open) {
|
@@ -4010,13 +4133,34 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4010
4133
|
}
|
4011
4134
|
}, [open, filterInputType]);
|
4012
4135
|
React.useEffect(() => {
|
4013
|
-
var _a2;
|
4136
|
+
var _a2, _b2;
|
4014
4137
|
if (!isAlwaysWip) {
|
4015
4138
|
setInputType("value");
|
4016
4139
|
setInputValue("");
|
4017
|
-
(_a2 =
|
4140
|
+
if (hasMultiValueOperator && ((_a2 = filter == null ? void 0 : filter.values) == null ? void 0 : _a2.length)) {
|
4141
|
+
const multiValueOptions = filter.values.reduce(
|
4142
|
+
(acc, value, i) => {
|
4143
|
+
var _a3;
|
4144
|
+
return [
|
4145
|
+
...acc,
|
4146
|
+
{
|
4147
|
+
label: ((_a3 = filter.valueLabels) == null ? void 0 : _a3[i]) || value,
|
4148
|
+
value
|
4149
|
+
}
|
4150
|
+
];
|
4151
|
+
},
|
4152
|
+
[]
|
4153
|
+
);
|
4154
|
+
setFilterMultiValues(multiValueOptions);
|
4155
|
+
}
|
4156
|
+
(_b2 = refs.domReference.current) == null ? void 0 : _b2.focus();
|
4018
4157
|
}
|
4019
4158
|
}, []);
|
4159
|
+
React.useEffect(() => {
|
4160
|
+
if (isMultiValueEdit && filterMultiValues) {
|
4161
|
+
setTimeout(() => setForceRefresh({}));
|
4162
|
+
}
|
4163
|
+
}, [filterMultiValues, isMultiValueEdit]);
|
4020
4164
|
React.useLayoutEffect(() => {
|
4021
4165
|
var _a2, _b2;
|
4022
4166
|
if (activeIndex !== null && rowVirtualizer.range && (activeIndex > ((_a2 = rowVirtualizer.range) == null ? void 0 : _a2.endIndex) || activeIndex < ((_b2 = rowVirtualizer.range) == null ? void 0 : _b2.startIndex))) {
|
@@ -4047,9 +4191,12 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4047
4191
|
switchInputType("operator", setInputType, void 0, refs.domReference.current);
|
4048
4192
|
}
|
4049
4193
|
}
|
4050
|
-
}, filter.operator) : null,
|
4051
|
-
|
4052
|
-
|
4194
|
+
}, filter.operator) : null, isMultiValueEdit ? filterMultiValues.map((item, i) => /* @__PURE__ */ React__default["default"].createElement(MultiValuePill, {
|
4195
|
+
key: `${item.value}-${i}`,
|
4196
|
+
item,
|
4197
|
+
index: i,
|
4198
|
+
handleRemoveMultiValue
|
4199
|
+
})) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$n(__spreadValues$A({}, getReferenceProps({
|
4053
4200
|
ref: refs.setReference,
|
4054
4201
|
onChange,
|
4055
4202
|
value: inputValue,
|
@@ -4063,9 +4210,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4063
4210
|
if (filterInputType === "operator") {
|
4064
4211
|
handleShiftTabInput(event);
|
4065
4212
|
}
|
4066
|
-
handleBackspaceInput(event);
|
4067
|
-
handleTabInput(event);
|
4068
|
-
handleEnterInput(event);
|
4213
|
+
handleBackspaceInput(event, isMultiValueEdit);
|
4214
|
+
handleTabInput(event, isMultiValueEdit);
|
4215
|
+
handleEnterInput(event, isMultiValueEdit);
|
4069
4216
|
}
|
4070
4217
|
})), {
|
4071
4218
|
className: css.cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading }),
|
@@ -4085,7 +4232,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4085
4232
|
initialFocus: -1,
|
4086
4233
|
visuallyHiddenDismiss: true,
|
4087
4234
|
modal: false
|
4088
|
-
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
4235
|
+
}, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
|
4089
4236
|
style: __spreadProps$n(__spreadValues$A({}, floatingStyles), {
|
4090
4237
|
width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`
|
4091
4238
|
}),
|
@@ -4126,17 +4273,24 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4126
4273
|
listRef.current[index] = node;
|
4127
4274
|
},
|
4128
4275
|
onClick(event) {
|
4276
|
+
var _a3;
|
4129
4277
|
if (filterInputType !== "value") {
|
4130
4278
|
event.stopPropagation();
|
4131
4279
|
}
|
4132
|
-
|
4133
|
-
|
4134
|
-
|
4135
|
-
|
4136
|
-
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4280
|
+
if (isMultiValueEdit) {
|
4281
|
+
event.stopPropagation();
|
4282
|
+
handleAddMultiValue(item);
|
4283
|
+
(_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
|
4284
|
+
} else {
|
4285
|
+
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
|
4286
|
+
setInputValue("");
|
4287
|
+
switchToNextInputType(
|
4288
|
+
filterInputType,
|
4289
|
+
setInputType,
|
4290
|
+
handleChangeViewMode,
|
4291
|
+
refs.domReference.current
|
4292
|
+
);
|
4293
|
+
}
|
4140
4294
|
}
|
4141
4295
|
})), {
|
4142
4296
|
active: activeIndex === index,
|
@@ -4146,19 +4300,56 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4146
4300
|
transform: `translateY(${virtualItem.start}px)`
|
4147
4301
|
},
|
4148
4302
|
"aria-setsize": filteredDropDownItems.length,
|
4149
|
-
"aria-posinset": virtualItem.index + 1
|
4150
|
-
|
4151
|
-
|
4303
|
+
"aria-posinset": virtualItem.index + 1,
|
4304
|
+
isMultiValueEdit,
|
4305
|
+
checked: filterMultiValues.some((val) => val.value === item.value)
|
4306
|
+
}), /* @__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", {
|
4307
|
+
className: styles.descriptionText
|
4308
|
+
}, item.description) : null);
|
4309
|
+
}))), isMultiValueEdit && !optionsLoading && !optionsError && filteredDropDownItems.length ? /* @__PURE__ */ React__default["default"].createElement(MultiValueApplyButton, {
|
4310
|
+
onClick: () => handleMultiValueUpdate(model, filter, filterMultiValues),
|
4311
|
+
floatingElement: refs.floating.current,
|
4312
|
+
maxOptionWidth
|
4313
|
+
}) : null))));
|
4152
4314
|
});
|
4315
|
+
const MultiValuePill = ({ item, handleRemoveMultiValue, index }) => {
|
4316
|
+
var _a, _b;
|
4317
|
+
const styles = ui.useStyles2(getStyles$b);
|
4318
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
4319
|
+
className: css.cx(styles.basePill, styles.valuePill)
|
4320
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", null, " ", (_a = item.label) != null ? _a : item.value), /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
|
4321
|
+
onClick: (e) => {
|
4322
|
+
e.stopPropagation();
|
4323
|
+
e.preventDefault();
|
4324
|
+
handleRemoveMultiValue(item);
|
4325
|
+
},
|
4326
|
+
onKeyDownCapture: (e) => {
|
4327
|
+
if (e.key === "Enter") {
|
4328
|
+
e.preventDefault();
|
4329
|
+
e.stopPropagation();
|
4330
|
+
handleRemoveMultiValue(item);
|
4331
|
+
}
|
4332
|
+
},
|
4333
|
+
fill: "text",
|
4334
|
+
size: "sm",
|
4335
|
+
variant: "secondary",
|
4336
|
+
className: styles.removeButton,
|
4337
|
+
tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
|
4338
|
+
}, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
|
4339
|
+
name: "times",
|
4340
|
+
size: "md",
|
4341
|
+
id: `${item.value}-${index}`
|
4342
|
+
})));
|
4343
|
+
};
|
4153
4344
|
const getStyles$b = (theme) => ({
|
4154
4345
|
comboboxWrapper: css.css({
|
4155
4346
|
display: "flex",
|
4156
|
-
flexWrap: "
|
4347
|
+
flexWrap: "wrap"
|
4157
4348
|
}),
|
4158
4349
|
pillWrapper: css.css({
|
4159
4350
|
display: "flex",
|
4160
4351
|
alignItems: "center",
|
4161
|
-
|
4352
|
+
flexWrap: "wrap"
|
4162
4353
|
}),
|
4163
4354
|
basePill: css.css(__spreadProps$n(__spreadValues$A({
|
4164
4355
|
display: "flex",
|
@@ -4183,7 +4374,8 @@ const getStyles$b = (theme) => ({
|
|
4183
4374
|
}
|
4184
4375
|
}),
|
4185
4376
|
valuePill: css.css({
|
4186
|
-
background: theme.colors.action.selected
|
4377
|
+
background: theme.colors.action.selected,
|
4378
|
+
padding: theme.spacing(0.125, 0, 0.125, 1)
|
4187
4379
|
}),
|
4188
4380
|
dropdownWrapper: css.css({
|
4189
4381
|
backgroundColor: theme.colors.background.primary,
|
@@ -4216,6 +4408,25 @@ const getStyles$b = (theme) => ({
|
|
4216
4408
|
"&:not(:first-child)": {
|
4217
4409
|
borderTop: `1px solid ${theme.colors.border.weak}`
|
4218
4410
|
}
|
4411
|
+
}),
|
4412
|
+
removeButton: css.css({
|
4413
|
+
marginInline: theme.spacing(0.5),
|
4414
|
+
height: "100%",
|
4415
|
+
padding: 0,
|
4416
|
+
cursor: "pointer",
|
4417
|
+
"&:hover": {
|
4418
|
+
color: theme.colors.text.primary
|
4419
|
+
}
|
4420
|
+
}),
|
4421
|
+
descriptionText: css.css(__spreadProps$n(__spreadValues$A({}, theme.typography.bodySmall), {
|
4422
|
+
color: theme.colors.text.secondary,
|
4423
|
+
paddingTop: theme.spacing(0.5)
|
4424
|
+
})),
|
4425
|
+
multiValueApply: css.css({
|
4426
|
+
position: "absolute",
|
4427
|
+
top: 0,
|
4428
|
+
left: 0,
|
4429
|
+
display: "flex"
|
4219
4430
|
})
|
4220
4431
|
});
|
4221
4432
|
|
@@ -4245,7 +4456,7 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
4245
4456
|
const [shouldFocus, setShouldFocus] = React.useState(false);
|
4246
4457
|
const pillWrapperRef = React.useRef(null);
|
4247
4458
|
const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
|
4248
|
-
const valueLabel = (
|
4459
|
+
const valueLabel = ((_b = filter.valueLabels) == null ? void 0 : _b.join(", ")) || ((_c = filter.values) == null ? void 0 : _c.join(", ")) || filter.value;
|
4249
4460
|
const handleChangeViewMode = React.useCallback(
|
4250
4461
|
(event) => {
|
4251
4462
|
event == null ? void 0 : event.stopPropagation();
|
@@ -4277,7 +4488,9 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
4277
4488
|
"aria-label": `Edit filter with key ${keyLabel}`,
|
4278
4489
|
tabIndex: 0,
|
4279
4490
|
ref: pillWrapperRef
|
4280
|
-
}, /* @__PURE__ */ React__default["default"].createElement("span",
|
4491
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
4492
|
+
className: styles.pillText
|
4493
|
+
}, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
|
4281
4494
|
onClick: (e) => {
|
4282
4495
|
e.stopPropagation();
|
4283
4496
|
model._removeFilter(filter);
|
@@ -4333,6 +4546,9 @@ const getStyles$a = (theme) => ({
|
|
4333
4546
|
"&:hover": {
|
4334
4547
|
color: theme.colors.text.primary
|
4335
4548
|
}
|
4549
|
+
}),
|
4550
|
+
pillText: css.css({
|
4551
|
+
whiteSpace: "break-spaces"
|
4336
4552
|
})
|
4337
4553
|
});
|
4338
4554
|
|
@@ -4598,7 +4814,7 @@ function renderExpression(builder, filters) {
|
|
4598
4814
|
function AdHocFiltersVariableRenderer({ model }) {
|
4599
4815
|
const { filters, readOnly, addFilterButtonText } = model.useState();
|
4600
4816
|
const styles = ui.useStyles2(getStyles$8);
|
4601
|
-
if (
|
4817
|
+
if (model.state.layout === "combobox") {
|
4602
4818
|
return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
|
4603
4819
|
model
|
4604
4820
|
});
|