@gridsuite/commons-ui 0.269.0 → 0.271.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 (142) hide show
  1. package/dist/components/ui/dialogs/customMuiDialog/CustomMuiDialog.d.ts +10 -3
  2. package/dist/components/ui/dialogs/customMuiDialog/CustomMuiDialog.js +33 -28
  3. package/dist/features/index.js +96 -3
  4. package/dist/features/network-modifications/common/branch/branchCreation.types.d.ts +26 -0
  5. package/dist/features/network-modifications/common/branch/branchModification.types.d.ts +36 -0
  6. package/dist/features/network-modifications/common/branch/branchModification.types.js +1 -0
  7. package/dist/features/network-modifications/{line/characteristics/lineCharacteristicsPane.types.d.ts → common/branch/index.d.ts} +2 -8
  8. package/dist/features/network-modifications/common/branch/index.js +1 -0
  9. package/dist/features/network-modifications/common/connectivity/connectivityForm.utils.d.ts +2 -0
  10. package/dist/features/network-modifications/common/currentLimits/limits.types.d.ts +1 -0
  11. package/dist/features/network-modifications/common/currentLimits/limitsPane.utils.d.ts +2 -2
  12. package/dist/features/network-modifications/common/index.d.ts +1 -0
  13. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.js +1 -1
  14. package/dist/features/network-modifications/common/regulatingTerminal/regulatingTerminal.utils.d.ts +2 -2
  15. package/dist/features/network-modifications/common/regulatingTerminal/regulatingTerminal.utils.js +2 -2
  16. package/dist/features/network-modifications/index.d.ts +1 -0
  17. package/dist/features/network-modifications/index.js +96 -3
  18. package/dist/features/network-modifications/line/characteristics/index.d.ts +0 -1
  19. package/dist/features/network-modifications/line/characteristics/index.js +1 -2
  20. package/dist/features/network-modifications/line/characteristics/lineCharacteristicsPane.utils.d.ts +4 -19
  21. package/dist/features/network-modifications/line/characteristics/lineCharacteristicsPane.utils.js +0 -14
  22. package/dist/features/network-modifications/line/creation/lineCreation.types.d.ts +6 -26
  23. package/dist/features/network-modifications/line/index.js +1 -2
  24. package/dist/features/network-modifications/line/modification/lineModification.types.d.ts +3 -35
  25. package/dist/features/network-modifications/twoWindingsTransformer/characteristics/TwoWindingsTransformerCharacteristicsPane.d.ts +7 -0
  26. package/dist/features/network-modifications/twoWindingsTransformer/characteristics/TwoWindingsTransformerCharacteristicsPane.js +168 -0
  27. package/dist/features/network-modifications/twoWindingsTransformer/characteristics/index.d.ts +8 -0
  28. package/dist/features/network-modifications/twoWindingsTransformer/characteristics/index.js +8 -0
  29. package/dist/features/network-modifications/twoWindingsTransformer/characteristics/twoWindingsTransformerCharacteristicsPane.utils.d.ts +41 -0
  30. package/dist/features/network-modifications/twoWindingsTransformer/characteristics/twoWindingsTransformerCharacteristicsPane.utils.js +51 -0
  31. package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerDialogHeader.d.ts +6 -0
  32. package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerDialogHeader.js +123 -0
  33. package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerDialogTabs.d.ts +9 -0
  34. package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerDialogTabs.js +89 -0
  35. package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerDialogTabsContent.d.ts +14 -0
  36. package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerDialogTabsContent.js +118 -0
  37. package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerForm.d.ts +6 -0
  38. package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerForm.js +47 -0
  39. package/dist/features/network-modifications/twoWindingsTransformer/common/index.d.ts +12 -0
  40. package/dist/features/network-modifications/twoWindingsTransformer/common/index.js +13 -0
  41. package/dist/features/network-modifications/twoWindingsTransformer/common/twoWindingsTransformer.types.d.ts +87 -0
  42. package/dist/features/network-modifications/twoWindingsTransformer/common/twoWindingsTransformer.types.js +1 -0
  43. package/dist/features/network-modifications/twoWindingsTransformer/common/twoWindingsTransformer.utils.d.ts +10 -0
  44. package/dist/features/network-modifications/twoWindingsTransformer/common/twoWindingsTransformer.utils.js +50 -0
  45. package/dist/features/network-modifications/twoWindingsTransformer/creation/index.d.ts +8 -0
  46. package/dist/features/network-modifications/twoWindingsTransformer/creation/index.js +12 -0
  47. package/dist/features/network-modifications/twoWindingsTransformer/creation/twoWindingsTransformerCreation.types.d.ts +47 -0
  48. package/dist/features/network-modifications/twoWindingsTransformer/creation/twoWindingsTransformerCreation.types.js +8 -0
  49. package/dist/features/network-modifications/twoWindingsTransformer/creation/twoWindingsTransformerCreation.utils.d.ts +248 -0
  50. package/dist/features/network-modifications/twoWindingsTransformer/creation/twoWindingsTransformerCreation.utils.js +325 -0
  51. package/dist/features/network-modifications/twoWindingsTransformer/index.d.ts +11 -0
  52. package/dist/features/network-modifications/twoWindingsTransformer/index.js +88 -0
  53. package/dist/features/network-modifications/twoWindingsTransformer/modification/index.d.ts +9 -0
  54. package/dist/features/network-modifications/twoWindingsTransformer/modification/index.js +10 -0
  55. package/dist/features/network-modifications/twoWindingsTransformer/modification/measurements/ToBeEstimatedForm.d.ts +6 -0
  56. package/dist/features/network-modifications/twoWindingsTransformer/modification/measurements/ToBeEstimatedForm.js +104 -0
  57. package/dist/features/network-modifications/twoWindingsTransformer/modification/measurements/index.d.ts +9 -0
  58. package/dist/features/network-modifications/twoWindingsTransformer/modification/measurements/index.js +7 -0
  59. package/dist/features/network-modifications/twoWindingsTransformer/modification/measurements/toBeEstimated.type.d.ts +10 -0
  60. package/dist/features/network-modifications/twoWindingsTransformer/modification/measurements/toBeEstimated.type.js +1 -0
  61. package/dist/features/network-modifications/twoWindingsTransformer/modification/measurements/toBeEstimated.utils.d.ts +12 -0
  62. package/dist/features/network-modifications/twoWindingsTransformer/modification/measurements/toBeEstimated.utils.js +18 -0
  63. package/dist/features/network-modifications/twoWindingsTransformer/modification/twoWindingsTransformerModification.types.d.ts +39 -0
  64. package/dist/features/network-modifications/twoWindingsTransformer/modification/twoWindingsTransformerModification.types.js +1 -0
  65. package/dist/features/network-modifications/twoWindingsTransformer/modification/twoWindingsTransformerModification.utils.d.ts +265 -0
  66. package/dist/features/network-modifications/twoWindingsTransformer/modification/twoWindingsTransformerModification.utils.js +100 -0
  67. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/RegulatedTerminalSection.d.ts +13 -0
  68. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/RegulatedTerminalSection.js +130 -0
  69. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/TapChangerSteps.d.ts +20 -0
  70. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/TapChangerSteps.js +311 -0
  71. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/index.d.ts +12 -0
  72. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/index.js +53 -0
  73. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/phaseTapChanger/PhaseTapChangerPane.d.ts +2 -0
  74. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/phaseTapChanger/PhaseTapChangerPane.js +198 -0
  75. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/phaseTapChanger/PhaseTapChangerPaneSteps.d.ts +9 -0
  76. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/phaseTapChanger/PhaseTapChangerPaneSteps.js +201 -0
  77. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/phaseTapChanger/index.d.ts +9 -0
  78. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/phaseTapChanger/index.js +15 -0
  79. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/phaseTapChanger/phaseTapChanger.utils.d.ts +114 -0
  80. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/phaseTapChanger/phaseTapChanger.utils.js +242 -0
  81. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/ratioTapChanger/RatioTapChangerPane.d.ts +2 -0
  82. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/ratioTapChanger/RatioTapChangerPane.js +283 -0
  83. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/ratioTapChanger/RatioTapChangerPaneSteps.d.ts +9 -0
  84. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/ratioTapChanger/RatioTapChangerPaneSteps.js +181 -0
  85. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/ratioTapChanger/index.d.ts +9 -0
  86. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/ratioTapChanger/index.js +18 -0
  87. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/ratioTapChanger/ratioTapChanger.utils.d.ts +132 -0
  88. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/ratioTapChanger/ratioTapChanger.utils.js +211 -0
  89. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/CreateRuleDialog.d.ts +2 -0
  90. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/CreateRuleDialog.js +102 -0
  91. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/CreateRuleDialogSubmitButton.d.ts +7 -0
  92. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/CreateRuleDialogSubmitButton.js +22 -0
  93. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/CreateRuleForm.d.ts +6 -0
  94. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/CreateRuleForm.js +86 -0
  95. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/ImportRuleDialog.d.ts +10 -0
  96. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/ImportRuleDialog.js +140 -0
  97. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/index.d.ts +12 -0
  98. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/index.js +13 -0
  99. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/regulationRule.types.d.ts +12 -0
  100. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/regulationRule.types.js +1 -0
  101. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/regulationRule.utils.d.ts +9 -0
  102. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/regulationRule/regulationRule.utils.js +19 -0
  103. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/tapChanger.utils.d.ts +14 -0
  104. package/dist/features/network-modifications/twoWindingsTransformer/tapChanger/tapChanger.utils.js +79 -0
  105. package/dist/features/network-modifications/voltageLevel/index.d.ts +1 -0
  106. package/dist/features/network-modifications/voltageLevel/index.js +9 -1
  107. package/dist/features/network-modifications/voltageLevel/section/VoltageLevelSectionCreationForm.d.ts +10 -0
  108. package/dist/features/network-modifications/voltageLevel/section/VoltageLevelSectionCreationForm.js +375 -0
  109. package/dist/features/network-modifications/voltageLevel/section/index.d.ts +9 -0
  110. package/dist/features/network-modifications/voltageLevel/section/index.js +10 -0
  111. package/dist/features/network-modifications/voltageLevel/section/voltageLevelSectionCreation.types.d.ts +15 -0
  112. package/dist/features/network-modifications/voltageLevel/section/voltageLevelSectionCreation.types.js +1 -0
  113. package/dist/features/network-modifications/voltageLevel/section/voltageLevelSectionCreation.utils.d.ts +48 -0
  114. package/dist/features/network-modifications/voltageLevel/section/voltageLevelSectionCreation.utils.js +100 -0
  115. package/dist/index.js +107 -7
  116. package/dist/translations/en/filterExpertEn.d.ts +0 -3
  117. package/dist/translations/en/filterExpertEn.js +0 -3
  118. package/dist/translations/en/network-modification-validationEn.d.ts +1 -0
  119. package/dist/translations/en/network-modification-validationEn.js +2 -1
  120. package/dist/translations/en/networkModificationsEn.d.ts +87 -9
  121. package/dist/translations/en/networkModificationsEn.js +91 -12
  122. package/dist/translations/fr/filterExpertFr.d.ts +0 -3
  123. package/dist/translations/fr/filterExpertFr.js +0 -3
  124. package/dist/translations/fr/network-modification-validationFr.d.ts +1 -0
  125. package/dist/translations/fr/network-modification-validationFr.js +2 -1
  126. package/dist/translations/fr/networkModificationsFr.d.ts +87 -9
  127. package/dist/translations/fr/networkModificationsFr.js +91 -12
  128. package/dist/utils/constants/fieldConstants.d.ts +37 -0
  129. package/dist/utils/constants/fieldConstants.js +37 -0
  130. package/dist/utils/constants/index.js +2 -1
  131. package/dist/utils/constants/translationKeys.d.ts +1 -0
  132. package/dist/utils/constants/translationKeys.js +2 -0
  133. package/dist/utils/functions.d.ts +9 -0
  134. package/dist/utils/functions.js +40 -0
  135. package/dist/utils/index.js +11 -4
  136. package/dist/utils/langs.d.ts +1 -0
  137. package/dist/utils/langs.js +9 -1
  138. package/dist/utils/types/equipmentType.d.ts +34 -0
  139. package/dist/utils/types/equipmentType.js +28 -0
  140. package/dist/utils/types/index.js +4 -1
  141. package/package.json +1 -1
  142. /package/dist/features/network-modifications/{line/characteristics/lineCharacteristicsPane.types.js → common/branch/branchCreation.types.js} +0 -0
@@ -0,0 +1,211 @@
1
+ import { object, array, number, ref, mixed, string, bool } from "yup";
2
+ import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
3
+ import { REGULATION_TYPES } from "../../../common/voltageRegulation/voltageRegulation.utils.js";
4
+ import { TARGET_DEADBAND_MUST_BE_GREATER_OR_EQUAL_TO_ZERO } from "../../../../../utils/constants/translationKeys.js";
5
+ import "../../../../../utils/conversionUtils.js";
6
+ import { RATIO_REGULATION_MODES, REGULATION_SIDES } from "../../../../../utils/types/equipmentType.js";
7
+ import { areNumbersOrdered, areArrayElementsUnique } from "../../../../../utils/functions.js";
8
+ import "react/jsx-runtime";
9
+ import "@mui/icons-material";
10
+ import { getRegulatingTerminalEmptyFormData, getRegulatingTerminalFormData } from "../../../common/regulatingTerminal/regulatingTerminal.utils.js";
11
+ const getRegulatingTerminalRatioTapChangerValidationSchema = () => ({
12
+ [FieldConstants.VOLTAGE_LEVEL]: object().nullable().shape({
13
+ [FieldConstants.ID]: string(),
14
+ [FieldConstants.NAME]: string(),
15
+ [FieldConstants.SUBSTATION_ID]: string(),
16
+ [FieldConstants.NOMINAL_VOLTAGE]: string(),
17
+ [FieldConstants.TOPOLOGY_KIND]: string().nullable()
18
+ }).when([FieldConstants.ENABLED, FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES, FieldConstants.REGULATION_TYPE], {
19
+ is: (enabled, hasLoadTapChangingCapabilities, regulationType) => enabled && hasLoadTapChangingCapabilities && regulationType === REGULATION_TYPES.DISTANT.id,
20
+ then: (schema) => schema.required()
21
+ }),
22
+ [FieldConstants.EQUIPMENT]: object().nullable().shape({
23
+ [FieldConstants.ID]: string(),
24
+ [FieldConstants.NAME]: string().nullable(),
25
+ [FieldConstants.TYPE]: string()
26
+ }).when([FieldConstants.ENABLED, FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES, FieldConstants.REGULATION_TYPE], {
27
+ is: (enabled, hasLoadTapChangingCapabilities, regulationType) => enabled && hasLoadTapChangingCapabilities && regulationType === REGULATION_TYPES.DISTANT.id,
28
+ then: (schema) => schema.required()
29
+ })
30
+ });
31
+ const getRatioTapChangerValidationSchemaProps = (isModification = false) => object().shape({
32
+ [FieldConstants.ENABLED]: bool().required(),
33
+ [FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES]: isModification ? bool().nullable() : bool().nullable().required(),
34
+ [FieldConstants.REGULATION_MODE]: string().nullable().when([FieldConstants.ENABLED, FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES], {
35
+ is: (enabled, hasLoadTapChangingCapabilities) => enabled && hasLoadTapChangingCapabilities,
36
+ then: (schema) => schema.required()
37
+ }),
38
+ [FieldConstants.REGULATION_TYPE]: string().nullable().when(
39
+ [FieldConstants.ENABLED, FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES, FieldConstants.REGULATION_MODE],
40
+ {
41
+ is: (enabled, hasLoadTapChangingCapabilities, regulationMode) => enabled && hasLoadTapChangingCapabilities && regulationMode === RATIO_REGULATION_MODES.VOLTAGE_REGULATION.id,
42
+ then: (schema) => schema.required()
43
+ }
44
+ ),
45
+ [FieldConstants.REGULATION_SIDE]: string().nullable().when(
46
+ [FieldConstants.ENABLED, FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES, FieldConstants.REGULATION_TYPE],
47
+ {
48
+ is: (enabled, hasLoadTapChangingCapabilities, regulationType) => enabled && hasLoadTapChangingCapabilities && regulationType === REGULATION_TYPES.LOCAL.id,
49
+ then: (schema) => schema.required()
50
+ }
51
+ ),
52
+ [FieldConstants.TARGET_V]: mixed().nullable().when([FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES], {
53
+ is: true,
54
+ then: () => number().nullable().positive("TargetVoltageMustBeGreaterThanZero")
55
+ }).when([FieldConstants.REGULATION_MODE, FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES], {
56
+ is: (regulationMode, hasLoadTapChangingCapabilities) => {
57
+ return hasLoadTapChangingCapabilities && regulationMode === RATIO_REGULATION_MODES.VOLTAGE_REGULATION.id;
58
+ },
59
+ then: (schema) => schema.required()
60
+ }),
61
+ [FieldConstants.TARGET_DEADBAND]: mixed().nullable().when(FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES, {
62
+ is: true,
63
+ then: () => number().nullable().min(0, TARGET_DEADBAND_MUST_BE_GREATER_OR_EQUAL_TO_ZERO)
64
+ }),
65
+ [FieldConstants.LOW_TAP_POSITION]: number().nullable().when(FieldConstants.ENABLED, {
66
+ is: (enabled) => enabled && !isModification,
67
+ then: (schema) => schema.required()
68
+ }),
69
+ [FieldConstants.HIGH_TAP_POSITION]: number().nullable().when(FieldConstants.ENABLED, {
70
+ is: (enabled) => enabled && !isModification,
71
+ then: (schema) => schema.required()
72
+ }),
73
+ [FieldConstants.TAP_POSITION]: number().nullable().when(FieldConstants.ENABLED, {
74
+ is: (enabled) => enabled && !isModification,
75
+ then: (schema) => schema.required().min(ref(FieldConstants.LOW_TAP_POSITION), "TapPositionMustBeBetweenLowAndHighTapPositionValue").max(
76
+ ref(FieldConstants.HIGH_TAP_POSITION),
77
+ "TapPositionMustBeBetweenLowAndHighTapPositionValue"
78
+ )
79
+ }),
80
+ [FieldConstants.STEPS]: array().of(
81
+ object().shape({
82
+ [FieldConstants.STEPS_TAP]: number().required(),
83
+ [FieldConstants.STEPS_RESISTANCE]: number(),
84
+ [FieldConstants.STEPS_REACTANCE]: number(),
85
+ [FieldConstants.STEPS_CONDUCTANCE]: number(),
86
+ [FieldConstants.STEPS_SUSCEPTANCE]: number(),
87
+ [FieldConstants.STEPS_RATIO]: number()
88
+ })
89
+ ).when(FieldConstants.ENABLED, {
90
+ is: true,
91
+ then: (schema) => schema.min(1, "GenerateRatioTapRowsError")
92
+ }).test("distinctOrderedRatio", "RatioValuesError", (stepsArray) => {
93
+ const ratioArray = (stepsArray ?? []).map((step) => step[FieldConstants.STEPS_RATIO]);
94
+ return areNumbersOrdered(ratioArray) && areArrayElementsUnique(ratioArray);
95
+ }),
96
+ ...getRegulatingTerminalRatioTapChangerValidationSchema()
97
+ });
98
+ const getRatioTapChangerEmptyFormData = (isModification = false) => {
99
+ return {
100
+ [FieldConstants.ENABLED]: false,
101
+ [FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES]: isModification ? null : false,
102
+ [FieldConstants.REGULATION_MODE]: null,
103
+ [FieldConstants.REGULATION_TYPE]: null,
104
+ [FieldConstants.REGULATION_SIDE]: isModification ? null : REGULATION_SIDES.SIDE1.id,
105
+ [FieldConstants.TARGET_V]: null,
106
+ [FieldConstants.TARGET_DEADBAND]: null,
107
+ [FieldConstants.LOW_TAP_POSITION]: null,
108
+ [FieldConstants.HIGH_TAP_POSITION]: null,
109
+ [FieldConstants.TAP_POSITION]: null,
110
+ [FieldConstants.STEPS]: [],
111
+ ...getRegulatingTerminalEmptyFormData()
112
+ };
113
+ };
114
+ const getRatioTapChangerFormData = ({
115
+ enabled = false,
116
+ hasLoadTapChangingCapabilities = false,
117
+ regulationMode = null,
118
+ regulationType = null,
119
+ regulationSide = REGULATION_SIDES.SIDE1.id,
120
+ targetV = null,
121
+ targetDeadband = null,
122
+ lowTapPosition = null,
123
+ highTapPosition = null,
124
+ tapPosition = null,
125
+ steps = [],
126
+ voltageLevelId,
127
+ equipmentId,
128
+ equipmentType
129
+ }, id = FieldConstants.RATIO_TAP_CHANGER) => ({
130
+ [id]: {
131
+ [FieldConstants.ENABLED]: enabled,
132
+ [FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES]: hasLoadTapChangingCapabilities,
133
+ [FieldConstants.REGULATION_MODE]: regulationMode,
134
+ [FieldConstants.REGULATION_TYPE]: regulationType,
135
+ [FieldConstants.REGULATION_SIDE]: regulationSide,
136
+ [FieldConstants.TARGET_V]: targetV,
137
+ [FieldConstants.TARGET_DEADBAND]: targetDeadband,
138
+ [FieldConstants.LOW_TAP_POSITION]: lowTapPosition,
139
+ [FieldConstants.HIGH_TAP_POSITION]: highTapPosition,
140
+ [FieldConstants.TAP_POSITION]: tapPosition,
141
+ [FieldConstants.STEPS]: steps,
142
+ ...getRegulatingTerminalFormData({
143
+ equipmentID: equipmentId,
144
+ voltageLevelId,
145
+ equipmentType
146
+ })
147
+ }
148
+ });
149
+ const getComputedRegulationType = (twt) => {
150
+ if (!twt?.[FieldConstants.RATIO_TAP_CHANGER]?.[FieldConstants.LOAD_TAP_CHANGING_CAPABILITIES] || !twt?.[FieldConstants.RATIO_TAP_CHANGER]?.regulatingTerminalConnectableId) {
151
+ return null;
152
+ }
153
+ if (twt?.[FieldConstants.RATIO_TAP_CHANGER]?.regulatingTerminalConnectableId !== twt?.[FieldConstants.ID]) {
154
+ return REGULATION_TYPES.DISTANT;
155
+ }
156
+ return REGULATION_TYPES.LOCAL;
157
+ };
158
+ const getComputedRegulationTypeId = (twt) => {
159
+ const regulationType = getComputedRegulationType(twt);
160
+ return regulationType?.id || null;
161
+ };
162
+ const getComputedRegulationMode = (twt) => {
163
+ const ratioTapChangerValues = twt?.ratioTapChanger;
164
+ if (!ratioTapChangerValues) {
165
+ return null;
166
+ }
167
+ if (ratioTapChangerValues[FieldConstants.REGULATING]) {
168
+ return RATIO_REGULATION_MODES.VOLTAGE_REGULATION;
169
+ }
170
+ return RATIO_REGULATION_MODES.FIXED_RATIO;
171
+ };
172
+ const getInitialTwtRatioRegulationModeId = (twt) => {
173
+ if (!twt?.ratioTapChanger?.hasLoadTapChangingCapabilities) {
174
+ return null;
175
+ }
176
+ const computedRegulationMode = getComputedRegulationMode(twt);
177
+ return computedRegulationMode?.id || null;
178
+ };
179
+ const getComputedRegulationModeId = (twt) => {
180
+ return getComputedRegulationMode(twt)?.id || null;
181
+ };
182
+ const getComputedPreviousRatioRegulationType = (previousValues) => {
183
+ const previousRegulationType = getComputedRegulationType(previousValues);
184
+ return previousRegulationType?.id || null;
185
+ };
186
+ const getComputedTapSide = (twt) => {
187
+ const ratioTapChangerValues = twt?.ratioTapChanger;
188
+ if (!ratioTapChangerValues || !twt) {
189
+ return null;
190
+ }
191
+ if (ratioTapChangerValues?.regulatingTerminalConnectableId === twt?.[FieldConstants.ID]) {
192
+ return ratioTapChangerValues?.regulatingTerminalVlId === twt?.voltageLevelId1 ? REGULATION_SIDES.SIDE1 : REGULATION_SIDES.SIDE2;
193
+ }
194
+ return null;
195
+ };
196
+ const getComputedTapSideId = (twt) => {
197
+ return getComputedTapSide(twt)?.id || null;
198
+ };
199
+ export {
200
+ getComputedPreviousRatioRegulationType,
201
+ getComputedRegulationMode,
202
+ getComputedRegulationModeId,
203
+ getComputedRegulationType,
204
+ getComputedRegulationTypeId,
205
+ getComputedTapSide,
206
+ getComputedTapSideId,
207
+ getInitialTwtRatioRegulationModeId,
208
+ getRatioTapChangerEmptyFormData,
209
+ getRatioTapChangerFormData,
210
+ getRatioTapChangerValidationSchemaProps
211
+ };
@@ -0,0 +1,2 @@
1
+ import { CreateRuleDialogProps } from './regulationRule.types';
2
+ export declare function CreateRuleDialog({ tapChanger, openCreateRuleDialog, setOpenCreateRuleDialog, handleCreateTapRule, allowNegativeValues, }: CreateRuleDialogProps): import("react").JSX.Element;
@@ -0,0 +1,102 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Dialog, DialogActions } from "@mui/material";
3
+ import { useForm } from "react-hook-form";
4
+ import { yupResolver } from "@hookform/resolvers/yup";
5
+ import { useCallback } from "react";
6
+ import { CreateRuleForm } from "./CreateRuleForm.js";
7
+ import { getCreateRuleEmptyFormData, getCreateRuleValidationSchema } from "./regulationRule.utils.js";
8
+ import { CreateRuleDialogSubmitButton } from "./CreateRuleDialogSubmitButton.js";
9
+ import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
10
+ import "../../../../../utils/conversionUtils.js";
11
+ import "../../../../../utils/types/equipmentType.js";
12
+ import "@mui/icons-material";
13
+ import "react-intl";
14
+ import "../../../../../components/ui/overflowableText/OverflowableText.js";
15
+ import "localized-countries";
16
+ import "localized-countries/data/fr";
17
+ import "localized-countries/data/en";
18
+ import "notistack";
19
+ import { CustomFormProvider } from "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
20
+ import { CancelButton } from "../../../../../components/ui/reactHookForm/utils/CancelButton.js";
21
+ import "yup";
22
+ import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
23
+ import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
24
+ import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
25
+ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
26
+ import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
27
+ import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
28
+ import "@material-symbols/svg-400/outlined/add_notes-fill.svg?react";
29
+ import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
30
+ import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
31
+ import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
32
+ import "@hello-pangea/dnd";
33
+ import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
34
+ import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
35
+ import "mui-nested-menu";
36
+ import "react-resizable-panels";
37
+ import "react-papaparse";
38
+ import "react-dom";
39
+ import "autosuggest-highlight/match";
40
+ import "autosuggest-highlight/parse";
41
+ import "clsx";
42
+ import "../../../../../components/composite/filter/FilterCreationDialog.js";
43
+ import "../../../../../components/composite/filter/HeaderFilterForm.js";
44
+ import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
45
+ import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
46
+ import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
47
+ import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
48
+ import "react-querybuilder";
49
+ import "uuid";
50
+ import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
51
+ import "../../../../../components/composite/filter/utils/filterFormUtils.js";
52
+ import "@react-querybuilder/material";
53
+ import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
54
+ import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
55
+ import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
56
+ import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
57
+ import "ag-grid-community";
58
+ import "../../../../../components/composite/customAGGrid/customAggrid.js";
59
+ import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
60
+ import "mathjs";
61
+ import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
62
+ import "react-window";
63
+ import "../../../../../components/composite/report/report-treeview/treeview-item.js";
64
+ import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
65
+ const EMPTY_FORM_DATA = getCreateRuleEmptyFormData();
66
+ const FORM_SCHEMA = getCreateRuleValidationSchema();
67
+ function CreateRuleDialog({
68
+ tapChanger,
69
+ openCreateRuleDialog,
70
+ setOpenCreateRuleDialog,
71
+ handleCreateTapRule,
72
+ allowNegativeValues
73
+ }) {
74
+ const formMethods = useForm({
75
+ defaultValues: EMPTY_FORM_DATA,
76
+ resolver: yupResolver(FORM_SCHEMA)
77
+ });
78
+ const { reset } = formMethods;
79
+ const handleCloseDialog = useCallback(() => {
80
+ reset(EMPTY_FORM_DATA);
81
+ setOpenCreateRuleDialog(false);
82
+ }, [reset, setOpenCreateRuleDialog]);
83
+ const handleSave = useCallback(
84
+ (data) => {
85
+ if (data[FieldConstants.LOW_TAP_POSITION] != null && data[FieldConstants.HIGH_TAP_POSITION] != null) {
86
+ handleCreateTapRule(data[FieldConstants.LOW_TAP_POSITION], data[FieldConstants.HIGH_TAP_POSITION]);
87
+ handleCloseDialog();
88
+ }
89
+ },
90
+ [handleCreateTapRule, handleCloseDialog]
91
+ );
92
+ return /* @__PURE__ */ jsx(Dialog, { open: openCreateRuleDialog, fullWidth: true, children: /* @__PURE__ */ jsxs(CustomFormProvider, { validationSchema: FORM_SCHEMA, ...formMethods, children: [
93
+ /* @__PURE__ */ jsx(CreateRuleForm, { tapChanger }),
94
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
95
+ /* @__PURE__ */ jsx(CancelButton, { onClick: handleCloseDialog }),
96
+ /* @__PURE__ */ jsx(CreateRuleDialogSubmitButton, { handleSave, allowNegativeValues })
97
+ ] })
98
+ ] }) });
99
+ }
100
+ export {
101
+ CreateRuleDialog
102
+ };
@@ -0,0 +1,7 @@
1
+ import { CreateRuleFormInput } from './regulationRule.types';
2
+ interface CreateRuleDialogSubmitButtonProps {
3
+ handleSave: (data: CreateRuleFormInput) => void;
4
+ allowNegativeValues: boolean;
5
+ }
6
+ export declare function CreateRuleDialogSubmitButton({ handleSave, allowNegativeValues, }: Readonly<CreateRuleDialogSubmitButtonProps>): import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,22 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Button } from "@mui/material";
3
+ import { useFormContext, useWatch } from "react-hook-form";
4
+ import { FormattedMessage } from "react-intl";
5
+ import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
6
+ import "../../../../../utils/conversionUtils.js";
7
+ import "../../../../../utils/types/equipmentType.js";
8
+ import "@mui/icons-material";
9
+ function CreateRuleDialogSubmitButton({
10
+ handleSave,
11
+ allowNegativeValues
12
+ }) {
13
+ const { handleSubmit } = useFormContext();
14
+ const [lowTapPosition, highTapPosition] = useWatch({
15
+ name: [FieldConstants.LOW_TAP_POSITION, FieldConstants.HIGH_TAP_POSITION]
16
+ });
17
+ const isTapValuesInvalid = highTapPosition == null || lowTapPosition == null || !allowNegativeValues && highTapPosition <= 0 || !allowNegativeValues && lowTapPosition <= 0 || highTapPosition === lowTapPosition;
18
+ return /* @__PURE__ */ jsx(Button, { onClick: handleSubmit(handleSave), variant: "outlined", disabled: isTapValuesInvalid, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "validate" }) });
19
+ }
20
+ export {
21
+ CreateRuleDialogSubmitButton
22
+ };
@@ -0,0 +1,6 @@
1
+ import { FieldConstants } from '../../../../../utils';
2
+ interface CreateRuleFormProps {
3
+ tapChanger: FieldConstants.PHASE_TAP_CHANGER | FieldConstants.RATIO_TAP_CHANGER;
4
+ }
5
+ export declare function CreateRuleForm({ tapChanger }: Readonly<CreateRuleFormProps>): import("react").JSX.Element;
6
+ export {};
@@ -0,0 +1,86 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { DialogTitle, DialogContent, Stack, Box } from "@mui/material";
3
+ import { FormattedMessage } from "react-intl";
4
+ import "@mui/icons-material";
5
+ import "../../../../../components/ui/overflowableText/OverflowableText.js";
6
+ import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
7
+ import "../../../../../utils/conversionUtils.js";
8
+ import "../../../../../utils/types/equipmentType.js";
9
+ import "react";
10
+ import "react-hook-form";
11
+ import "localized-countries";
12
+ import "localized-countries/data/fr";
13
+ import "localized-countries/data/en";
14
+ import "notistack";
15
+ import "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
16
+ import "yup";
17
+ import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
18
+ import { FloatInput } from "../../../../../components/ui/reactHookForm/numbers/FloatInput.js";
19
+ import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
20
+ import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
21
+ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
22
+ import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
23
+ import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
24
+ import "@material-symbols/svg-400/outlined/add_notes-fill.svg?react";
25
+ import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
26
+ import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
27
+ import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
28
+ import "@hello-pangea/dnd";
29
+ import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
30
+ import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
31
+ import "mui-nested-menu";
32
+ import "react-resizable-panels";
33
+ import "react-papaparse";
34
+ import "react-dom";
35
+ import "autosuggest-highlight/match";
36
+ import "autosuggest-highlight/parse";
37
+ import "clsx";
38
+ import "../../../../../components/composite/filter/FilterCreationDialog.js";
39
+ import "../../../../../components/composite/filter/HeaderFilterForm.js";
40
+ import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
41
+ import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
42
+ import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
43
+ import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
44
+ import "react-querybuilder";
45
+ import "uuid";
46
+ import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
47
+ import "../../../../../components/composite/filter/utils/filterFormUtils.js";
48
+ import "@react-querybuilder/material";
49
+ import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
50
+ import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
51
+ import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
52
+ import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
53
+ import "ag-grid-community";
54
+ import "../../../../../components/composite/customAGGrid/customAggrid.js";
55
+ import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
56
+ import "mathjs";
57
+ import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
58
+ import "react-window";
59
+ import "../../../../../components/composite/report/report-treeview/treeview-item.js";
60
+ import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
61
+ const TAP_LABELS = {
62
+ [FieldConstants.PHASE_TAP_CHANGER]: {
63
+ low: "LowTapAlpha",
64
+ high: "HighTapAlpha",
65
+ title: "CreateDephasingRule"
66
+ },
67
+ [FieldConstants.RATIO_TAP_CHANGER]: {
68
+ low: "LowTapRatio",
69
+ high: "HighTapRatio",
70
+ title: "CreateRegulationRule"
71
+ }
72
+ };
73
+ const DIALOG_CONTENT_STYLE = { paddingTop: "5px" };
74
+ function CreateRuleForm({ tapChanger }) {
75
+ const labels = TAP_LABELS[tapChanger] ?? { low: "", high: "", title: "" };
76
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
77
+ /* @__PURE__ */ jsx(DialogTitle, { children: /* @__PURE__ */ jsx(FormattedMessage, { id: labels.title }) }),
78
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs(Stack, { spacing: 2, sx: DIALOG_CONTENT_STYLE, children: [
79
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(FloatInput, { label: labels.low, name: FieldConstants.LOW_TAP_POSITION }) }),
80
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(FloatInput, { label: labels.high, name: FieldConstants.HIGH_TAP_POSITION }) })
81
+ ] }) })
82
+ ] });
83
+ }
84
+ export {
85
+ CreateRuleForm
86
+ };
@@ -0,0 +1,10 @@
1
+ import { default as Papa } from 'papaparse';
2
+ import { FieldConstants } from '../../../../../utils';
3
+ export interface ImportRuleDialogProps {
4
+ tapChanger: FieldConstants.PHASE_TAP_CHANGER | FieldConstants.RATIO_TAP_CHANGER;
5
+ openImportRuleDialog: boolean;
6
+ setOpenImportRuleDialog: (open: boolean) => void;
7
+ csvColumns: string[];
8
+ handleImportTapRule: (results: Papa.ParseResult<Record<string, string>>) => void;
9
+ }
10
+ export declare function ImportRuleDialog({ tapChanger, openImportRuleDialog, setOpenImportRuleDialog, csvColumns, handleImportTapRule, }: ImportRuleDialogProps): import("react").JSX.Element;
@@ -0,0 +1,140 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { Dialog, DialogTitle, DialogContent, Stack, Grid, Button, Alert, DialogActions } from "@mui/material";
3
+ import { useState, useEffect, useMemo } from "react";
4
+ import { useIntl, FormattedMessage } from "react-intl";
5
+ import { useCSVDownloader } from "react-papaparse";
6
+ import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
7
+ import "../../../../../utils/conversionUtils.js";
8
+ import "../../../../../utils/types/equipmentType.js";
9
+ import { transformIfFrenchNumber, getCsvDelimiter } from "../../../../../utils/langs.js";
10
+ import "@mui/icons-material";
11
+ import "../../../../../components/ui/overflowableText/OverflowableText.js";
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 "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
18
+ import { CancelButton } from "../../../../../components/ui/reactHookForm/utils/CancelButton.js";
19
+ import "yup";
20
+ import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
21
+ import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
22
+ import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
23
+ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
24
+ import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
25
+ import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
26
+ import "@material-symbols/svg-400/outlined/add_notes-fill.svg?react";
27
+ import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
28
+ import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
29
+ import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
30
+ import "@hello-pangea/dnd";
31
+ import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
32
+ import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
33
+ import "mui-nested-menu";
34
+ import "react-resizable-panels";
35
+ import { CsvPicker } from "../../../../../components/ui/csvPicker/csv-picker.js";
36
+ import "react-dom";
37
+ import { MAX_ROWS_NUMBER } from "../../../../../components/composite/dnd-table/dnd-table.type.js";
38
+ import "autosuggest-highlight/match";
39
+ import "autosuggest-highlight/parse";
40
+ import "clsx";
41
+ import "../../../../../components/composite/filter/FilterCreationDialog.js";
42
+ import "../../../../../components/composite/filter/HeaderFilterForm.js";
43
+ import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
44
+ import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
45
+ import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
46
+ import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
47
+ import "react-querybuilder";
48
+ import "uuid";
49
+ import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
50
+ import "../../../../../components/composite/filter/utils/filterFormUtils.js";
51
+ import "@react-querybuilder/material";
52
+ import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
53
+ import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
54
+ import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
55
+ import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
56
+ import "ag-grid-community";
57
+ import "../../../../../components/composite/customAGGrid/customAggrid.js";
58
+ import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
59
+ import "mathjs";
60
+ import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
61
+ import "react-window";
62
+ import "../../../../../components/composite/report/report-treeview/treeview-item.js";
63
+ import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
64
+ const NO_REQUIRED_COLUMNS = [];
65
+ function ImportRuleDialog({
66
+ tapChanger,
67
+ openImportRuleDialog,
68
+ setOpenImportRuleDialog,
69
+ csvColumns,
70
+ handleImportTapRule
71
+ }) {
72
+ const { locale } = useIntl();
73
+ const { CSVDownloader } = useCSVDownloader();
74
+ const [selectedFile, setSelectedFile] = useState();
75
+ const [fileErrorMessage, setFileErrorMessage] = useState();
76
+ const [parsedResults, setParsedResults] = useState();
77
+ const language = locale;
78
+ useEffect(() => {
79
+ setSelectedFile(void 0);
80
+ setFileErrorMessage(void 0);
81
+ setParsedResults(void 0);
82
+ }, [openImportRuleDialog]);
83
+ const parseConfig = useMemo(
84
+ () => ({ transform: (value) => transformIfFrenchNumber(value, language) }),
85
+ [language]
86
+ );
87
+ const handleCloseDialog = () => {
88
+ setOpenImportRuleDialog(false);
89
+ };
90
+ const handleSave = () => {
91
+ if (!fileErrorMessage && parsedResults) {
92
+ handleImportTapRule(parsedResults);
93
+ handleCloseDialog();
94
+ }
95
+ };
96
+ const isInvalid = useMemo(() => {
97
+ return typeof parsedResults === "undefined" || typeof fileErrorMessage !== "undefined";
98
+ }, [parsedResults, fileErrorMessage]);
99
+ return /* @__PURE__ */ jsxs(Dialog, { open: openImportRuleDialog, fullWidth: true, children: [
100
+ /* @__PURE__ */ jsx(DialogTitle, { children: /* @__PURE__ */ jsx(
101
+ FormattedMessage,
102
+ {
103
+ id: tapChanger === FieldConstants.PHASE_TAP_CHANGER ? "ImportDephasingRule" : "ImportRegulationRule"
104
+ }
105
+ ) }),
106
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs(Stack, { spacing: 2, children: [
107
+ /* @__PURE__ */ jsx(Grid, { children: /* @__PURE__ */ jsx(
108
+ CSVDownloader,
109
+ {
110
+ data: [csvColumns],
111
+ filename: tapChanger === FieldConstants.PHASE_TAP_CHANGER ? "tap-dephasing-rule" : "tap-regulating-rule",
112
+ config: { delimiter: getCsvDelimiter(language) },
113
+ children: /* @__PURE__ */ jsx(Button, { variant: "contained", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "GenerateSkeleton" }) })
114
+ }
115
+ ) }),
116
+ /* @__PURE__ */ jsx(Grid, { children: /* @__PURE__ */ jsx(
117
+ CsvPicker,
118
+ {
119
+ label: tapChanger === FieldConstants.PHASE_TAP_CHANGER ? "ImportDephasingRule" : "ImportRegulationRule",
120
+ requiredColumns: NO_REQUIRED_COLUMNS,
121
+ maxLineNumber: MAX_ROWS_NUMBER,
122
+ language,
123
+ parseConfig,
124
+ selectedFile,
125
+ onFileChange: setSelectedFile,
126
+ onFileError: setFileErrorMessage,
127
+ onComplete: setParsedResults
128
+ }
129
+ ) }),
130
+ fileErrorMessage && /* @__PURE__ */ jsx(Grid, { children: /* @__PURE__ */ jsx(Alert, { severity: "error", children: fileErrorMessage }) })
131
+ ] }) }),
132
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
133
+ /* @__PURE__ */ jsx(CancelButton, { onClick: handleCloseDialog }),
134
+ /* @__PURE__ */ jsx(Button, { onClick: handleSave, variant: "outlined", disabled: isInvalid, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "validate" }) })
135
+ ] })
136
+ ] });
137
+ }
138
+ export {
139
+ ImportRuleDialog
140
+ };
@@ -0,0 +1,12 @@
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 './regulationRule.types';
8
+ export * from './regulationRule.utils';
9
+ export * from './CreateRuleDialogSubmitButton';
10
+ export * from './CreateRuleForm';
11
+ export * from './CreateRuleDialog';
12
+ export * from './ImportRuleDialog';
@@ -0,0 +1,13 @@
1
+ import { getCreateRuleEmptyFormData, getCreateRuleValidationSchema } from "./regulationRule.utils.js";
2
+ import { CreateRuleDialogSubmitButton } from "./CreateRuleDialogSubmitButton.js";
3
+ import { CreateRuleForm } from "./CreateRuleForm.js";
4
+ import { CreateRuleDialog } from "./CreateRuleDialog.js";
5
+ import { ImportRuleDialog } from "./ImportRuleDialog.js";
6
+ export {
7
+ CreateRuleDialog,
8
+ CreateRuleDialogSubmitButton,
9
+ CreateRuleForm,
10
+ ImportRuleDialog,
11
+ getCreateRuleEmptyFormData,
12
+ getCreateRuleValidationSchema
13
+ };
@@ -0,0 +1,12 @@
1
+ import { FieldConstants } from '../../../../../utils';
2
+ export interface CreateRuleFormInput {
3
+ lowTapPosition: number | null;
4
+ highTapPosition: number | null;
5
+ }
6
+ export interface CreateRuleDialogProps {
7
+ tapChanger: FieldConstants.PHASE_TAP_CHANGER | FieldConstants.RATIO_TAP_CHANGER;
8
+ openCreateRuleDialog: boolean;
9
+ setOpenCreateRuleDialog: (open: boolean) => void;
10
+ handleCreateTapRule: (lowTap: number, highTap: number) => void;
11
+ allowNegativeValues: boolean;
12
+ }