@gridsuite/commons-ui 0.124.0 → 0.125.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.
@@ -26,6 +26,8 @@ const formatComputingTypeLabel = (type) => {
26
26
  return "NonEvacuatedEnergy";
27
27
  case "SHORT_CIRCUIT":
28
28
  return "ShortCircuit";
29
+ case "SHORT_CIRCUIT_ONE_BUS":
30
+ return "OneBusShortCircuitAnalysis";
29
31
  case "VOLTAGE_INITIALIZATION":
30
32
  return "VoltageInit";
31
33
  case "DYNAMIC_SIMULATION":
@@ -35,7 +35,7 @@ function LimitReductionTableCell({
35
35
  column,
36
36
  limits
37
37
  }) {
38
- return column.dataKey === VOLTAGE_LEVELS_FORM ? /* @__PURE__ */ jsx(
38
+ return column.dataKey === VOLTAGE_LEVELS_FORM && limits[rowIndex] ? /* @__PURE__ */ jsx(
39
39
  Tooltip,
40
40
  {
41
41
  title: /* @__PURE__ */ jsx(
@@ -50,7 +50,7 @@ function LimitReductionTableCell({
50
50
  ),
51
51
  children: /* @__PURE__ */ jsx(TableCell, { sx: { fontWeight: "bold" }, children: /* @__PURE__ */ jsx(RawReadOnlyInput, { name: `${LIMIT_REDUCTIONS_FORM}[${rowIndex}].${column.dataKey}` }) })
52
52
  }
53
- ) : /* @__PURE__ */ jsx(TableCell, { sx: { fontWeight: "bold" }, children: /* @__PURE__ */ jsx(FloatInput, { name: `${LIMIT_REDUCTIONS_FORM}[${rowIndex}].${column.dataKey}` }) });
53
+ ) : /* @__PURE__ */ jsx(TableCell, { sx: { fontWeight: "bold" }, children: column.dataKey === VOLTAGE_LEVELS_FORM ? /* @__PURE__ */ jsx(RawReadOnlyInput, { name: `${LIMIT_REDUCTIONS_FORM}[${rowIndex}].${column.dataKey}` }) : /* @__PURE__ */ jsx(FloatInput, { name: `${LIMIT_REDUCTIONS_FORM}[${rowIndex}].${column.dataKey}` }) });
54
54
  }
55
55
  export {
56
56
  LimitReductionTableCell
@@ -3,7 +3,7 @@ interface LimitReductionsTableProps {
3
3
  columnsDefinition: LimitReductionIColumnsDef[];
4
4
  tableHeight: number;
5
5
  formName: string;
6
- limits: ILimitReductionsByVoltageLevel[];
6
+ limits?: ILimitReductionsByVoltageLevel[];
7
7
  }
8
8
  export declare function CustomVoltageLevelTable({ formName, columnsDefinition, tableHeight, limits, }: Readonly<LimitReductionsTableProps>): import("react/jsx-runtime").JSX.Element;
9
9
  export {};
@@ -1,6 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { TableContainer, Table, TableHead, TableRow, Tooltip, TableCell, TableBody } from "@mui/material";
3
- import { useMemo } from "react";
4
3
  import { useFieldArray } from "react-hook-form";
5
4
  import { LIMIT_REDUCTIONS_FORM } from "../limitreductions/columns-definitions.js";
6
5
  import { LimitReductionTableRow } from "../limitreductions/limit-reduction-table-row.js";
@@ -14,10 +13,6 @@ function CustomVoltageLevelTable({
14
13
  const { fields: rows } = useFieldArray({
15
14
  name: formName
16
15
  });
17
- const TableRowComponent = useMemo(
18
- () => formName === LIMIT_REDUCTIONS_FORM ? LimitReductionTableRow : CustomVoltageLevelTableRow,
19
- [formName]
20
- );
21
16
  return /* @__PURE__ */ jsx(
22
17
  TableContainer,
23
18
  {
@@ -37,16 +32,25 @@ function CustomVoltageLevelTable({
37
32
  },
38
33
  column.dataKey
39
34
  ) })) }) }),
40
- /* @__PURE__ */ jsx(TableBody, { children: rows.map((row, index) => /* @__PURE__ */ jsx(
41
- TableRowComponent,
42
- {
43
- columnsDefinition,
44
- index,
45
- formName,
46
- limits
47
- },
48
- `${row.id}`
49
- )) })
35
+ /* @__PURE__ */ jsx(TableBody, { children: rows.map(
36
+ (row, index) => formName === LIMIT_REDUCTIONS_FORM && limits ? /* @__PURE__ */ jsx(
37
+ LimitReductionTableRow,
38
+ {
39
+ columnsDefinition,
40
+ index,
41
+ limits
42
+ },
43
+ `${row.id}`
44
+ ) : /* @__PURE__ */ jsx(
45
+ CustomVoltageLevelTableRow,
46
+ {
47
+ columnsDefinition,
48
+ index,
49
+ formName
50
+ },
51
+ `${row.id}`
52
+ )
53
+ ) })
50
54
  ] })
51
55
  }
52
56
  );
@@ -20,11 +20,10 @@ function useUniqueNameValidation({
20
20
  setError,
21
21
  clearErrors,
22
22
  trigger,
23
- formState: { errors, defaultValues }
23
+ formState: { errors, defaultValues, isDirty: formIsDirty }
24
24
  } = useFormContext();
25
25
  const {
26
- field: { value },
27
- fieldState: { isDirty }
26
+ field: { value }
28
27
  } = useController({ name });
29
28
  const {
30
29
  field: { value: selectedDirectory }
@@ -65,10 +64,13 @@ function useUniqueNameValidation({
65
64
  if (selectedDirectory) {
66
65
  debouncedHandleCheckName(trimmedValue);
67
66
  }
68
- if (!isDirty) {
67
+ if (!formIsDirty) {
69
68
  clearErrors(name);
70
69
  return;
71
70
  }
71
+ if (trimmedValue === defaultFieldValue && trimmedValue.length > 0) {
72
+ return;
73
+ }
72
74
  if (trimmedValue) {
73
75
  clearErrors(name);
74
76
  setError("root.isValidating", {
@@ -89,7 +91,7 @@ function useUniqueNameValidation({
89
91
  setError,
90
92
  clearErrors,
91
93
  name,
92
- isDirty,
94
+ formIsDirty,
93
95
  defaultFieldValue,
94
96
  directory,
95
97
  selectedDirectory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.124.0",
3
+ "version": "0.125.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",