@gridsuite/commons-ui 0.66.0 → 0.66.1
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/dist/components/inputs/reactQueryBuilder/AutocompleteWithFavorites.js +1 -0
- package/dist/components/inputs/reactQueryBuilder/CustomReactQueryBuilder.js +2 -1
- package/dist/components/inputs/reactQueryBuilder/FieldSelector.d.ts +4 -0
- package/dist/components/inputs/reactQueryBuilder/FieldSelector.js +28 -0
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ function AutocompleteWithFavorites({
|
|
|
27
27
|
size: "small",
|
|
28
28
|
value,
|
|
29
29
|
options: optionsWithFavorites,
|
|
30
|
+
isOptionEqualToValue: (option, val) => option === val || val === "",
|
|
30
31
|
...otherProps,
|
|
31
32
|
groupBy: (option) => favorites.includes(option) ? `fav` : "not_fav",
|
|
32
33
|
multiple: Array.isArray(value),
|
|
@@ -17,6 +17,7 @@ import ErrorInput from "../reactHookForm/errorManagement/ErrorInput.js";
|
|
|
17
17
|
import FieldErrorAlert from "../reactHookForm/errorManagement/FieldErrorAlert.js";
|
|
18
18
|
import { countRules, getOperators, queryValidator } from "../../filter/expert/expertFilterUtils.js";
|
|
19
19
|
import RemoveButton from "./RemoveButton.js";
|
|
20
|
+
import FieldSelector from "./FieldSelector.js";
|
|
20
21
|
function RuleAddButton(props) {
|
|
21
22
|
return /* @__PURE__ */ jsx(AddButton, { ...props, label: "rule" });
|
|
22
23
|
}
|
|
@@ -74,7 +75,7 @@ function CustomReactQueryBuilder(props) {
|
|
|
74
75
|
removeGroupAction: RemoveButton,
|
|
75
76
|
valueEditor: ValueEditor,
|
|
76
77
|
operatorSelector: ValueSelector,
|
|
77
|
-
fieldSelector:
|
|
78
|
+
fieldSelector: FieldSelector,
|
|
78
79
|
valueSourceSelector: ValueSelector
|
|
79
80
|
},
|
|
80
81
|
listsAsArrays: true
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { toFlatOptionArray } from "react-querybuilder";
|
|
3
|
+
import { Autocomplete, TextField } from "@mui/material";
|
|
4
|
+
function FieldSelector({ options, className, value, disabled, handleOnChange }) {
|
|
5
|
+
const optionList = toFlatOptionArray(options);
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
Autocomplete,
|
|
8
|
+
{
|
|
9
|
+
onChange: (event, newValue) => {
|
|
10
|
+
if (newValue) {
|
|
11
|
+
handleOnChange(newValue.name);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
value: optionList.find((option) => option.name === value),
|
|
15
|
+
disabled,
|
|
16
|
+
className,
|
|
17
|
+
options: optionList,
|
|
18
|
+
disableClearable: true,
|
|
19
|
+
size: "small",
|
|
20
|
+
renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, label: "", variant: "standard" }),
|
|
21
|
+
autoHighlight: true,
|
|
22
|
+
getOptionLabel: (option) => option.label
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
FieldSelector as default
|
|
28
|
+
};
|