@gridsuite/commons-ui 0.55.0 → 0.56.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 (157) hide show
  1. package/dist/assets/criteria-based-filter-edition-dialog.css +168 -0
  2. package/dist/chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js +1673 -0
  3. package/dist/chunks/filter-properties.GRon8-ML.js +195 -0
  4. package/dist/components/DirectoryItemSelector/directory-item-selector.d.ts +13 -3
  5. package/dist/components/DirectoryItemSelector/directory-item-selector.js +14 -10
  6. package/dist/components/dialogs/custom-mui-dialog.d.ts +21 -0
  7. package/dist/components/dialogs/custom-mui-dialog.js +87 -0
  8. package/dist/components/dialogs/description-modification-dialog.d.ts +11 -0
  9. package/dist/components/dialogs/description-modification-dialog.js +71 -0
  10. package/dist/components/dialogs/popup-confirmation-dialog.d.ts +11 -0
  11. package/dist/components/dialogs/popup-confirmation-dialog.js +38 -0
  12. package/dist/components/filter/constants/equipment-types.d.ts +72 -0
  13. package/dist/components/filter/constants/equipment-types.js +63 -0
  14. package/dist/components/filter/constants/expert-filter-constants.d.ts +546 -0
  15. package/dist/components/filter/constants/expert-filter-constants.js +663 -0
  16. package/dist/components/filter/constants/field-constants.d.ts +45 -0
  17. package/dist/components/filter/constants/field-constants.js +43 -0
  18. package/dist/components/filter/constants/filter-constants.d.ts +21 -0
  19. package/dist/components/filter/constants/filter-constants.js +10 -0
  20. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.d.ts +29 -0
  21. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.js +19 -0
  22. package/dist/components/filter/criteria-based/criteria-based-filter-form.d.ts +15 -0
  23. package/dist/components/filter/criteria-based/criteria-based-filter-form.js +33 -0
  24. package/dist/components/filter/criteria-based/criteria-based-filter-utils.d.ts +37 -0
  25. package/dist/components/filter/criteria-based/criteria-based-filter-utils.js +127 -0
  26. package/dist/components/filter/criteria-based/criteria-based-form.d.ts +7 -0
  27. package/dist/components/filter/criteria-based/criteria-based-form.js +50 -0
  28. package/dist/components/filter/criteria-based/filter-free-properties.d.ts +10 -0
  29. package/dist/components/filter/criteria-based/filter-free-properties.js +15 -0
  30. package/dist/components/filter/criteria-based/filter-properties.d.ts +21 -0
  31. package/dist/components/filter/criteria-based/filter-properties.js +19 -0
  32. package/dist/components/filter/criteria-based/filter-property.d.ts +19 -0
  33. package/dist/components/filter/criteria-based/filter-property.js +67 -0
  34. package/dist/components/filter/expert/expert-filter-edition-dialog.d.ts +28 -0
  35. package/dist/components/filter/expert/expert-filter-edition-dialog.js +20 -0
  36. package/dist/components/filter/expert/expert-filter-form.d.ts +21 -0
  37. package/dist/components/filter/expert/expert-filter-form.js +22 -0
  38. package/dist/components/filter/expert/expert-filter-utils.d.ts +19 -0
  39. package/dist/components/filter/expert/expert-filter-utils.js +302 -0
  40. package/dist/components/filter/expert/expert-filter.type.d.ts +113 -0
  41. package/dist/components/filter/expert/expert-filter.type.js +103 -0
  42. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.d.ts +22 -0
  43. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.js +19 -0
  44. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.d.ts +22 -0
  45. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.js +23 -0
  46. package/dist/components/filter/filter-context.d.ts +12 -0
  47. package/dist/components/filter/filter-context.js +10 -0
  48. package/dist/components/filter/filter-creation-dialog.d.ts +21 -0
  49. package/dist/components/filter/filter-creation-dialog.js +17 -0
  50. package/dist/components/filter/filter-form.d.ts +11 -0
  51. package/dist/components/filter/filter-form.js +14 -0
  52. package/dist/components/filter/utils/criteria-based-utils.d.ts +28 -0
  53. package/dist/components/filter/utils/criteria-based-utils.js +197 -0
  54. package/dist/components/filter/utils/filters-utils.d.ts +5 -0
  55. package/dist/components/filter/utils/filters-utils.js +99 -0
  56. package/dist/components/inputs/select-clearable.d.ts +14 -0
  57. package/dist/components/inputs/select-clearable.js +40 -0
  58. package/dist/components/react-hook-form/ExpandingTextField.d.ts +1 -1
  59. package/dist/components/react-hook-form/ExpandingTextField.js +0 -37
  60. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.d.ts +17 -0
  61. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.js +15 -0
  62. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.d.ts +23 -0
  63. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.js +70 -0
  64. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.d.ts +16 -0
  65. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.js +69 -0
  66. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.d.ts +23 -0
  67. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.js +15 -0
  68. package/dist/components/react-hook-form/autocomplete-input.d.ts +17 -29
  69. package/dist/components/react-hook-form/autocomplete-input.js +4 -15
  70. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.d.ts +2 -0
  71. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.js +46 -0
  72. package/dist/components/react-hook-form/directory-items-input.d.ts +0 -3
  73. package/dist/components/react-hook-form/directory-items-input.js +5 -6
  74. package/dist/components/react-hook-form/error-management/error-input.d.ts +13 -4
  75. package/dist/components/react-hook-form/error-management/error-input.js +7 -7
  76. package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +6 -3
  77. package/dist/components/react-hook-form/error-management/field-error-alert.js +3 -1
  78. package/dist/components/react-hook-form/numbers/float-input.d.ts +5 -17
  79. package/dist/components/react-hook-form/numbers/float-input.js +3 -5
  80. package/dist/components/react-hook-form/numbers/integer-input.d.ts +15 -12
  81. package/dist/components/react-hook-form/numbers/utils.d.ts +8 -2
  82. package/dist/components/react-hook-form/provider/custom-form-provider.d.ts +1 -0
  83. package/dist/components/react-hook-form/provider/custom-form-provider.js +12 -3
  84. package/dist/components/react-hook-form/radio-input.d.ts +14 -17
  85. package/dist/components/react-hook-form/radio-input.js +7 -9
  86. package/dist/components/react-hook-form/range-input.d.ts +54 -0
  87. package/dist/components/react-hook-form/range-input.js +118 -0
  88. package/dist/components/react-hook-form/select-inputs/countries-input.d.ts +8 -0
  89. package/dist/components/react-hook-form/select-inputs/countries-input.js +36 -0
  90. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.d.ts +2 -0
  91. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.js +61 -0
  92. package/dist/components/react-hook-form/select-inputs/mui-select-input.d.ts +12 -0
  93. package/dist/components/react-hook-form/select-inputs/mui-select-input.js +25 -0
  94. package/dist/components/react-hook-form/select-inputs/select-input.d.ts +9 -0
  95. package/dist/components/react-hook-form/select-inputs/select-input.js +37 -0
  96. package/dist/components/react-hook-form/text-input.d.ts +23 -32
  97. package/dist/components/react-hook-form/text-input.js +6 -20
  98. package/dist/components/react-hook-form/unique-name-input.d.ts +21 -0
  99. package/dist/components/react-hook-form/unique-name-input.js +129 -0
  100. package/dist/components/react-hook-form/utils/cancel-button.d.ts +9 -8
  101. package/dist/components/react-hook-form/utils/field-label.d.ts +12 -5
  102. package/dist/components/react-hook-form/utils/field-label.js +5 -1
  103. package/dist/components/react-hook-form/utils/functions.d.ts +12 -4
  104. package/dist/components/react-hook-form/utils/functions.js +21 -1
  105. package/dist/components/react-hook-form/utils/submit-button.d.ts +9 -8
  106. package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +11 -11
  107. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +18 -23
  108. package/dist/components/react-query-builder-inputs/add-button.d.ts +8 -0
  109. package/dist/components/react-query-builder-inputs/add-button.js +17 -0
  110. package/dist/components/react-query-builder-inputs/combinator-selector.d.ts +5 -0
  111. package/dist/components/react-query-builder-inputs/combinator-selector.js +38 -0
  112. package/dist/components/react-query-builder-inputs/country-value-editor.d.ts +5 -0
  113. package/dist/components/react-query-builder-inputs/country-value-editor.js +46 -0
  114. package/dist/components/react-query-builder-inputs/custom-react-query-builder.d.ts +8 -0
  115. package/dist/components/react-query-builder-inputs/custom-react-query-builder.js +21 -0
  116. package/dist/components/react-query-builder-inputs/element-value-editor.d.ts +14 -0
  117. package/dist/components/react-query-builder-inputs/element-value-editor.js +69 -0
  118. package/dist/components/react-query-builder-inputs/property-value-editor.d.ts +9 -0
  119. package/dist/components/react-query-builder-inputs/property-value-editor.js +100 -0
  120. package/dist/components/react-query-builder-inputs/remove-button.d.ts +5 -0
  121. package/dist/components/react-query-builder-inputs/remove-button.js +9 -0
  122. package/dist/components/react-query-builder-inputs/text-value-editor.d.ts +5 -0
  123. package/dist/components/react-query-builder-inputs/text-value-editor.js +34 -0
  124. package/dist/components/react-query-builder-inputs/translated-value-editor.d.ts +5 -0
  125. package/dist/components/react-query-builder-inputs/translated-value-editor.js +58 -0
  126. package/dist/components/react-query-builder-inputs/use-convert-value.d.ts +9 -0
  127. package/dist/components/react-query-builder-inputs/use-convert-value.js +24 -0
  128. package/dist/components/react-query-builder-inputs/use-valid.d.ts +7 -0
  129. package/dist/components/react-query-builder-inputs/use-valid.js +13 -0
  130. package/dist/components/react-query-builder-inputs/value-editor.d.ts +5 -0
  131. package/dist/components/react-query-builder-inputs/value-editor.js +18 -0
  132. package/dist/components/react-query-builder-inputs/value-selector.d.ts +4 -0
  133. package/dist/components/react-query-builder-inputs/value-selector.js +14 -0
  134. package/dist/hooks/localized-countries-hook.d.ts +6 -0
  135. package/dist/hooks/localized-countries-hook.js +45 -0
  136. package/dist/hooks/predefined-properties-hook.d.ts +18 -0
  137. package/dist/hooks/predefined-properties-hook.js +43 -0
  138. package/dist/hooks/useDebounce.d.ts +7 -1
  139. package/dist/hooks/useSnackMessage.d.ts +23 -5
  140. package/dist/hooks/useSnackMessage.js +14 -12
  141. package/dist/index.d.ts +87 -142
  142. package/dist/index.js +168 -91
  143. package/dist/utils/FetchStatus.d.ts +12 -0
  144. package/dist/utils/FetchStatus.js +9 -0
  145. package/dist/utils/conversion-utils.d.ts +12 -0
  146. package/dist/utils/conversion-utils.js +22 -0
  147. package/dist/utils/equipment-types-for-predefined-properties-mapper.d.ts +3 -0
  148. package/dist/utils/equipment-types-for-predefined-properties-mapper.js +31 -0
  149. package/dist/utils/functions.d.ts +14 -0
  150. package/dist/utils/functions.js +16 -0
  151. package/dist/utils/types.d.ts +21 -0
  152. package/dist/utils/types.js +1 -0
  153. package/dist/utils/yup-config.d.ts +8 -0
  154. package/dist/utils/yup-config.js +16 -0
  155. package/package.json +15 -2
  156. package/dist/components/react-hook-form/select-input.d.ts +0 -17
  157. package/dist/components/react-hook-form/select-input.js +0 -30
@@ -0,0 +1,195 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import Grid$1 from "@mui/material/Grid";
3
+ import { useMemo, useEffect } from "react";
4
+ import { useWatch, useFieldArray } from "react-hook-form";
5
+ import { FormattedMessage } from "react-intl";
6
+ import { Line, Hvdc, Substation, Load, Generator, TwoWindingTransfo, Battery, ShuntCompensator, VoltageLevel } from "../components/filter/constants/equipment-types.js";
7
+ import { areArrayElementsUnique } from "../utils/functions.js";
8
+ import { FieldConstants } from "../components/filter/constants/field-constants.js";
9
+ import "../utils/yup-config.js";
10
+ import ErrorInput from "../components/react-hook-form/error-management/error-input.js";
11
+ import FieldErrorAlert from "../components/react-hook-form/error-management/field-error-alert.js";
12
+ import { Grid, ListItem, Button } from "@mui/material";
13
+ import FilterProperty, { PROPERTY_NAME, PROPERTY_VALUES_1, PROPERTY_VALUES_2, PROPERTY_VALUES } from "../components/filter/criteria-based/filter-property.js";
14
+ import { usePredefinedProperties } from "../hooks/predefined-properties-hook.js";
15
+ import { FilterType } from "../components/filter/constants/filter-constants.js";
16
+ import * as yup from "yup";
17
+ import AddIcon from "@mui/icons-material/Add";
18
+ const FilterFreeProperties = ({
19
+ freePropertiesType,
20
+ predefined
21
+ }) => {
22
+ const watchEquipmentType = useWatch({
23
+ name: FieldConstants.EQUIPMENT_TYPE
24
+ });
25
+ const isForLineOrHvdcLineSubstation = (watchEquipmentType === Line.type || watchEquipmentType === Hvdc.type) && freePropertiesType === FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES;
26
+ const fieldName = `${FieldConstants.CRITERIA_BASED}.${freePropertiesType}`;
27
+ const {
28
+ fields: filterProperties,
29
+ // don't use it to access form data ! check doc,
30
+ append,
31
+ remove
32
+ } = useFieldArray({
33
+ name: fieldName
34
+ });
35
+ function addNewProp() {
36
+ if (isForLineOrHvdcLineSubstation) {
37
+ append({
38
+ [PROPERTY_NAME]: null,
39
+ [PROPERTY_VALUES_1]: [],
40
+ [PROPERTY_VALUES_2]: []
41
+ });
42
+ } else {
43
+ append({ [PROPERTY_NAME]: null, [PROPERTY_VALUES]: [] });
44
+ }
45
+ }
46
+ const valuesFields = isForLineOrHvdcLineSubstation ? [
47
+ { name: PROPERTY_VALUES_1, label: "PropertyValues1" },
48
+ { name: PROPERTY_VALUES_2, label: "PropertyValues2" }
49
+ ] : [{ name: PROPERTY_VALUES, label: "PropertyValues" }];
50
+ const title = useMemo(() => {
51
+ return freePropertiesType === FreePropertiesTypes.FREE_FILTER_PROPERTIES ? "FreeProps" : "SubstationFreeProps";
52
+ }, [freePropertiesType]);
53
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
54
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(FormattedMessage, { id: title, children: (title2) => /* @__PURE__ */ jsx("h4", { children: title2 }) }) }),
55
+ filterProperties.map((prop, index) => /* @__PURE__ */ jsx(ListItem, { children: /* @__PURE__ */ jsx(
56
+ FilterProperty,
57
+ {
58
+ index,
59
+ valuesFields,
60
+ predefined,
61
+ handleDelete: remove,
62
+ propertyType: freePropertiesType
63
+ }
64
+ ) }, prop.id)),
65
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: addNewProp, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "AddFreePropCrit" }) }) }),
66
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(ErrorInput, { name: fieldName, InputField: FieldErrorAlert }) })
67
+ ] });
68
+ };
69
+ var FreePropertiesTypes = /* @__PURE__ */ ((FreePropertiesTypes2) => {
70
+ FreePropertiesTypes2["SUBSTATION_FILTER_PROPERTIES"] = "substationFreeProperties";
71
+ FreePropertiesTypes2["FREE_FILTER_PROPERTIES"] = "freeProperties";
72
+ return FreePropertiesTypes2;
73
+ })(FreePropertiesTypes || {});
74
+ function propertyValuesTest(values, context, doublePropertyValues) {
75
+ const rootLevelForm = context.from[context.from.length - 1];
76
+ const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
77
+ if (filterType !== FilterType.CRITERIA_BASED.id) {
78
+ return true;
79
+ }
80
+ const equipmentType = rootLevelForm.value[FieldConstants.EQUIPMENT_TYPE];
81
+ const isForLineOrHvdcLine = equipmentType === Line.type || equipmentType === Hvdc.type;
82
+ if (doublePropertyValues) {
83
+ return isForLineOrHvdcLine ? (values == null ? void 0 : values.length) > 0 : true;
84
+ } else {
85
+ return isForLineOrHvdcLine ? true : (values == null ? void 0 : values.length) > 0;
86
+ }
87
+ }
88
+ const filterPropertiesYupSchema = {
89
+ [
90
+ "substationFreeProperties"
91
+ /* SUBSTATION_FILTER_PROPERTIES */
92
+ ]: yup.array().of(
93
+ yup.object().shape({
94
+ [PROPERTY_NAME]: yup.string().required(),
95
+ [PROPERTY_VALUES]: yup.array().of(yup.string()).test(
96
+ "can not be empty if not line",
97
+ "YupRequired",
98
+ (values, context) => propertyValuesTest(values, context, false)
99
+ ),
100
+ [PROPERTY_VALUES_1]: yup.array().of(yup.string()).test(
101
+ "can not be empty if line",
102
+ "YupRequired",
103
+ (values, context) => propertyValuesTest(values, context, true)
104
+ ),
105
+ [PROPERTY_VALUES_2]: yup.array().of(yup.string()).test(
106
+ "can not be empty if line",
107
+ "YupRequired",
108
+ (values, context) => propertyValuesTest(values, context, true)
109
+ )
110
+ })
111
+ ).test(
112
+ "distinct names",
113
+ "filterPropertiesNameUniquenessError",
114
+ (properties, context) => {
115
+ const rootLevelForm = context.from[context.from.length - 1];
116
+ const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
117
+ if (filterType !== FilterType.CRITERIA_BASED.id) {
118
+ return true;
119
+ }
120
+ const names = properties.filter((prop) => !!prop[PROPERTY_NAME]).map((prop) => prop[PROPERTY_NAME]);
121
+ return areArrayElementsUnique(names);
122
+ }
123
+ ),
124
+ [
125
+ "freeProperties"
126
+ /* FREE_FILTER_PROPERTIES */
127
+ ]: yup.array().of(
128
+ yup.object().shape({
129
+ [PROPERTY_NAME]: yup.string().required(),
130
+ [PROPERTY_VALUES]: yup.array().of(yup.string()).test(
131
+ "can not be empty if not line",
132
+ "YupRequired",
133
+ (values, context) => propertyValuesTest(values, context, false)
134
+ )
135
+ })
136
+ ).test(
137
+ "distinct names",
138
+ "filterPropertiesNameUniquenessError",
139
+ (properties, context) => {
140
+ const rootLevelForm = context.from[context.from.length - 1];
141
+ const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
142
+ if (filterType !== FilterType.CRITERIA_BASED.id) {
143
+ return true;
144
+ }
145
+ const names = properties.filter((prop) => !!prop[PROPERTY_NAME]).map((prop) => prop[PROPERTY_NAME]);
146
+ return areArrayElementsUnique(names);
147
+ }
148
+ )
149
+ };
150
+ const FilterProperties = () => {
151
+ const watchEquipmentType = useWatch({
152
+ name: FieldConstants.EQUIPMENT_TYPE
153
+ });
154
+ const [equipmentPredefinedProps, setEquipmentType] = usePredefinedProperties(watchEquipmentType);
155
+ const [substationPredefinedProps, setSubstationType] = usePredefinedProperties(null);
156
+ const displayEquipmentProperties = useMemo(() => {
157
+ return watchEquipmentType === Substation.type || watchEquipmentType === Load.type || watchEquipmentType === Generator.type || watchEquipmentType === Line.type || watchEquipmentType === TwoWindingTransfo.type || watchEquipmentType === Battery.type || watchEquipmentType === ShuntCompensator.type || watchEquipmentType === VoltageLevel.type;
158
+ }, [watchEquipmentType]);
159
+ const displaySubstationProperties = useMemo(() => {
160
+ return watchEquipmentType !== Substation.type && watchEquipmentType !== null;
161
+ }, [watchEquipmentType]);
162
+ useEffect(() => {
163
+ if (displayEquipmentProperties) {
164
+ setEquipmentType(watchEquipmentType);
165
+ }
166
+ }, [displayEquipmentProperties, watchEquipmentType, setEquipmentType]);
167
+ useEffect(() => {
168
+ if (displaySubstationProperties) {
169
+ setSubstationType(Substation.type);
170
+ }
171
+ }, [displaySubstationProperties, setSubstationType]);
172
+ return watchEquipmentType && /* @__PURE__ */ jsx(Grid$1, { item: true, container: true, spacing: 1, children: /* @__PURE__ */ jsxs(Grid$1, { item: true, xs: 12, children: [
173
+ /* @__PURE__ */ jsx(FormattedMessage, { id: "FreePropsCrit", children: (txt) => /* @__PURE__ */ jsx("h3", { children: txt }) }),
174
+ displayEquipmentProperties && /* @__PURE__ */ jsx(
175
+ FilterFreeProperties,
176
+ {
177
+ freePropertiesType: "freeProperties",
178
+ predefined: equipmentPredefinedProps
179
+ }
180
+ ),
181
+ displaySubstationProperties && /* @__PURE__ */ jsx(
182
+ FilterFreeProperties,
183
+ {
184
+ freePropertiesType: "substationFreeProperties",
185
+ predefined: substationPredefinedProps
186
+ }
187
+ )
188
+ ] }) });
189
+ };
190
+ export {
191
+ FreePropertiesTypes as F,
192
+ FilterProperties as a,
193
+ FilterFreeProperties as b,
194
+ filterPropertiesYupSchema as f
195
+ };
@@ -1,3 +1,4 @@
1
+ import { ElementAttributes } from '../../utils/types.ts';
1
2
  import { UUID } from 'crypto';
2
3
  import { TreeViewFinderProps } from '../TreeViewFinder/TreeViewFinder';
3
4
  import { FunctionComponent } from 'react';
@@ -7,9 +8,18 @@ interface DirectoryItemSelectorProps extends TreeViewFinderProps {
7
8
  types: string[];
8
9
  equipmentTypes?: string[];
9
10
  itemFilter?: any;
10
- fetchDirectoryContent: (directoryUuid: UUID, elementTypes: string[]) => Promise<any>;
11
- fetchRootFolders: (types: string[]) => Promise<any>;
12
- fetchElementsInfos: (ids: UUID[], elementTypes: string[], equipmentTypes: string[]) => Promise<any>;
11
+ fetchDirectoryContent?: (directoryUuid: UUID, elementTypes: string[]) => Promise<ElementAttributes[]>;
12
+ fetchRootFolders?: (types: string[]) => Promise<ElementAttributes[]>;
13
+ fetchElementsInfos?: (ids: UUID[], elementTypes: string[], equipmentTypes: string[]) => Promise<ElementAttributes[]>;
14
+ classes?: any;
15
+ contentText?: string;
16
+ defaultExpanded?: string[];
17
+ defaultSelected?: string[];
18
+ validationButtonText?: string;
19
+ className?: string;
20
+ cancelButtonProps?: any;
21
+ onlyLeaves?: boolean;
22
+ multiselect?: boolean;
13
23
  expanded?: UUID[];
14
24
  }
15
25
  declare const DirectoryItemSelector: FunctionComponent<DirectoryItemSelectorProps>;
@@ -2,8 +2,8 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useState, useRef, useCallback, useEffect } from "react";
3
3
  import { getFileIcon } from "../../utils/ElementIcon.js";
4
4
  import { ElementType } from "../../utils/ElementType.js";
5
- import { useSnackMessage } from "../../hooks/useSnackMessage.js";
6
5
  import TreeViewFinder from "../TreeViewFinder/TreeViewFinder.js";
6
+ import { useSnackMessage } from "../../hooks/useSnackMessage.js";
7
7
  const styles = {
8
8
  icon: (theme) => ({
9
9
  marginRight: theme.spacing(1),
@@ -77,7 +77,7 @@ const DirectoryItemSelector = ({
77
77
  [convertRoots]
78
78
  );
79
79
  const updateRootDirectories = useCallback(() => {
80
- fetchRootFolders(types).then((data2) => {
80
+ fetchRootFolders && fetchRootFolders(types).then((data2) => {
81
81
  let [nrs, mdr] = updatedTree(
82
82
  rootsRef.current,
83
83
  nodeMap.current,
@@ -96,22 +96,26 @@ const DirectoryItemSelector = ({
96
96
  }, [convertRoots, types, snackError, fetchRootFolders]);
97
97
  const fetchDirectory = useCallback(
98
98
  (nodeId) => {
99
- fetchDirectoryContent(nodeId, types).then((children) => {
99
+ fetchDirectoryContent && fetchDirectoryContent(nodeId, types).then((children) => {
100
100
  const childrenMatchedTypes = children.filter(
101
101
  (item) => contentFilter().has(item.type)
102
102
  );
103
103
  if (childrenMatchedTypes.length > 0 && equipmentTypes && equipmentTypes.length > 0) {
104
- fetchElementsInfos(
105
- childrenMatchedTypes.map((e) => e.elementUuid),
104
+ fetchElementsInfos && fetchElementsInfos(
105
+ childrenMatchedTypes.map(
106
+ (e) => e.elementUuid
107
+ ),
106
108
  types,
107
109
  equipmentTypes
108
110
  ).then((childrenWithMetadata) => {
109
- const children2 = itemFilter ? childrenWithMetadata.filter((val) => {
110
- if (val.type === ElementType.DIRECTORY) {
111
- return true;
111
+ const children2 = itemFilter ? childrenWithMetadata.filter(
112
+ (val) => {
113
+ if (val.type === ElementType.DIRECTORY) {
114
+ return true;
115
+ }
116
+ return itemFilter(val);
112
117
  }
113
- return itemFilter(val);
114
- }) : childrenWithMetadata;
118
+ ) : childrenWithMetadata;
115
119
  addToDirectory(nodeId, children2);
116
120
  });
117
121
  } else {
@@ -0,0 +1,21 @@
1
+ import { MergedFormContextProps } from '../react-hook-form/provider/custom-form-provider';
2
+ import { FieldErrors, UseFormReturn } from 'react-hook-form';
3
+ import { default as React, FunctionComponent } from 'react';
4
+
5
+ import * as yup from 'yup';
6
+ interface ICustomMuiDialog {
7
+ open: boolean;
8
+ formSchema: yup.AnySchema;
9
+ formMethods: UseFormReturn<any> | MergedFormContextProps;
10
+ onClose: (event: React.MouseEvent) => void;
11
+ onSave: (data: any) => void;
12
+ onValidationError?: (errors: FieldErrors) => void;
13
+ titleId: string;
14
+ disabledSave?: boolean;
15
+ removeOptional?: boolean;
16
+ onCancel?: () => void;
17
+ children: React.ReactNode;
18
+ isDataFetching?: boolean;
19
+ }
20
+ declare const CustomMuiDialog: FunctionComponent<ICustomMuiDialog>;
21
+ export default CustomMuiDialog;
@@ -0,0 +1,87 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { FormattedMessage } from "react-intl";
3
+ import { Dialog, LinearProgress, DialogTitle, Grid, DialogContent, DialogActions } from "@mui/material";
4
+ import SubmitButton from "../react-hook-form/utils/submit-button.js";
5
+ import CancelButton from "../react-hook-form/utils/cancel-button.js";
6
+ import CustomFormProvider from "../react-hook-form/provider/custom-form-provider.js";
7
+ const styles = {
8
+ dialogPaper: {
9
+ ".MuiDialog-paper": {
10
+ width: "auto",
11
+ minWidth: "1100px",
12
+ margin: "auto"
13
+ }
14
+ }
15
+ };
16
+ const CustomMuiDialog = ({
17
+ open,
18
+ formSchema,
19
+ formMethods,
20
+ onClose,
21
+ onSave,
22
+ isDataFetching = false,
23
+ onValidationError,
24
+ titleId,
25
+ disabledSave,
26
+ removeOptional = false,
27
+ onCancel,
28
+ children
29
+ }) => {
30
+ const { handleSubmit } = formMethods;
31
+ const handleCancel = (event) => {
32
+ onCancel && onCancel();
33
+ onClose(event);
34
+ };
35
+ const handleClose = (event, reason) => {
36
+ if (reason === "backdropClick" && onCancel) {
37
+ onCancel();
38
+ }
39
+ onClose(event);
40
+ };
41
+ const handleValidate = (data) => {
42
+ onSave(data);
43
+ onClose(data);
44
+ };
45
+ const handleValidationError = (errors) => {
46
+ onValidationError && onValidationError(errors);
47
+ };
48
+ return /* @__PURE__ */ jsx(
49
+ CustomFormProvider,
50
+ {
51
+ ...formMethods,
52
+ validationSchema: formSchema,
53
+ removeOptional,
54
+ children: /* @__PURE__ */ jsxs(
55
+ Dialog,
56
+ {
57
+ sx: styles.dialogPaper,
58
+ open,
59
+ onClose: handleClose,
60
+ fullWidth: true,
61
+ children: [
62
+ isDataFetching && /* @__PURE__ */ jsx(LinearProgress, {}),
63
+ /* @__PURE__ */ jsx(DialogTitle, { children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 11, children: /* @__PURE__ */ jsx(FormattedMessage, { id: titleId }) }) }),
64
+ /* @__PURE__ */ jsx(DialogContent, { children }),
65
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
66
+ /* @__PURE__ */ jsx(CancelButton, { onClick: handleCancel }),
67
+ /* @__PURE__ */ jsx(
68
+ SubmitButton,
69
+ {
70
+ variant: "outlined",
71
+ disabled: disabledSave,
72
+ onClick: handleSubmit(
73
+ handleValidate,
74
+ handleValidationError
75
+ )
76
+ }
77
+ )
78
+ ] })
79
+ ]
80
+ }
81
+ )
82
+ }
83
+ );
84
+ };
85
+ export {
86
+ CustomMuiDialog as default
87
+ };
@@ -0,0 +1,11 @@
1
+ import { FunctionComponent } from 'react';
2
+
3
+ export interface IDescriptionModificationDialog {
4
+ elementUuid: string;
5
+ description: string;
6
+ open: boolean;
7
+ onClose: () => void;
8
+ updateElement: (uuid: string, data: Record<string, string>) => Promise<void>;
9
+ }
10
+ declare const DescriptionModificationDialog: FunctionComponent<IDescriptionModificationDialog>;
11
+ export default DescriptionModificationDialog;
@@ -0,0 +1,71 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import "../../utils/yup-config.js";
4
+ import { FieldConstants } from "../filter/constants/field-constants.js";
5
+ import { useForm } from "react-hook-form";
6
+ import { yupResolver } from "@hookform/resolvers/yup";
7
+ import { useSnackMessage } from "../../hooks/useSnackMessage.js";
8
+ import CustomMuiDialog from "./custom-mui-dialog.js";
9
+ import ExpandingTextField from "../react-hook-form/ExpandingTextField.js";
10
+ import { Box } from "@mui/material";
11
+ import * as yup from "yup";
12
+ const schema = yup.object().shape({
13
+ [FieldConstants.DESCRIPTION]: yup.string().max(500, "descriptionLimitError")
14
+ });
15
+ const DescriptionModificationDialog = ({ elementUuid, description, open, onClose, updateElement }) => {
16
+ const { snackError } = useSnackMessage();
17
+ const emptyFormData = {
18
+ [FieldConstants.DESCRIPTION]: description ?? ""
19
+ };
20
+ const methods = useForm({
21
+ defaultValues: emptyFormData,
22
+ resolver: yupResolver(schema)
23
+ });
24
+ const { reset } = methods;
25
+ const onCancel = () => {
26
+ reset({
27
+ [FieldConstants.DESCRIPTION]: ""
28
+ });
29
+ onClose();
30
+ };
31
+ const onSubmit = useCallback(
32
+ (data) => {
33
+ updateElement(elementUuid, {
34
+ [FieldConstants.DESCRIPTION]: data[FieldConstants.DESCRIPTION].trim()
35
+ }).catch((error) => {
36
+ snackError({
37
+ messageTxt: error.message,
38
+ headerId: "descriptionModificationError"
39
+ });
40
+ });
41
+ },
42
+ [elementUuid, updateElement, snackError]
43
+ );
44
+ return /* @__PURE__ */ jsxs(
45
+ CustomMuiDialog,
46
+ {
47
+ open,
48
+ onClose: onCancel,
49
+ onSave: onSubmit,
50
+ formSchema: schema,
51
+ formMethods: methods,
52
+ titleId: "description",
53
+ removeOptional: true,
54
+ children: [
55
+ /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(
56
+ ExpandingTextField,
57
+ {
58
+ name: FieldConstants.DESCRIPTION,
59
+ label: "descriptionProperty",
60
+ minRows: 3,
61
+ rows: 5
62
+ }
63
+ ) }),
64
+ " "
65
+ ]
66
+ }
67
+ );
68
+ };
69
+ export {
70
+ DescriptionModificationDialog as default
71
+ };
@@ -0,0 +1,11 @@
1
+ import { FunctionComponent } from 'react';
2
+
3
+ export interface PopupConfirmationDialogProps {
4
+ message: string;
5
+ validateButtonLabel: string;
6
+ openConfirmationPopup: boolean;
7
+ setOpenConfirmationPopup: (value: boolean) => void;
8
+ handlePopupConfirmation: () => void;
9
+ }
10
+ declare const PopupConfirmationDialog: FunctionComponent<PopupConfirmationDialogProps>;
11
+ export default PopupConfirmationDialog;
@@ -0,0 +1,38 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import Dialog from "@mui/material/Dialog";
3
+ import DialogTitle from "@mui/material/DialogTitle";
4
+ import DialogContent from "@mui/material/DialogContent";
5
+ import { DialogContentText } from "@mui/material";
6
+ import DialogActions from "@mui/material/DialogActions";
7
+ import Button from "@mui/material/Button";
8
+ import { FormattedMessage } from "react-intl";
9
+ import CancelButton from "../react-hook-form/utils/cancel-button.js";
10
+ const PopupConfirmationDialog = ({
11
+ message,
12
+ validateButtonLabel,
13
+ openConfirmationPopup,
14
+ setOpenConfirmationPopup,
15
+ handlePopupConfirmation
16
+ }) => {
17
+ return /* @__PURE__ */ jsxs(
18
+ Dialog,
19
+ {
20
+ open: openConfirmationPopup,
21
+ "aria-labelledby": "dialog-title-change-equipment-type",
22
+ children: [
23
+ /* @__PURE__ */ jsx(DialogTitle, { id: "dialog-title-change-equipment-type", children: "Confirmation" }),
24
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogContentText, { children: /* @__PURE__ */ jsx(FormattedMessage, { id: message }) }) }),
25
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
26
+ /* @__PURE__ */ jsx(CancelButton, { onClick: () => setOpenConfirmationPopup(false) }),
27
+ /* @__PURE__ */ jsx(Button, { onClick: handlePopupConfirmation, variant: "outlined", children: /* @__PURE__ */ jsx(FormattedMessage, { id: validateButtonLabel ?? "validate" }) })
28
+ ] })
29
+ ]
30
+ }
31
+ );
32
+ };
33
+ PopupConfirmationDialog.defaultProps = {
34
+ validateButtonLabel: void 0
35
+ };
36
+ export {
37
+ PopupConfirmationDialog as default
38
+ };
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Copyright (c) 2021, 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 Line: {
8
+ label: string;
9
+ type: string;
10
+ };
11
+ export declare const Generator: {
12
+ label: string;
13
+ type: string;
14
+ };
15
+ export declare const Load: {
16
+ label: string;
17
+ type: string;
18
+ };
19
+ export declare const Battery: {
20
+ label: string;
21
+ type: string;
22
+ };
23
+ export declare const SVC: {
24
+ label: string;
25
+ type: string;
26
+ };
27
+ export declare const DanglingLine: {
28
+ label: string;
29
+ type: string;
30
+ };
31
+ export declare const LCC: {
32
+ label: string;
33
+ type: string;
34
+ };
35
+ export declare const VSC: {
36
+ label: string;
37
+ type: string;
38
+ };
39
+ export declare const Hvdc: {
40
+ label: string;
41
+ type: string;
42
+ };
43
+ export declare const BusBar: {
44
+ label: string;
45
+ type: string;
46
+ };
47
+ export declare const TwoWindingTransfo: {
48
+ label: string;
49
+ type: string;
50
+ };
51
+ export declare const ThreeWindingTransfo: {
52
+ label: string;
53
+ type: string;
54
+ };
55
+ export declare const ShuntCompensator: {
56
+ label: string;
57
+ type: string;
58
+ };
59
+ export declare const VoltageLevel: {
60
+ label: string;
61
+ type: string;
62
+ };
63
+ export declare const Substation: {
64
+ label: string;
65
+ type: string;
66
+ };
67
+ export declare const noSelectionForCopy: {
68
+ sourceCaseUuid: null;
69
+ name: null;
70
+ description: null;
71
+ parentDirectoryUuid: null;
72
+ };
@@ -0,0 +1,63 @@
1
+ const Line = { label: "Lines", type: "LINE" };
2
+ const Generator = { label: "Generators", type: "GENERATOR" };
3
+ const Load = { label: "Loads", type: "LOAD" };
4
+ const Battery = { label: "Batteries", type: "BATTERY" };
5
+ const SVC = {
6
+ label: "StaticVarCompensators",
7
+ type: "STATIC_VAR_COMPENSATOR"
8
+ };
9
+ const DanglingLine = { label: "DanglingLines", type: "DANGLING_LINE" };
10
+ const LCC = {
11
+ label: "LccConverterStations",
12
+ type: "LCC_CONVERTER_STATION"
13
+ };
14
+ const VSC = {
15
+ label: "VscConverterStations",
16
+ type: "VSC_CONVERTER_STATION"
17
+ };
18
+ const Hvdc = { label: "HvdcLines", type: "HVDC_LINE" };
19
+ const BusBar = { label: "BusBarSections", type: "BUSBAR_SECTION" };
20
+ const TwoWindingTransfo = {
21
+ label: "TwoWindingsTransformers",
22
+ type: "TWO_WINDINGS_TRANSFORMER"
23
+ };
24
+ const ThreeWindingTransfo = {
25
+ label: "ThreeWindingsTransformers",
26
+ type: "THREE_WINDINGS_TRANSFORMER"
27
+ };
28
+ const ShuntCompensator = {
29
+ label: "ShuntCompensators",
30
+ type: "SHUNT_COMPENSATOR"
31
+ };
32
+ const VoltageLevel = {
33
+ label: "VoltageLevels",
34
+ type: "VOLTAGE_LEVEL"
35
+ };
36
+ const Substation = {
37
+ label: "Substations",
38
+ type: "SUBSTATION"
39
+ };
40
+ const noSelectionForCopy = {
41
+ sourceCaseUuid: null,
42
+ name: null,
43
+ description: null,
44
+ parentDirectoryUuid: null
45
+ };
46
+ export {
47
+ Battery,
48
+ BusBar,
49
+ DanglingLine,
50
+ Generator,
51
+ Hvdc,
52
+ LCC,
53
+ Line,
54
+ Load,
55
+ SVC,
56
+ ShuntCompensator,
57
+ Substation,
58
+ ThreeWindingTransfo,
59
+ TwoWindingTransfo,
60
+ VSC,
61
+ VoltageLevel,
62
+ noSelectionForCopy
63
+ };