@gridsuite/commons-ui 0.54.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 (165) 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 +7 -6
  5. package/dist/components/DirectoryItemSelector/directory-item-selector.js +34 -43
  6. package/dist/components/FlatParameters/FlatParameters.js +3 -0
  7. package/dist/components/ReportViewer/log-report.d.ts +2 -2
  8. package/dist/components/TreeViewFinder/TreeViewFinder.d.ts +32 -58
  9. package/dist/components/TreeViewFinder/TreeViewFinder.js +126 -82
  10. package/dist/components/dialogs/custom-mui-dialog.d.ts +21 -0
  11. package/dist/components/dialogs/custom-mui-dialog.js +87 -0
  12. package/dist/components/dialogs/description-modification-dialog.d.ts +11 -0
  13. package/dist/components/dialogs/description-modification-dialog.js +71 -0
  14. package/dist/components/dialogs/popup-confirmation-dialog.d.ts +11 -0
  15. package/dist/components/dialogs/popup-confirmation-dialog.js +38 -0
  16. package/dist/components/filter/constants/equipment-types.d.ts +72 -0
  17. package/dist/components/filter/constants/equipment-types.js +63 -0
  18. package/dist/components/filter/constants/expert-filter-constants.d.ts +546 -0
  19. package/dist/components/filter/constants/expert-filter-constants.js +663 -0
  20. package/dist/components/filter/constants/field-constants.d.ts +45 -0
  21. package/dist/components/filter/constants/field-constants.js +43 -0
  22. package/dist/components/filter/constants/filter-constants.d.ts +21 -0
  23. package/dist/components/filter/constants/filter-constants.js +10 -0
  24. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.d.ts +29 -0
  25. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.js +19 -0
  26. package/dist/components/filter/criteria-based/criteria-based-filter-form.d.ts +15 -0
  27. package/dist/components/filter/criteria-based/criteria-based-filter-form.js +33 -0
  28. package/dist/components/filter/criteria-based/criteria-based-filter-utils.d.ts +37 -0
  29. package/dist/components/filter/criteria-based/criteria-based-filter-utils.js +127 -0
  30. package/dist/components/filter/criteria-based/criteria-based-form.d.ts +7 -0
  31. package/dist/components/filter/criteria-based/criteria-based-form.js +50 -0
  32. package/dist/components/filter/criteria-based/filter-free-properties.d.ts +10 -0
  33. package/dist/components/filter/criteria-based/filter-free-properties.js +15 -0
  34. package/dist/components/filter/criteria-based/filter-properties.d.ts +21 -0
  35. package/dist/components/filter/criteria-based/filter-properties.js +19 -0
  36. package/dist/components/filter/criteria-based/filter-property.d.ts +19 -0
  37. package/dist/components/filter/criteria-based/filter-property.js +67 -0
  38. package/dist/components/filter/expert/expert-filter-edition-dialog.d.ts +28 -0
  39. package/dist/components/filter/expert/expert-filter-edition-dialog.js +20 -0
  40. package/dist/components/filter/expert/expert-filter-form.d.ts +21 -0
  41. package/dist/components/filter/expert/expert-filter-form.js +22 -0
  42. package/dist/components/filter/expert/expert-filter-utils.d.ts +19 -0
  43. package/dist/components/filter/expert/expert-filter-utils.js +302 -0
  44. package/dist/components/filter/expert/expert-filter.type.d.ts +113 -0
  45. package/dist/components/filter/expert/expert-filter.type.js +103 -0
  46. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.d.ts +22 -0
  47. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.js +19 -0
  48. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.d.ts +22 -0
  49. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.js +23 -0
  50. package/dist/components/filter/filter-context.d.ts +12 -0
  51. package/dist/components/filter/filter-context.js +10 -0
  52. package/dist/components/filter/filter-creation-dialog.d.ts +21 -0
  53. package/dist/components/filter/filter-creation-dialog.js +17 -0
  54. package/dist/components/filter/filter-form.d.ts +11 -0
  55. package/dist/components/filter/filter-form.js +14 -0
  56. package/dist/components/filter/utils/criteria-based-utils.d.ts +28 -0
  57. package/dist/components/filter/utils/criteria-based-utils.js +197 -0
  58. package/dist/components/filter/utils/filters-utils.d.ts +5 -0
  59. package/dist/components/filter/utils/filters-utils.js +99 -0
  60. package/dist/components/inputs/select-clearable.d.ts +14 -0
  61. package/dist/components/inputs/select-clearable.js +40 -0
  62. package/dist/components/react-hook-form/ExpandingTextField.d.ts +1 -1
  63. package/dist/components/react-hook-form/ExpandingTextField.js +0 -37
  64. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.d.ts +17 -0
  65. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.js +15 -0
  66. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.d.ts +23 -0
  67. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.js +70 -0
  68. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.d.ts +16 -0
  69. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.js +69 -0
  70. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.d.ts +23 -0
  71. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.js +15 -0
  72. package/dist/components/react-hook-form/autocomplete-input.d.ts +17 -29
  73. package/dist/components/react-hook-form/autocomplete-input.js +4 -15
  74. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.d.ts +2 -0
  75. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.js +46 -0
  76. package/dist/components/react-hook-form/directory-items-input.d.ts +2 -4
  77. package/dist/components/react-hook-form/directory-items-input.js +61 -12
  78. package/dist/components/react-hook-form/error-management/error-input.d.ts +13 -4
  79. package/dist/components/react-hook-form/error-management/error-input.js +7 -7
  80. package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +6 -3
  81. package/dist/components/react-hook-form/error-management/field-error-alert.js +3 -1
  82. package/dist/components/react-hook-form/numbers/float-input.d.ts +5 -17
  83. package/dist/components/react-hook-form/numbers/float-input.js +3 -5
  84. package/dist/components/react-hook-form/numbers/integer-input.d.ts +15 -12
  85. package/dist/components/react-hook-form/numbers/utils.d.ts +8 -2
  86. package/dist/components/react-hook-form/provider/custom-form-provider.d.ts +1 -0
  87. package/dist/components/react-hook-form/provider/custom-form-provider.js +12 -3
  88. package/dist/components/react-hook-form/radio-input.d.ts +14 -17
  89. package/dist/components/react-hook-form/radio-input.js +7 -9
  90. package/dist/components/react-hook-form/range-input.d.ts +54 -0
  91. package/dist/components/react-hook-form/range-input.js +118 -0
  92. package/dist/components/react-hook-form/select-inputs/countries-input.d.ts +8 -0
  93. package/dist/components/react-hook-form/select-inputs/countries-input.js +36 -0
  94. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.d.ts +2 -0
  95. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.js +61 -0
  96. package/dist/components/react-hook-form/select-inputs/mui-select-input.d.ts +12 -0
  97. package/dist/components/react-hook-form/select-inputs/mui-select-input.js +25 -0
  98. package/dist/components/react-hook-form/select-inputs/select-input.d.ts +9 -0
  99. package/dist/components/react-hook-form/select-inputs/select-input.js +37 -0
  100. package/dist/components/react-hook-form/text-input.d.ts +23 -32
  101. package/dist/components/react-hook-form/text-input.js +6 -20
  102. package/dist/components/react-hook-form/unique-name-input.d.ts +21 -0
  103. package/dist/components/react-hook-form/unique-name-input.js +129 -0
  104. package/dist/components/react-hook-form/utils/cancel-button.d.ts +9 -8
  105. package/dist/components/react-hook-form/utils/field-label.d.ts +12 -5
  106. package/dist/components/react-hook-form/utils/field-label.js +5 -1
  107. package/dist/components/react-hook-form/utils/functions.d.ts +12 -4
  108. package/dist/components/react-hook-form/utils/functions.js +21 -1
  109. package/dist/components/react-hook-form/utils/submit-button.d.ts +9 -8
  110. package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +11 -11
  111. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +18 -23
  112. package/dist/components/react-query-builder-inputs/add-button.d.ts +8 -0
  113. package/dist/components/react-query-builder-inputs/add-button.js +17 -0
  114. package/dist/components/react-query-builder-inputs/combinator-selector.d.ts +5 -0
  115. package/dist/components/react-query-builder-inputs/combinator-selector.js +38 -0
  116. package/dist/components/react-query-builder-inputs/country-value-editor.d.ts +5 -0
  117. package/dist/components/react-query-builder-inputs/country-value-editor.js +46 -0
  118. package/dist/components/react-query-builder-inputs/custom-react-query-builder.d.ts +8 -0
  119. package/dist/components/react-query-builder-inputs/custom-react-query-builder.js +21 -0
  120. package/dist/components/react-query-builder-inputs/element-value-editor.d.ts +14 -0
  121. package/dist/components/react-query-builder-inputs/element-value-editor.js +69 -0
  122. package/dist/components/react-query-builder-inputs/property-value-editor.d.ts +9 -0
  123. package/dist/components/react-query-builder-inputs/property-value-editor.js +100 -0
  124. package/dist/components/react-query-builder-inputs/remove-button.d.ts +5 -0
  125. package/dist/components/react-query-builder-inputs/remove-button.js +9 -0
  126. package/dist/components/react-query-builder-inputs/text-value-editor.d.ts +5 -0
  127. package/dist/components/react-query-builder-inputs/text-value-editor.js +34 -0
  128. package/dist/components/react-query-builder-inputs/translated-value-editor.d.ts +5 -0
  129. package/dist/components/react-query-builder-inputs/translated-value-editor.js +58 -0
  130. package/dist/components/react-query-builder-inputs/use-convert-value.d.ts +9 -0
  131. package/dist/components/react-query-builder-inputs/use-convert-value.js +24 -0
  132. package/dist/components/react-query-builder-inputs/use-valid.d.ts +7 -0
  133. package/dist/components/react-query-builder-inputs/use-valid.js +13 -0
  134. package/dist/components/react-query-builder-inputs/value-editor.d.ts +5 -0
  135. package/dist/components/react-query-builder-inputs/value-editor.js +18 -0
  136. package/dist/components/react-query-builder-inputs/value-selector.d.ts +4 -0
  137. package/dist/components/react-query-builder-inputs/value-selector.js +14 -0
  138. package/dist/components/translations/treeview-finder-en.d.ts +1 -0
  139. package/dist/components/translations/treeview-finder-en.js +4 -3
  140. package/dist/components/translations/treeview-finder-fr.d.ts +1 -0
  141. package/dist/components/translations/treeview-finder-fr.js +4 -3
  142. package/dist/hooks/localized-countries-hook.d.ts +6 -0
  143. package/dist/hooks/localized-countries-hook.js +45 -0
  144. package/dist/hooks/predefined-properties-hook.d.ts +18 -0
  145. package/dist/hooks/predefined-properties-hook.js +43 -0
  146. package/dist/hooks/useDebounce.d.ts +7 -1
  147. package/dist/hooks/useSnackMessage.d.ts +23 -5
  148. package/dist/hooks/useSnackMessage.js +14 -12
  149. package/dist/index.d.ts +92 -143
  150. package/dist/index.js +168 -91
  151. package/dist/utils/FetchStatus.d.ts +12 -0
  152. package/dist/utils/FetchStatus.js +9 -0
  153. package/dist/utils/conversion-utils.d.ts +12 -0
  154. package/dist/utils/conversion-utils.js +22 -0
  155. package/dist/utils/equipment-types-for-predefined-properties-mapper.d.ts +3 -0
  156. package/dist/utils/equipment-types-for-predefined-properties-mapper.js +31 -0
  157. package/dist/utils/functions.d.ts +14 -0
  158. package/dist/utils/functions.js +16 -0
  159. package/dist/utils/types.d.ts +21 -0
  160. package/dist/utils/types.js +1 -0
  161. package/dist/utils/yup-config.d.ts +8 -0
  162. package/dist/utils/yup-config.js +16 -0
  163. package/package.json +27 -4
  164. package/dist/components/react-hook-form/select-input.d.ts +0 -17
  165. package/dist/components/react-hook-form/select-input.js +0 -30
@@ -1,7 +1,6 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState, useCallback, useEffect } from "react";
2
+ import { useState, useRef, useCallback, useEffect } from "react";
3
3
  import { useIntl } from "react-intl";
4
- import PropTypes from "prop-types";
5
4
  import { toNestedGlobalSelectors, makeComposeClasses } from "../../utils/styles.js";
6
5
  import { styled } from "@mui/system";
7
6
  import { Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Typography } from "@mui/material";
@@ -39,7 +38,7 @@ const composeClasses = makeComposeClasses(generateTreeViewFinderClass);
39
38
  const TreeViewFinder = (props) => {
40
39
  const intl = useIntl();
41
40
  const {
42
- classes,
41
+ classes = {},
43
42
  title,
44
43
  contentText,
45
44
  open,
@@ -49,52 +48,63 @@ const TreeViewFinder = (props) => {
49
48
  onClose,
50
49
  onTreeBrowse,
51
50
  validationButtonText,
52
- onlyLeaves,
53
- multiselect,
51
+ onlyLeaves = true,
52
+ multiSelect = false,
54
53
  sortMethod,
55
54
  className,
56
- cancelButtonProps
55
+ cancelButtonProps,
56
+ selected: selectedProp,
57
+ expanded: expandedProp
57
58
  } = props;
58
59
  const [mapPrintedNodes, setMapPrintedNodes] = useState({});
59
- const [expanded, setExpanded] = useState(defaultExpanded);
60
- const [selected, setSelected] = useState(defaultSelected);
60
+ const [expanded, setExpanded] = useState(
61
+ defaultExpanded ?? []
62
+ );
63
+ const [selected, setSelected] = useState(
64
+ defaultSelected ?? []
65
+ );
66
+ const scrollRef = useRef([]);
67
+ const [autoScrollAllowed, setAutoScrollAllowed] = useState(true);
61
68
  const isSelectable = (node) => {
62
69
  return onlyLeaves ? isLeaf(node) : true;
63
70
  };
64
71
  const isLeaf = (node) => {
65
72
  return node && node.children === void 0;
66
73
  };
67
- const computeMapPrintedNodes = useCallback((nodes) => {
68
- let newMapPrintedNodes = {};
69
- nodes.forEach((node) => {
70
- newMapPrintedNodes[node.id] = node;
71
- if (!isLeaf(node)) {
72
- Object.assign(
73
- newMapPrintedNodes,
74
- computeMapPrintedNodes(node.children)
75
- );
76
- }
77
- });
78
- return newMapPrintedNodes;
79
- }, []);
74
+ const isValidationDisabled = () => {
75
+ return (selected == null ? void 0 : selected.length) === 0 || (selected == null ? void 0 : selected.length) === (selectedProp == null ? void 0 : selectedProp.length) && (selected == null ? void 0 : selected.every((nodeId) => selectedProp == null ? void 0 : selectedProp.includes(nodeId)));
76
+ };
77
+ const computeMapPrintedNodes = useCallback(
78
+ (nodes) => {
79
+ let newMapPrintedNodes = {};
80
+ nodes == null ? void 0 : nodes.forEach((node) => {
81
+ newMapPrintedNodes[node.id] = node;
82
+ if (!isLeaf(node)) {
83
+ Object.assign(
84
+ newMapPrintedNodes,
85
+ computeMapPrintedNodes(node.children)
86
+ );
87
+ }
88
+ });
89
+ return newMapPrintedNodes;
90
+ },
91
+ []
92
+ );
80
93
  useEffect(() => {
81
94
  let newMapPrintedNodes = computeMapPrintedNodes(data);
82
- console.debug(
83
- "data updated, new mapPrintedNodes (nbNodes = ",
84
- Object.keys(newMapPrintedNodes).length,
85
- ") : ",
86
- newMapPrintedNodes
87
- );
88
95
  setMapPrintedNodes(newMapPrintedNodes);
89
96
  }, [data, computeMapPrintedNodes]);
90
97
  const computeSelectedNodes = () => {
91
- return selected.map((nodeId) => {
98
+ if (!selected) {
99
+ return [];
100
+ }
101
+ return selected == null ? void 0 : selected.map((nodeId) => {
92
102
  return mapPrintedNodes[nodeId];
93
103
  });
94
104
  };
95
- const handleNodeToggle = (e, nodeIds) => {
105
+ const handleNodeToggle = (_e, nodeIds) => {
96
106
  nodeIds.every((nodeId) => {
97
- if (!expanded.includes(nodeId)) {
107
+ if (!(expanded == null ? void 0 : expanded.includes(nodeId))) {
98
108
  onTreeBrowse && onTreeBrowse(nodeId);
99
109
  return false;
100
110
  }
@@ -102,18 +112,61 @@ const TreeViewFinder = (props) => {
102
112
  });
103
113
  setExpanded(nodeIds);
104
114
  };
105
- const handleNodeSelect = (e, values) => {
106
- if (multiselect) {
115
+ useEffect(() => {
116
+ if (!selectedProp) {
117
+ return;
118
+ }
119
+ if (selectedProp.length > 0) {
120
+ setSelected((oldSelectedNodes) => [
121
+ ...oldSelectedNodes ? oldSelectedNodes : [],
122
+ ...selectedProp
123
+ ]);
124
+ }
125
+ }, [selectedProp]);
126
+ useEffect(() => {
127
+ if (!expandedProp || expandedProp.length === 0) {
128
+ return;
129
+ }
130
+ if (expandedProp.length > 0) {
131
+ setExpanded((oldExpandedNodes) => [
132
+ ...oldExpandedNodes ? oldExpandedNodes : [],
133
+ ...expandedProp
134
+ ]);
135
+ }
136
+ }, [expandedProp]);
137
+ useEffect(() => {
138
+ if (!selectedProp) {
139
+ return;
140
+ }
141
+ if (selectedProp.length > 0 && autoScrollAllowed) {
142
+ const isNodeExpanded = expandedProp == null ? void 0 : expandedProp.every(
143
+ (nodeId) => expanded == null ? void 0 : expanded.includes(nodeId)
144
+ );
145
+ const lastScrollRef = scrollRef.current[scrollRef.current.length - 1];
146
+ if (isNodeExpanded && lastScrollRef) {
147
+ lastScrollRef.scrollIntoView({
148
+ behavior: "smooth",
149
+ block: "center",
150
+ inline: "center"
151
+ });
152
+ setAutoScrollAllowed(false);
153
+ }
154
+ }
155
+ }, [expanded, selectedProp, expandedProp, data, autoScrollAllowed]);
156
+ const handleNodeSelect = (_e, values) => {
157
+ if (multiSelect && Array.isArray(values)) {
107
158
  setSelected(
108
159
  values.filter((nodeId) => isSelectable(mapPrintedNodes[nodeId]))
109
160
  );
110
161
  } else {
111
- if (selected.includes(values)) {
112
- setSelected([]);
113
- } else {
114
- setSelected(
115
- isSelectable(mapPrintedNodes[values]) ? [values] : []
116
- );
162
+ if (!Array.isArray(values)) {
163
+ if (selected == null ? void 0 : selected.includes(values)) {
164
+ setSelected([]);
165
+ } else {
166
+ setSelected(
167
+ isSelectable(mapPrintedNodes[values]) ? [values] : []
168
+ );
169
+ }
117
170
  }
118
171
  }
119
172
  };
@@ -121,10 +174,16 @@ const TreeViewFinder = (props) => {
121
174
  if (validationButtonText) {
122
175
  return validationButtonText;
123
176
  } else {
177
+ let buttonLabelId = "";
178
+ if (Array.isArray(selectedProp)) {
179
+ buttonLabelId = (selectedProp == null ? void 0 : selectedProp.length) > 0 ? "treeview_finder/replaceElementsValidation" : "treeview_finder/addElementsValidation";
180
+ } else {
181
+ buttonLabelId = selectedProp ? "treeview_finder/replaceElementsValidation" : "treeview_finder/addElementsValidation";
182
+ }
124
183
  return intl.formatMessage(
125
- { id: "treeview_finder/addElementsValidation" },
184
+ { id: buttonLabelId },
126
185
  {
127
- nbElements: selected.length
186
+ nbElements: selected == null ? void 0 : selected.length
128
187
  }
129
188
  );
130
189
  }
@@ -133,7 +192,7 @@ const TreeViewFinder = (props) => {
133
192
  if (!node) {
134
193
  return null;
135
194
  }
136
- if (isSelectable(node) && selected.find((nodeId) => nodeId === node.id)) {
195
+ if (isSelectable(node) && (selected == null ? void 0 : selected.find((nodeId) => nodeId === node.id))) {
137
196
  return /* @__PURE__ */ jsx(Check, { className: composeClasses(classes, cssLabelIcon) });
138
197
  } else {
139
198
  if (node.icon) {
@@ -173,18 +232,35 @@ const TreeViewFinder = (props) => {
173
232
  className: composeClasses(classes, cssIcon)
174
233
  }
175
234
  ) : null,
235
+ ref: (element) => {
236
+ if (selectedProp == null ? void 0 : selectedProp.includes(node.id)) {
237
+ scrollRef.current.push(element);
238
+ }
239
+ },
176
240
  children: Array.isArray(node.children) ? node.children.length ? node.children.sort(sortMethod).map((child) => renderTree(child)) : [false] : null
177
241
  },
178
242
  node.id
179
243
  );
180
244
  };
245
+ const getTreeViewSelectionProps = () => {
246
+ if (!multiSelect) {
247
+ return {
248
+ multiSelect: false,
249
+ selected: selected && selected.length > 0 ? selected.at(0) : ""
250
+ };
251
+ }
252
+ return {
253
+ multiSelect: true,
254
+ selected: selected ?? []
255
+ };
256
+ };
181
257
  return /* @__PURE__ */ jsxs(
182
258
  Dialog,
183
259
  {
184
260
  open,
185
261
  onClose: (e, r) => {
186
262
  if (r === "escapeKeyDown" || r === "backdropClick") {
187
- onClose([]);
263
+ onClose && onClose([]);
188
264
  setSelected([]);
189
265
  }
190
266
  },
@@ -196,21 +272,20 @@ const TreeViewFinder = (props) => {
196
272
  children: [
197
273
  /* @__PURE__ */ jsx(DialogTitle, { id: "TreeViewFindertitle", children: title ? title : intl.formatMessage(
198
274
  { id: "treeview_finder/finderTitle" },
199
- { multiselect }
275
+ { multiSelect }
200
276
  ) }),
201
277
  /* @__PURE__ */ jsxs(DialogContent, { children: [
202
278
  /* @__PURE__ */ jsx(DialogContentText, { children: contentText ? contentText : intl.formatMessage(
203
279
  { id: "treeview_finder/contentText" },
204
- { multiselect }
280
+ { multiSelect }
205
281
  ) }),
206
282
  /* @__PURE__ */ jsx(
207
283
  TreeView,
208
284
  {
209
285
  expanded,
210
- selected,
211
286
  onNodeToggle: handleNodeToggle,
212
287
  onNodeSelect: handleNodeSelect,
213
- multiSelect: multiselect,
288
+ ...getTreeViewSelectionProps(),
214
289
  children: data && Array.isArray(data) ? data.sort(sortMethod).map((child) => renderTree(child)) : null
215
290
  }
216
291
  )
@@ -221,8 +296,9 @@ const TreeViewFinder = (props) => {
221
296
  {
222
297
  style: { float: "left", margin: "5px" },
223
298
  onClick: () => {
224
- onClose([]);
299
+ onClose && onClose([]);
225
300
  setSelected([]);
301
+ setAutoScrollAllowed(true);
226
302
  },
227
303
  ...cancelButtonProps
228
304
  }
@@ -233,10 +309,11 @@ const TreeViewFinder = (props) => {
233
309
  variant: "outlined",
234
310
  style: { float: "left", margin: "5px" },
235
311
  onClick: () => {
236
- onClose(computeSelectedNodes());
312
+ onClose && onClose(computeSelectedNodes());
237
313
  setSelected([]);
314
+ setAutoScrollAllowed(true);
238
315
  },
239
- disabled: selected.length === 0,
316
+ disabled: isValidationDisabled(),
240
317
  children: getValidationButtonText()
241
318
  }
242
319
  )
@@ -245,39 +322,6 @@ const TreeViewFinder = (props) => {
245
322
  }
246
323
  );
247
324
  };
248
- TreeViewFinder.propTypes = {
249
- // Controlled
250
- open: PropTypes.bool.isRequired,
251
- onClose: PropTypes.func,
252
- data: PropTypes.arrayOf(
253
- PropTypes.shape({
254
- id: PropTypes.string.isRequired,
255
- name: PropTypes.string.isRequired,
256
- children: PropTypes.array
257
- })
258
- ).isRequired,
259
- onTreeBrowse: PropTypes.func,
260
- //uncontrolled
261
- classes: PropTypes.object,
262
- title: PropTypes.string,
263
- contentText: PropTypes.string,
264
- validationButtonText: PropTypes.string,
265
- defaultSelected: PropTypes.arrayOf(PropTypes.string),
266
- defaultExpanded: PropTypes.arrayOf(PropTypes.string),
267
- onlyLeaves: PropTypes.bool,
268
- multiselect: PropTypes.bool,
269
- sortMethod: PropTypes.func,
270
- cancelButtonProps: PropTypes.object,
271
- className: PropTypes.string
272
- };
273
- TreeViewFinder.defaultProps = {
274
- defaultSelected: [],
275
- defaultExpanded: [],
276
- onlyLeaves: true,
277
- multiselect: false,
278
- sortMethod: void 0,
279
- classes: {}
280
- };
281
325
  const nestedGlobalSelectorsStyles = toNestedGlobalSelectors(
282
326
  defaultStyles,
283
327
  generateTreeViewFinderClass
@@ -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
+ };