@gridsuite/commons-ui 0.275.0 → 0.277.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.
@@ -9,5 +9,5 @@ export type BooleanInputProps<TInput extends InputTypes> = {
9
9
  Input: TInput;
10
10
  dataTestId?: string;
11
11
  };
12
- export declare function BooleanInput<TInput extends InputTypes>({ name, label, formProps, Input, dataTestId, }: Readonly<BooleanInputProps<TInput>>): JSX.Element;
12
+ export declare function BooleanInput<TInput extends InputTypes>({ name, label, formProps, Input, dataTestId, ...props }: Readonly<BooleanInputProps<TInput>>): JSX.Element;
13
13
  export {};
@@ -8,7 +8,8 @@ function BooleanInput({
8
8
  label,
9
9
  formProps,
10
10
  Input,
11
- dataTestId
11
+ dataTestId,
12
+ ...props
12
13
  }) {
13
14
  const { onChange, slotProps, ...otherFormProps } = formProps ?? { onChange: void 0 };
14
15
  const {
@@ -30,7 +31,8 @@ function BooleanInput({
30
31
  inputRef: ref,
31
32
  slotProps: { input: { "aria-label": "primary checkbox" }, ...slotProps },
32
33
  "data-testid": dataTestId,
33
- ...otherFormProps
34
+ ...otherFormProps,
35
+ ...props
34
36
  }
35
37
  );
36
38
  if (label) {
@@ -5,5 +5,5 @@ interface TableTextInputProps {
5
5
  inputProps?: InputBaseComponentProps;
6
6
  dataTestId?: string;
7
7
  }
8
- export declare function TableTextInput({ name, hideErrorMessage, inputProps, dataTestId }: Readonly<TableTextInputProps>): import("react").JSX.Element;
8
+ export declare function TableTextInput({ name, hideErrorMessage, inputProps, dataTestId, ...props }: Readonly<TableTextInputProps>): import("react").JSX.Element;
9
9
  export {};
@@ -5,7 +5,13 @@ import "react-intl";
5
5
  import "react";
6
6
  import "@mui/icons-material";
7
7
  import { genHelperError } from "../utils/functions.js";
8
- function TableTextInput({ name, hideErrorMessage, inputProps, dataTestId }) {
8
+ function TableTextInput({
9
+ name,
10
+ hideErrorMessage,
11
+ inputProps,
12
+ dataTestId,
13
+ ...props
14
+ }) {
9
15
  const {
10
16
  field: { onChange, value, ref },
11
17
  fieldState: { error }
@@ -38,7 +44,8 @@ function TableTextInput({ name, hideErrorMessage, inputProps, dataTestId }) {
38
44
  }
39
45
  }
40
46
  },
41
- ...hideErrorMessage ? {} : genHelperError(error?.message)
47
+ ...hideErrorMessage ? {} : genHelperError(error?.message),
48
+ ...props
42
49
  }
43
50
  );
44
51
  }
@@ -95,7 +95,7 @@ function LimitsPane({
95
95
  const watchedOperationalLimitsGroups = useWatch({
96
96
  name: operationalLimitsGroupsFormName
97
97
  });
98
- const isAModification = useMemo(() => !!equipmentToModify, [equipmentToModify]);
98
+ const equipmentPresent = useMemo(() => !!equipmentToModify, [equipmentToModify]);
99
99
  const getCurrentLimits = (equipment, operationalLimitsGroupId) => {
100
100
  if (equipment?.currentLimits) {
101
101
  return equipment.currentLimits.find(
@@ -155,7 +155,7 @@ function LimitsPane({
155
155
  display: "flex",
156
156
  alignItems: "center"
157
157
  },
158
- children: isAModification && /* @__PURE__ */ jsx(
158
+ children: isModification && /* @__PURE__ */ jsx(
159
159
  InputWithPopupConfirmation,
160
160
  {
161
161
  Input: SwitchInput,
@@ -163,7 +163,7 @@ function LimitsPane({
163
163
  label: olgEditable ? "Edit" : "View",
164
164
  shouldOpenPopup: () => olgEditable,
165
165
  onValueChange: resetOLGs,
166
- message: "disableOLGedition",
166
+ message: equipmentPresent ? "disableOLGeditionByReplace" : "disableOLGedition",
167
167
  validateButtonLabel: "validate"
168
168
  }
169
169
  )
@@ -12,3 +12,6 @@ export type Property = {
12
12
  export type Properties = {
13
13
  [FieldConstants.ADDITIONAL_PROPERTIES]?: Property[];
14
14
  };
15
+ export type FilledProperties = {
16
+ [FieldConstants.ADDITIONAL_PROPERTIES]: FilledProperty[];
17
+ };
@@ -1,5 +1,5 @@
1
1
  import { PredefinedProperties } from '../../../../utils';
2
- import { FilledProperty, Properties, Property } from './properties.type';
2
+ import { FilledProperties, FilledProperty, Properties, Property } from './properties.type';
3
3
  export type EquipmentWithProperties = {
4
4
  properties?: Record<string, string>;
5
5
  };
@@ -7,9 +7,9 @@ export declare const fetchPredefinedProperties: (networkElementType: string) =>
7
7
  export declare const emptyProperties: Properties;
8
8
  export declare const createPropertyModification: (name: string, value: string | null) => Property;
9
9
  export declare const initializedProperty: () => Property;
10
- export declare const getFilledPropertiesFromModification: (properties: Property[] | undefined | null) => FilledProperty[];
10
+ export declare const getFilledPropertiesFromModification: (properties: Property[] | undefined | null, includePreviousValue?: boolean) => FilledProperty[];
11
11
  export declare const getPropertiesFromModification: (properties: Property[] | undefined | null, includePreviousValue?: boolean) => Properties;
12
- export declare const copyEquipmentPropertiesForCreation: (equipmentInfos: EquipmentWithProperties) => Properties;
12
+ export declare const copyEquipmentPropertiesForCreation: (equipmentInfos: EquipmentWithProperties) => FilledProperties;
13
13
  export declare const mergeModificationAndEquipmentProperties: (modificationProperties: Property[], equipment: EquipmentWithProperties) => Property[];
14
14
  export declare function getConcatenatedProperties(equipment: EquipmentWithProperties, getValues: (name: string) => any, id?: string): any;
15
15
  export declare const toModificationProperties: (properties: Properties) => Property[] | null;
@@ -29,12 +29,12 @@ const initializedProperty = () => {
29
29
  const isFilledProperty = (property) => {
30
30
  return property.value != null;
31
31
  };
32
- const getFilledPropertiesFromModification = (properties) => {
32
+ const getFilledPropertiesFromModification = (properties, includePreviousValue = true) => {
33
33
  return properties?.filter(isFilledProperty).map((p) => {
34
34
  return {
35
35
  [FieldConstants.NAME]: p[FieldConstants.NAME],
36
36
  [FieldConstants.VALUE]: p[FieldConstants.VALUE],
37
- [FieldConstants.PREVIOUS_VALUE]: p[FieldConstants.PREVIOUS_VALUE],
37
+ [FieldConstants.PREVIOUS_VALUE]: includePreviousValue ? p[FieldConstants.PREVIOUS_VALUE] : void 0,
38
38
  [FieldConstants.ADDED]: p[FieldConstants.ADDED],
39
39
  [FieldConstants.DELETION_MARK]: p[FieldConstants.DELETION_MARK]
40
40
  };
@@ -118,28 +118,4 @@ export declare const voltageLevelCreationEmptyFormData: {
118
118
  };
119
119
  export declare const voltageLevelCreationFormToDto: (voltageLevelForm: VoltageLevelCreationFormData) => VoltageLevelCreationDto;
120
120
  export declare const translateSwitchKinds: (switchKinds: SwitchKind[] | null, intl?: IntlShape) => string;
121
- export declare const voltageLevelCreationDtoToForm: (voltageLevelDto: VoltageLevelCreationDto, intl?: IntlShape, includePreviousValue?: boolean) => {
122
- AdditionalProperties?: import('../..').Property[];
123
- equipmentID: string;
124
- equipmentName: string;
125
- substationId: string | null;
126
- nominalV: number | null;
127
- lowVoltageLimit: number | null;
128
- highVoltageLimit: number | null;
129
- lowShortCircuitCurrentLimit: any;
130
- highShortCircuitCurrentLimit: any;
131
- busbarCount: number;
132
- sectionCount: number;
133
- switchesBetweenSections: string;
134
- couplingOmnibus: import('./voltageLevelCreation.types').CouplingDevice[];
135
- switchKinds: {
136
- switchKind: SwitchKind;
137
- }[];
138
- addSubstationCreationId: boolean;
139
- substationCreationId: string | null;
140
- substationName: string | null;
141
- country: string | null;
142
- substationCreation: import('../..').Properties;
143
- hideNominalVoltage: boolean;
144
- hideBusBarSection: boolean;
145
- };
121
+ export declare const voltageLevelCreationDtoToForm: (voltageLevelDto: VoltageLevelCreationDto, intl?: IntlShape, includePreviousValue?: boolean) => VoltageLevelCreationFormData;
@@ -1,5 +1,5 @@
1
1
  import { object, array, string, ref, number, boolean } from "yup";
2
- import { creationPropertiesSchema, getPropertiesFromModification, emptyProperties, toModificationProperties } from "../../common/properties/propertyUtils.js";
2
+ import { creationPropertiesSchema, getFilledPropertiesFromModification, toModificationProperties } from "../../common/properties/propertyUtils.js";
3
3
  import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
4
4
  import { SHORT_CIRCUIT_CURRENT_LIMIT_MUST_BE_GREATER_OR_EQUAL_TO_ZERO, MUST_BE_GREATER_OR_EQUAL_TO_ZERO, CREATE_SUBSTATION_IN_VOLTAGE_LEVEL_IDENTICAL_ID } from "../../../../utils/constants/translationKeys.js";
5
5
  import { convertInputValue, convertOutputValue } from "../../../../utils/conversionUtils.js";
@@ -234,7 +234,9 @@ const voltageLevelCreationFormToDto = (voltageLevelForm) => {
234
234
  const translateSwitchKinds = (switchKinds, intl) => switchKinds?.map((kind) => intl ? intl.formatMessage({ id: kind }) : kind).join(" / ") ?? "";
235
235
  const voltageLevelCreationDtoToForm = (voltageLevelDto, intl, includePreviousValue = true) => {
236
236
  const isSubstationCreation = voltageLevelDto.substationCreation?.equipmentId != null;
237
- const substationProperties = isSubstationCreation ? getPropertiesFromModification(voltageLevelDto.substationCreation?.properties, includePreviousValue) : emptyProperties;
237
+ const substationProperties = {
238
+ [FieldConstants.ADDITIONAL_PROPERTIES]: isSubstationCreation ? getFilledPropertiesFromModification(voltageLevelDto.substationCreation?.properties, includePreviousValue) : []
239
+ };
238
240
  return {
239
241
  [FieldConstants.EQUIPMENT_ID]: voltageLevelDto.equipmentId,
240
242
  [FieldConstants.EQUIPMENT_NAME]: voltageLevelDto.equipmentName ?? "",
@@ -264,7 +266,10 @@ const voltageLevelCreationDtoToForm = (voltageLevelDto, intl, includePreviousVal
264
266
  [FieldConstants.SUBSTATION_CREATION]: substationProperties,
265
267
  [FieldConstants.HIDE_NOMINAL_VOLTAGE]: false,
266
268
  [FieldConstants.HIDE_BUS_BAR_SECTION]: false,
267
- ...getPropertiesFromModification(voltageLevelDto.properties, includePreviousValue)
269
+ [FieldConstants.ADDITIONAL_PROPERTIES]: getFilledPropertiesFromModification(
270
+ voltageLevelDto.properties,
271
+ includePreviousValue
272
+ )
268
273
  };
269
274
  };
270
275
  export {
@@ -289,6 +289,7 @@ export declare const networkModificationsEn: {
289
289
  unlimited: string;
290
290
  forbidden: string;
291
291
  Applicability: string;
292
+ disableOLGeditionByReplace: string;
292
293
  disableOLGedition: string;
293
294
  Edit: string;
294
295
  View: string;
@@ -284,7 +284,8 @@ const networkModificationsEn = {
284
284
  unlimited: "Unlimited",
285
285
  forbidden: "Forbidden",
286
286
  Applicability: "Applicability",
287
- disableOLGedition: "Entered limit sets data will be lost. Do you wish to continue?",
287
+ disableOLGeditionByReplace: "Entered limit sets data will be lost to display their current values. Do you wish to continue ?",
288
+ disableOLGedition: "Entered limit sets data will be lost. Do you wish to continue ?",
288
289
  Edit: "Edit",
289
290
  View: "View",
290
291
  TemporaryCurrentLimitsText: "Temporary current limits",
@@ -289,6 +289,7 @@ export declare const networkModificationsFr: {
289
289
  unlimited: string;
290
290
  forbidden: string;
291
291
  Applicability: string;
292
+ disableOLGeditionByReplace: string;
292
293
  disableOLGedition: string;
293
294
  Edit: string;
294
295
  View: string;
@@ -284,7 +284,8 @@ const networkModificationsFr = {
284
284
  unlimited: "Illimité",
285
285
  forbidden: "Interdit",
286
286
  Applicability: "Applicable sur",
287
- disableOLGedition: "Les données saisies pour les jeux de limites ne seront pas conservées. Voulez-vous continuer ?",
287
+ disableOLGeditionByReplace: "Les données saisies pour les jeux de limites seront perdues pour afficher leurs valeurs courantes. Voulez-vous continuer ?",
288
+ disableOLGedition: "Les données saisies pour les jeux de limites seront perdues. Voulez-vous continuer ?",
288
289
  Edit: "Édition",
289
290
  View: "Visualisation",
290
291
  TemporaryCurrentLimitsText: "Limites d'intensité temporaires",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.275.0",
3
+ "version": "0.277.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",