@gridsuite/commons-ui 0.132.0 → 0.132.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/filter/FilterCreationDialog.js +6 -5
- package/dist/components/filter/expert/ExpertFilterForm.d.ts +0 -1
- package/dist/components/filter/expert/ExpertFilterForm.js +10 -19
- package/dist/components/filter/expert/index.js +1 -2
- package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +7 -10
- package/dist/components/filter/index.js +1 -2
- package/dist/components/index.js +1 -2
- package/dist/index.js +1 -2
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo, useCallback } from "react";
|
|
3
3
|
import { useForm } from "react-hook-form";
|
|
4
4
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
5
5
|
import { saveExplicitNamingFilter, saveExpertFilter } from "./utils/filterApi.js";
|
|
@@ -9,7 +9,7 @@ import { getExplicitNamingFilterEmptyFormData, explicitNamingFilterSchema } from
|
|
|
9
9
|
import { FieldConstants } from "../../utils/constants/fieldConstants.js";
|
|
10
10
|
import "../../utils/yupConfig.js";
|
|
11
11
|
import { FilterForm } from "./FilterForm.js";
|
|
12
|
-
import {
|
|
12
|
+
import { getExpertFilterEmptyFormData, expertFilterSchema } from "./expert/ExpertFilterForm.js";
|
|
13
13
|
import { FilterType } from "./constants/FilterConstants.js";
|
|
14
14
|
import { MAX_CHAR_DESCRIPTION } from "../../utils/constants/uiConstants.js";
|
|
15
15
|
import { EXPERT_FILTER_QUERY } from "./expert/expertFilterConstants.js";
|
|
@@ -22,12 +22,12 @@ const emptyFormData = {
|
|
|
22
22
|
...getExplicitNamingFilterEmptyFormData(),
|
|
23
23
|
...getExpertFilterEmptyFormData()
|
|
24
24
|
};
|
|
25
|
-
const
|
|
25
|
+
const formSchemaByFilterType = (filterType) => yup.object().shape({
|
|
26
26
|
[FieldConstants.NAME]: yup.string().trim().required("nameEmpty"),
|
|
27
27
|
[FieldConstants.DESCRIPTION]: yup.string().max(MAX_CHAR_DESCRIPTION, "descriptionLimitError"),
|
|
28
28
|
[FieldConstants.EQUIPMENT_TYPE]: yup.string().required(),
|
|
29
|
-
...explicitNamingFilterSchema,
|
|
30
|
-
...expertFilterSchema
|
|
29
|
+
...(filterType == null ? void 0 : filterType.id) === FilterType.EXPLICIT_NAMING.id ? explicitNamingFilterSchema : {},
|
|
30
|
+
...(filterType == null ? void 0 : filterType.id) === FilterType.EXPERT.id ? expertFilterSchema : {}
|
|
31
31
|
}).required();
|
|
32
32
|
function FilterCreationDialog({
|
|
33
33
|
open,
|
|
@@ -39,6 +39,7 @@ function FilterCreationDialog({
|
|
|
39
39
|
}) {
|
|
40
40
|
var _a;
|
|
41
41
|
const { snackError } = useSnackMessage();
|
|
42
|
+
const formSchema = useMemo(() => formSchemaByFilterType(filterType), [filterType]);
|
|
42
43
|
const formMethods = useForm({
|
|
43
44
|
defaultValues: emptyFormData,
|
|
44
45
|
resolver: yupResolver(formSchema)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FieldType } from '../../../utils/types/fieldType';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
|
-
export declare const rqbQuerySchemaValidator: (schema: yup.Schema) => yup.Schema<any, any, any, "">;
|
|
4
3
|
export declare const expertFilterSchema: {
|
|
5
4
|
rules: yup.ObjectSchema<{}, yup.AnyObject, {}, "">;
|
|
6
5
|
};
|
|
@@ -6,11 +6,10 @@ import * as yup from "yup";
|
|
|
6
6
|
import { v4 } from "uuid";
|
|
7
7
|
import { Box } from "@mui/material";
|
|
8
8
|
import { testQuery } from "./expertFilterUtils.js";
|
|
9
|
-
import { EXPERT_FILTER_QUERY,
|
|
9
|
+
import { EXPERT_FILTER_QUERY, RULES, OPERATOR_OPTIONS, COMBINATOR_OPTIONS, EXPERT_FILTER_FIELDS, EXPERT_FILTER_EQUIPMENTS } from "./expertFilterConstants.js";
|
|
10
10
|
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
11
11
|
import { InputWithPopupConfirmation } from "../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation.js";
|
|
12
12
|
import { SelectInput } from "../../inputs/reactHookForm/selectInputs/SelectInput.js";
|
|
13
|
-
import { FilterType } from "../constants/FilterConstants.js";
|
|
14
13
|
import { CustomReactQueryBuilder } from "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
15
14
|
import { unscrollableDialogStyles } from "../../dialogs/customMuiDialog/CustomMuiDialog.js";
|
|
16
15
|
import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
@@ -39,22 +38,15 @@ yup.setLocale({
|
|
|
39
38
|
import '../../../assets/ExpertFilterForm.css';function isSupportedEquipmentType(equipmentType) {
|
|
40
39
|
return Object.values(EXPERT_FILTER_EQUIPMENTS).map((equipments) => equipments.id).includes(equipmentType);
|
|
41
40
|
}
|
|
42
|
-
const rqbQuerySchemaValidator = (schema) => schema.test(RULES.EMPTY_GROUP, RULES.EMPTY_GROUP, (query) => {
|
|
43
|
-
return testQuery(RULES.EMPTY_GROUP, query);
|
|
44
|
-
}).test(RULES.EMPTY_RULE, RULES.EMPTY_RULE, (query) => {
|
|
45
|
-
return testQuery(RULES.EMPTY_RULE, query);
|
|
46
|
-
}).test(RULES.INCORRECT_RULE, RULES.INCORRECT_RULE, (query) => {
|
|
47
|
-
return testQuery(RULES.INCORRECT_RULE, query);
|
|
48
|
-
}).test(RULES.BETWEEN_RULE, RULES.BETWEEN_RULE, (query) => {
|
|
49
|
-
return testQuery(RULES.BETWEEN_RULE, query);
|
|
50
|
-
});
|
|
51
41
|
const expertFilterSchema = {
|
|
52
|
-
[EXPERT_FILTER_QUERY]: yup.object().
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
[EXPERT_FILTER_QUERY]: yup.object().test(RULES.EMPTY_GROUP, RULES.EMPTY_GROUP, (query) => {
|
|
43
|
+
return testQuery(RULES.EMPTY_GROUP, query);
|
|
44
|
+
}).test(RULES.EMPTY_RULE, RULES.EMPTY_RULE, (query) => {
|
|
45
|
+
return testQuery(RULES.EMPTY_RULE, query);
|
|
46
|
+
}).test(RULES.INCORRECT_RULE, RULES.INCORRECT_RULE, (query) => {
|
|
47
|
+
return testQuery(RULES.INCORRECT_RULE, query);
|
|
48
|
+
}).test(RULES.BETWEEN_RULE, RULES.BETWEEN_RULE, (query) => {
|
|
49
|
+
return testQuery(RULES.BETWEEN_RULE, query);
|
|
58
50
|
})
|
|
59
51
|
};
|
|
60
52
|
const defaultQuery = {
|
|
@@ -116,6 +108,5 @@ function ExpertFilterForm() {
|
|
|
116
108
|
export {
|
|
117
109
|
ExpertFilterForm,
|
|
118
110
|
expertFilterSchema,
|
|
119
|
-
getExpertFilterEmptyFormData
|
|
120
|
-
rqbQuerySchemaValidator
|
|
111
|
+
getExpertFilterEmptyFormData
|
|
121
112
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExpertFilterEditionDialog } from "./ExpertFilterEditionDialog.js";
|
|
2
|
-
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData
|
|
2
|
+
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData } from "./ExpertFilterForm.js";
|
|
3
3
|
import { CombinatorType, DataType, OperatorType } from "./expertFilter.type.js";
|
|
4
4
|
import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXPERT_FILTER_EQUIPMENTS, EXPERT_FILTER_FIELDS, EXPERT_FILTER_QUERY, FIELDS_OPTIONS, LOAD_TYPE_OPTIONS, OPERATOR_OPTIONS, PHASE_REGULATION_MODE_OPTIONS, RATIO_REGULATION_MODE_OPTIONS, REGULATION_TYPE_OPTIONS, RULES, SHUNT_COMPENSATOR_TYPE_OPTIONS, SVAR_REGULATION_MODE_OPTIONS } from "./expertFilterConstants.js";
|
|
5
5
|
import { countRules, exportExpertRules, getFilterEquipmentTypeLabel, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./expertFilterUtils.js";
|
|
@@ -34,6 +34,5 @@ export {
|
|
|
34
34
|
importExpertRules,
|
|
35
35
|
queryValidator,
|
|
36
36
|
recursiveRemove,
|
|
37
|
-
rqbQuerySchemaValidator,
|
|
38
37
|
testQuery
|
|
39
38
|
};
|
|
@@ -12,7 +12,7 @@ import { Generator, Load } from "../../../utils/types/equipmentTypes.js";
|
|
|
12
12
|
import { NumericEditor } from "../../inputs/reactHookForm/agGridTable/cellEditors/numericEditor.js";
|
|
13
13
|
import { InputWithPopupConfirmation } from "../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation.js";
|
|
14
14
|
import { toFloatOrNullValue } from "../../inputs/reactHookForm/utils/functions.js";
|
|
15
|
-
import { DISTRIBUTION_KEY
|
|
15
|
+
import { DISTRIBUTION_KEY } from "../constants/FilterConstants.js";
|
|
16
16
|
import { FILTER_EQUIPMENTS } from "../utils/filterFormUtils.js";
|
|
17
17
|
import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
|
|
18
18
|
import { ElementType } from "../../../utils/types/elementType.js";
|
|
@@ -33,15 +33,12 @@ const explicitNamingFilterSchema = {
|
|
|
33
33
|
[FieldConstants.EQUIPMENT_ID]: yup.string().nullable(),
|
|
34
34
|
[DISTRIBUTION_KEY]: yup.number().nullable()
|
|
35
35
|
})
|
|
36
|
-
).compact((row) => !row[DISTRIBUTION_KEY] && !row[FieldConstants.EQUIPMENT_ID]).when([FieldConstants.
|
|
37
|
-
is:
|
|
38
|
-
then: (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}).test("ifOneKeyThenKeyEverywhere", "missingDistributionKeyError", (array) => {
|
|
43
|
-
return !(array.some((row) => row[DISTRIBUTION_KEY]) && array.some((row) => !row[DISTRIBUTION_KEY]));
|
|
44
|
-
})
|
|
36
|
+
).compact((row) => !row[DISTRIBUTION_KEY] && !row[FieldConstants.EQUIPMENT_ID]).min(1, "emptyFilterError").when([FieldConstants.EQUIPMENT_TYPE], {
|
|
37
|
+
is: (equipmentType) => isGeneratorOrLoad(equipmentType),
|
|
38
|
+
then: (innerSchema) => innerSchema.test("noKeyWithoutId", "distributionKeyWithMissingIdError", (array) => {
|
|
39
|
+
return !array.some((row) => !row[FieldConstants.EQUIPMENT_ID]);
|
|
40
|
+
}).test("ifOneKeyThenKeyEverywhere", "missingDistributionKeyError", (array) => {
|
|
41
|
+
return !(array.some((row) => row[DISTRIBUTION_KEY]) && array.some((row) => !row[DISTRIBUTION_KEY]));
|
|
45
42
|
})
|
|
46
43
|
})
|
|
47
44
|
};
|
|
@@ -4,7 +4,7 @@ import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./cons
|
|
|
4
4
|
import { CriteriaBasedForm } from "../contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
5
5
|
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "../contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
6
6
|
import { ExpertFilterEditionDialog } from "./expert/ExpertFilterEditionDialog.js";
|
|
7
|
-
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData
|
|
7
|
+
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData } from "./expert/ExpertFilterForm.js";
|
|
8
8
|
import { CombinatorType, DataType, OperatorType } from "./expert/expertFilter.type.js";
|
|
9
9
|
import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXPERT_FILTER_EQUIPMENTS, EXPERT_FILTER_FIELDS, EXPERT_FILTER_QUERY, FIELDS_OPTIONS, LOAD_TYPE_OPTIONS, OPERATOR_OPTIONS, PHASE_REGULATION_MODE_OPTIONS, RATIO_REGULATION_MODE_OPTIONS, REGULATION_TYPE_OPTIONS, RULES, SHUNT_COMPENSATOR_TYPE_OPTIONS, SVAR_REGULATION_MODE_OPTIONS } from "./expert/expertFilterConstants.js";
|
|
10
10
|
import { countRules, exportExpertRules, getFilterEquipmentTypeLabel, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./expert/expertFilterUtils.js";
|
|
@@ -59,7 +59,6 @@ export {
|
|
|
59
59
|
importExpertRules,
|
|
60
60
|
queryValidator,
|
|
61
61
|
recursiveRemove,
|
|
62
|
-
rqbQuerySchemaValidator,
|
|
63
62
|
saveExpertFilter,
|
|
64
63
|
saveExplicitNamingFilter,
|
|
65
64
|
testQuery
|
package/dist/components/index.js
CHANGED
|
@@ -42,7 +42,7 @@ import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./filt
|
|
|
42
42
|
import { CriteriaBasedForm } from "./contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
43
43
|
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
44
44
|
import { ExpertFilterEditionDialog } from "./filter/expert/ExpertFilterEditionDialog.js";
|
|
45
|
-
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData
|
|
45
|
+
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData } from "./filter/expert/ExpertFilterForm.js";
|
|
46
46
|
import { CombinatorType, DataType, OperatorType } from "./filter/expert/expertFilter.type.js";
|
|
47
47
|
import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXPERT_FILTER_EQUIPMENTS, EXPERT_FILTER_FIELDS, EXPERT_FILTER_QUERY, FIELDS_OPTIONS, LOAD_TYPE_OPTIONS, OPERATOR_OPTIONS, PHASE_REGULATION_MODE_OPTIONS, RATIO_REGULATION_MODE_OPTIONS, REGULATION_TYPE_OPTIONS, RULES, SHUNT_COMPENSATOR_TYPE_OPTIONS, SVAR_REGULATION_MODE_OPTIONS } from "./filter/expert/expertFilterConstants.js";
|
|
48
48
|
import { countRules, exportExpertRules, getFilterEquipmentTypeLabel, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./filter/expert/expertFilterUtils.js";
|
|
@@ -516,7 +516,6 @@ export {
|
|
|
516
516
|
logout,
|
|
517
517
|
queryValidator,
|
|
518
518
|
recursiveRemove,
|
|
519
|
-
rqbQuerySchemaValidator,
|
|
520
519
|
sanitizePercentageValue,
|
|
521
520
|
saveExpertFilter,
|
|
522
521
|
saveExplicitNamingFilter,
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./comp
|
|
|
43
43
|
import { CriteriaBasedForm } from "./components/contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
44
44
|
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./components/contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
45
45
|
import { ExpertFilterEditionDialog } from "./components/filter/expert/ExpertFilterEditionDialog.js";
|
|
46
|
-
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData
|
|
46
|
+
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData } from "./components/filter/expert/ExpertFilterForm.js";
|
|
47
47
|
import { CombinatorType, DataType, OperatorType } from "./components/filter/expert/expertFilter.type.js";
|
|
48
48
|
import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXPERT_FILTER_EQUIPMENTS, EXPERT_FILTER_FIELDS, EXPERT_FILTER_QUERY, FIELDS_OPTIONS, LOAD_TYPE_OPTIONS, OPERATOR_OPTIONS, PHASE_REGULATION_MODE_OPTIONS, RATIO_REGULATION_MODE_OPTIONS, REGULATION_TYPE_OPTIONS, RULES, SHUNT_COMPENSATOR_TYPE_OPTIONS, SVAR_REGULATION_MODE_OPTIONS } from "./components/filter/expert/expertFilterConstants.js";
|
|
49
49
|
import { countRules, exportExpertRules, getFilterEquipmentTypeLabel, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./components/filter/expert/expertFilterUtils.js";
|
|
@@ -804,7 +804,6 @@ export {
|
|
|
804
804
|
resetAuthenticationRouterError,
|
|
805
805
|
roundToDefaultPrecision,
|
|
806
806
|
roundToPrecision,
|
|
807
|
-
rqbQuerySchemaValidator,
|
|
808
807
|
safeEncodeURIComponent,
|
|
809
808
|
sanitizePercentageValue,
|
|
810
809
|
saveExpertFilter,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridsuite/commons-ui",
|
|
3
|
-
"version": "0.132.
|
|
3
|
+
"version": "0.132.1",
|
|
4
4
|
"description": "common react components for gridsuite applications",
|
|
5
5
|
"author": "gridsuite team",
|
|
6
6
|
"homepage": "https://github.com/gridsuite",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@ag-grid-community/locale": "^33.3.2",
|
|
38
38
|
"@hello-pangea/dnd": "^18.0.1",
|
|
39
39
|
"@material-symbols/svg-400": "^0.31.9",
|
|
40
|
-
"@react-querybuilder/dnd": "^8.
|
|
41
|
-
"@react-querybuilder/material": "^8.
|
|
40
|
+
"@react-querybuilder/dnd": "^8.11.0",
|
|
41
|
+
"@react-querybuilder/material": "^8.11.0",
|
|
42
42
|
"autosuggest-highlight": "^3.3.4",
|
|
43
43
|
"clsx": "^2.1.1",
|
|
44
44
|
"jwt-decode": "^4.0.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-csv-downloader": "^3.3.0",
|
|
50
50
|
"react-dnd": "^16.0.1",
|
|
51
51
|
"react-dnd-html5-backend": "^16.0.1",
|
|
52
|
-
"react-querybuilder": "^8.
|
|
52
|
+
"react-querybuilder": "^8.11.0",
|
|
53
53
|
"reconnecting-websocket": "^4.4.0",
|
|
54
54
|
"type-fest": "^4.41.0",
|
|
55
55
|
"uuid": "^13.0.0"
|