@gridsuite/commons-ui 0.193.0 → 0.195.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 (112) hide show
  1. package/dist/components/directoryItemSelector/DirectoryItemSelector.js +0 -1
  2. package/dist/components/dnd-table-v2/deletable-table-row.d.ts +7 -0
  3. package/dist/components/dnd-table-v2/deletable-table-row.js +37 -0
  4. package/dist/components/dnd-table-v2/dnd-table-add-rows-dialog.d.ts +13 -0
  5. package/dist/components/dnd-table-v2/dnd-table-add-rows-dialog.js +75 -0
  6. package/dist/components/dnd-table-v2/dnd-table-bottom-left-buttons.d.ts +17 -0
  7. package/dist/components/dnd-table-v2/dnd-table-bottom-left-buttons.js +48 -0
  8. package/dist/components/dnd-table-v2/dnd-table-bottom-right-buttons.d.ts +17 -0
  9. package/dist/components/dnd-table-v2/dnd-table-bottom-right-buttons.js +103 -0
  10. package/dist/components/dnd-table-v2/dnd-table-row.d.ts +23 -0
  11. package/dist/components/dnd-table-v2/dnd-table-row.js +183 -0
  12. package/dist/components/dnd-table-v2/dnd-table-utils.d.ts +2 -0
  13. package/dist/components/dnd-table-v2/dnd-table-utils.js +10 -0
  14. package/dist/components/dnd-table-v2/dnd-table.d.ts +32 -0
  15. package/dist/components/dnd-table-v2/dnd-table.js +381 -0
  16. package/dist/components/dnd-table-v2/dnd-table.type.d.ts +70 -0
  17. package/dist/components/dnd-table-v2/dnd-table.type.js +19 -0
  18. package/dist/components/dnd-table-v2/index.d.ts +12 -0
  19. package/dist/components/dnd-table-v2/index.js +16 -0
  20. package/dist/components/index.js +3 -8
  21. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.d.ts +1 -2
  22. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +2 -5
  23. package/dist/components/inputs/reactHookForm/booleans/BooleanInput.js +6 -4
  24. package/dist/components/inputs/reactQueryBuilder/OperatorSelector.js +0 -1
  25. package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-form.js +72 -53
  26. package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.d.ts +1 -0
  27. package/dist/components/network-modifications/by-filter/assignment/assignment/assignment-utils.js +8 -5
  28. package/dist/components/network-modifications/by-filter/assignment/modificationByAssignment.utils.js +5 -5
  29. package/dist/components/parameters/common/contingency-table/columns-definitions.d.ts +4 -3
  30. package/dist/components/parameters/common/contingency-table/columns-definitions.js +23 -15
  31. package/dist/components/parameters/common/contingency-table/contingency-table.d.ts +2 -1
  32. package/dist/components/parameters/common/contingency-table/contingency-table.js +45 -44
  33. package/dist/components/parameters/common/contingency-table/index.js +2 -2
  34. package/dist/components/parameters/common/index.js +2 -2
  35. package/dist/components/parameters/common/parameter-field.js +2 -0
  36. package/dist/components/parameters/common/parameter-table/table-cell.js +1 -1
  37. package/dist/components/parameters/common/parameter-table-field/constants.d.ts +10 -0
  38. package/dist/components/parameters/common/parameter-table-field/constants.js +10 -0
  39. package/dist/components/parameters/common/{parameter-table → parameter-table-field}/index.d.ts +2 -3
  40. package/dist/components/parameters/common/parameter-table-field/index.js +9 -0
  41. package/dist/components/parameters/common/parameter-table-field/parameter-table-field.d.ts +11 -0
  42. package/dist/components/parameters/common/parameter-table-field/parameter-table-field.js +121 -0
  43. package/dist/components/parameters/common/parameters-edition-dialog-props.d.ts +1 -1
  44. package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.js +2 -0
  45. package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +2 -0
  46. package/dist/components/parameters/dynamic-margin-calculation/loads-variations-parameters.js +7 -6
  47. package/dist/components/parameters/dynamic-margin-calculation/use-dynamic-margin-calculation-parameters-form.js +2 -0
  48. package/dist/components/parameters/dynamic-security-analysis/contingency-parameters.js +2 -0
  49. package/dist/components/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +2 -0
  50. package/dist/components/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.js +2 -0
  51. package/dist/components/parameters/dynamic-security-analysis/use-dynamic-security-analysis-parameters-form.js +2 -0
  52. package/dist/components/parameters/dynamic-simulation/dynamic-simulation-inline.js +2 -0
  53. package/dist/components/parameters/dynamic-simulation/dynamic-simulation-parameters-form.js +2 -0
  54. package/dist/components/parameters/dynamic-simulation/mapping/mapping-parameters.js +0 -1
  55. package/dist/components/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.js +2 -0
  56. package/dist/components/parameters/index.js +3 -8
  57. package/dist/components/parameters/loadflow/load-flow-general-parameters.js +2 -0
  58. package/dist/components/parameters/loadflow/load-flow-parameters-content.js +2 -0
  59. package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +2 -0
  60. package/dist/components/parameters/loadflow/load-flow-parameters-header.js +2 -0
  61. package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +3 -1
  62. package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +2 -0
  63. package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +2 -0
  64. package/dist/components/parameters/network-visualizations/map-parameters.js +2 -0
  65. package/dist/components/parameters/network-visualizations/network-visualizations-form.js +2 -0
  66. package/dist/components/parameters/network-visualizations/network-visualizations-parameters-inline.js +3 -1
  67. package/dist/components/parameters/network-visualizations/single-line-diagram-parameters.js +2 -0
  68. package/dist/components/parameters/pcc-min/pcc-min-parameters-form.js +2 -0
  69. package/dist/components/parameters/pcc-min/pcc-min-parameters-inline.js +3 -1
  70. package/dist/components/parameters/security-analysis/columns-definitions.js +2 -0
  71. package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +3 -1
  72. package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +5 -4
  73. package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.js +2 -0
  74. package/dist/components/parameters/security-analysis/security-analysis-parameters-selector.js +2 -0
  75. package/dist/components/parameters/security-analysis/security-analysis-violations-hiding.js +2 -0
  76. package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.d.ts +1 -1
  77. package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +7 -3
  78. package/dist/components/parameters/sensi/columns-definitions.d.ts +7 -180
  79. package/dist/components/parameters/sensi/columns-definitions.js +81 -73
  80. package/dist/components/parameters/sensi/index.js +1 -6
  81. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +3 -1
  82. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +4 -2
  83. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +2 -0
  84. package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +52 -51
  85. package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.d.ts +2 -2
  86. package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +41 -61
  87. package/dist/components/parameters/sensi/utils.d.ts +4 -4
  88. package/dist/components/parameters/sensi/utils.js +8 -6
  89. package/dist/components/parameters/short-circuit/short-circuit-general-tab-panel.js +2 -0
  90. package/dist/components/parameters/short-circuit/short-circuit-parameters-content.js +2 -0
  91. package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +2 -0
  92. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +3 -1
  93. package/dist/components/parameters/short-circuit/short-circuit-parameters-utils.js +2 -0
  94. package/dist/components/parameters/short-circuit/short-circuit-power-electronics-tab-panel.js +2 -0
  95. package/dist/components/parameters/short-circuit/short-circuit-study-area-tab-panel.js +2 -0
  96. package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +2 -0
  97. package/dist/components/parameters/voltage-init/equipment-selection-parameters.js +2 -0
  98. package/dist/components/parameters/voltage-init/general-parameters.js +2 -0
  99. package/dist/components/parameters/voltage-init/voltage-init-parameters-form.js +2 -0
  100. package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.js +3 -1
  101. package/dist/components/parameters/voltage-init/voltage-limits-parameters.js +17 -31
  102. package/dist/hooks/index.d.ts +0 -1
  103. package/dist/hooks/index.js +0 -2
  104. package/dist/index.js +3 -10
  105. package/package.json +1 -1
  106. package/dist/components/parameters/common/parameter-dnd-table-field.d.ts +0 -9
  107. package/dist/components/parameters/common/parameter-dnd-table-field.js +0 -86
  108. package/dist/components/parameters/common/parameter-table/index.js +0 -10
  109. package/dist/hooks/use-create-row-data.d.ts +0 -4
  110. package/dist/hooks/use-create-row-data.js +0 -19
  111. /package/dist/components/parameters/sensi/{sensitivity-Flow-parameters.d.ts → sensitivity-parameters-fields.d.ts} +0 -0
  112. /package/dist/components/parameters/sensi/{sensitivity-Flow-parameters.js → sensitivity-parameters-fields.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useMemo, useCallback } from "react";
2
+ import { useMemo, useRef, useState, useEffect, useCallback } from "react";
3
3
  import { DensityLarge } from "@mui/icons-material";
4
4
  import { useFormContext, useWatch } from "react-hook-form";
5
5
  import { useIntl } from "react-intl";
@@ -8,14 +8,13 @@ import "../../../../../utils/conversionUtils.js";
8
8
  import { ElementType } from "../../../../../utils/types/elementType.js";
9
9
  import "../../../../../utils/types/equipmentType.js";
10
10
  import { FieldType } from "../../../../../utils/types/fieldType.js";
11
- import { areIdsEqual, getIdOrValue } from "../../../../../utils/ts-utils.js";
11
+ import { getIdOrValue, areIdsEqual } from "../../../../../utils/ts-utils.js";
12
12
  import "../../../../../utils/yupConfig.js";
13
13
  import "@mui/material";
14
14
  import "localized-countries";
15
15
  import "localized-countries/data/fr";
16
16
  import "localized-countries/data/en";
17
17
  import { usePredefinedProperties } from "../../../../../hooks/usePredefinedProperties.js";
18
- import { usePrevious } from "../../../../../hooks/usePrevious.js";
19
18
  import "notistack";
20
19
  import { useFormatLabelWithUnit } from "../../../../../hooks/useFormatLabelWithUnit.js";
21
20
  import "../../../../overflowableText/OverflowableText.js";
@@ -49,6 +48,7 @@ import "react-querybuilder";
49
48
  import { DataType } from "./assignment.type.js";
50
49
  import GridItem from "../../../../grid/grid-item.js";
51
50
  import { EQUIPMENTS_FIELDS } from "./assignment-constants.js";
51
+ import { EMPTY_FIELD_VALUE } from "./assignment-utils.js";
52
52
  const comparatorStrIgnoreCase = (str1, str2) => {
53
53
  return str1?.toLowerCase()?.localeCompare(str2?.toLowerCase());
54
54
  };
@@ -94,24 +94,31 @@ function AssignmentForm(props) {
94
94
  const options = useMemo(() => {
95
95
  return equipmentFields?.find((fieldOption) => fieldOption?.id === watchEditedField)?.values ?? [];
96
96
  }, [watchEditedField, equipmentFields]);
97
- const prevDataType = usePrevious(dataType);
98
- if (prevDataType && prevDataType !== dataType) {
99
- setValue(`${name}.${index}.${FieldConstants.VALUE}`, dataType === DataType.BOOLEAN ? false : null);
100
- }
101
- const emptyValueStr = useMemo(() => {
97
+ const emptyFieldLabel = useMemo(() => {
102
98
  return intl.formatMessage({ id: "EmptyField" });
103
99
  }, [intl]);
104
100
  const formatLabelWithUnit = useFormatLabelWithUnit();
101
+ const prevEditedField = useRef(watchEditedField);
102
+ const [editedFieldKey, setEditedFieldKey] = useState(watchEditedField);
103
+ useEffect(() => {
104
+ if (prevEditedField.current !== watchEditedField) {
105
+ prevEditedField.current = watchEditedField;
106
+ setValue(`${name}.${index}.${FieldConstants.VALUE}`, dataType === DataType.BOOLEAN ? false : null);
107
+ setValue(`${name}.${index}.${FieldConstants.PROPERTY_NAME}`, null);
108
+ setEditedFieldKey(watchEditedField);
109
+ }
110
+ }, [dataType, index, name, setValue, watchEditedField]);
105
111
  const renderAutoCompleteSettableToNone = useCallback(
106
112
  (numberOnly) => /* @__PURE__ */ jsx(
107
113
  AutocompleteInput,
108
114
  {
109
115
  name: `${name}.${index}.${FieldConstants.VALUE}`,
110
116
  label: "ValueOrEmptyField",
111
- options: [emptyValueStr],
117
+ options: [emptyFieldLabel],
112
118
  size: "small",
113
119
  onCheckNewValue: numberOnly ? (option) => {
114
- if (option && option !== emptyValueStr && Number.isNaN(Number(option))) {
120
+ const optionValue = getIdOrValue(option);
121
+ if (optionValue && optionValue !== emptyFieldLabel && optionValue !== EMPTY_FIELD_VALUE && Number.isNaN(Number(optionValue))) {
115
122
  setError(`${name}.${index}.${FieldConstants.VALUE}`, {
116
123
  message: "NumericValueOrEmptyField"
117
124
  });
@@ -123,10 +130,19 @@ function AssignmentForm(props) {
123
130
  return true;
124
131
  } : void 0,
125
132
  getOptionLabel: (option) => typeof option !== "string" ? option?.label ?? option : option,
133
+ inputTransform: (value) => value === EMPTY_FIELD_VALUE ? emptyFieldLabel : value,
134
+ outputTransform: (value) => {
135
+ const optionValue = getIdOrValue(value);
136
+ if (optionValue === emptyFieldLabel) {
137
+ return EMPTY_FIELD_VALUE;
138
+ }
139
+ return optionValue ?? null;
140
+ },
126
141
  allowNewValue: true
127
- }
142
+ },
143
+ editedFieldKey
128
144
  ),
129
- [emptyValueStr, index, name, setError]
145
+ [emptyFieldLabel, index, name, setError, editedFieldKey]
130
146
  );
131
147
  const filtersField = /* @__PURE__ */ jsx(
132
148
  DirectoryItemsInput,
@@ -162,47 +178,50 @@ function AssignmentForm(props) {
162
178
  allowNewValue: true
163
179
  }
164
180
  );
165
- const valueField = useMemo(() => {
166
- if (dataType === DataType.PROPERTY) {
167
- return /* @__PURE__ */ jsx(
168
- AutocompleteInput,
169
- {
170
- name: `${name}.${index}.${FieldConstants.VALUE}`,
171
- label: "PropertyValue",
172
- options: predefinedPropertiesValues,
173
- size: "small",
174
- allowNewValue: true
175
- }
176
- );
177
- }
178
- if (dataType === DataType.INTEGER) {
179
- return /* @__PURE__ */ jsx(IntegerInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" });
180
- }
181
- if (dataType === DataType.BOOLEAN) {
182
- return /* @__PURE__ */ jsx(SwitchInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, formProps: { value: false } });
183
- }
184
- if (dataType === DataType.ENUM) {
185
- return /* @__PURE__ */ jsx(
186
- SelectInput,
187
- {
188
- name: `${name}.${index}.${FieldConstants.VALUE}`,
189
- label: "Value",
190
- options,
191
- size: "small"
192
- }
193
- );
194
- }
195
- if (dataType === DataType.STRING && settableToNone) {
196
- return renderAutoCompleteSettableToNone();
197
- }
198
- if (dataType === DataType.STRING) {
199
- return /* @__PURE__ */ jsx(TextInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value", clearable: true });
200
- }
201
- if (dataType === DataType.DOUBLE && settableToNone) {
202
- return renderAutoCompleteSettableToNone(true);
203
- }
204
- return /* @__PURE__ */ jsx(FloatInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" });
205
- }, [dataType, settableToNone, name, index, predefinedPropertiesValues, options, renderAutoCompleteSettableToNone]);
181
+ let valueField;
182
+ if (dataType === DataType.PROPERTY) {
183
+ valueField = /* @__PURE__ */ jsx(
184
+ AutocompleteInput,
185
+ {
186
+ name: `${name}.${index}.${FieldConstants.VALUE}`,
187
+ label: "PropertyValue",
188
+ options: predefinedPropertiesValues,
189
+ size: "small",
190
+ allowNewValue: true
191
+ },
192
+ editedFieldKey
193
+ );
194
+ } else if (dataType === DataType.INTEGER) {
195
+ valueField = /* @__PURE__ */ jsx(IntegerInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" }, editedFieldKey);
196
+ } else if (dataType === DataType.BOOLEAN) {
197
+ valueField = /* @__PURE__ */ jsx(
198
+ SwitchInput,
199
+ {
200
+ name: `${name}.${index}.${FieldConstants.VALUE}`,
201
+ formProps: { value: false }
202
+ },
203
+ editedFieldKey
204
+ );
205
+ } else if (dataType === DataType.ENUM) {
206
+ valueField = /* @__PURE__ */ jsx(
207
+ SelectInput,
208
+ {
209
+ name: `${name}.${index}.${FieldConstants.VALUE}`,
210
+ label: "Value",
211
+ options,
212
+ size: "small"
213
+ },
214
+ editedFieldKey
215
+ );
216
+ } else if (dataType === DataType.STRING && settableToNone) {
217
+ valueField = renderAutoCompleteSettableToNone();
218
+ } else if (dataType === DataType.STRING) {
219
+ valueField = /* @__PURE__ */ jsx(TextInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value", clearable: true }, editedFieldKey);
220
+ } else if (dataType === DataType.DOUBLE && settableToNone) {
221
+ valueField = renderAutoCompleteSettableToNone(true);
222
+ } else {
223
+ valueField = /* @__PURE__ */ jsx(FloatInput, { name: `${name}.${index}.${FieldConstants.VALUE}`, label: "Value" }, editedFieldKey);
224
+ }
206
225
  return /* @__PURE__ */ jsxs(Fragment, { children: [
207
226
  /* @__PURE__ */ jsx(GridItem, { size: 3.25, children: filtersField }),
208
227
  /* @__PURE__ */ jsx(GridItem, { size: 3, children: editedField }),
@@ -1,5 +1,6 @@
1
1
  import { yupConfig as yup } from '../../../../../utils';
2
2
  import { Assignment, DataType, FieldOptionType, FieldValue } from './assignment.type';
3
+ export declare const EMPTY_FIELD_VALUE = "\u2014";
3
4
  export declare const getFieldOption: (fieldName?: string | null) => FieldOptionType | undefined;
4
5
  export declare const getDataType: (fieldName?: string | null) => DataType | undefined;
5
6
  export declare const getUnsettable: (fieldName?: string | null) => boolean | undefined;
@@ -1,4 +1,5 @@
1
1
  import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
2
+ import { YUP_REQUIRED } from "../../../../../utils/constants/translationKeys.js";
2
3
  import "../../../../../utils/conversionUtils.js";
3
4
  import "../../../../../utils/types/equipmentType.js";
4
5
  import "react/jsx-runtime";
@@ -7,6 +8,7 @@ import "../../../../../utils/yupConfig.js";
7
8
  import { DataType } from "./assignment.type.js";
8
9
  import { FIELD_OPTIONS } from "./assignment-constants.js";
9
10
  import * as yup from "yup";
11
+ const EMPTY_FIELD_VALUE = "—";
10
12
  const getFieldOption = (fieldName) => {
11
13
  return Object.values(FIELD_OPTIONS).find((fieldOption) => fieldOption.id === fieldName);
12
14
  };
@@ -40,7 +42,7 @@ function getValueSchema(emptyValueStr, dataType, settable_to_none) {
40
42
  default:
41
43
  schema = yup.number();
42
44
  }
43
- return schema.required();
45
+ return schema.required(YUP_REQUIRED);
44
46
  }
45
47
  const getAssignmentInitialValue = () => ({
46
48
  [FieldConstants.FILTERS]: [],
@@ -56,12 +58,12 @@ function getAssignmentsSchema(emptyValueStr) {
56
58
  [FieldConstants.ID]: yup.string().required(),
57
59
  [FieldConstants.NAME]: yup.string().required()
58
60
  })
59
- ).required().min(1, "YupRequired"),
60
- [FieldConstants.EDITED_FIELD]: yup.string().required(),
61
+ ).required().min(1, YUP_REQUIRED),
62
+ [FieldConstants.EDITED_FIELD]: yup.string().required(YUP_REQUIRED),
61
63
  [FieldConstants.PROPERTY_NAME]: yup.string().when([FieldConstants.EDITED_FIELD], ([editedField], schema) => {
62
64
  const dataType = getDataType(editedField);
63
65
  if (dataType === DataType.PROPERTY) {
64
- return schema.required();
66
+ return schema.required(YUP_REQUIRED);
65
67
  }
66
68
  return schema.nullable();
67
69
  }),
@@ -69,7 +71,7 @@ function getAssignmentsSchema(emptyValueStr) {
69
71
  const dataType = getDataType(editedField);
70
72
  const unsettable = getUnsettable(editedField);
71
73
  return getValueSchema(emptyValueStr, dataType, unsettable);
72
- }).required()
74
+ }).required(YUP_REQUIRED)
73
75
  })
74
76
  ).required();
75
77
  }
@@ -80,6 +82,7 @@ function getAssignmentFromEditData(assignment) {
80
82
  };
81
83
  }
82
84
  export {
85
+ EMPTY_FIELD_VALUE,
83
86
  getAssignmentFromEditData,
84
87
  getAssignmentInitialValue,
85
88
  getAssignmentsSchema,
@@ -8,12 +8,11 @@ import { FieldType } from "../../../../utils/types/fieldType.js";
8
8
  import "react/jsx-runtime";
9
9
  import "@mui/icons-material";
10
10
  import "../../../../utils/yupConfig.js";
11
- import { getAssignmentsSchema, getAssignmentInitialValue, getAssignmentFromEditData, getDataType } from "./assignment/assignment-utils.js";
11
+ import { getAssignmentsSchema, getAssignmentInitialValue, getAssignmentFromEditData, getUnsettable, EMPTY_FIELD_VALUE, getDataType } from "./assignment/assignment-utils.js";
12
12
  import { DataType } from "./assignment/assignment.type.js";
13
- const emptyValueStr = "—";
14
13
  const modificationByAssignmentFormSchema = yup.object().shape({
15
14
  [FieldConstants.EQUIPMENT_TYPE]: mixed().oneOf(Object.values(EquipmentType)).required(),
16
- [FieldConstants.ASSIGNMENTS]: getAssignmentsSchema(emptyValueStr)
15
+ [FieldConstants.ASSIGNMENTS]: getAssignmentsSchema(EMPTY_FIELD_VALUE)
17
16
  }).required();
18
17
  const emptyModificationByAssignmentFormData = {
19
18
  [FieldConstants.EQUIPMENT_TYPE]: null,
@@ -27,9 +26,10 @@ const modificationByAssignmentDtoToForm = (dto) => ({
27
26
  const field = FieldType[fieldKey];
28
27
  const { value } = assignment;
29
28
  const valueConverted = convertInputValue(field, value);
29
+ const unsettable = getUnsettable(assignment.editedField);
30
30
  return {
31
31
  ...assignment,
32
- value: valueConverted !== 0 && !valueConverted ? emptyValueStr : valueConverted
32
+ value: unsettable && valueConverted !== 0 && !valueConverted ? EMPTY_FIELD_VALUE : valueConverted
33
33
  };
34
34
  }) ?? [getAssignmentInitialValue()]
35
35
  });
@@ -39,7 +39,7 @@ const modificationByAssignmentFormToDto = (formData) => ({
39
39
  assignmentInfosList: formData.assignments.map((assignment) => {
40
40
  const fieldKey = assignment.editedField;
41
41
  const field = FieldType[fieldKey];
42
- const value = assignment.value === emptyValueStr ? "" : assignment.value;
42
+ const value = assignment.value === EMPTY_FIELD_VALUE ? "" : assignment.value;
43
43
  return {
44
44
  ...assignment,
45
45
  dataType: getDataType(assignment.editedField) ?? DataType.STRING,
@@ -1,8 +1,8 @@
1
- import { Parameters, ColumnsDef } from '../parameter-table';
1
+ import { FieldValues } from 'react-hook-form';
2
2
  import { default as yup } from '../../../../utils/yupConfig';
3
3
  import { ContingencyListsInfos } from './types';
4
- export declare const COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS: ColumnsDef[];
5
- export declare const ParamContingencyLists: Parameters;
4
+ import { DndColumn } from '../../../dnd-table-v2';
5
+ export declare const COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS: DndColumn[];
6
6
  export declare const getContingencyListsInfosFormSchema: () => yup.ObjectSchema<{
7
7
  contingencyListsInfos: {
8
8
  description?: string | undefined;
@@ -25,3 +25,4 @@ export declare const toFormValuesContingencyListsInfos: (contingencyListsInfos:
25
25
  activated: boolean;
26
26
  }[];
27
27
  };
28
+ export declare const isValidContingencyRow: (row?: FieldValues) => boolean;
@@ -1,10 +1,14 @@
1
- import { DESCRIPTION, ACTIVATED, NAME, ID } from "../parameter-table/constants.js";
1
+ import { CONTINGENCY_LISTS, CONTINGENCY_LISTS_INFOS } from "../constants.js";
2
+ import { DESCRIPTION, ACTIVATED, NAME, ID } from "../parameter-table-field/constants.js";
2
3
  import "react/jsx-runtime";
3
4
  import "@mui/material";
4
- import "@mui/icons-material";
5
- import "react";
6
5
  import "react-intl";
7
6
  import "react-hook-form";
7
+ import "@mui/icons-material";
8
+ import "react";
9
+ import "react-dom";
10
+ import "@hello-pangea/dnd";
11
+ import { DndColumnType } from "../../../dnd-table-v2/dnd-table.type.js";
8
12
  import "../../../overflowableText/OverflowableText.js";
9
13
  import "../../../../utils/conversionUtils.js";
10
14
  import { ElementType } from "../../../../utils/types/elementType.js";
@@ -35,38 +39,38 @@ import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
35
39
  import "uuid";
36
40
  import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
37
41
  import "react-querybuilder";
38
- import { CONTINGENCY_LISTS, CONTINGENCY_LISTS_INFOS } from "../constants.js";
39
42
  const COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS = [
40
43
  {
41
44
  label: "ContingencyLists",
42
45
  dataKey: CONTINGENCY_LISTS,
43
46
  initialValue: [],
44
47
  editable: true,
45
- directoryItems: true,
48
+ type: DndColumnType.DIRECTORY_ITEMS,
49
+ equipmentTypes: [],
46
50
  elementType: ElementType.CONTINGENCY_LIST,
47
- titleId: "ContingencyListsSelection"
51
+ titleId: "ContingencyListsSelection",
52
+ shouldHandleOnChangeCell: true
48
53
  },
49
54
  {
50
55
  label: "description",
56
+ sxHeader: { textAlign: "center" },
51
57
  dataKey: DESCRIPTION,
52
58
  initialValue: "",
53
59
  editable: true,
54
- descriptionItems: true,
55
- width: "8rem"
60
+ width: "8rem",
61
+ type: DndColumnType.DESCRIPTIONS
56
62
  },
57
63
  {
58
64
  label: "Active",
65
+ sxHeader: { textAlign: "center" },
59
66
  dataKey: ACTIVATED,
60
67
  initialValue: true,
61
- checkboxItems: true,
62
68
  editable: true,
63
- width: "4rem"
69
+ width: "4rem",
70
+ type: DndColumnType.SWITCH,
71
+ shouldHandleOnChangeCell: true
64
72
  }
65
73
  ];
66
- const ParamContingencyLists = {
67
- columnsDef: COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS,
68
- name: CONTINGENCY_LISTS_INFOS
69
- };
70
74
  const getContingencyListsInfosFormSchema = () => {
71
75
  return yup.object().shape({
72
76
  [CONTINGENCY_LISTS_INFOS]: yup.array().of(
@@ -95,9 +99,13 @@ const toFormValuesContingencyListsInfos = (contingencyListsInfos) => {
95
99
  }))
96
100
  };
97
101
  };
102
+ const isValidContingencyRow = (row) => {
103
+ const contingencyLists = row?.[CONTINGENCY_LISTS];
104
+ return row?.[ACTIVATED] === true && Array.isArray(contingencyLists) && contingencyLists.length > 0;
105
+ };
98
106
  export {
99
107
  COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS,
100
- ParamContingencyLists,
101
108
  getContingencyListsInfosFormSchema,
109
+ isValidContingencyRow,
102
110
  toFormValuesContingencyListsInfos
103
111
  };
@@ -1,6 +1,7 @@
1
1
  import { UUID } from 'node:crypto';
2
2
  import { ContingencyCount } from './types';
3
- export declare function ContingencyTable({ showContingencyCount, fetchContingencyCount, isBuiltCurrentNode, }: Readonly<{
3
+ export declare function ContingencyTable({ name, showContingencyCount, fetchContingencyCount, isBuiltCurrentNode, }: Readonly<{
4
+ name: string;
4
5
  showContingencyCount: boolean;
5
6
  fetchContingencyCount?: (contingencyLists: UUID[] | null, abortSignal: AbortSignal) => Promise<ContingencyCount>;
6
7
  isBuiltCurrentNode?: boolean;
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Stack, Alert, CircularProgress } from "@mui/material";
3
- import { useState, useCallback, useEffect } from "react";
2
+ import { Grid, Alert, CircularProgress } from "@mui/material";
3
+ import { useState, useCallback, useMemo, useEffect } from "react";
4
4
  import { useIntl, FormattedMessage } from "react-intl";
5
- import { useWatch } from "react-hook-form";
5
+ import { useFormContext } from "react-hook-form";
6
6
  import "../../../../utils/conversionUtils.js";
7
7
  import { snackWithFallback } from "../../../../utils/error.js";
8
8
  import "../../../../utils/types/equipmentType.js";
@@ -13,40 +13,44 @@ import "localized-countries";
13
13
  import "localized-countries/data/fr";
14
14
  import "localized-countries/data/en";
15
15
  import { useSnackMessage } from "../../../../hooks/useSnackMessage.js";
16
- import { useCreateRowData } from "../../../../hooks/use-create-row-data.js";
17
- import { ACTIVATED, ID } from "../parameter-table/constants.js";
18
- import { ParameterTable } from "../parameter-table/parameter-table.js";
19
- import { CONTINGENCY_LISTS_INFOS, CONTINGENCY_LISTS } from "../constants.js";
20
- import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, ParamContingencyLists } from "./columns-definitions.js";
16
+ import { ACTIVATED, ID } from "../parameter-table-field/constants.js";
17
+ import { ParameterTableField } from "../parameter-table-field/parameter-table-field.js";
18
+ import { CONTINGENCY_LISTS } from "../constants.js";
19
+ import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, isValidContingencyRow } from "./columns-definitions.js";
20
+ const styles = {
21
+ alert: { color: "text.primary", paddingTop: 0, paddingBottom: 0 }
22
+ };
21
23
  function ContingencyTable({
24
+ name,
22
25
  showContingencyCount = false,
23
26
  fetchContingencyCount,
24
27
  isBuiltCurrentNode
25
28
  }) {
26
29
  const intl = useIntl();
27
30
  const [simulatedContingencyCount, setSimulatedContingencyCount] = useState(null);
28
- const [rowData, useFieldArrayOutput] = useCreateRowData(ParamContingencyLists);
29
- const contingencyListsInfos = useWatch({ name: CONTINGENCY_LISTS_INFOS });
30
31
  const [isLoading, setIsLoading] = useState(false);
32
+ const [contingencyCountRefreshTrigger, setContingencyCountRefreshTrigger] = useState(0);
31
33
  const { snackError } = useSnackMessage();
32
- const getColumnsDefinition = useCallback(
33
- (columns) => {
34
- if (columns) {
35
- return columns.map((column) => ({
36
- ...column,
37
- label: intl.formatMessage({ id: column.label })
38
- }));
39
- }
40
- return [];
41
- },
42
- [intl]
43
- );
34
+ const { getValues } = useFormContext();
35
+ const handleOnChange = useCallback(() => {
36
+ setContingencyCountRefreshTrigger((prevValue) => prevValue + 1);
37
+ }, []);
38
+ const columnsDefinition = useMemo(() => {
39
+ return COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS.map(
40
+ (colDef) => ({
41
+ ...colDef,
42
+ label: intl.formatMessage({ id: colDef.label })
43
+ })
44
+ );
45
+ }, [intl]);
44
46
  useEffect(() => {
45
47
  if (!showContingencyCount || !isBuiltCurrentNode) {
46
48
  setIsLoading(false);
49
+ setSimulatedContingencyCount(null);
47
50
  return () => {
48
51
  };
49
52
  }
53
+ const contingencyListsInfos = getValues(name);
50
54
  const hasNoContingencies = !contingencyListsInfos || (contingencyListsInfos.length ?? 0) === 0 || contingencyListsInfos.every(
51
55
  (contingencyList) => !contingencyList[ACTIVATED] || (contingencyList[CONTINGENCY_LISTS]?.length ?? 0) === 0
52
56
  );
@@ -80,26 +84,26 @@ function ContingencyTable({
80
84
  controller?.abort(new Error(IGNORE_SIGNAL));
81
85
  clearTimeout(loadingTimeoutId);
82
86
  };
83
- }, [snackError, contingencyListsInfos, fetchContingencyCount, showContingencyCount, isBuiltCurrentNode]);
87
+ }, [
88
+ snackError,
89
+ getValues,
90
+ fetchContingencyCount,
91
+ showContingencyCount,
92
+ isBuiltCurrentNode,
93
+ name,
94
+ contingencyCountRefreshTrigger
95
+ ]);
84
96
  const renderContingencyCount = () => {
85
97
  if (!isBuiltCurrentNode) {
86
- return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "warning", sx: { color: "text.primary" }, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "contingencyCountImpossibleOnUnbuiltNode" }) });
98
+ return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "warning", sx: styles.alert, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "contingencyCountImpossibleOnUnbuiltNode" }) });
87
99
  }
88
100
  if (isLoading) {
89
- return /* @__PURE__ */ jsx(
90
- Alert,
91
- {
92
- variant: "standard",
93
- icon: /* @__PURE__ */ jsx(CircularProgress, { size: 22 }),
94
- severity: "info",
95
- sx: { color: "text.primary" }
96
- }
97
- );
101
+ return /* @__PURE__ */ jsx(Alert, { variant: "standard", icon: /* @__PURE__ */ jsx(CircularProgress, { size: 22 }), severity: "info", sx: styles.alert });
98
102
  }
99
103
  if (simulatedContingencyCount?.contingencies === 0 && simulatedContingencyCount.notFoundElements === 0) {
100
- return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "error", sx: { color: "text.primary" }, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "noContingency" }) });
104
+ return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "error", sx: styles.alert, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "noContingency" }) });
101
105
  }
102
- return /* @__PURE__ */ jsx(Alert, { variant: "standard", icon: false, severity: "info", sx: { color: "text.primary" }, children: /* @__PURE__ */ jsx(
106
+ return /* @__PURE__ */ jsx(Alert, { variant: "standard", icon: false, severity: "info", sx: styles.alert, children: /* @__PURE__ */ jsx(
103
107
  FormattedMessage,
104
108
  {
105
109
  id: "xContingenciesWillBeSimulatedAndYNotFound",
@@ -110,18 +114,15 @@ function ContingencyTable({
110
114
  }
111
115
  ) });
112
116
  };
113
- return /* @__PURE__ */ jsxs(Stack, { spacing: 0, sx: { width: "100%" }, children: [
117
+ return /* @__PURE__ */ jsxs(Grid, { container: true, direction: "column", children: [
114
118
  /* @__PURE__ */ jsx(
115
- ParameterTable,
119
+ ParameterTableField,
116
120
  {
117
- arrayFormName: CONTINGENCY_LISTS_INFOS,
118
- useFieldArrayOutput,
119
- columnsDefinition: getColumnsDefinition(COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS),
121
+ name,
122
+ columnsDefinition,
120
123
  tableHeight: 270,
121
- createRows: rowData,
122
- onFormChanged: () => {
123
- },
124
- isValidParameterRow: (row) => row[CONTINGENCY_LISTS]?.length > 0
124
+ onChange: handleOnChange,
125
+ isValidRow: isValidContingencyRow
125
126
  }
126
127
  ),
127
128
  showContingencyCount && renderContingencyCount()
@@ -1,9 +1,9 @@
1
1
  import { ContingencyTable } from "./contingency-table.js";
2
- import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, ParamContingencyLists, getContingencyListsInfosFormSchema, toFormValuesContingencyListsInfos } from "./columns-definitions.js";
2
+ import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, getContingencyListsInfosFormSchema, isValidContingencyRow, toFormValuesContingencyListsInfos } from "./columns-definitions.js";
3
3
  export {
4
4
  COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS,
5
5
  ContingencyTable,
6
- ParamContingencyLists,
7
6
  getContingencyListsInfosFormSchema,
7
+ isValidContingencyRow,
8
8
  toFormValuesContingencyListsInfos
9
9
  };
@@ -17,7 +17,7 @@ import { LimitReductionsTableForm } from "./limitreductions/limit-reductions-tab
17
17
  import { LimitReductionTableRow } from "./limitreductions/limit-reduction-table-row.js";
18
18
  import { LimitReductionTableCell } from "./limitreductions/limit-reduction-table-cell.js";
19
19
  import { ContingencyTable } from "./contingency-table/contingency-table.js";
20
- import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, ParamContingencyLists, getContingencyListsInfosFormSchema, toFormValuesContingencyListsInfos } from "./contingency-table/columns-definitions.js";
20
+ import { COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS, getContingencyListsInfosFormSchema, isValidContingencyRow, toFormValuesContingencyListsInfos } from "./contingency-table/columns-definitions.js";
21
21
  import { useTabs } from "./hook/use-tabs.js";
22
22
  import { useParametersForm } from "./hook/use-parameters-form.js";
23
23
  export {
@@ -48,7 +48,6 @@ export {
48
48
  PARAM_SA_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD,
49
49
  PARAM_SA_PROVIDER,
50
50
  PROVIDER,
51
- ParamContingencyLists,
52
51
  ParameterFloat,
53
52
  ParameterGroup,
54
53
  ParameterLineDirectoryItemsInput,
@@ -67,6 +66,7 @@ export {
67
66
  getContingencyListsInfosFormSchema,
68
67
  getLimitReductionsFormSchema,
69
68
  isValidComputingType,
69
+ isValidContingencyRow,
70
70
  sanitizePercentageValue,
71
71
  toFormValuesContingencyListsInfos,
72
72
  toFormValuesLimitReductions,
@@ -47,6 +47,8 @@ import { LineSeparator } from "./line-separator.js";
47
47
  import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
48
48
  import "./widget/parameter-line-slider.js";
49
49
  import "./limitreductions/columns-definitions.js";
50
+ import "react-dom";
51
+ import "@hello-pangea/dnd";
50
52
  import "./contingency-table/columns-definitions.js";
51
53
  import "@hookform/resolvers/yup";
52
54
  import "../../filter/HeaderFilterForm.js";
@@ -51,7 +51,7 @@ function EditableTableCell(arrayFormName, rowIndex, column, onRowChanged) {
51
51
  hideErrorMessage: true,
52
52
  label: void 0,
53
53
  itemFilter: void 0,
54
- onRowChanged
54
+ onChange: onRowChanged
55
55
  }
56
56
  ),
57
57
  column.menuItems && /* @__PURE__ */ jsx(
@@ -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 declare const NAME = "name";
8
+ export declare const ID = "id";
9
+ export declare const ACTIVATED = "activated";
10
+ export declare const DESCRIPTION = "description";
@@ -0,0 +1,10 @@
1
+ const NAME = "name";
2
+ const ID = "id";
3
+ const ACTIVATED = "activated";
4
+ const DESCRIPTION = "description";
5
+ export {
6
+ ACTIVATED,
7
+ DESCRIPTION,
8
+ ID,
9
+ NAME
10
+ };
@@ -2,8 +2,7 @@
2
2
  * Copyright (c) 2026, RTE (http://www.rte-france.com)
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public
4
4
  * License, v. 2.0. If a copy of the MPL was not distributed with this
5
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
7
  export * from './constants';
8
- export * from './parameter-table';
9
- export * from './types';
8
+ export * from './parameter-table-field';
@@ -0,0 +1,9 @@
1
+ import { ACTIVATED, DESCRIPTION, ID, NAME } from "./constants.js";
2
+ import { ParameterTableField } from "./parameter-table-field.js";
3
+ export {
4
+ ACTIVATED,
5
+ DESCRIPTION,
6
+ ID,
7
+ NAME,
8
+ ParameterTableField
9
+ };