@gridsuite/commons-ui 0.65.2 → 0.65.3

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.
@@ -1,9 +1,5 @@
1
- /**
2
- * Copyright (c) 2024, 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
- */
1
+ import { SelectionForCopy } from '../filter.type';
2
+
7
3
  export declare const DISTRIBUTION_KEY = "distributionKey";
8
4
  export declare const FilterType: {
9
5
  CRITERIA_BASED: {
@@ -19,3 +15,4 @@ export declare const FilterType: {
19
15
  label: string;
20
16
  };
21
17
  };
18
+ export declare const NO_SELECTION_FOR_COPY: SelectionForCopy;
@@ -4,7 +4,16 @@ const FilterType = {
4
4
  EXPLICIT_NAMING: { id: "IDENTIFIER_LIST", label: "filter.explicitNaming" },
5
5
  EXPERT: { id: "EXPERT", label: "filter.expert" }
6
6
  };
7
+ const NO_SELECTION_FOR_COPY = {
8
+ sourceItemUuid: null,
9
+ nameItem: null,
10
+ descriptionItem: null,
11
+ parentDirectoryUuid: null,
12
+ typeItem: null,
13
+ specificTypeItem: null
14
+ };
7
15
  export {
8
16
  DISTRIBUTION_KEY,
9
- FilterType
17
+ FilterType,
18
+ NO_SELECTION_FOR_COPY
10
19
  };
@@ -1,14 +1,7 @@
1
+ import { SelectionForCopy } from '../filter.type';
1
2
  import { ElementExistsType } from '../../../utils/types/elementType';
2
3
  import { UUID } from 'crypto';
3
- import { Dispatch, SetStateAction } from 'react';
4
4
 
5
- export type SelectionCopy = {
6
- sourceItemUuid: UUID | null;
7
- name: string | null;
8
- description: string | null;
9
- parentDirectoryUuid: UUID | null;
10
- };
11
- export declare const noSelectionForCopy: SelectionCopy;
12
5
  export interface CriteriaBasedFilterEditionDialogProps {
13
6
  id: string;
14
7
  name: string;
@@ -17,11 +10,11 @@ export interface CriteriaBasedFilterEditionDialogProps {
17
10
  onClose: () => void;
18
11
  broadcastChannel: BroadcastChannel;
19
12
  getFilterById: (id: string) => Promise<any>;
20
- selectionForCopy: SelectionCopy;
21
- setSelelectionForCopy: (selection: SelectionCopy) => Dispatch<SetStateAction<SelectionCopy>>;
13
+ selectionForCopy: SelectionForCopy;
14
+ setSelectionForCopy: (selection: SelectionForCopy) => void;
22
15
  activeDirectory?: UUID;
23
16
  elementExists?: ElementExistsType;
24
17
  language?: string;
25
18
  }
26
- declare function CriteriaBasedFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, getFilterById, selectionForCopy, setSelelectionForCopy, activeDirectory, elementExists, language, }: Readonly<CriteriaBasedFilterEditionDialogProps>): import("react/jsx-runtime").JSX.Element;
19
+ declare function CriteriaBasedFilterEditionDialog({ id, name, titleId, open, onClose, broadcastChannel, getFilterById, selectionForCopy, setSelectionForCopy, activeDirectory, elementExists, language, }: Readonly<CriteriaBasedFilterEditionDialogProps>): import("react/jsx-runtime").JSX.Element;
27
20
  export default CriteriaBasedFilterEditionDialog;
@@ -8,17 +8,11 @@ import CustomMuiDialog from "../../dialogs/customMuiDialog/CustomMuiDialog.js";
8
8
  import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
9
9
  import { criteriaBasedFilterSchema } from "./CriteriaBasedFilterForm.js";
10
10
  import "../../../utils/yupConfig.js";
11
- import { FilterType } from "../constants/FilterConstants.js";
11
+ import { FilterType, NO_SELECTION_FOR_COPY } from "../constants/FilterConstants.js";
12
12
  import FetchStatus from "../../../utils/constants/fetchStatus.js";
13
13
  import { saveFilter } from "../../../services/explore.js";
14
14
  import FilterForm from "../FilterForm.js";
15
15
  import * as yup from "yup";
16
- const noSelectionForCopy = {
17
- sourceItemUuid: null,
18
- name: null,
19
- description: null,
20
- parentDirectoryUuid: null
21
- };
22
16
  const formSchema = yup.object().shape({
23
17
  [FieldConstants.NAME]: yup.string().trim().required("nameEmpty"),
24
18
  [FieldConstants.FILTER_TYPE]: yup.string().required(),
@@ -34,7 +28,7 @@ function CriteriaBasedFilterEditionDialog({
34
28
  broadcastChannel,
35
29
  getFilterById,
36
30
  selectionForCopy,
37
- setSelelectionForCopy,
31
+ setSelectionForCopy,
38
32
  activeDirectory,
39
33
  elementExists,
40
34
  language
@@ -74,9 +68,9 @@ function CriteriaBasedFilterEditionDialog({
74
68
  (filterForm) => {
75
69
  saveFilter(frontToBackTweak(id, filterForm), filterForm[FieldConstants.NAME]).then(() => {
76
70
  if (selectionForCopy.sourceItemUuid === id) {
77
- setSelelectionForCopy(noSelectionForCopy);
71
+ setSelectionForCopy(NO_SELECTION_FOR_COPY);
78
72
  broadcastChannel.postMessage({
79
- noSelectionForCopy
73
+ NO_SELECTION_FOR_COPY
80
74
  });
81
75
  }
82
76
  }).catch((error) => {
@@ -85,7 +79,7 @@ function CriteriaBasedFilterEditionDialog({
85
79
  });
86
80
  });
87
81
  },
88
- [broadcastChannel, id, selectionForCopy.sourceItemUuid, snackError, setSelelectionForCopy]
82
+ [broadcastChannel, id, selectionForCopy.sourceItemUuid, snackError, setSelectionForCopy]
89
83
  );
90
84
  const isDataReady = dataFetchStatus === FetchStatus.FETCH_SUCCESS;
91
85
  return /* @__PURE__ */ jsx(
@@ -106,6 +100,5 @@ function CriteriaBasedFilterEditionDialog({
106
100
  );
107
101
  }
108
102
  export {
109
- CriteriaBasedFilterEditionDialog as default,
110
- noSelectionForCopy
103
+ CriteriaBasedFilterEditionDialog as default
111
104
  };
@@ -1,3 +1,4 @@
1
+ import { SelectionForCopy } from '../filter.type';
1
2
  import { ElementExistsType } from '../../../utils/types/elementType';
2
3
  import { UUID } from 'crypto';
3
4
 
@@ -8,11 +9,11 @@ export interface ExpertFilterEditionDialogProps {
8
9
  open: boolean;
9
10
  onClose: () => void;
10
11
  broadcastChannel: BroadcastChannel;
11
- selectionForCopy: any;
12
+ selectionForCopy: SelectionForCopy;
12
13
  getFilterById: (id: string) => Promise<{
13
14
  [prop: string]: any;
14
15
  }>;
15
- setSelectionForCopy: (selection: any) => void;
16
+ setSelectionForCopy: (selection: SelectionForCopy) => void;
16
17
  activeDirectory?: UUID;
17
18
  elementExists?: ElementExistsType;
18
19
  language?: string;
@@ -3,7 +3,6 @@ import { useState, useEffect, useCallback } from "react";
3
3
  import { useForm } from "react-hook-form";
4
4
  import { yupResolver } from "@hookform/resolvers/yup";
5
5
  import FieldConstants from "../../../utils/constants/fieldConstants.js";
6
- import { noSelectionForCopy } from "../../../utils/types/equipmentTypes.js";
7
6
  import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
8
7
  import CustomMuiDialog from "../../dialogs/customMuiDialog/CustomMuiDialog.js";
9
8
  import "../../../utils/yupConfig.js";
@@ -11,7 +10,7 @@ import FilterForm from "../FilterForm.js";
11
10
  import { expertFilterSchema, EXPERT_FILTER_QUERY } from "./ExpertFilterForm.js";
12
11
  import { saveExpertFilter } from "../utils/filterApi.js";
13
12
  import { importExpertRules } from "./expertFilterUtils.js";
14
- import { FilterType } from "../constants/FilterConstants.js";
13
+ import { FilterType, NO_SELECTION_FOR_COPY } from "../constants/FilterConstants.js";
15
14
  import FetchStatus from "../../../utils/constants/fetchStatus.js";
16
15
  import * as yup from "yup";
17
16
  const formSchema = yup.object().shape({
@@ -85,9 +84,9 @@ function ExpertFilterEditionDialog({
85
84
  }
86
85
  );
87
86
  if (selectionForCopy.sourceItemUuid === id) {
88
- setSelectionForCopy(noSelectionForCopy);
87
+ setSelectionForCopy(NO_SELECTION_FOR_COPY);
89
88
  broadcastChannel.postMessage({
90
- noSelectionForCopy
89
+ NO_SELECTION_FOR_COPY
91
90
  });
92
91
  }
93
92
  },
@@ -1,3 +1,4 @@
1
+ import { SelectionForCopy } from '../filter.type';
1
2
  import { ElementExistsType } from '../../../utils/types/elementType';
2
3
  import { UUID } from 'crypto';
3
4
 
@@ -8,8 +9,8 @@ export interface ExplicitNamingFilterEditionDialogProps {
8
9
  open: boolean;
9
10
  onClose: () => void;
10
11
  broadcastChannel: BroadcastChannel;
11
- selectionForCopy: any;
12
- setSelectionForCopy: (selection: any) => void;
12
+ selectionForCopy: SelectionForCopy;
13
+ setSelectionForCopy: (selection: SelectionForCopy) => void;
13
14
  getFilterById: (id: string) => Promise<any>;
14
15
  activeDirectory?: UUID;
15
16
  elementExists?: ElementExistsType;
@@ -11,8 +11,7 @@ import "../../../utils/yupConfig.js";
11
11
  import { explicitNamingFilterSchema, FILTER_EQUIPMENTS_ATTRIBUTES } from "./ExplicitNamingFilterForm.js";
12
12
  import FieldConstants from "../../../utils/constants/fieldConstants.js";
13
13
  import FilterForm from "../FilterForm.js";
14
- import { noSelectionForCopy } from "../../../utils/types/equipmentTypes.js";
15
- import { FilterType } from "../constants/FilterConstants.js";
14
+ import { FilterType, NO_SELECTION_FOR_COPY } from "../constants/FilterConstants.js";
16
15
  import FetchStatus from "../../../utils/constants/fetchStatus.js";
17
16
  import * as yup from "yup";
18
17
  const formSchema = yup.object().shape({
@@ -88,9 +87,9 @@ function ExplicitNamingFilterEditionDialog({
88
87
  onClose
89
88
  );
90
89
  if (selectionForCopy.sourceItemUuid === id) {
91
- setSelectionForCopy(noSelectionForCopy);
90
+ setSelectionForCopy(NO_SELECTION_FOR_COPY);
92
91
  broadcastChannel.postMessage({
93
- noSelectionForCopy
92
+ NO_SELECTION_FOR_COPY
94
93
  });
95
94
  }
96
95
  },
@@ -163,7 +163,7 @@ function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversion }) {
163
163
  Input: SelectInput,
164
164
  name: FieldConstants.EQUIPMENT_TYPE,
165
165
  options: Object.values(FILTER_EQUIPMENTS),
166
- disabled: sourceFilterForExplicitNamingConversion,
166
+ disabled: !!sourceFilterForExplicitNamingConversion,
167
167
  label: "equipmentType",
168
168
  shouldOpenPopup: openConfirmationPopup,
169
169
  resetOnConfirmation: handleResetOnConfirmation,
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2024, 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 type SelectionForCopy = {
8
+ sourceItemUuid: string | null;
9
+ typeItem: string | null;
10
+ nameItem: string | null;
11
+ descriptionItem: string | null;
12
+ parentDirectoryUuid: string | null;
13
+ specificTypeItem: string | null;
14
+ };
package/dist/index.d.ts CHANGED
@@ -41,7 +41,8 @@ export type { BottomRightButtonsProps } from './components/inputs/reactHookForm/
41
41
  export { default as CustomAgGridTable } from './components/inputs/reactHookForm/agGridTable/CustomAgGridTable';
42
42
  export type { CustomAgGridTableProps } from './components/inputs/reactHookForm/agGridTable/CustomAgGridTable';
43
43
  export { ROW_DRAGGING_SELECTION_COLUMN_DEF } from './components/inputs/reactHookForm/agGridTable/CustomAgGridTable';
44
- export { Line, Generator, Load, Battery, SVC, DanglingLine, LCC, VSC, Hvdc, BusBar, TwoWindingTransfo, ThreeWindingTransfo, ShuntCompensator, VoltageLevel, Substation, noSelectionForCopy, } from './utils/types/equipmentTypes';
44
+ export { Line, Generator, Load, Battery, SVC, DanglingLine, LCC, VSC, Hvdc, BusBar, TwoWindingTransfo, ThreeWindingTransfo, ShuntCompensator, VoltageLevel, Substation, } from './utils/types/equipmentTypes';
45
+ export { NO_SELECTION_FOR_COPY as noSelectionForCopy } from './components/filter/constants/FilterConstants';
45
46
  export { default as FieldConstants } from './utils/constants/fieldConstants';
46
47
  export { fields as EXPERT_FILTER_FIELDS } from './components/filter/expert/expertFilterConstants';
47
48
  export { default as CustomReactQueryBuilder } from './components/inputs/reactQueryBuilder/CustomReactQueryBuilder';
package/dist/index.js CHANGED
@@ -36,7 +36,8 @@ import { default as default21 } from "./components/filter/criteriaBased/Criteria
36
36
  import { default as default22 } from "./components/dialogs/popupConfirmationDialog/PopupConfirmationDialog.js";
37
37
  import { default as default23 } from "./components/inputs/reactHookForm/agGridTable/BottomRightButtons.js";
38
38
  import { default as default24, ROW_DRAGGING_SELECTION_COLUMN_DEF } from "./components/inputs/reactHookForm/agGridTable/CustomAgGridTable.js";
39
- import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel, noSelectionForCopy } from "./utils/types/equipmentTypes.js";
39
+ import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./utils/types/equipmentTypes.js";
40
+ import { NO_SELECTION_FOR_COPY } from "./components/filter/constants/FilterConstants.js";
40
41
  import { default as default25 } from "./utils/constants/fieldConstants.js";
41
42
  import { fields } from "./components/filter/expert/expertFilterConstants.js";
42
43
  import { default as default26 } from "./components/inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
@@ -324,7 +325,7 @@ export {
324
325
  microUnitToUnit,
325
326
  default56 as multiple_selection_dialog_en,
326
327
  default57 as multiple_selection_dialog_fr,
327
- noSelectionForCopy,
328
+ NO_SELECTION_FOR_COPY as noSelectionForCopy,
328
329
  default28 as report_viewer_en,
329
330
  default29 as report_viewer_fr,
330
331
  roundToDefaultPrecision,
@@ -64,9 +64,3 @@ export declare const Substation: {
64
64
  label: string;
65
65
  type: string;
66
66
  };
67
- export declare const noSelectionForCopy: {
68
- sourceCaseUuid: null;
69
- name: null;
70
- description: null;
71
- parentDirectoryUuid: null;
72
- };
@@ -37,12 +37,6 @@ const Substation = {
37
37
  label: "Substations",
38
38
  type: "SUBSTATION"
39
39
  };
40
- const noSelectionForCopy = {
41
- sourceCaseUuid: null,
42
- name: null,
43
- description: null,
44
- parentDirectoryUuid: null
45
- };
46
40
  export {
47
41
  Battery,
48
42
  BusBar,
@@ -58,6 +52,5 @@ export {
58
52
  ThreeWindingTransfo,
59
53
  TwoWindingTransfo,
60
54
  VSC,
61
- VoltageLevel,
62
- noSelectionForCopy
55
+ VoltageLevel
63
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.65.2",
3
+ "version": "0.65.3",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": ">=9",