@gridsuite/commons-ui 0.76.2 → 0.77.0

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.
Files changed (45) hide show
  1. package/dist/components/checkBoxList/DraggableClickableRowItem.js +1 -0
  2. package/dist/components/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js +2 -1
  3. package/dist/components/dialogs/modifyElementSelection/ModifyElementSelection.js +14 -27
  4. package/dist/components/filter/FilterCreationDialog.js +2 -1
  5. package/dist/components/filter/HeaderFilterForm.d.ts +7 -0
  6. package/dist/components/filter/HeaderFilterForm.js +14 -4
  7. package/dist/components/filter/constants/FilterConstants.d.ts +2 -2
  8. package/dist/components/filter/constants/FilterConstants.js +2 -2
  9. package/dist/components/filter/expert/ExpertFilterEditionDialog.d.ts +2 -20
  10. package/dist/components/filter/expert/ExpertFilterEditionDialog.js +7 -7
  11. package/dist/components/filter/expert/ExpertFilterForm.d.ts +1 -1
  12. package/dist/components/filter/expert/ExpertFilterForm.js +1 -1
  13. package/dist/components/filter/expert/expertFilter.type.d.ts +1 -136
  14. package/dist/components/filter/expert/expertFilter.type.js +0 -138
  15. package/dist/components/filter/expert/expertFilterConstants.d.ts +2 -1
  16. package/dist/components/filter/expert/expertFilterConstants.js +2 -1
  17. package/dist/components/filter/expert/expertFilterUtils.js +7 -37
  18. package/dist/components/filter/expert/index.js +1 -2
  19. package/dist/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.d.ts +2 -18
  20. package/dist/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js +7 -7
  21. package/dist/components/filter/filter.type.d.ts +18 -0
  22. package/dist/components/filter/index.js +1 -2
  23. package/dist/components/filter/utils/filterApi.js +2 -0
  24. package/dist/components/index.js +1 -2
  25. package/dist/components/inputs/reactHookForm/text/DescriptionField.js +4 -3
  26. package/dist/components/inputs/reactQueryBuilder/ValueEditor.js +2 -1
  27. package/dist/components/notifications/NotificationsProvider.d.ts +1 -1
  28. package/dist/components/notifications/NotificationsProvider.js +6 -5
  29. package/dist/components/notifications/hooks/useListenerManager.d.ts +1 -1
  30. package/dist/index.js +7 -2
  31. package/dist/services/appsMetadata.d.ts +2 -1
  32. package/dist/services/explore.d.ts +1 -1
  33. package/dist/services/explore.js +2 -1
  34. package/dist/utils/constants/index.d.ts +1 -0
  35. package/dist/utils/constants/index.js +3 -1
  36. package/dist/utils/constants/uiConstants.d.ts +1 -0
  37. package/dist/utils/constants/uiConstants.js +4 -0
  38. package/dist/utils/conversionUtils.d.ts +8 -10
  39. package/dist/utils/conversionUtils.js +58 -4
  40. package/dist/utils/index.js +7 -1
  41. package/dist/utils/types/fieldType.d.ts +169 -0
  42. package/dist/utils/types/fieldType.js +167 -0
  43. package/dist/utils/types/index.d.ts +1 -0
  44. package/dist/utils/types/index.js +2 -0
  45. package/package.json +1 -1
@@ -1,15 +1,9 @@
1
1
  import { defaultOperators, getParentPath, findPath, remove } from "react-querybuilder";
2
2
  import { validate } from "uuid";
3
- import { FieldType, DataType } from "./expertFilter.type.js";
3
+ import { DataType } from "./expertFilter.type.js";
4
4
  import { FIELDS_OPTIONS, OPERATOR_OPTIONS, RULES } from "./expertFilterConstants.js";
5
- import { isBlankOrEmpty, microUnitToUnit, kiloUnitToUnit, unitToMicroUnit, unitToKiloUnit } from "../../../utils/conversionUtils.js";
6
- const microUnits = [
7
- FieldType.SHUNT_CONDUCTANCE_1,
8
- FieldType.SHUNT_CONDUCTANCE_2,
9
- FieldType.SHUNT_SUSCEPTANCE_1,
10
- FieldType.SHUNT_SUSCEPTANCE_2
11
- ];
12
- const kiloUnits = [FieldType.HIGH_SHORT_CIRCUIT_CURRENT_LIMIT, FieldType.LOW_SHORT_CIRCUIT_CURRENT_LIMIT];
5
+ import { convertOutputValue, isBlankOrEmpty, convertInputValue } from "../../../utils/conversionUtils.js";
6
+ import { FieldType } from "../../../utils/types/fieldType.js";
13
7
  const searchTree = (tree, key, value) => {
14
8
  const stack = Object.values(tree);
15
9
  while (stack.length) {
@@ -125,21 +119,6 @@ const getOperators = (fieldName, intl) => {
125
119
  return defaultOperators;
126
120
  }
127
121
  };
128
- function changeValueUnit(value, field) {
129
- if (microUnits.includes(field)) {
130
- if (!Array.isArray(value)) {
131
- return microUnitToUnit(value);
132
- }
133
- return value.map((a) => microUnitToUnit(a));
134
- }
135
- if (kiloUnits.includes(field)) {
136
- if (!Array.isArray(value)) {
137
- return kiloUnitToUnit(value);
138
- }
139
- return value.map((a) => kiloUnitToUnit(a));
140
- }
141
- return value;
142
- }
143
122
  function exportExpertRules(query) {
144
123
  function transformRule(rule) {
145
124
  var _a;
@@ -152,8 +131,8 @@ function exportExpertRules(query) {
152
131
  id: rule.id,
153
132
  field: rule.field,
154
133
  operator: dataType !== DataType.PROPERTY ? (_a = Object.values(OPERATOR_OPTIONS).find((operator) => operator.name === rule.operator)) == null ? void 0 : _a.customName : rule.value.propertyOperator,
155
- value: !isValueAnArray && rule.operator !== OPERATOR_OPTIONS.EXISTS.name && rule.operator !== OPERATOR_OPTIONS.NOT_EXISTS.name && dataType !== DataType.PROPERTY ? changeValueUnit(rule.value, rule.field) : void 0,
156
- values: isValueAnArray && dataType !== DataType.PROPERTY ? changeValueUnit(rule.value, rule.field) : void 0,
134
+ value: !isValueAnArray && rule.operator !== OPERATOR_OPTIONS.EXISTS.name && rule.operator !== OPERATOR_OPTIONS.NOT_EXISTS.name && dataType !== DataType.PROPERTY ? convertOutputValue(rule.field, rule.value) : void 0,
135
+ values: isValueAnArray && dataType !== DataType.PROPERTY ? convertOutputValue(rule.field, rule.value) : void 0,
157
136
  dataType,
158
137
  propertyName: dataType === DataType.PROPERTY ? rule.value.propertyName : void 0,
159
138
  propertyValues: dataType === DataType.PROPERTY ? rule.value.propertyValues : void 0
@@ -207,20 +186,11 @@ function importExpertRules(query) {
207
186
  }
208
187
  if (rule.values) {
209
188
  if (rule.dataType === DataType.NUMBER) {
210
- return rule.values.map((value) => parseFloat(value)).map((numberValue) => {
211
- return microUnits.includes(rule.field) ? unitToMicroUnit(numberValue) : numberValue;
212
- }).map((numberValue) => {
213
- return kiloUnits.includes(rule.field) ? unitToKiloUnit(numberValue) : numberValue;
214
- }).sort((a, b) => a - b);
189
+ return rule.values.map((value) => parseFloat(value)).map((numberValue) => convertInputValue(rule.field, numberValue)).sort((a, b) => a - b);
215
190
  }
216
191
  return rule.values.sort();
217
192
  }
218
- if (microUnits.includes(rule.field)) {
219
- return unitToMicroUnit(parseFloat(rule.value));
220
- }
221
- if (kiloUnits.includes(rule.field)) {
222
- return unitToKiloUnit(parseFloat(rule.value));
223
- }
193
+ convertInputValue(rule.field, parseFloat(rule.value));
224
194
  return rule.value;
225
195
  }
226
196
  function transformRule(rule) {
@@ -1,6 +1,6 @@
1
1
  import { ExpertFilterEditionDialog } from "./ExpertFilterEditionDialog.js";
2
2
  import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./ExpertFilterForm.js";
3
- import { CombinatorType, DataType, FieldType, OperatorType } from "./expertFilter.type.js";
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, 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, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./expertFilterUtils.js";
6
6
  export {
@@ -15,7 +15,6 @@ export {
15
15
  ExpertFilterEditionDialog,
16
16
  ExpertFilterForm,
17
17
  FIELDS_OPTIONS,
18
- FieldType,
19
18
  LOAD_TYPE_OPTIONS,
20
19
  OPERATOR_OPTIONS,
21
20
  OperatorType,
@@ -1,19 +1,3 @@
1
- import { ItemSelectionForCopy } from '../filter.type';
2
- import { ElementExistsType } from '../../../utils/types/elementType';
3
- import { UUID } from 'crypto';
1
+ import { FilterEditionProps } from '../filter.type';
4
2
 
5
- export interface ExplicitNamingFilterEditionDialogProps {
6
- id: string;
7
- name: string;
8
- titleId: string;
9
- open: boolean;
10
- onClose: () => void;
11
- broadcastChannel: BroadcastChannel;
12
- itemSelectionForCopy: ItemSelectionForCopy;
13
- setItemSelectionForCopy: (selection: ItemSelectionForCopy) => void;
14
- getFilterById: (id: string) => Promise<any>;
15
- activeDirectory?: UUID;
16
- elementExists?: ElementExistsType;
17
- language?: string;
18
- }
19
- export declare function ExplicitNamingFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, itemSelectionForCopy, setItemSelectionForCopy, getFilterById, activeDirectory, elementExists, language, }: Readonly<ExplicitNamingFilterEditionDialogProps>): import("react/jsx-runtime").JSX.Element;
3
+ export declare function ExplicitNamingFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, itemSelectionForCopy, setItemSelectionForCopy, getFilterById, activeDirectory, elementExists, language, description, }: Readonly<FilterEditionProps>): import("react/jsx-runtime").JSX.Element;
@@ -13,11 +13,10 @@ import { explicitNamingFilterSchema, FILTER_EQUIPMENTS_ATTRIBUTES } from "./Expl
13
13
  import { FetchStatus } from "../../../utils/constants/fetchStatus.js";
14
14
  import { FilterForm } from "../FilterForm.js";
15
15
  import { FilterType, NO_ITEM_SELECTION_FOR_COPY } from "../constants/FilterConstants.js";
16
+ import { HeaderFilterSchema } from "../HeaderFilterForm.js";
16
17
  import * as yup from "yup";
17
18
  const formSchema = yup.object().shape({
18
- [FieldConstants.NAME]: yup.string().trim().required("nameEmpty"),
19
- [FieldConstants.FILTER_TYPE]: yup.string().required(),
20
- [FieldConstants.EQUIPMENT_TYPE]: yup.string().required(),
19
+ ...HeaderFilterSchema,
21
20
  ...explicitNamingFilterSchema
22
21
  }).required();
23
22
  function ExplicitNamingFilterEditionDialog({
@@ -32,7 +31,8 @@ function ExplicitNamingFilterEditionDialog({
32
31
  getFilterById,
33
32
  activeDirectory,
34
33
  elementExists,
35
- language
34
+ language,
35
+ description
36
36
  }) {
37
37
  var _a;
38
38
  const { snackError } = useSnackMessage();
@@ -53,6 +53,7 @@ function ExplicitNamingFilterEditionDialog({
53
53
  setDataFetchStatus(FetchStatus.FETCH_SUCCESS);
54
54
  reset({
55
55
  [FieldConstants.NAME]: name,
56
+ [FieldConstants.DESCRIPTION]: description,
56
57
  [FieldConstants.FILTER_TYPE]: FilterType.EXPLICIT_NAMING.id,
57
58
  [FieldConstants.EQUIPMENT_TYPE]: response[FieldConstants.EQUIPMENT_TYPE],
58
59
  [FILTER_EQUIPMENTS_ATTRIBUTES]: response[FILTER_EQUIPMENTS_ATTRIBUTES].map((row) => ({
@@ -68,7 +69,7 @@ function ExplicitNamingFilterEditionDialog({
68
69
  });
69
70
  });
70
71
  }
71
- }, [id, name, open, reset, snackError, getFilterById]);
72
+ }, [id, name, open, reset, snackError, getFilterById, description]);
72
73
  const onSubmit = useCallback(
73
74
  (filterForm) => {
74
75
  saveExplicitNamingFilter(
@@ -76,8 +77,7 @@ function ExplicitNamingFilterEditionDialog({
76
77
  false,
77
78
  filterForm[FieldConstants.EQUIPMENT_TYPE],
78
79
  filterForm[FieldConstants.NAME],
79
- "",
80
- // The description can not be edited from this dialog
80
+ filterForm[FieldConstants.DESCRIPTION] ?? "",
81
81
  id,
82
82
  (error) => {
83
83
  snackError({
@@ -1,3 +1,4 @@
1
+ import { ElementExistsType } from '../../utils';
1
2
  import { UUID } from 'crypto';
2
3
 
3
4
  /**
@@ -11,3 +12,20 @@ export type ItemSelectionForCopy = {
11
12
  parentDirectoryUuid: UUID | null;
12
13
  specificTypeItem: string | null;
13
14
  };
15
+ export interface FilterEditionProps {
16
+ id: string;
17
+ name: string;
18
+ titleId: string;
19
+ open: boolean;
20
+ onClose: () => void;
21
+ broadcastChannel: BroadcastChannel;
22
+ itemSelectionForCopy: ItemSelectionForCopy;
23
+ setItemSelectionForCopy: (selection: ItemSelectionForCopy) => void;
24
+ getFilterById: (id: string) => Promise<{
25
+ [prop: string]: any;
26
+ }>;
27
+ activeDirectory?: UUID;
28
+ elementExists?: ElementExistsType;
29
+ language?: string;
30
+ description?: string;
31
+ }
@@ -5,7 +5,7 @@ import { CriteriaBasedForm } from "../contingencyList/criteriaBased/CriteriaBase
5
5
  import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "../contingencyList/criteriaBased/criteriaBasedUtils.js";
6
6
  import { ExpertFilterEditionDialog } from "./expert/ExpertFilterEditionDialog.js";
7
7
  import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./expert/ExpertFilterForm.js";
8
- import { CombinatorType, DataType, FieldType, OperatorType } from "./expert/expertFilter.type.js";
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, 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, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./expert/expertFilterUtils.js";
11
11
  import { ExplicitNamingFilterEditionDialog } from "./explicitNaming/ExplicitNamingFilterEditionDialog.js";
@@ -31,7 +31,6 @@ export {
31
31
  FIELDS_OPTIONS,
32
32
  FILTER_EQUIPMENTS,
33
33
  FILTER_EQUIPMENTS_ATTRIBUTES,
34
- FieldType,
35
34
  FilterCreationDialog,
36
35
  FilterForm,
37
36
  FilterType,
@@ -41,6 +41,7 @@ const saveExplicitNamingFilter = (tableValues, isFilterCreation, equipmentType,
41
41
  filterEquipmentsAttributes: cleanedTableValues
42
42
  },
43
43
  name,
44
+ description,
44
45
  token
45
46
  ).then(() => {
46
47
  handleClose();
@@ -75,6 +76,7 @@ const saveExpertFilter = (id, query, equipmentType, name, description, isFilterC
75
76
  rules: exportExpertRules(query)
76
77
  },
77
78
  name,
79
+ description,
78
80
  token
79
81
  ).then(() => {
80
82
  onClose();
@@ -30,7 +30,7 @@ import { CriteriaBasedForm } from "./contingencyList/criteriaBased/CriteriaBased
30
30
  import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./contingencyList/criteriaBased/criteriaBasedUtils.js";
31
31
  import { ExpertFilterEditionDialog } from "./filter/expert/ExpertFilterEditionDialog.js";
32
32
  import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./filter/expert/ExpertFilterForm.js";
33
- import { CombinatorType, DataType, FieldType, OperatorType } from "./filter/expert/expertFilter.type.js";
33
+ import { CombinatorType, DataType, OperatorType } from "./filter/expert/expertFilter.type.js";
34
34
  import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXPERT_FILTER_EQUIPMENTS, EXPERT_FILTER_FIELDS, 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";
35
35
  import { countRules, exportExpertRules, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./filter/expert/expertFilterUtils.js";
36
36
  import { ExplicitNamingFilterEditionDialog } from "./filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
@@ -164,7 +164,6 @@ export {
164
164
  FILTER_EQUIPMENTS_ATTRIBUTES,
165
165
  FieldErrorAlert,
166
166
  FieldLabel,
167
- FieldType,
168
167
  FilterCreationDialog,
169
168
  FilterForm,
170
169
  FilterType,
@@ -8,14 +8,15 @@ import { useFormContext } from "react-hook-form";
8
8
  import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
9
9
  import { ExpandingTextField } from "./ExpandingTextField.js";
10
10
  function DescriptionField() {
11
- const [isDescriptionFieldVisible, setIsDescriptionFieldVisible] = useState(false);
12
- const { setValue } = useFormContext();
11
+ const { setValue, getValues } = useFormContext();
12
+ const description = getValues(FieldConstants.DESCRIPTION);
13
+ const [isDescriptionFieldVisible, setIsDescriptionFieldVisible] = useState(!!description);
13
14
  const handleOpenDescription = () => {
14
15
  setIsDescriptionFieldVisible(true);
15
16
  };
16
17
  const handleCloseDescription = () => {
17
18
  setIsDescriptionFieldVisible(false);
18
- setValue(FieldConstants.DESCRIPTION, "");
19
+ setValue(FieldConstants.DESCRIPTION, "", { shouldDirty: true });
19
20
  };
20
21
  return /* @__PURE__ */ jsx(Box, { children: !isDescriptionFieldVisible ? /* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: handleOpenDescription, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "AddDescription" }) }) : /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "flex-start" }, children: [
21
22
  /* @__PURE__ */ jsx(
@@ -6,7 +6,7 @@ import { useFormContext } from "react-hook-form";
6
6
  import { CountryValueEditor } from "./CountryValueEditor.js";
7
7
  import { TranslatedValueEditor } from "./TranslatedValueEditor.js";
8
8
  import { TextValueEditor } from "./TextValueEditor.js";
9
- import { FieldType, DataType } from "../../filter/expert/expertFilter.type.js";
9
+ import { DataType } from "../../filter/expert/expertFilter.type.js";
10
10
  import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
11
11
  import { VoltageLevel, Substation } from "../../../utils/types/equipmentTypes.js";
12
12
  import { ElementValueEditor } from "./ElementValueEditor.js";
@@ -15,6 +15,7 @@ import { PropertyValueEditor } from "./PropertyValueEditor.js";
15
15
  import { FilterType } from "../../filter/constants/FilterConstants.js";
16
16
  import { GroupValueEditor } from "./compositeRuleEditor/GroupValueEditor.js";
17
17
  import { OPERATOR_OPTIONS } from "../../filter/expert/expertFilterConstants.js";
18
+ import { FieldType } from "../../../utils/types/fieldType.js";
18
19
  const styles = {
19
20
  noArrows: {
20
21
  "& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button": {
@@ -1,6 +1,6 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
 
3
3
  export type NotificationsProviderProps = {
4
- urls: Record<string, string>;
4
+ urls: Record<string, string | undefined>;
5
5
  };
6
6
  export declare function NotificationsProvider({ urls, children }: PropsWithChildren<NotificationsProviderProps>): import("react/jsx-runtime").JSX.Element;
@@ -4,6 +4,9 @@ import ReconnectingWebSocket from "reconnecting-websocket";
4
4
  import { NotificationsContext } from "./contexts/NotificationsContext.js";
5
5
  import { useListenerManager } from "./hooks/useListenerManager.js";
6
6
  const DELAY_BEFORE_WEBSOCKET_CONNECTED = 12e3;
7
+ function isUrlDefined(tuple) {
8
+ return tuple[1] !== void 0;
9
+ }
7
10
  function NotificationsProvider({ urls, children }) {
8
11
  const {
9
12
  broadcast: broadcastMessage,
@@ -16,8 +19,8 @@ function NotificationsProvider({ urls, children }) {
16
19
  removeListener: removeListenerOnReopen
17
20
  } = useListenerManager(urls);
18
21
  useEffect(() => {
19
- const connections = Object.keys(urls).filter((u) => urls[u] != null).map((urlKey) => {
20
- const rws = new ReconnectingWebSocket(() => urls[urlKey], [], {
22
+ const connections = Object.entries(urls).filter(isUrlDefined).map(([urlKey, url]) => {
23
+ const rws = new ReconnectingWebSocket(() => url, [], {
21
24
  // this option set the minimum duration being connected before reset the retry count to 0
22
25
  minUptime: DELAY_BEFORE_WEBSOCKET_CONNECTED
23
26
  });
@@ -34,9 +37,7 @@ function NotificationsProvider({ urls, children }) {
34
37
  };
35
38
  return rws;
36
39
  });
37
- return () => {
38
- connections.forEach((c) => c.close());
39
- };
40
+ return () => connections.forEach((c) => c.close());
40
41
  }, [broadcastMessage, broadcastOnReopen, urls]);
41
42
  const contextValue = useMemo(
42
43
  () => ({
@@ -1,6 +1,6 @@
1
1
  import { ListenerEventWS, ListenerOnReopen } from '../contexts/NotificationsContext';
2
2
 
3
- export declare const useListenerManager: <TListener extends ListenerEventWS | ListenerOnReopen, TMessage extends MessageEvent<any>>(urls: Record<string, string>) => {
3
+ export declare const useListenerManager: <TListener extends ListenerEventWS | ListenerOnReopen, TMessage extends MessageEvent<any>>(urls: Record<string, string | undefined>) => {
4
4
  addListener: (urlKey: string, listener: TListener) => void;
5
5
  removeListener: (urlKey: string, id: string) => void;
6
6
  broadcast: (urlKey: string) => (event: TMessage) => void;
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import { CriteriaBasedForm } from "./components/contingencyList/criteriaBased/Cr
31
31
  import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./components/contingencyList/criteriaBased/criteriaBasedUtils.js";
32
32
  import { ExpertFilterEditionDialog } from "./components/filter/expert/ExpertFilterEditionDialog.js";
33
33
  import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./components/filter/expert/ExpertFilterForm.js";
34
- import { CombinatorType, DataType, FieldType, OperatorType } from "./components/filter/expert/expertFilter.type.js";
34
+ import { CombinatorType, DataType, OperatorType } from "./components/filter/expert/expertFilter.type.js";
35
35
  import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXPERT_FILTER_EQUIPMENTS, EXPERT_FILTER_FIELDS, 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";
36
36
  import { countRules, exportExpertRules, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./components/filter/expert/expertFilterUtils.js";
37
37
  import { ExplicitNamingFilterEditionDialog } from "./components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
@@ -125,7 +125,8 @@ import { equalsArray } from "./utils/algos.js";
125
125
  import { DARK_THEME, LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM, LIGHT_THEME } from "./utils/constants/browserConstants.js";
126
126
  import { FetchStatus } from "./utils/constants/fetchStatus.js";
127
127
  import { FieldConstants } from "./utils/constants/fieldConstants.js";
128
- import { GRIDSUITE_DEFAULT_PRECISION, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./utils/conversionUtils.js";
128
+ import { MAX_CHAR_DESCRIPTION } from "./utils/constants/uiConstants.js";
129
+ import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./utils/conversionUtils.js";
129
130
  import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./utils/functions.js";
130
131
  import { getFileIcon } from "./utils/mapper/getFileIcon.js";
131
132
  import { equipmentTypesForPredefinedPropertiesMapper } from "./utils/mapper/equipmentTypesForPredefinedPropertiesMapper.js";
@@ -134,6 +135,7 @@ import { ElementType } from "./utils/types/elementType.js";
134
135
  import { EQUIPMENT_TYPE, EquipmentType, OperatingStatus, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./utils/types/equipmentType.js";
135
136
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./utils/types/equipmentTypes.js";
136
137
  import { MODIFICATION_TYPES, ModificationType } from "./utils/types/modificationType.js";
138
+ import { FieldType } from "./utils/types/fieldType.js";
137
139
  import "./utils/yupConfig.js";
138
140
  import { cardErrorBoundaryEn } from "./translations/en/cardErrorBoundaryEn.js";
139
141
  import { commonButtonEn } from "./translations/en/commonButtonEn.js";
@@ -274,6 +276,7 @@ export {
274
276
  Login,
275
277
  LogoText,
276
278
  Logout,
279
+ MAX_CHAR_DESCRIPTION,
277
280
  MODIFICATION_TYPES,
278
281
  MidFormError,
279
282
  ModificationType,
@@ -350,6 +353,8 @@ export {
350
353
  collectibleHelper,
351
354
  commonButtonEn,
352
355
  commonButtonFr,
356
+ convertInputValue,
357
+ convertOutputValue,
353
358
  countRules,
354
359
  createFilter,
355
360
  csvEn,
@@ -1,6 +1,7 @@
1
1
  import { Metadata, StudyMetadata } from '../utils';
2
2
 
3
- export type Url = string | URL;
3
+ export type UrlString = `${string}://${string}` | `/${string}` | `./${string}`;
4
+ export type Url = UrlString | URL;
4
5
  export type Env = {
5
6
  appsMetadataServerUrl?: Url;
6
7
  mapBoxToken?: string;
@@ -2,5 +2,5 @@ import { ElementAttributes } from '../utils/types/types';
2
2
  import { UUID } from 'crypto';
3
3
 
4
4
  export declare function createFilter(newFilter: any, name: string, description: string, parentDirectoryUuid?: UUID, token?: string): Promise<any>;
5
- export declare function saveFilter(filter: any, name: string, token?: string): Promise<any>;
5
+ export declare function saveFilter(filter: any, name: string, description: string, token?: string): Promise<any>;
6
6
  export declare function fetchElementsInfos(ids: UUID[], elementTypes?: string[], equipmentTypes?: string[]): Promise<ElementAttributes[]>;
@@ -17,9 +17,10 @@ function createFilter(newFilter, name, description, parentDirectoryUuid, token)
17
17
  token
18
18
  );
19
19
  }
20
- function saveFilter(filter, name, token) {
20
+ function saveFilter(filter, name, description, token) {
21
21
  const urlSearchParams = new URLSearchParams();
22
22
  urlSearchParams.append("name", name);
23
+ urlSearchParams.append("description", description);
23
24
  return backendFetch(
24
25
  `${PREFIX_EXPLORE_SERVER_QUERIES}/v1/explore/filters/${filter.id}?${urlSearchParams.toString()}`,
25
26
  {
@@ -7,3 +7,4 @@
7
7
  export * from './browserConstants';
8
8
  export * from './fetchStatus';
9
9
  export * from './fieldConstants';
10
+ export * from './uiConstants';
@@ -1,6 +1,7 @@
1
1
  import { DARK_THEME, LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM, LIGHT_THEME } from "./browserConstants.js";
2
2
  import { FetchStatus } from "./fetchStatus.js";
3
3
  import { FieldConstants } from "./fieldConstants.js";
4
+ import { MAX_CHAR_DESCRIPTION } from "./uiConstants.js";
4
5
  export {
5
6
  DARK_THEME,
6
7
  FetchStatus,
@@ -8,5 +9,6 @@ export {
8
9
  LANG_ENGLISH,
9
10
  LANG_FRENCH,
10
11
  LANG_SYSTEM,
11
- LIGHT_THEME
12
+ LIGHT_THEME,
13
+ MAX_CHAR_DESCRIPTION
12
14
  };
@@ -0,0 +1 @@
1
+ export declare const MAX_CHAR_DESCRIPTION = 500;
@@ -0,0 +1,4 @@
1
+ const MAX_CHAR_DESCRIPTION = 500;
2
+ export {
3
+ MAX_CHAR_DESCRIPTION
4
+ };
@@ -1,14 +1,12 @@
1
- /**
2
- * Copyright (c) 2024, RTE (http://www.rte-france.com)
3
- * This Source Code Form is subject to the terms of the Mozilla Public
4
- * License, v. 2.0. If a copy of the MPL was not distributed with this
5
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
- */
1
+ import { FieldType } from './types/fieldType';
2
+
7
3
  export declare const GRIDSUITE_DEFAULT_PRECISION: number;
8
4
  export declare const roundToPrecision: (num: number, precision: number) => number;
9
5
  export declare const roundToDefaultPrecision: (num: number) => number;
10
6
  export declare function isBlankOrEmpty(value: unknown): boolean;
11
- export declare const unitToMicroUnit: (num: number) => number | undefined;
12
- export declare const microUnitToUnit: (num: number) => number | undefined;
13
- export declare const unitToKiloUnit: (num: number) => number | undefined;
14
- export declare const kiloUnitToUnit: (num: number) => number | undefined;
7
+ export declare function unitToMicroUnit(num: number): number | undefined;
8
+ export declare function microUnitToUnit(num: number): number | undefined;
9
+ export declare function unitToKiloUnit(num: number): number | undefined;
10
+ export declare function kiloUnitToUnit(num: number): number | undefined;
11
+ export declare function convertInputValue(field: FieldType, value: any): any;
12
+ export declare function convertOutputValue(field: FieldType, value: any): any;
@@ -1,3 +1,4 @@
1
+ import { FieldType } from "./types/fieldType.js";
1
2
  const GRIDSUITE_DEFAULT_PRECISION = 13;
2
3
  const roundToPrecision = (num, precision) => Number(num.toPrecision(precision));
3
4
  const roundToDefaultPrecision = (num) => roundToPrecision(num, GRIDSUITE_DEFAULT_PRECISION);
@@ -10,12 +11,65 @@ function isBlankOrEmpty(value) {
10
11
  }
11
12
  return false;
12
13
  }
13
- const unitToMicroUnit = (num) => isBlankOrEmpty(num) ? void 0 : roundToDefaultPrecision(num * 1e6);
14
- const microUnitToUnit = (num) => isBlankOrEmpty(num) ? void 0 : roundToDefaultPrecision(num / 1e6);
15
- const unitToKiloUnit = (num) => isBlankOrEmpty(num) ? void 0 : roundToDefaultPrecision(num / 1e3);
16
- const kiloUnitToUnit = (num) => isBlankOrEmpty(num) ? void 0 : roundToDefaultPrecision(num * 1e3);
14
+ function unitToMicroUnit(num) {
15
+ return isBlankOrEmpty(num) ? void 0 : roundToDefaultPrecision(num * 1e6);
16
+ }
17
+ function microUnitToUnit(num) {
18
+ return isBlankOrEmpty(num) ? void 0 : roundToDefaultPrecision(num / 1e6);
19
+ }
20
+ function unitToKiloUnit(num) {
21
+ return isBlankOrEmpty(num) ? void 0 : roundToDefaultPrecision(num / 1e3);
22
+ }
23
+ function kiloUnitToUnit(num) {
24
+ return isBlankOrEmpty(num) ? void 0 : roundToDefaultPrecision(num * 1e3);
25
+ }
26
+ const microToUnit = [
27
+ FieldType.SHUNT_CONDUCTANCE_1,
28
+ FieldType.SHUNT_CONDUCTANCE_2,
29
+ FieldType.SHUNT_SUSCEPTANCE_1,
30
+ FieldType.SHUNT_SUSCEPTANCE_2,
31
+ FieldType.G,
32
+ FieldType.B,
33
+ FieldType.G1,
34
+ FieldType.B1,
35
+ FieldType.G2,
36
+ FieldType.B2
37
+ ];
38
+ const kiloToUnit = [FieldType.HIGH_SHORT_CIRCUIT_CURRENT_LIMIT, FieldType.LOW_SHORT_CIRCUIT_CURRENT_LIMIT];
39
+ function convertInputValue(field, value) {
40
+ if (microToUnit.includes(field)) {
41
+ if (!Array.isArray(value)) {
42
+ return value ? unitToMicroUnit(value) : value;
43
+ }
44
+ return value.map((a) => unitToMicroUnit(a));
45
+ }
46
+ if (kiloToUnit.includes(field)) {
47
+ if (!Array.isArray(value)) {
48
+ return value ? unitToKiloUnit(value) : value;
49
+ }
50
+ return value.map((a) => unitToKiloUnit(a));
51
+ }
52
+ return value;
53
+ }
54
+ function convertOutputValue(field, value) {
55
+ if (microToUnit.includes(field)) {
56
+ if (!Array.isArray(value)) {
57
+ return value ? microUnitToUnit(value) : value;
58
+ }
59
+ return value.map((a) => microUnitToUnit(a));
60
+ }
61
+ if (kiloToUnit.includes(field)) {
62
+ if (!Array.isArray(value)) {
63
+ return value ? kiloUnitToUnit(value) : value;
64
+ }
65
+ return value.map((a) => kiloUnitToUnit(a));
66
+ }
67
+ return value;
68
+ }
17
69
  export {
18
70
  GRIDSUITE_DEFAULT_PRECISION,
71
+ convertInputValue,
72
+ convertOutputValue,
19
73
  isBlankOrEmpty,
20
74
  kiloUnitToUnit,
21
75
  microUnitToUnit,
@@ -2,7 +2,8 @@ import { equalsArray } from "./algos.js";
2
2
  import { DARK_THEME, LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM, LIGHT_THEME } from "./constants/browserConstants.js";
3
3
  import { FetchStatus } from "./constants/fetchStatus.js";
4
4
  import { FieldConstants } from "./constants/fieldConstants.js";
5
- import { GRIDSUITE_DEFAULT_PRECISION, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./conversionUtils.js";
5
+ import { MAX_CHAR_DESCRIPTION } from "./constants/uiConstants.js";
6
+ import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./conversionUtils.js";
6
7
  import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./functions.js";
7
8
  import { getFileIcon } from "./mapper/getFileIcon.js";
8
9
  import { equipmentTypesForPredefinedPropertiesMapper } from "./mapper/equipmentTypesForPredefinedPropertiesMapper.js";
@@ -11,6 +12,7 @@ import { ElementType } from "./types/elementType.js";
11
12
  import { EQUIPMENT_TYPE, EquipmentType, OperatingStatus, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./types/equipmentType.js";
12
13
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./types/equipmentTypes.js";
13
14
  import { MODIFICATION_TYPES, ModificationType } from "./types/modificationType.js";
15
+ import { FieldType } from "./types/fieldType.js";
14
16
  import "./yupConfig.js";
15
17
  import * as yup from "yup";
16
18
  export {
@@ -23,6 +25,7 @@ export {
23
25
  EquipmentType,
24
26
  FetchStatus,
25
27
  FieldConstants,
28
+ FieldType,
26
29
  GRIDSUITE_DEFAULT_PRECISION,
27
30
  Generator,
28
31
  Hvdc,
@@ -33,6 +36,7 @@ export {
33
36
  LIGHT_THEME,
34
37
  Line,
35
38
  Load,
39
+ MAX_CHAR_DESCRIPTION,
36
40
  MODIFICATION_TYPES,
37
41
  ModificationType,
38
42
  OperatingStatus,
@@ -46,6 +50,8 @@ export {
46
50
  VSC,
47
51
  VoltageLevel,
48
52
  areArrayElementsUnique,
53
+ convertInputValue,
54
+ convertOutputValue,
49
55
  equalsArray,
50
56
  equipmentStyles,
51
57
  equipmentTypesForPredefinedPropertiesMapper,