@gridsuite/commons-ui 0.72.0 → 0.72.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.
@@ -2,6 +2,9 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import DragIndicatorIcon from "@mui/icons-material/DragIndicator";
3
3
  import { ListItemButton, IconButton, ListItemIcon, Checkbox, ListItemText } from "@mui/material";
4
4
  import { OverflowableText } from "../overflowableText/OverflowableText.js";
5
+ import "@mui/icons-material";
6
+ import { mergeSx } from "../../utils/styles.js";
7
+ import "../../utils/yupConfig.js";
5
8
  const styles = {
6
9
  dragIcon: (theme) => ({
7
10
  padding: "unset",
@@ -36,11 +39,7 @@ function DraggableClickableRowItem({
36
39
  ListItemButton,
37
40
  {
38
41
  disableTouchRipple: !isItemClickable,
39
- sx: {
40
- paddingLeft: 0,
41
- ...sx == null ? void 0 : sx.checkboxButton,
42
- ...!isItemClickable && styles.unclickableItem
43
- },
42
+ sx: mergeSx({ paddingLeft: 0 }, sx == null ? void 0 : sx.checkboxButton, !isItemClickable ? styles.unclickableItem : void 0),
44
43
  disabled,
45
44
  onClick: handleItemClick,
46
45
  children: [
@@ -1,14 +1,14 @@
1
1
  import { MergedFormContextProps } from '../../inputs/reactHookForm/provider/CustomFormProvider';
2
- import { FieldErrors, UseFormReturn } from 'react-hook-form';
2
+ import { FieldErrors, FieldValues, SubmitHandler, UseFormReturn } from 'react-hook-form';
3
3
  import { default as React } from 'react';
4
4
 
5
5
  import * as yup from 'yup';
6
- export interface CustomMuiDialogProps {
6
+ export interface CustomMuiDialogProps<T extends FieldValues = FieldValues> {
7
7
  open: boolean;
8
8
  formSchema: yup.AnySchema;
9
- formMethods: UseFormReturn<any> | MergedFormContextProps;
10
- onClose: (event: React.MouseEvent) => void;
11
- onSave: (data: any) => void;
9
+ formMethods: UseFormReturn<T> | MergedFormContextProps;
10
+ onClose: (event?: React.MouseEvent) => void;
11
+ onSave: SubmitHandler<T>;
12
12
  onValidationError?: (errors: FieldErrors) => void;
13
13
  titleId: string;
14
14
  disabledSave?: boolean;
@@ -52,4 +52,4 @@ export declare const unscrollableDialogStyles: {
52
52
  padding: number;
53
53
  };
54
54
  };
55
- export declare function CustomMuiDialog({ open, formSchema, formMethods, onClose, onSave, isDataFetching, onValidationError, titleId, disabledSave, removeOptional, onCancel, children, language, confirmationMessageKey, unscrollableFullHeight, }: Readonly<CustomMuiDialogProps>): import("react/jsx-runtime").JSX.Element;
55
+ export declare function CustomMuiDialog<T extends FieldValues = FieldValues>({ open, formSchema, formMethods, onClose, onSave, isDataFetching, onValidationError, titleId, disabledSave, removeOptional, onCancel, children, language, confirmationMessageKey, unscrollableFullHeight, }: Readonly<CustomMuiDialogProps<T>>): import("react/jsx-runtime").JSX.Element;
@@ -56,7 +56,7 @@ function CustomMuiDialog({
56
56
  unscrollableFullHeight = false
57
57
  }) {
58
58
  const [openConfirmationPopup, setOpenConfirmationPopup] = useState(false);
59
- const [validatedData, setValidatedData] = useState(void 0);
59
+ const [validatedData, setValidatedData] = useState();
60
60
  const { handleSubmit } = formMethods;
61
61
  const handleCancel = useCallback(
62
62
  (event) => {
@@ -74,7 +74,7 @@ function CustomMuiDialog({
74
74
  const validate = useCallback(
75
75
  (data) => {
76
76
  onSave(data);
77
- onClose(data);
77
+ onClose();
78
78
  },
79
79
  [onClose, onSave]
80
80
  );
@@ -91,7 +91,9 @@ function CustomMuiDialog({
91
91
  );
92
92
  const handlePopupConfirmation = useCallback(() => {
93
93
  setOpenConfirmationPopup(false);
94
- validate(validatedData);
94
+ if (validatedData) {
95
+ validate(validatedData);
96
+ }
95
97
  }, [validate, validatedData]);
96
98
  const handleValidationError = (errors) => {
97
99
  onValidationError == null ? void 0 : onValidationError(errors);
@@ -36,13 +36,16 @@ function DescriptionModificationDialog({
36
36
  };
37
37
  const onSubmit = useCallback(
38
38
  (data) => {
39
+ var _a;
39
40
  updateElement(elementUuid, {
40
- [FieldConstants.DESCRIPTION]: data[FieldConstants.DESCRIPTION].trim()
41
+ [FieldConstants.DESCRIPTION]: ((_a = data[FieldConstants.DESCRIPTION]) == null ? void 0 : _a.trim()) ?? ""
41
42
  }).catch((error) => {
42
- snackError({
43
- messageTxt: error.message,
44
- headerId: "descriptionModificationError"
45
- });
43
+ if (error instanceof Object && "message" in error && typeof error.message === "string") {
44
+ snackError({
45
+ messageTxt: error.message,
46
+ headerId: "descriptionModificationError"
47
+ });
48
+ }
46
49
  });
47
50
  },
48
51
  [elementUuid, updateElement, snackError]
@@ -13,14 +13,14 @@ const styles = {
13
13
  height: "18px"
14
14
  })
15
15
  };
16
- function sameRights(a, b) {
17
- if (!a && !b) {
16
+ function sameRights(sourceAccessRights, accessRightsToCompare) {
17
+ if (!sourceAccessRights && !accessRightsToCompare) {
18
18
  return true;
19
19
  }
20
- if (!a || !b) {
20
+ if (!sourceAccessRights || !accessRightsToCompare) {
21
21
  return false;
22
22
  }
23
- return a.isPrivate === b.isPrivate;
23
+ return sourceAccessRights.isPrivate === accessRightsToCompare.isPrivate;
24
24
  }
25
25
  function flattenDownNodes(n, cef) {
26
26
  const subs = cef(n);
@@ -29,17 +29,17 @@ function flattenDownNodes(n, cef) {
29
29
  }
30
30
  return Array.prototype.concat([n], ...subs.map((sn) => flattenDownNodes(sn, cef)));
31
31
  }
32
- function refreshedUpNodes(m, nn) {
33
- if (!(nn == null ? void 0 : nn.elementUuid)) {
32
+ function refreshedUpNodes(nodeMap, newElement) {
33
+ if (!(newElement == null ? void 0 : newElement.elementUuid)) {
34
34
  return [];
35
35
  }
36
- if (nn.parentUuid === null) {
37
- return [nn];
36
+ if (newElement.parentUuid === null) {
37
+ return [newElement];
38
38
  }
39
- const parent = m[nn.parentUuid];
40
- const nextChildren = parent.children.map((c) => c.elementUuid === nn.elementUuid ? nn : c);
39
+ const parent = nodeMap[newElement.parentUuid];
40
+ const nextChildren = parent.children.map((c) => c.elementUuid === newElement.elementUuid ? newElement : c);
41
41
  const nextParent = { ...parent, children: nextChildren };
42
- return [nn, ...refreshedUpNodes(m, nextParent)];
42
+ return [newElement, ...refreshedUpNodes(nodeMap, nextParent)];
43
43
  }
44
44
  function updatedTree(prevRoots, prevMap, nodeId, children) {
45
45
  var _a;
@@ -16,7 +16,7 @@ import * as yup from "yup";
16
16
  const emptyFormData = {
17
17
  [FieldConstants.NAME]: "",
18
18
  [FieldConstants.DESCRIPTION]: "",
19
- [FieldConstants.FILTER_TYPE]: FilterType.CRITERIA_BASED.id,
19
+ [FieldConstants.FILTER_TYPE]: FilterType.EXPERT.id,
20
20
  [FieldConstants.EQUIPMENT_TYPE]: null,
21
21
  ...criteriaBasedFilterEmptyFormData,
22
22
  ...getExplicitNamingFilterEmptyFormData(),
@@ -13,6 +13,7 @@ function HeaderFilterForm({
13
13
  elementExists,
14
14
  handleFilterTypeChange
15
15
  }) {
16
+ const filterTypes = Object.values(FilterType).filter((value) => value.id !== "CRITERIA");
16
17
  return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
17
18
  /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
18
19
  UniqueNameInput,
@@ -31,7 +32,7 @@ function HeaderFilterForm({
31
32
  RadioInput,
32
33
  {
33
34
  name: FieldConstants.FILTER_TYPE,
34
- options: Object.values(FilterType),
35
+ options: filterTypes,
35
36
  formProps: { onChange: handleFilterTypeChange }
36
37
  }
37
38
  ) })
@@ -2,12 +2,20 @@ import { default as yup } from '../../../utils/yupConfig';
2
2
 
3
3
  export declare const criteriaBasedFilterSchema: {
4
4
  criteriaBased: yup.ObjectSchema<{
5
- [x: string]: any;
5
+ countries: (string | undefined)[] | undefined;
6
+ countries1: (string | undefined)[] | undefined;
7
+ countries2: (string | undefined)[] | undefined;
6
8
  }, yup.AnyObject, {
7
- [x: string]: any;
9
+ countries: "";
10
+ countries1: "";
11
+ countries2: "";
8
12
  }, "">;
9
13
  };
10
14
  export declare const criteriaBasedFilterEmptyFormData: {
11
- criteriaBased: any;
15
+ criteriaBased: {
16
+ countries: any;
17
+ countries1: any;
18
+ countries2: any;
19
+ };
12
20
  };
13
21
  export declare function CriteriaBasedFilterForm(): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,22 @@
1
1
  import { default as yup } from '../../../utils/yupConfig';
2
2
 
3
- export declare const getCriteriaBasedSchema: (extraFields: any) => {
3
+ export declare const getCriteriaBasedSchema: (extraFields: Record<string, yup.AnyObject | null>) => {
4
4
  criteriaBased: yup.ObjectSchema<{
5
- [x: string]: any;
5
+ countries: (string | undefined)[] | undefined;
6
+ countries1: (string | undefined)[] | undefined;
7
+ countries2: (string | undefined)[] | undefined;
6
8
  }, yup.AnyObject, {
7
- [x: string]: any;
9
+ countries: "";
10
+ countries1: "";
11
+ countries2: "";
8
12
  }, "">;
9
13
  };
10
- export declare const getCriteriaBasedFormData: (criteriaValues: any, extraFields: any) => {
11
- criteriaBased: any;
14
+ export declare const getCriteriaBasedFormData: (criteriaValues: any, extraFields: Record<string, yup.AnyObject | null>) => {
15
+ criteriaBased: {
16
+ countries: any;
17
+ countries1: any;
18
+ countries2: any;
19
+ };
12
20
  };
13
21
  /**
14
22
  * Transform
@@ -22,7 +30,11 @@ export declare const getCriteriaBasedFormData: (criteriaValues: any, extraFields
22
30
  * @author Laurent LAUGARN modified by Florent MILLOT
23
31
  */
24
32
  export declare const backToFrontTweak: (response: any) => {
25
- criteriaBased: any;
33
+ criteriaBased: {
34
+ countries: any;
35
+ countries1: any;
36
+ countries2: any;
37
+ };
26
38
  equipmentType: any;
27
39
  };
28
40
  /**
@@ -129,7 +129,6 @@ export declare enum FieldType {
129
129
  SUBSTATION_PROPERTY = "SUBSTATION_PROPERTIES",
130
130
  SUBSTATION_PROPERTY_1 = "SUBSTATION_PROPERTIES_1",
131
131
  SUBSTATION_PROPERTY_2 = "SUBSTATION_PROPERTIES_2",
132
- SUBSTATION_PROPERTY_3 = "SUBSTATION_PROPERTIES_3",
133
132
  VOLTAGE_LEVEL_PROPERTY = "VOLTAGE_LEVEL_PROPERTIES",
134
133
  VOLTAGE_LEVEL_PROPERTY_1 = "VOLTAGE_LEVEL_PROPERTIES_1",
135
134
  VOLTAGE_LEVEL_PROPERTY_2 = "VOLTAGE_LEVEL_PROPERTIES_2",
@@ -128,7 +128,6 @@ var FieldType = /* @__PURE__ */ ((FieldType2) => {
128
128
  FieldType2["SUBSTATION_PROPERTY"] = "SUBSTATION_PROPERTIES";
129
129
  FieldType2["SUBSTATION_PROPERTY_1"] = "SUBSTATION_PROPERTIES_1";
130
130
  FieldType2["SUBSTATION_PROPERTY_2"] = "SUBSTATION_PROPERTIES_2";
131
- FieldType2["SUBSTATION_PROPERTY_3"] = "SUBSTATION_PROPERTIES_3";
132
131
  FieldType2["VOLTAGE_LEVEL_PROPERTY"] = "VOLTAGE_LEVEL_PROPERTIES";
133
132
  FieldType2["VOLTAGE_LEVEL_PROPERTY_1"] = "VOLTAGE_LEVEL_PROPERTIES_1";
134
133
  FieldType2["VOLTAGE_LEVEL_PROPERTY_2"] = "VOLTAGE_LEVEL_PROPERTIES_2";
@@ -870,13 +870,6 @@ export declare const FIELDS_OPTIONS: {
870
870
  valueEditorType: string;
871
871
  defaultValue: string;
872
872
  };
873
- SUBSTATION_PROPERTY_3: {
874
- name: FieldType;
875
- label: string;
876
- dataType: DataType;
877
- valueEditorType: string;
878
- defaultValue: string;
879
- };
880
873
  VOLTAGE_LEVEL_PROPERTY: {
881
874
  name: FieldType;
882
875
  label: string;
@@ -830,13 +830,6 @@ const FIELDS_OPTIONS = {
830
830
  valueEditorType: "select",
831
831
  defaultValue: ""
832
832
  },
833
- SUBSTATION_PROPERTY_3: {
834
- name: FieldType.SUBSTATION_PROPERTY_3,
835
- label: "substationProperty3Twt",
836
- dataType: DataType.PROPERTY,
837
- valueEditorType: "select",
838
- defaultValue: ""
839
- },
840
833
  VOLTAGE_LEVEL_PROPERTY: {
841
834
  name: FieldType.VOLTAGE_LEVEL_PROPERTY,
842
835
  label: "voltageLevelProperty",
@@ -1095,8 +1088,7 @@ const EXPERT_FILTER_FIELDS = {
1095
1088
  FIELDS_OPTIONS.PHASE_REGULATION_MODE,
1096
1089
  FIELDS_OPTIONS.PHASE_REGULATION_VALUE,
1097
1090
  FIELDS_OPTIONS.PROPERTY,
1098
- FIELDS_OPTIONS.SUBSTATION_PROPERTY_1,
1099
- FIELDS_OPTIONS.SUBSTATION_PROPERTY_2,
1091
+ FIELDS_OPTIONS.SUBSTATION_PROPERTY,
1100
1092
  FIELDS_OPTIONS.VOLTAGE_LEVEL_PROPERTY_1,
1101
1093
  FIELDS_OPTIONS.VOLTAGE_LEVEL_PROPERTY_2
1102
1094
  ],
@@ -1178,15 +1170,7 @@ const EXPERT_FILTER_FIELDS = {
1178
1170
  FIELDS_OPTIONS.PHASE_REGULATION_MODE_2,
1179
1171
  FIELDS_OPTIONS.PHASE_REGULATION_MODE_3,
1180
1172
  FIELDS_OPTIONS.PROPERTY,
1181
- {
1182
- ...FIELDS_OPTIONS.SUBSTATION_PROPERTY_1,
1183
- label: `${FIELDS_OPTIONS.SUBSTATION_PROPERTY_1.label}Twt`
1184
- },
1185
- {
1186
- ...FIELDS_OPTIONS.SUBSTATION_PROPERTY_2,
1187
- label: `${FIELDS_OPTIONS.SUBSTATION_PROPERTY_2.label}Twt`
1188
- },
1189
- FIELDS_OPTIONS.SUBSTATION_PROPERTY_3,
1173
+ FIELDS_OPTIONS.SUBSTATION_PROPERTY,
1190
1174
  {
1191
1175
  ...FIELDS_OPTIONS.VOLTAGE_LEVEL_PROPERTY_1,
1192
1176
  label: `${FIELDS_OPTIONS.VOLTAGE_LEVEL_PROPERTY_1.label}Twt`
@@ -72,7 +72,7 @@ function ExplicitNamingFilterEditionDialog({
72
72
  const onSubmit = useCallback(
73
73
  (filterForm) => {
74
74
  saveExplicitNamingFilter(
75
- filterForm[FILTER_EQUIPMENTS_ATTRIBUTES],
75
+ filterForm[FILTER_EQUIPMENTS_ATTRIBUTES] ?? [],
76
76
  false,
77
77
  filterForm[FieldConstants.EQUIPMENT_TYPE],
78
78
  filterForm[FieldConstants.NAME],
@@ -1,5 +1,5 @@
1
1
  import { UUID } from 'crypto';
2
2
 
3
- export declare const saveExplicitNamingFilter: (tableValues: any[], isFilterCreation: boolean, equipmentType: string, name: string, description: string, id: string | null, setCreateFilterErr: (value: any) => void, handleClose: () => void, activeDirectory?: UUID, token?: string) => void;
3
+ export declare const saveExplicitNamingFilter: (tableValues: any[], isFilterCreation: boolean, equipmentType: string, name: string, description: string, id: string | null, setCreateFilterErr: (value?: string) => void, handleClose: () => void, activeDirectory?: UUID, token?: string) => void;
4
4
  export declare const saveCriteriaBasedFilter: (filter: any, activeDirectory: any, onClose: () => void, onError: (message: string) => void, token?: string) => void;
5
5
  export declare const saveExpertFilter: (id: string | null, query: any, equipmentType: string, name: string, description: string, isFilterCreation: boolean, activeDirectory: any, onClose: () => void, onError: (message: string) => void, token?: string) => void;
@@ -80,7 +80,7 @@ function ValueEditor(props) {
80
80
  }
81
81
  if (fieldData.dataType === DataType.PROPERTY) {
82
82
  let equipmentType;
83
- if (field === FieldType.SUBSTATION_PROPERTY || field === FieldType.SUBSTATION_PROPERTY_1 || field === FieldType.SUBSTATION_PROPERTY_2 || field === FieldType.SUBSTATION_PROPERTY_3) {
83
+ if (field === FieldType.SUBSTATION_PROPERTY || field === FieldType.SUBSTATION_PROPERTY_1 || field === FieldType.SUBSTATION_PROPERTY_2) {
84
84
  equipmentType = Substation.type;
85
85
  } else if (field === FieldType.VOLTAGE_LEVEL_PROPERTY || field === FieldType.VOLTAGE_LEVEL_PROPERTY_1 || field === FieldType.VOLTAGE_LEVEL_PROPERTY_2 || field === FieldType.VOLTAGE_LEVEL_PROPERTY_3) {
86
86
  equipmentType = VoltageLevel.type;
@@ -94,7 +94,6 @@ export declare const filterExpertEn: {
94
94
  substationProperty2: string;
95
95
  substationProperty1Twt: string;
96
96
  substationProperty2Twt: string;
97
- substationProperty3Twt: string;
98
97
  ratedVoltage1KV: string;
99
98
  ratedVoltage2KV: string;
100
99
  ratedVoltage0KVTwt: string;
@@ -88,7 +88,6 @@ const filterExpertEn = {
88
88
  substationProperty2: "Substation property 2",
89
89
  substationProperty1Twt: "Substation property 1",
90
90
  substationProperty2Twt: "Substation property 2",
91
- substationProperty3Twt: "Substation property 3",
92
91
  ratedVoltage1KV: "Rated Voltage 1 (kV)",
93
92
  ratedVoltage2KV: "Rated Voltage 2 (kV)",
94
93
  ratedVoltage0KVTwt: "Rated Voltage 0 (kV)",
@@ -94,7 +94,6 @@ export declare const filterExpertFr: {
94
94
  substationProperty2: string;
95
95
  substationProperty1Twt: string;
96
96
  substationProperty2Twt: string;
97
- substationProperty3Twt: string;
98
97
  ratedVoltage1KV: string;
99
98
  ratedVoltage2KV: string;
100
99
  ratedVoltage0KVTwt: string;
@@ -88,7 +88,6 @@ const filterExpertFr = {
88
88
  substationProperty2: "Propriété site 2",
89
89
  substationProperty1Twt: "Propriété site 1",
90
90
  substationProperty2Twt: "Propriété site 2",
91
- substationProperty3Twt: "Propriété site 3",
92
91
  ratedVoltage1KV: "Tension d'enroulement 1 (kV)",
93
92
  ratedVoltage2KV: "Tension d'enroulement 2 (kV)",
94
93
  ratedVoltage0KVTwt: "Tension d'enroulement 0 (kV)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.72.0",
3
+ "version": "0.72.1",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": ">=9",