@gridsuite/commons-ui 0.249.0 → 0.249.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.
@@ -16,7 +16,7 @@ import { ValueSelector } from "./ValueSelector.js";
16
16
  import { COMBINATOR_OPTIONS } from "../filter/expert/expertFilterConstants.js";
17
17
  import { ErrorInput } from "../../ui/reactHookForm/errorManagement/ErrorInput.js";
18
18
  import { FieldErrorAlert } from "../../ui/reactHookForm/errorManagement/FieldErrorAlert.js";
19
- import { countRules, queryValidator, getOperators } from "../filter/expert/expertFilterUtils.js";
19
+ import { getOperators, countRules, queryValidator } from "../filter/expert/expertFilterUtils.js";
20
20
  import { RemoveButton } from "./RemoveButton.js";
21
21
  import { FieldSelector } from "./FieldSelector.js";
22
22
  import { OperatorSelector } from "./OperatorSelector.js";
@@ -38,6 +38,22 @@ const customTranslations = {
38
38
  value: { title: "" },
39
39
  combinators: { title: "" }
40
40
  };
41
+ const dnd = { ...ReactDnD, ...ReactDndHtml5Backend };
42
+ const controlElements = {
43
+ addRuleAction: RuleAddButton,
44
+ addGroupAction: GroupAddButton,
45
+ combinatorSelector: CombinatorSelector,
46
+ removeRuleAction: RemoveButton,
47
+ removeGroupAction: RemoveButton,
48
+ valueEditor: ValueEditor,
49
+ operatorSelector: OperatorSelector,
50
+ fieldSelector: FieldSelector,
51
+ valueSourceSelector: ValueSelector
52
+ };
53
+ const accessibleDescriptionGenerator = () => "";
54
+ const controlClassnames = {
55
+ queryBuilder: "queryBuilder-branches"
56
+ };
41
57
  function CustomReactQueryBuilder(props) {
42
58
  const { name, fields } = props;
43
59
  const {
@@ -49,6 +65,7 @@ function CustomReactQueryBuilder(props) {
49
65
  } = useFormContext();
50
66
  const intl = useIntl();
51
67
  const query = watch(name);
68
+ const getOperatorsMemo = useCallback((fieldName) => getOperators(fieldName, intl), [intl]);
52
69
  const handleQueryChange = useCallback(
53
70
  (newQuery) => {
54
71
  const oldQuery = getValues(name);
@@ -68,7 +85,7 @@ function CustomReactQueryBuilder(props) {
68
85
  }));
69
86
  }, [intl]);
70
87
  return /* @__PURE__ */ jsxs(Fragment, { children: [
71
- /* @__PURE__ */ jsx(QueryBuilderMaterial, { children: /* @__PURE__ */ jsx(QueryBuilderDnD, { dnd: { ...ReactDnD, ...ReactDndHtml5Backend }, children: /* @__PURE__ */ jsx(
88
+ /* @__PURE__ */ jsx(QueryBuilderMaterial, { children: /* @__PURE__ */ jsx(QueryBuilderDnD, { dnd, children: /* @__PURE__ */ jsx(
72
89
  QueryBuilder,
73
90
  {
74
91
  fields,
@@ -76,24 +93,12 @@ function CustomReactQueryBuilder(props) {
76
93
  addRuleToNewGroups: true,
77
94
  combinators,
78
95
  onQueryChange: handleQueryChange,
79
- getOperators: (fieldName) => getOperators(fieldName, intl),
96
+ getOperators: getOperatorsMemo,
80
97
  validator: queryValidator,
81
- controlClassnames: {
82
- queryBuilder: "queryBuilder-branches"
83
- },
84
- controlElements: {
85
- addRuleAction: RuleAddButton,
86
- addGroupAction: GroupAddButton,
87
- combinatorSelector: CombinatorSelector,
88
- removeRuleAction: RemoveButton,
89
- removeGroupAction: RemoveButton,
90
- valueEditor: ValueEditor,
91
- operatorSelector: OperatorSelector,
92
- fieldSelector: FieldSelector,
93
- valueSourceSelector: ValueSelector
94
- },
98
+ controlClassnames,
99
+ controlElements,
95
100
  listsAsArrays: true,
96
- accessibleDescriptionGenerator: () => "",
101
+ accessibleDescriptionGenerator,
97
102
  translations: customTranslations
98
103
  }
99
104
  ) }) }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.249.0",
3
+ "version": "0.249.1",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",