@gridsuite/commons-ui 0.162.0 → 0.164.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 (116) hide show
  1. package/dist/components/directoryItemSelector/DirectoryItemSelector.js +1 -1
  2. package/dist/components/dnd-table/dnd-table.js +1 -0
  3. package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +1 -1
  4. package/dist/components/filter/utils/filterApi.js +1 -1
  5. package/dist/components/index.d.ts +1 -0
  6. package/dist/components/index.js +34 -3
  7. package/dist/components/inputs/index.js +4 -0
  8. package/dist/components/inputs/reactHookForm/CountrySelectionInput.d.ts +5 -0
  9. package/dist/components/inputs/reactHookForm/CountrySelectionInput.js +27 -0
  10. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +1 -1
  11. package/dist/components/inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js +1 -1
  12. package/dist/components/inputs/reactHookForm/expandableInput/DeletableRow.d.ts +8 -0
  13. package/dist/components/inputs/reactHookForm/expandableInput/DeletableRow.js +41 -0
  14. package/dist/components/inputs/reactHookForm/expandableInput/ExpandableInput.d.ts +24 -0
  15. package/dist/components/inputs/reactHookForm/expandableInput/ExpandableInput.js +80 -0
  16. package/dist/components/inputs/reactHookForm/expandableInput/index.d.ts +7 -0
  17. package/dist/components/inputs/reactHookForm/expandableInput/index.js +4 -0
  18. package/dist/components/inputs/reactHookForm/index.d.ts +2 -0
  19. package/dist/components/inputs/reactHookForm/index.js +4 -0
  20. package/dist/components/inputs/reactHookForm/selectInputs/CountriesInput.d.ts +2 -1
  21. package/dist/components/inputs/reactHookForm/selectInputs/CountriesInput.js +12 -2
  22. package/dist/components/inputs/reactHookForm/text/TextInput.d.ts +2 -1
  23. package/dist/components/inputs/reactHookForm/text/TextInput.js +4 -2
  24. package/dist/components/network-modifications/common/form.utils.d.ts +8 -0
  25. package/dist/components/network-modifications/common/form.utils.js +14 -0
  26. package/dist/components/network-modifications/common/index.d.ts +8 -0
  27. package/dist/components/network-modifications/common/index.js +24 -0
  28. package/dist/components/network-modifications/common/properties/PropertiesForm.d.ts +7 -0
  29. package/dist/components/network-modifications/common/properties/PropertiesForm.js +109 -0
  30. package/dist/components/network-modifications/common/properties/PropertyForm.d.ts +8 -0
  31. package/dist/components/network-modifications/common/properties/PropertyForm.js +102 -0
  32. package/dist/components/network-modifications/common/properties/index.d.ts +10 -0
  33. package/dist/components/network-modifications/common/properties/index.js +20 -0
  34. package/dist/components/network-modifications/common/properties/properties.type.d.ts +14 -0
  35. package/dist/components/network-modifications/common/properties/properties.type.js +1 -0
  36. package/dist/components/network-modifications/common/properties/propertyUtils.d.ts +39 -0
  37. package/dist/components/network-modifications/common/properties/propertyUtils.js +160 -0
  38. package/dist/components/network-modifications/index.d.ts +8 -0
  39. package/dist/components/network-modifications/index.js +31 -0
  40. package/dist/components/network-modifications/substation/creation/SubstationCreationForm.d.ts +7 -0
  41. package/dist/components/network-modifications/substation/creation/SubstationCreationForm.js +52 -0
  42. package/dist/components/network-modifications/substation/creation/index.d.ts +9 -0
  43. package/dist/components/network-modifications/substation/creation/index.js +9 -0
  44. package/dist/components/network-modifications/substation/creation/substationCreation.types.d.ts +8 -0
  45. package/dist/components/network-modifications/substation/creation/substationCreation.types.js +1 -0
  46. package/dist/components/network-modifications/substation/creation/substationCreation.utils.d.ts +24 -0
  47. package/dist/components/network-modifications/substation/creation/substationCreation.utils.js +43 -0
  48. package/dist/components/network-modifications/substation/index.d.ts +7 -0
  49. package/dist/components/network-modifications/substation/index.js +9 -0
  50. package/dist/components/parameters/common/constant.d.ts +0 -8
  51. package/dist/components/parameters/common/constant.js +1 -12
  52. package/dist/components/parameters/common/index.js +1 -3
  53. package/dist/components/parameters/common/parameters-creation-dialog.js +1 -1
  54. package/dist/components/parameters/index.js +1 -3
  55. package/dist/components/parameters/loadflow/load-flow-parameter-field.js +25 -7
  56. package/dist/components/parameters/loadflow/load-flow-parameters-header.js +13 -3
  57. package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +21 -5
  58. package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +1 -1
  59. package/dist/components/parameters/network-visualizations/map-parameters.js +1 -1
  60. package/dist/components/parameters/network-visualizations/network-visualizations-parameters-inline.js +1 -1
  61. package/dist/components/parameters/network-visualizations/use-network-visualizations-parameters-form.js +1 -1
  62. package/dist/components/parameters/pcc-min/pcc-min-parameters-inline.js +1 -1
  63. package/dist/components/parameters/pcc-min/use-pcc-min-parameters-form.js +1 -1
  64. package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.js +2 -2
  65. package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +2 -2
  66. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +2 -2
  67. package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +1 -1
  68. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +1 -1
  69. package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +1 -1
  70. package/dist/components/parameters/voltage-init/general-parameters.js +1 -1
  71. package/dist/components/parameters/voltage-init/use-voltage-init-parameters-form.js +1 -1
  72. package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.js +1 -1
  73. package/dist/components/parameters/voltage-init/voltage-limits-parameters.js +5 -9
  74. package/dist/hooks/useModificationLabelComputer.d.ts +2 -1
  75. package/dist/hooks/usePredefinedProperties.js +1 -1
  76. package/dist/hooks/useSnackMessage.d.ts +1 -3
  77. package/dist/index.js +61 -7
  78. package/dist/services/appsMetadata.d.ts +2 -1
  79. package/dist/services/appsMetadata.js +4 -0
  80. package/dist/services/index.d.ts +1 -0
  81. package/dist/services/index.js +7 -3
  82. package/dist/services/networkModification.d.ts +6 -0
  83. package/dist/services/networkModification.js +26 -0
  84. package/dist/services/security-analysis.d.ts +0 -1
  85. package/dist/services/security-analysis.js +1 -5
  86. package/dist/services/sensitivity-analysis.js +1 -2
  87. package/dist/services/study.js +7 -6
  88. package/dist/services/utils.d.ts +1 -0
  89. package/dist/services/utils.js +5 -1
  90. package/dist/translations/en/businessErrorsEn.js +1 -1
  91. package/dist/translations/en/commonButtonEn.d.ts +1 -0
  92. package/dist/translations/en/commonButtonEn.js +2 -1
  93. package/dist/translations/en/networkModificationsEn.d.ts +10 -0
  94. package/dist/translations/en/networkModificationsEn.js +11 -1
  95. package/dist/translations/fr/businessErrorsFr.js +1 -1
  96. package/dist/translations/fr/commonButtonFr.d.ts +1 -0
  97. package/dist/translations/fr/commonButtonFr.js +2 -1
  98. package/dist/translations/fr/networkModificationsFr.d.ts +10 -0
  99. package/dist/translations/fr/networkModificationsFr.js +11 -1
  100. package/dist/utils/constants/adornments.d.ts +44 -0
  101. package/dist/utils/constants/adornments.js +58 -0
  102. package/dist/utils/constants/fieldConstants.d.ts +7 -0
  103. package/dist/utils/constants/fieldConstants.js +7 -0
  104. package/dist/utils/constants/index.d.ts +1 -0
  105. package/dist/utils/constants/index.js +13 -1
  106. package/dist/utils/error.d.ts +2 -0
  107. package/dist/utils/error.js +27 -22
  108. package/dist/utils/index.d.ts +2 -1
  109. package/dist/utils/index.js +22 -3
  110. package/dist/utils/labelUtils.d.ts +0 -1
  111. package/dist/utils/labelUtils.js +1 -8
  112. package/dist/utils/ts-utils.d.ts +18 -0
  113. package/dist/utils/ts-utils.js +40 -0
  114. package/dist/utils/types/metadata.d.ts +4 -0
  115. package/dist/utils/types/types.d.ts +6 -0
  116. package/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Grid } from "@mui/material";
3
+ import { useState, useEffect, useCallback } from "react";
4
+ import { useWatch, useFormContext } from "react-hook-form";
5
+ import { fetchPredefinedProperties, initializedProperty } from "./propertyUtils.js";
6
+ import { PropertyForm } from "./PropertyForm.js";
7
+ import GridSection from "../../../grid/grid-section.js";
8
+ import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
9
+ import "../../../../utils/conversionUtils.js";
10
+ import "../../../../utils/types/equipmentType.js";
11
+ import "@mui/icons-material";
12
+ import "../../../../utils/yupConfig.js";
13
+ import "react-intl";
14
+ import "../../../overflowableText/OverflowableText.js";
15
+ import "localized-countries";
16
+ import "localized-countries/data/fr";
17
+ import "localized-countries/data/en";
18
+ import "notistack";
19
+ import "../../../inputs/reactHookForm/provider/CustomFormProvider.js";
20
+ import "yup";
21
+ import "../../../treeViewFinder/TreeViewFinder.js";
22
+ import "../../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
23
+ import "../../../customAGGrid/customAggrid.js";
24
+ import "ag-grid-community";
25
+ import "react-papaparse";
26
+ import "react-csv-downloader";
27
+ import "../../../inputs/reactHookForm/numbers/RangeInput.js";
28
+ import { ExpandableInput } from "../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
29
+ import "@react-querybuilder/material";
30
+ import "../../../filter/expert/expertFilterConstants.js";
31
+ import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
32
+ import "uuid";
33
+ import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
34
+ import "react-querybuilder";
35
+ function PropertiesForm({ id, networkElementType, isModification = false }) {
36
+ const additionalProperties = id ? `${id}.${FieldConstants.ADDITIONAL_PROPERTIES}` : FieldConstants.ADDITIONAL_PROPERTIES;
37
+ const watchProps = useWatch({
38
+ name: additionalProperties
39
+ });
40
+ const { getValues, setValue } = useFormContext();
41
+ const [predefinedProperties, setPredefinedProperties] = useState({});
42
+ useEffect(() => {
43
+ if (networkElementType) {
44
+ fetchPredefinedProperties(networkElementType).then((res) => {
45
+ if (res) {
46
+ setPredefinedProperties(res);
47
+ }
48
+ });
49
+ }
50
+ }, [networkElementType]);
51
+ const getDeletionMark = useCallback(
52
+ (idx) => {
53
+ const properties = getValues(`${additionalProperties}`);
54
+ if (properties && typeof properties[idx] !== "undefined") {
55
+ return watchProps && properties[idx][FieldConstants.DELETION_MARK];
56
+ }
57
+ return false;
58
+ },
59
+ [getValues, watchProps, additionalProperties]
60
+ );
61
+ const deleteCallback = useCallback(
62
+ (idx) => {
63
+ let markedForDeletion = false;
64
+ const properties = getValues(`${additionalProperties}`);
65
+ if (properties && typeof properties[idx] !== "undefined") {
66
+ markedForDeletion = properties[idx][FieldConstants.DELETION_MARK];
67
+ } else {
68
+ return false;
69
+ }
70
+ let canRemoveLine = true;
71
+ if (markedForDeletion) {
72
+ setValue(`${additionalProperties}.${idx}.${FieldConstants.DELETION_MARK}`, false, {
73
+ shouldDirty: true
74
+ });
75
+ canRemoveLine = false;
76
+ } else if (properties[idx][FieldConstants.PREVIOUS_VALUE] && properties[idx][FieldConstants.ADDED] === false) {
77
+ setValue(`${additionalProperties}.${idx}.${FieldConstants.DELETION_MARK}`, true, {
78
+ shouldDirty: true
79
+ });
80
+ canRemoveLine = false;
81
+ }
82
+ return canRemoveLine;
83
+ },
84
+ [getValues, setValue, additionalProperties]
85
+ );
86
+ const modificationProperties = isModification ? {
87
+ getDeletionMark,
88
+ deleteCallback,
89
+ watchProps
90
+ } : {};
91
+ const additionalProps = /* @__PURE__ */ jsx(
92
+ ExpandableInput,
93
+ {
94
+ name: additionalProperties,
95
+ Field: PropertyForm,
96
+ fieldProps: { predefinedProperties },
97
+ addButtonLabel: "AddProperty",
98
+ initialValue: initializedProperty(),
99
+ ...modificationProperties
100
+ }
101
+ );
102
+ return /* @__PURE__ */ jsxs(Grid, { container: true, children: [
103
+ /* @__PURE__ */ jsx(GridSection, { title: "AdditionalInformation" }),
104
+ additionalProps
105
+ ] });
106
+ }
107
+ export {
108
+ PropertiesForm
109
+ };
@@ -0,0 +1,8 @@
1
+ import { PredefinedProperties } from '../../../../utils';
2
+ type PropertyFormProps = {
3
+ name: string;
4
+ index: string;
5
+ predefinedProperties: PredefinedProperties;
6
+ };
7
+ export declare const PropertyForm: ({ name, index, predefinedProperties }: PropertyFormProps) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,102 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { useWatch } from "react-hook-form";
4
+ import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
5
+ import "../../../../utils/conversionUtils.js";
6
+ import "../../../../utils/types/equipmentType.js";
7
+ import "@mui/icons-material";
8
+ import "../../../../utils/yupConfig.js";
9
+ import GridItem from "../../../grid/grid-item.js";
10
+ import "react-intl";
11
+ import "@mui/material";
12
+ import "../../../overflowableText/OverflowableText.js";
13
+ import "localized-countries";
14
+ import "localized-countries/data/fr";
15
+ import "localized-countries/data/en";
16
+ import "notistack";
17
+ import "../../../inputs/reactHookForm/provider/CustomFormProvider.js";
18
+ import "yup";
19
+ import "../../../treeViewFinder/TreeViewFinder.js";
20
+ import "../../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
21
+ import "../../../customAGGrid/customAggrid.js";
22
+ import "ag-grid-community";
23
+ import "react-papaparse";
24
+ import "react-csv-downloader";
25
+ import { AutocompleteInput } from "../../../inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
26
+ import { TextInput } from "../../../inputs/reactHookForm/text/TextInput.js";
27
+ import "../../../inputs/reactHookForm/numbers/RangeInput.js";
28
+ import "@react-querybuilder/material";
29
+ import "../../../filter/expert/expertFilterConstants.js";
30
+ import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
31
+ import "uuid";
32
+ import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
33
+ import "react-querybuilder";
34
+ import { italicFontTextField } from "../form.utils.js";
35
+ const PropertyForm = ({ name, index, predefinedProperties }) => {
36
+ const watchPropertyName = useWatch({ name: `${name}.${index}.${FieldConstants.NAME}` });
37
+ const watchPropertyPreviousValue = useWatch({
38
+ name: `${name}.${index}.${FieldConstants.PREVIOUS_VALUE}`
39
+ });
40
+ const watchPropertyDeletionMark = useWatch({
41
+ name: `${name}.${index}.${FieldConstants.DELETION_MARK}`
42
+ });
43
+ const watchPropertyAdded = useWatch({
44
+ name: `${name}.${index}.${FieldConstants.ADDED}`
45
+ });
46
+ const predefinedNames = useMemo(() => {
47
+ const keys = Object.keys(predefinedProperties ?? {});
48
+ return keys.sort((a, b) => a.localeCompare(b));
49
+ }, [predefinedProperties]);
50
+ const predefinedValues = useMemo(() => {
51
+ const values = predefinedProperties?.[watchPropertyName] ?? [];
52
+ return values.sort((a, b) => a.localeCompare(b));
53
+ }, [watchPropertyName, predefinedProperties]);
54
+ const nameField = /* @__PURE__ */ jsx(
55
+ AutocompleteInput,
56
+ {
57
+ name: `${name}.${index}.${FieldConstants.NAME}`,
58
+ options: predefinedNames,
59
+ label: "PropertyName",
60
+ size: "small",
61
+ allowNewValue: true
62
+ }
63
+ );
64
+ const nameReadOnlyField = /* @__PURE__ */ jsx(
65
+ TextInput,
66
+ {
67
+ name: `${name}.${index}.${FieldConstants.NAME}`,
68
+ label: "PropertyName",
69
+ formProps: { disabled: true, ...italicFontTextField }
70
+ }
71
+ );
72
+ const valueField = /* @__PURE__ */ jsx(
73
+ AutocompleteInput,
74
+ {
75
+ name: `${name}.${index}.${FieldConstants.VALUE}`,
76
+ options: predefinedValues,
77
+ label: "PropertyValue",
78
+ size: "small",
79
+ allowNewValue: true,
80
+ previousValue: watchPropertyPreviousValue
81
+ }
82
+ );
83
+ const valueReadOnlyField = /* @__PURE__ */ jsx(
84
+ TextInput,
85
+ {
86
+ name: `${name}.${index}.${FieldConstants.VALUE}`,
87
+ label: "PropertyValue",
88
+ previousValue: watchPropertyPreviousValue,
89
+ formProps: { disabled: true, ...italicFontTextField }
90
+ }
91
+ );
92
+ function renderPropertyLine() {
93
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
94
+ watchPropertyDeletionMark || watchPropertyAdded === false && watchPropertyPreviousValue ? /* @__PURE__ */ jsx(GridItem, { size: 5, children: nameReadOnlyField }) : /* @__PURE__ */ jsx(GridItem, { size: 5, children: nameField }),
95
+ watchPropertyDeletionMark ? /* @__PURE__ */ jsx(GridItem, { size: 5, children: valueReadOnlyField }) : /* @__PURE__ */ jsx(GridItem, { size: 5, children: valueField })
96
+ ] });
97
+ }
98
+ return renderPropertyLine();
99
+ };
100
+ export {
101
+ PropertyForm
102
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2026, 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
+ */
7
+ export * from './PropertiesForm';
8
+ export * from './PropertyForm';
9
+ export * from './properties.type';
10
+ export * from './propertyUtils';
@@ -0,0 +1,20 @@
1
+ import { PropertiesForm } from "./PropertiesForm.js";
2
+ import { PropertyForm } from "./PropertyForm.js";
3
+ import { copyEquipmentPropertiesForCreation, createPropertyModification, creationPropertiesSchema, emptyProperties, fetchPredefinedProperties, getConcatenatedProperties, getFilledPropertiesFromModification, getPropertiesFromModification, getPropertyValue, initializedProperty, mergeModificationAndEquipmentProperties, modificationPropertiesSchema, toModificationProperties } from "./propertyUtils.js";
4
+ export {
5
+ PropertiesForm,
6
+ PropertyForm,
7
+ copyEquipmentPropertiesForCreation,
8
+ createPropertyModification,
9
+ creationPropertiesSchema,
10
+ emptyProperties,
11
+ fetchPredefinedProperties,
12
+ getConcatenatedProperties,
13
+ getFilledPropertiesFromModification,
14
+ getPropertiesFromModification,
15
+ getPropertyValue,
16
+ initializedProperty,
17
+ mergeModificationAndEquipmentProperties,
18
+ modificationPropertiesSchema,
19
+ toModificationProperties
20
+ };
@@ -0,0 +1,14 @@
1
+ import { FieldConstants } from '../../../../utils';
2
+ export type FilledProperty = Omit<Property, FieldConstants.VALUE> & {
3
+ [FieldConstants.VALUE]: string;
4
+ };
5
+ export type Property = {
6
+ [FieldConstants.NAME]: string;
7
+ [FieldConstants.VALUE]?: string | null;
8
+ [FieldConstants.PREVIOUS_VALUE]?: string | null;
9
+ [FieldConstants.DELETION_MARK]: boolean;
10
+ [FieldConstants.ADDED]: boolean;
11
+ };
12
+ export type Properties = {
13
+ [FieldConstants.ADDITIONAL_PROPERTIES]?: Property[];
14
+ };
@@ -0,0 +1,39 @@
1
+ import { PredefinedProperties } from '../../../../utils';
2
+ import { default as yup } from '../../../../utils/yupConfig';
3
+ import { FilledProperty, Properties, Property } from './properties.type';
4
+ export type EquipmentWithProperties = {
5
+ properties?: Record<string, string>;
6
+ };
7
+ export declare const fetchPredefinedProperties: (networkElementType: string) => Promise<PredefinedProperties | undefined>;
8
+ export declare const emptyProperties: Properties;
9
+ export declare const createPropertyModification: (name: string, value: string | null) => Property;
10
+ export declare const initializedProperty: () => Property;
11
+ export declare const getFilledPropertiesFromModification: (properties: Property[] | undefined | null) => FilledProperty[];
12
+ export declare const getPropertiesFromModification: (properties: Property[] | undefined | null) => Properties;
13
+ export declare const copyEquipmentPropertiesForCreation: (equipmentInfos: EquipmentWithProperties) => Properties;
14
+ export declare const mergeModificationAndEquipmentProperties: (modificationProperties: Property[], equipment: EquipmentWithProperties) => Property[];
15
+ export declare function getConcatenatedProperties(equipment: EquipmentWithProperties, getValues: (name: string) => any, id?: string): any;
16
+ export declare const toModificationProperties: (properties: Properties) => Property[] | null;
17
+ export declare const creationPropertiesSchema: yup.ObjectSchema<{
18
+ AdditionalProperties: {
19
+ previousValue?: string | null | undefined;
20
+ added: NonNullable<boolean | undefined>;
21
+ deletionMark: NonNullable<boolean | undefined>;
22
+ name: string;
23
+ value: string;
24
+ }[] | undefined;
25
+ }, yup.AnyObject, {
26
+ AdditionalProperties: "";
27
+ }, "">;
28
+ export declare const modificationPropertiesSchema: yup.ObjectSchema<{
29
+ AdditionalProperties: {
30
+ previousValue?: string | null | undefined;
31
+ value?: string | null | undefined;
32
+ added: NonNullable<boolean | undefined>;
33
+ deletionMark: NonNullable<boolean | undefined>;
34
+ name: string;
35
+ }[] | undefined;
36
+ }, yup.AnyObject, {
37
+ AdditionalProperties: "";
38
+ }, "">;
39
+ export declare const getPropertyValue: (properties: Record<string, string> | undefined, keyName: string) => string | undefined;
@@ -0,0 +1,160 @@
1
+ import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
2
+ import { isBlankOrEmpty } from "../../../../utils/conversionUtils.js";
3
+ import "../../../../utils/types/equipmentType.js";
4
+ import "react/jsx-runtime";
5
+ import "@mui/icons-material";
6
+ import "../../../../utils/yupConfig.js";
7
+ import { fetchStudyMetadata } from "../../../../services/appsMetadata.js";
8
+ import * as yup from "yup";
9
+ const fetchPredefinedProperties = (networkElementType) => {
10
+ return fetchStudyMetadata().then((studyMetadata) => {
11
+ return studyMetadata.predefinedEquipmentProperties?.[networkElementType];
12
+ });
13
+ };
14
+ const emptyProperties = {
15
+ [FieldConstants.ADDITIONAL_PROPERTIES]: []
16
+ };
17
+ const createPropertyModification = (name, value) => {
18
+ return {
19
+ [FieldConstants.NAME]: name,
20
+ [FieldConstants.VALUE]: value,
21
+ [FieldConstants.PREVIOUS_VALUE]: value,
22
+ [FieldConstants.DELETION_MARK]: false,
23
+ [FieldConstants.ADDED]: true
24
+ };
25
+ };
26
+ const initializedProperty = () => {
27
+ return createPropertyModification("", null);
28
+ };
29
+ const isFilledProperty = (property) => {
30
+ return property.value != null;
31
+ };
32
+ const getFilledPropertiesFromModification = (properties) => {
33
+ return properties?.filter(isFilledProperty).map((p) => {
34
+ return {
35
+ [FieldConstants.NAME]: p[FieldConstants.NAME],
36
+ [FieldConstants.VALUE]: p[FieldConstants.VALUE],
37
+ [FieldConstants.PREVIOUS_VALUE]: p[FieldConstants.PREVIOUS_VALUE],
38
+ [FieldConstants.ADDED]: p[FieldConstants.ADDED],
39
+ [FieldConstants.DELETION_MARK]: p[FieldConstants.DELETION_MARK]
40
+ };
41
+ }) ?? [];
42
+ };
43
+ const getPropertiesFromModification = (properties) => {
44
+ return {
45
+ [FieldConstants.ADDITIONAL_PROPERTIES]: properties ? properties.map((p) => {
46
+ return {
47
+ [FieldConstants.NAME]: p[FieldConstants.NAME],
48
+ [FieldConstants.VALUE]: p[FieldConstants.VALUE],
49
+ [FieldConstants.PREVIOUS_VALUE]: p[FieldConstants.PREVIOUS_VALUE],
50
+ [FieldConstants.ADDED]: p[FieldConstants.ADDED],
51
+ [FieldConstants.DELETION_MARK]: p[FieldConstants.DELETION_MARK]
52
+ };
53
+ }) : []
54
+ };
55
+ };
56
+ const copyEquipmentPropertiesForCreation = (equipmentInfos) => {
57
+ return {
58
+ [FieldConstants.ADDITIONAL_PROPERTIES]: equipmentInfos.properties ? Object.entries(equipmentInfos.properties).map(([name, value]) => {
59
+ return {
60
+ [FieldConstants.NAME]: name,
61
+ [FieldConstants.VALUE]: value,
62
+ [FieldConstants.PREVIOUS_VALUE]: null,
63
+ [FieldConstants.DELETION_MARK]: false,
64
+ [FieldConstants.ADDED]: true
65
+ };
66
+ }) : []
67
+ };
68
+ };
69
+ const mergeModificationAndEquipmentProperties = (modificationProperties, equipment) => {
70
+ const newModificationProperties = /* @__PURE__ */ new Map();
71
+ modificationProperties.forEach((property) => {
72
+ if (property.name !== null) {
73
+ newModificationProperties.set(property.name, property);
74
+ }
75
+ });
76
+ if (equipment.properties !== void 0) {
77
+ Object.entries(equipment.properties).forEach(([name, value]) => {
78
+ if (name !== null) {
79
+ let propertyToAdd;
80
+ if (newModificationProperties.has(name)) {
81
+ const modProperty = newModificationProperties.get(name);
82
+ propertyToAdd = {
83
+ ...modProperty,
84
+ previousValue: value
85
+ // We set previous value of the modification to the equipment value
86
+ };
87
+ } else {
88
+ propertyToAdd = {
89
+ [FieldConstants.NAME]: name,
90
+ [FieldConstants.VALUE]: null,
91
+ [FieldConstants.PREVIOUS_VALUE]: value,
92
+ [FieldConstants.DELETION_MARK]: false,
93
+ [FieldConstants.ADDED]: false
94
+ };
95
+ }
96
+ newModificationProperties.set(name, propertyToAdd);
97
+ }
98
+ });
99
+ }
100
+ return Array.from(newModificationProperties.values());
101
+ };
102
+ function getConcatenatedProperties(equipment, getValues, id) {
103
+ const path = id ? `${id}.${FieldConstants.ADDITIONAL_PROPERTIES}` : `${FieldConstants.ADDITIONAL_PROPERTIES}`;
104
+ const modificationProperties = getValues(path);
105
+ return mergeModificationAndEquipmentProperties(modificationProperties, equipment);
106
+ }
107
+ const toModificationProperties = (properties) => {
108
+ const filteredProperties = properties[FieldConstants.ADDITIONAL_PROPERTIES]?.filter(
109
+ (p) => !isBlankOrEmpty(p.value) || p[FieldConstants.DELETION_MARK]
110
+ );
111
+ return filteredProperties === void 0 || filteredProperties?.length === 0 ? null : filteredProperties;
112
+ };
113
+ const checkUniquePropertyNames = (properties) => {
114
+ if (properties === void 0) {
115
+ return true;
116
+ }
117
+ const validValues = properties.filter((v) => v.name);
118
+ return validValues.length === new Set(validValues.map((v) => v.name)).size;
119
+ };
120
+ const creationPropertiesSchema = yup.object({
121
+ [FieldConstants.ADDITIONAL_PROPERTIES]: yup.array().of(
122
+ yup.object().shape({
123
+ [FieldConstants.NAME]: yup.string().required(),
124
+ [FieldConstants.VALUE]: yup.string().required(),
125
+ [FieldConstants.PREVIOUS_VALUE]: yup.string().nullable(),
126
+ [FieldConstants.DELETION_MARK]: yup.boolean().required(),
127
+ [FieldConstants.ADDED]: yup.boolean().required()
128
+ })
129
+ ).test("checkUniqueProperties", "DuplicatedPropsError", (values) => checkUniquePropertyNames(values))
130
+ });
131
+ const modificationPropertiesSchema = yup.object({
132
+ [FieldConstants.ADDITIONAL_PROPERTIES]: yup.array().of(
133
+ yup.object().shape({
134
+ [FieldConstants.NAME]: yup.string().required(),
135
+ [FieldConstants.VALUE]: yup.string().nullable().when([FieldConstants.ADDED], {
136
+ is: (added) => added,
137
+ then: (schema) => schema.required()
138
+ }),
139
+ [FieldConstants.PREVIOUS_VALUE]: yup.string().nullable(),
140
+ [FieldConstants.DELETION_MARK]: yup.boolean().required(),
141
+ [FieldConstants.ADDED]: yup.boolean().required()
142
+ })
143
+ ).test("checkUniqueProperties", "DuplicatedPropsError", (values) => checkUniquePropertyNames(values))
144
+ });
145
+ const getPropertyValue = (properties, keyName) => properties?.[keyName];
146
+ export {
147
+ copyEquipmentPropertiesForCreation,
148
+ createPropertyModification,
149
+ creationPropertiesSchema,
150
+ emptyProperties,
151
+ fetchPredefinedProperties,
152
+ getConcatenatedProperties,
153
+ getFilledPropertiesFromModification,
154
+ getPropertiesFromModification,
155
+ getPropertyValue,
156
+ initializedProperty,
157
+ mergeModificationAndEquipmentProperties,
158
+ modificationPropertiesSchema,
159
+ toModificationProperties
160
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2026, 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
+ */
7
+ export * from './common';
8
+ export * from './substation';
@@ -0,0 +1,31 @@
1
+ import { PropertiesForm } from "./common/properties/PropertiesForm.js";
2
+ import { PropertyForm } from "./common/properties/PropertyForm.js";
3
+ import { copyEquipmentPropertiesForCreation, createPropertyModification, creationPropertiesSchema, emptyProperties, fetchPredefinedProperties, getConcatenatedProperties, getFilledPropertiesFromModification, getPropertiesFromModification, getPropertyValue, initializedProperty, mergeModificationAndEquipmentProperties, modificationPropertiesSchema, toModificationProperties } from "./common/properties/propertyUtils.js";
4
+ import { filledTextField, italicFontTextField, standardTextField } from "./common/form.utils.js";
5
+ import { SubstationCreationForm } from "./substation/creation/SubstationCreationForm.js";
6
+ import { substationCreationDtoToForm, substationCreationEmptyFormData, substationCreationFormSchema, substationCreationFormToDto } from "./substation/creation/substationCreation.utils.js";
7
+ export {
8
+ PropertiesForm,
9
+ PropertyForm,
10
+ SubstationCreationForm,
11
+ copyEquipmentPropertiesForCreation,
12
+ createPropertyModification,
13
+ creationPropertiesSchema,
14
+ emptyProperties,
15
+ fetchPredefinedProperties,
16
+ filledTextField,
17
+ getConcatenatedProperties,
18
+ getFilledPropertiesFromModification,
19
+ getPropertiesFromModification,
20
+ getPropertyValue,
21
+ initializedProperty,
22
+ italicFontTextField,
23
+ mergeModificationAndEquipmentProperties,
24
+ modificationPropertiesSchema,
25
+ standardTextField,
26
+ substationCreationDtoToForm,
27
+ substationCreationEmptyFormData,
28
+ substationCreationFormSchema,
29
+ substationCreationFormToDto,
30
+ toModificationProperties
31
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2026, 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
+ */
7
+ export declare function SubstationCreationForm(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,52 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { Grid } from "@mui/material";
3
+ import GridItem from "../../../grid/grid-item.js";
4
+ import "react-intl";
5
+ import "../../../overflowableText/OverflowableText.js";
6
+ import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
7
+ import "../../../../utils/conversionUtils.js";
8
+ import "../../../../utils/types/equipmentType.js";
9
+ import "@mui/icons-material";
10
+ import "../../../../utils/yupConfig.js";
11
+ import "react";
12
+ import "react-hook-form";
13
+ import "localized-countries";
14
+ import "localized-countries/data/fr";
15
+ import "localized-countries/data/en";
16
+ import "notistack";
17
+ import "../../../inputs/reactHookForm/provider/CustomFormProvider.js";
18
+ import "yup";
19
+ import "../../../treeViewFinder/TreeViewFinder.js";
20
+ import "../../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
21
+ import "../../../customAGGrid/customAggrid.js";
22
+ import "ag-grid-community";
23
+ import "react-papaparse";
24
+ import "react-csv-downloader";
25
+ import { TextInput } from "../../../inputs/reactHookForm/text/TextInput.js";
26
+ import "../../../inputs/reactHookForm/numbers/RangeInput.js";
27
+ import { CountrySelectionInput } from "../../../inputs/reactHookForm/CountrySelectionInput.js";
28
+ import "@react-querybuilder/material";
29
+ import "../../../filter/expert/expertFilterConstants.js";
30
+ import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
31
+ import "uuid";
32
+ import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
33
+ import "react-querybuilder";
34
+ import { PropertiesForm } from "../../common/properties/PropertiesForm.js";
35
+ import { filledTextField } from "../../common/form.utils.js";
36
+ import "../../common/properties/propertyUtils.js";
37
+ function SubstationCreationForm() {
38
+ const substationIdField = /* @__PURE__ */ jsx(TextInput, { name: FieldConstants.EQUIPMENT_ID, label: "ID", formProps: filledTextField });
39
+ const substationNameField = /* @__PURE__ */ jsx(TextInput, { name: FieldConstants.EQUIPMENT_NAME, label: "Name", formProps: filledTextField });
40
+ const substationCountryField = /* @__PURE__ */ jsx(CountrySelectionInput, { name: FieldConstants.COUNTRY, label: "Country", formProps: filledTextField, size: "small" });
41
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
42
+ /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
43
+ /* @__PURE__ */ jsx(GridItem, { size: 4, children: substationIdField }),
44
+ /* @__PURE__ */ jsx(GridItem, { size: 4, children: substationNameField }),
45
+ /* @__PURE__ */ jsx(GridItem, { size: 4, children: substationCountryField })
46
+ ] }),
47
+ /* @__PURE__ */ jsx(PropertiesForm, { networkElementType: "substation" })
48
+ ] });
49
+ }
50
+ export {
51
+ SubstationCreationForm
52
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2026, 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
+ */
7
+ export * from './SubstationCreationForm';
8
+ export * from './substationCreation.types';
9
+ export * from './substationCreation.utils';
@@ -0,0 +1,9 @@
1
+ import { SubstationCreationForm } from "./SubstationCreationForm.js";
2
+ import { substationCreationDtoToForm, substationCreationEmptyFormData, substationCreationFormSchema, substationCreationFormToDto } from "./substationCreation.utils.js";
3
+ export {
4
+ SubstationCreationForm,
5
+ substationCreationDtoToForm,
6
+ substationCreationEmptyFormData,
7
+ substationCreationFormSchema,
8
+ substationCreationFormToDto
9
+ };
@@ -0,0 +1,8 @@
1
+ import { Property } from '../../common';
2
+ export type SubstationCreationDto = {
3
+ type: string;
4
+ equipmentId: string;
5
+ equipmentName: string | null;
6
+ country: string | null;
7
+ properties: Property[] | null;
8
+ };
@@ -0,0 +1,24 @@
1
+ import { default as yup } from '../../../../utils/yupConfig';
2
+ import { SubstationCreationDto } from './substationCreation.types';
3
+ export declare const substationCreationFormToDto: (substationForm: SubstationCreationFormData) => SubstationCreationDto;
4
+ export declare const substationCreationDtoToForm: (substationDto: SubstationCreationDto) => SubstationCreationFormData;
5
+ export declare const substationCreationFormSchema: yup.ObjectSchema<{
6
+ equipmentID: string;
7
+ equipmentName: string | null | undefined;
8
+ country: string | null | undefined;
9
+ } & {
10
+ AdditionalProperties: {
11
+ previousValue?: string | null | undefined;
12
+ added: NonNullable<boolean | undefined>;
13
+ deletionMark: NonNullable<boolean | undefined>;
14
+ name: string;
15
+ value: string;
16
+ }[] | undefined;
17
+ }, yup.AnyObject, {
18
+ equipmentID: undefined;
19
+ equipmentName: undefined;
20
+ country: undefined;
21
+ AdditionalProperties: "";
22
+ }, "">;
23
+ export type SubstationCreationFormData = yup.InferType<typeof substationCreationFormSchema>;
24
+ export declare const substationCreationEmptyFormData: SubstationCreationFormData;