@gridsuite/commons-ui 0.57.0 → 0.58.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 (167) hide show
  1. package/dist/_mocks_/svg.d.ts +4 -0
  2. package/dist/_mocks_/svg.js +8 -0
  3. package/dist/chunks/{criteria-based-filter-edition-dialog.BEXoNmzz.js → criteria-based-filter-edition-dialog.CbhgOSRk.js} +139 -110
  4. package/dist/chunks/{filter-properties.GRon8-ML.js → filter-properties.B7-q_yPf.js} +4 -4
  5. package/dist/components/DirectoryItemSelector/directory-item-selector.js +2 -1
  6. package/dist/components/ElementSearchDialog/element-search-dialog.d.ts +18 -15
  7. package/dist/components/ElementSearchDialog/element-search-dialog.js +28 -65
  8. package/dist/components/ElementSearchDialog/equipment-item.js +4 -3
  9. package/dist/components/OverflowableText/overflowable-text.js +39 -9
  10. package/dist/components/TreeViewFinder/TreeViewFinder.js +1 -1
  11. package/dist/components/TreeViewFinder/index.d.ts +7 -0
  12. package/dist/components/dialogs/custom-mui-dialog.d.ts +2 -1
  13. package/dist/components/dialogs/custom-mui-dialog.js +6 -4
  14. package/dist/components/dialogs/description-modification-dialog.js +2 -2
  15. package/dist/components/dialogs/modify-element-selection.d.ts +14 -0
  16. package/dist/components/dialogs/modify-element-selection.js +108 -0
  17. package/dist/components/dialogs/popup-confirmation-dialog.js +1 -1
  18. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.d.ts +1 -2
  19. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.js +4 -4
  20. package/dist/components/filter/criteria-based/criteria-based-filter-form.js +5 -3
  21. package/dist/components/filter/criteria-based/criteria-based-filter-utils.d.ts +12 -6
  22. package/dist/components/filter/criteria-based/criteria-based-filter-utils.js +44 -4
  23. package/dist/components/filter/criteria-based/criteria-based-form.d.ts +2 -0
  24. package/dist/components/filter/criteria-based/criteria-based-form.js +6 -6
  25. package/dist/components/filter/criteria-based/filter-free-properties.js +5 -5
  26. package/dist/components/filter/criteria-based/filter-properties.js +3 -3
  27. package/dist/components/filter/criteria-based/filter-property.js +3 -3
  28. package/dist/components/filter/{constants → expert}/expert-filter-constants.js +7 -6
  29. package/dist/components/filter/expert/expert-filter-edition-dialog.d.ts +3 -3
  30. package/dist/components/filter/expert/expert-filter-edition-dialog.js +5 -6
  31. package/dist/components/filter/expert/expert-filter-form.js +5 -5
  32. package/dist/components/filter/expert/expert-filter-utils.js +1 -1
  33. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.d.ts +0 -2
  34. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.js +4 -4
  35. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.d.ts +10 -2
  36. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.js +12 -8
  37. package/dist/components/filter/filter-context.d.ts +1 -0
  38. package/dist/components/filter/filter-context.js +2 -1
  39. package/dist/components/filter/filter-creation-dialog.d.ts +5 -2
  40. package/dist/components/filter/filter-creation-dialog.js +3 -3
  41. package/dist/components/filter/filter-form.d.ts +4 -0
  42. package/dist/components/filter/filter-form.js +6 -5
  43. package/dist/components/filter/utils/filter-api.d.ts +5 -0
  44. package/dist/components/filter/utils/{filters-utils.js → filter-api.js} +16 -10
  45. package/dist/components/filter/utils/filter-form-utils.d.ts +17 -0
  46. package/dist/components/filter/utils/{criteria-based-utils.js → filter-form-utils.js} +5 -45
  47. package/dist/components/{react-hook-form/ag-grid-table-rhf → inputs/react-hook-form/ag-grid-table}/bottom-right-buttons.js +1 -1
  48. package/dist/components/{react-hook-form/ag-grid-table-rhf → inputs/react-hook-form/ag-grid-table}/csv-uploader/csv-uploader.js +23 -23
  49. package/dist/components/{react-hook-form/ag-grid-table-rhf → inputs/react-hook-form/ag-grid-table}/custom-ag-grid-table.js +2 -2
  50. package/dist/components/{react-hook-form → inputs/react-hook-form/autocomplete-inputs}/autocomplete-input.d.ts +3 -3
  51. package/dist/components/{react-hook-form → inputs/react-hook-form/autocomplete-inputs}/autocomplete-input.js +4 -4
  52. package/dist/components/{react-hook-form → inputs/react-hook-form}/autocomplete-inputs/multiple-autocomplete-input.js +1 -1
  53. package/dist/components/{react-hook-form → inputs/react-hook-form}/directory-items-input.js +5 -5
  54. package/dist/components/{react-hook-form → inputs/react-hook-form}/numbers/integer-input.d.ts +3 -3
  55. package/dist/components/{react-hook-form → inputs/react-hook-form}/provider/custom-form-provider.js +1 -1
  56. package/dist/components/{react-hook-form → inputs/react-hook-form}/range-input.d.ts +1 -1
  57. package/dist/components/{react-hook-form → inputs/react-hook-form}/range-input.js +2 -2
  58. package/dist/components/{react-hook-form → inputs/react-hook-form}/select-inputs/countries-input.d.ts +1 -1
  59. package/dist/components/{react-hook-form → inputs/react-hook-form}/select-inputs/countries-input.js +2 -3
  60. package/dist/components/{react-hook-form → inputs/react-hook-form}/select-inputs/input-with-popup-confirmation.js +1 -1
  61. package/dist/components/{react-hook-form → inputs/react-hook-form}/select-inputs/select-input.d.ts +2 -2
  62. package/dist/components/{react-hook-form → inputs/react-hook-form}/select-inputs/select-input.js +4 -1
  63. package/dist/components/{react-hook-form → inputs/react-hook-form}/text-input.d.ts +1 -1
  64. package/dist/components/{react-hook-form → inputs/react-hook-form}/unique-name-input.d.ts +2 -2
  65. package/dist/components/{react-hook-form → inputs/react-hook-form}/unique-name-input.js +2 -2
  66. package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/text-field-with-adornment.d.ts +1 -1
  67. package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/combinator-selector.js +1 -1
  68. package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/country-value-editor.js +1 -1
  69. package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/custom-react-query-builder.js +3 -3
  70. package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/element-value-editor.js +22 -22
  71. package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/property-value-editor.js +3 -3
  72. package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/remove-button.js +2 -2
  73. package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/use-convert-value.js +1 -1
  74. package/dist/components/inputs/react-query-builder/value-editor.js +18 -0
  75. package/dist/components/inputs/select-clearable.js +1 -1
  76. package/dist/hooks/useDebounce.d.ts +1 -1
  77. package/dist/hooks/useSnackMessage.d.ts +4 -7
  78. package/dist/hooks/useSnackMessage.js +36 -43
  79. package/dist/index.d.ts +51 -39
  80. package/dist/index.js +129 -120
  81. package/dist/redux/commonStore.d.ts +15 -0
  82. package/dist/redux/commonStore.js +11 -0
  83. package/dist/services/explore.d.ts +4 -0
  84. package/dist/services/explore.js +34 -0
  85. package/dist/services/study.d.ts +3 -0
  86. package/dist/services/study.js +16 -0
  87. package/dist/services/utils.d.ts +8 -0
  88. package/dist/services/utils.js +58 -0
  89. package/dist/utils/AuthService.js +1 -1
  90. package/dist/utils/types.d.ts +1 -1
  91. package/package.json +8 -7
  92. package/dist/components/filter/utils/criteria-based-utils.d.ts +0 -28
  93. package/dist/components/filter/utils/filters-utils.d.ts +0 -5
  94. package/dist/components/react-query-builder-inputs/value-editor.js +0 -18
  95. /package/dist/components/filter/{constants → expert}/expert-filter-constants.d.ts +0 -0
  96. /package/dist/components/{react-hook-form → inputs/react-hook-form}/ExpandingTextField.d.ts +0 -0
  97. /package/dist/components/{react-hook-form → inputs/react-hook-form}/ExpandingTextField.js +0 -0
  98. /package/dist/components/{react-hook-form/ag-grid-table-rhf → inputs/react-hook-form/ag-grid-table}/bottom-right-buttons.d.ts +0 -0
  99. /package/dist/components/{react-hook-form/ag-grid-table-rhf → inputs/react-hook-form/ag-grid-table}/cell-editors/numericEditor.d.ts +0 -0
  100. /package/dist/components/{react-hook-form/ag-grid-table-rhf → inputs/react-hook-form/ag-grid-table}/cell-editors/numericEditor.js +0 -0
  101. /package/dist/components/{react-hook-form/ag-grid-table-rhf → inputs/react-hook-form/ag-grid-table}/csv-uploader/csv-uploader.d.ts +0 -0
  102. /package/dist/components/{react-hook-form/ag-grid-table-rhf → inputs/react-hook-form/ag-grid-table}/custom-ag-grid-table.d.ts +0 -0
  103. /package/dist/components/{react-hook-form → inputs/react-hook-form}/autocomplete-inputs/multiple-autocomplete-input.d.ts +0 -0
  104. /package/dist/components/{react-hook-form → inputs/react-hook-form}/booleans/boolean-input.d.ts +0 -0
  105. /package/dist/components/{react-hook-form → inputs/react-hook-form}/booleans/boolean-input.js +0 -0
  106. /package/dist/components/{react-hook-form → inputs/react-hook-form}/booleans/checkbox-input.d.ts +0 -0
  107. /package/dist/components/{react-hook-form → inputs/react-hook-form}/booleans/checkbox-input.js +0 -0
  108. /package/dist/components/{react-hook-form → inputs/react-hook-form}/booleans/switch-input.d.ts +0 -0
  109. /package/dist/components/{react-hook-form → inputs/react-hook-form}/booleans/switch-input.js +0 -0
  110. /package/dist/components/{react-hook-form → inputs/react-hook-form}/directory-items-input.d.ts +0 -0
  111. /package/dist/components/{react-hook-form → inputs/react-hook-form}/error-management/error-input.d.ts +0 -0
  112. /package/dist/components/{react-hook-form → inputs/react-hook-form}/error-management/error-input.js +0 -0
  113. /package/dist/components/{react-hook-form → inputs/react-hook-form}/error-management/field-error-alert.d.ts +0 -0
  114. /package/dist/components/{react-hook-form → inputs/react-hook-form}/error-management/field-error-alert.js +0 -0
  115. /package/dist/components/{react-hook-form → inputs/react-hook-form}/error-management/mid-form-error.d.ts +0 -0
  116. /package/dist/components/{react-hook-form → inputs/react-hook-form}/error-management/mid-form-error.js +0 -0
  117. /package/dist/components/{react-hook-form → inputs/react-hook-form}/numbers/float-input.d.ts +0 -0
  118. /package/dist/components/{react-hook-form → inputs/react-hook-form}/numbers/float-input.js +0 -0
  119. /package/dist/components/{react-hook-form → inputs/react-hook-form}/numbers/integer-input.js +0 -0
  120. /package/dist/components/{react-hook-form → inputs/react-hook-form}/numbers/utils.d.ts +0 -0
  121. /package/dist/components/{react-hook-form → inputs/react-hook-form}/numbers/utils.js +0 -0
  122. /package/dist/components/{react-hook-form → inputs/react-hook-form}/provider/custom-form-provider.d.ts +0 -0
  123. /package/dist/components/{react-hook-form → inputs/react-hook-form}/provider/use-custom-form-context.d.ts +0 -0
  124. /package/dist/components/{react-hook-form → inputs/react-hook-form}/provider/use-custom-form-context.js +0 -0
  125. /package/dist/components/{react-hook-form → inputs/react-hook-form}/radio-input.d.ts +0 -0
  126. /package/dist/components/{react-hook-form → inputs/react-hook-form}/radio-input.js +0 -0
  127. /package/dist/components/{react-hook-form → inputs/react-hook-form}/raw-read-only-input.d.ts +0 -0
  128. /package/dist/components/{react-hook-form → inputs/react-hook-form}/raw-read-only-input.js +0 -0
  129. /package/dist/components/{react-hook-form → inputs/react-hook-form}/select-inputs/input-with-popup-confirmation.d.ts +0 -0
  130. /package/dist/components/{react-hook-form → inputs/react-hook-form}/select-inputs/mui-select-input.d.ts +0 -0
  131. /package/dist/components/{react-hook-form → inputs/react-hook-form}/select-inputs/mui-select-input.js +0 -0
  132. /package/dist/components/{react-hook-form → inputs/react-hook-form}/slider-input.d.ts +0 -0
  133. /package/dist/components/{react-hook-form → inputs/react-hook-form}/slider-input.js +0 -0
  134. /package/dist/components/{react-hook-form → inputs/react-hook-form}/text-input.js +0 -0
  135. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/cancel-button.d.ts +0 -0
  136. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/cancel-button.js +0 -0
  137. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/field-label.d.ts +0 -0
  138. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/field-label.js +0 -0
  139. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/functions.d.ts +0 -0
  140. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/functions.js +0 -0
  141. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/submit-button.d.ts +0 -0
  142. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/submit-button.js +0 -0
  143. /package/dist/components/{react-hook-form → inputs/react-hook-form}/utils/text-field-with-adornment.js +0 -0
  144. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/add-button.d.ts +0 -0
  145. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/add-button.js +0 -0
  146. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/combinator-selector.d.ts +0 -0
  147. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/country-value-editor.d.ts +0 -0
  148. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/custom-react-query-builder.d.ts +0 -0
  149. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/element-value-editor.d.ts +0 -0
  150. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/property-value-editor.d.ts +0 -0
  151. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/remove-button.d.ts +0 -0
  152. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/text-value-editor.d.ts +0 -0
  153. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/text-value-editor.js +0 -0
  154. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/translated-value-editor.d.ts +0 -0
  155. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/translated-value-editor.js +0 -0
  156. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/use-convert-value.d.ts +0 -0
  157. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/use-valid.d.ts +0 -0
  158. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/use-valid.js +0 -0
  159. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/value-editor.d.ts +0 -0
  160. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/value-selector.d.ts +0 -0
  161. /package/dist/components/{react-query-builder-inputs → inputs/react-query-builder}/value-selector.js +0 -0
  162. /package/dist/{utils → redux}/actions.d.ts +0 -0
  163. /package/dist/{utils → redux}/actions.js +0 -0
  164. /package/dist/{components/filter/constants → utils}/equipment-types.d.ts +0 -0
  165. /package/dist/{components/filter/constants → utils}/equipment-types.js +0 -0
  166. /package/dist/{components/filter/constants → utils}/field-constants.d.ts +0 -0
  167. /package/dist/{components/filter/constants → utils}/field-constants.js +0 -0
@@ -1,7 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect, useCallback } from "react";
2
+ import { useMemo, useCallback } from "react";
3
3
  import { Dialog, DialogContent, Autocomplete, TextField } from "@mui/material";
4
- import PropTypes from "prop-types";
5
4
  import { SearchOff, Search } from "@mui/icons-material";
6
5
  import { useIntl } from "react-intl";
7
6
  const ElementSearchDialog = (props) => {
@@ -10,48 +9,23 @@ const ElementSearchDialog = (props) => {
10
9
  open,
11
10
  onClose,
12
11
  searchingLabel,
12
+ searchTerm,
13
13
  onSearchTermChange,
14
14
  onSelectionChange,
15
15
  elementsFound,
16
- // [{ label: aLabel, id: anId }, ...]
17
16
  renderElement,
18
17
  searchTermDisabled,
19
- searchTermDisableReason
18
+ searchTermDisableReason,
19
+ isLoading,
20
+ loadingText
20
21
  } = props;
21
- const [expanded, setExpanded] = useState(false);
22
- const [value, setValue] = useState(
23
- searchTermDisabled && searchTermDisableReason ? { label: searchTermDisableReason } : null
24
- );
25
- const [loading, setLoading] = useState(false);
26
- useEffect(() => {
27
- setLoading(false);
28
- }, [elementsFound]);
29
- useEffect(() => {
30
- if (!searchTermDisabled || !searchTermDisableReason) {
31
- setValue(null);
32
- } else {
33
- setValue({ label: searchTermDisableReason });
34
- }
35
- }, [searchTermDisabled, searchTermDisableReason]);
36
- useEffect(() => {
37
- setValue((old) => !open ? null : old);
38
- }, [open]);
39
- const handleSearchTermChange = (term) => {
40
- if (term) {
41
- setLoading(true);
42
- onSearchTermChange(term);
43
- setExpanded(true);
44
- setValue({ label: term });
45
- } else {
46
- setExpanded(false);
47
- setValue(null);
48
- }
49
- };
22
+ const displayedValue = useMemo(() => {
23
+ return searchTermDisabled || searchTermDisableReason ? searchTermDisableReason : searchTerm;
24
+ }, [searchTerm, searchTermDisabled, searchTermDisableReason]);
50
25
  const handleClose = useCallback(() => {
51
- setValue(null);
52
- setExpanded(false);
26
+ onSearchTermChange("");
53
27
  onClose();
54
- }, [onClose]);
28
+ }, [onSearchTermChange, onClose]);
55
29
  return /* @__PURE__ */ jsx(
56
30
  Dialog,
57
31
  {
@@ -63,32 +37,32 @@ const ElementSearchDialog = (props) => {
63
37
  children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(
64
38
  Autocomplete,
65
39
  {
40
+ open: isLoading || (elementsFound == null ? void 0 : elementsFound.length) > 0,
66
41
  id: "element-search",
67
42
  forcePopupIcon: false,
68
- open: expanded,
69
- onClose: () => {
70
- setExpanded(false);
71
- },
72
43
  fullWidth: true,
73
44
  freeSolo: true,
74
- clearOnBlur: true,
75
- onInputChange: (_event, value2) => {
76
- if (!searchTermDisabled) {
77
- handleSearchTermChange(value2);
45
+ onInputChange: (_event, value, reason) => {
46
+ if (!searchTermDisabled && reason !== "reset") {
47
+ onSearchTermChange(value);
78
48
  }
79
49
  },
80
50
  onChange: (_event, newValue, reason) => {
81
- if (reason === "selectOption") {
51
+ if (newValue != null && typeof newValue !== "string" && reason === "selectOption") {
82
52
  onSelectionChange(newValue);
83
- setValue(newValue);
53
+ }
54
+ },
55
+ getOptionLabel: (option) => typeof option === "string" ? option : option.label,
56
+ isOptionEqualToValue: (option, value) => {
57
+ if (typeof option === "string" || typeof value === "string") {
58
+ return option === value;
84
59
  } else {
85
- setValue(null);
60
+ return option.id === value.id;
86
61
  }
87
62
  },
88
- getOptionLabel: (option) => option.label,
89
- isOptionEqualToValue: (option, value2) => option.id === value2.id,
90
- options: loading ? [] : elementsFound,
91
- loading,
63
+ options: isLoading ? [] : elementsFound,
64
+ loading: isLoading,
65
+ loadingText,
92
66
  autoHighlight: true,
93
67
  noOptionsText: intl.formatMessage({
94
68
  id: "element_search/noResult"
@@ -104,7 +78,7 @@ const ElementSearchDialog = (props) => {
104
78
  {
105
79
  autoFocus: true,
106
80
  ...params,
107
- label: searchingLabel || intl.formatMessage({
81
+ label: searchingLabel ?? intl.formatMessage({
108
82
  id: "element_search/label"
109
83
  }),
110
84
  InputProps: {
@@ -113,27 +87,16 @@ const ElementSearchDialog = (props) => {
113
87
  searchTermDisabled ? /* @__PURE__ */ jsx(SearchOff, { color: "disabled" }) : /* @__PURE__ */ jsx(Search, { color: "disabled" }),
114
88
  params.InputProps.startAdornment
115
89
  ] })
116
- }
90
+ },
91
+ value: displayedValue ?? ""
117
92
  }
118
93
  ),
119
- value,
120
94
  disabled: searchTermDisabled
121
95
  }
122
96
  ) })
123
97
  }
124
98
  );
125
99
  };
126
- ElementSearchDialog.propTypes = {
127
- open: PropTypes.bool.isRequired,
128
- onClose: PropTypes.func.isRequired,
129
- searchingLabel: PropTypes.string,
130
- onSearchTermChange: PropTypes.func.isRequired,
131
- onSelectionChange: PropTypes.func.isRequired,
132
- elementsFound: PropTypes.array.isRequired,
133
- renderElement: PropTypes.func.isRequired,
134
- searchTermDisabled: PropTypes.bool,
135
- searchTermDisableReason: PropTypes.string
136
- };
137
100
  export {
138
101
  ElementSearchDialog as default
139
102
  };
@@ -1,13 +1,14 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import "./element-search-dialog.js";
2
+ import "react";
3
+ import { Box } from "@mui/material";
4
+ import "@mui/icons-material";
5
+ import { FormattedMessage } from "react-intl";
3
6
  import { TagRenderer } from "./tag-renderer.js";
4
7
  import match from "autosuggest-highlight/match";
5
8
  import parse from "autosuggest-highlight/parse";
6
9
  import clsx from "clsx";
7
- import { FormattedMessage } from "react-intl";
8
10
  import { OverflowableText } from "../OverflowableText/overflowable-text.js";
9
11
  import { EQUIPMENT_TYPE } from "../../utils/EquipmentType.js";
10
- import { Box } from "@mui/material";
11
12
  import { mergeSx } from "../../utils/styles.js";
12
13
  const EquipmentItem = ({
13
14
  inputValue,
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useRef, useState, useCallback, useLayoutEffect } from "react";
2
+ import { useRef, useMemo, useState, useCallback, useLayoutEffect } from "react";
3
3
  import { Tooltip, Box } from "@mui/material";
4
4
  import PropTypes from "prop-types";
5
5
  import { styled } from "@mui/system";
@@ -16,26 +16,56 @@ const overflowStyle = {
16
16
  maxWidth: "fit-content"
17
17
  }
18
18
  };
19
+ const multilineOverflowStyle = (numberOfLinesToDisplay) => ({
20
+ overflow: "hidden",
21
+ display: "-webkit-box",
22
+ WebkitLineClamp: numberOfLinesToDisplay,
23
+ lineClamp: numberOfLinesToDisplay,
24
+ WebkitBoxOrient: "vertical",
25
+ wordWrap: "break-word"
26
+ // prevent bug when writing a very long word
27
+ });
19
28
  const OverflowableText = styled(
20
- ({ text, tooltipStyle, tooltipSx, className, children, ...props }) => {
21
- var _a, _b;
29
+ ({
30
+ text,
31
+ maxLineCount,
32
+ // overflowable text can be displayed on several lines if this is set to a number > 1
33
+ tooltipStyle,
34
+ tooltipSx,
35
+ className,
36
+ children,
37
+ ...props
38
+ }) => {
39
+ var _a, _b, _c, _d;
22
40
  const element = useRef();
41
+ const isMultiLine = useMemo(
42
+ () => maxLineCount && maxLineCount > 1,
43
+ [maxLineCount]
44
+ );
23
45
  const [overflowed, setOverflowed] = useState(false);
24
46
  const checkOverflow = useCallback(() => {
25
47
  if (!element.current) {
26
48
  return;
27
49
  }
28
- setOverflowed(
29
- element.current.scrollWidth > element.current.clientWidth
30
- );
31
- }, [setOverflowed, element]);
50
+ if (isMultiLine) {
51
+ setOverflowed(
52
+ element.current.scrollHeight > element.current.clientHeight
53
+ );
54
+ } else {
55
+ setOverflowed(
56
+ element.current.scrollWidth > element.current.clientWidth
57
+ );
58
+ }
59
+ }, [isMultiLine, setOverflowed, element]);
32
60
  useLayoutEffect(() => {
33
61
  checkOverflow();
34
62
  }, [
35
63
  checkOverflow,
36
64
  text,
37
65
  (_a = element.current) == null ? void 0 : _a.scrollWidth,
38
- (_b = element.current) == null ? void 0 : _b.clientWidth
66
+ (_b = element.current) == null ? void 0 : _b.clientWidth,
67
+ (_c = element.current) == null ? void 0 : _c.scrollHeight,
68
+ (_d = element.current) == null ? void 0 : _d.clientHeight
39
69
  ]);
40
70
  const defaultTooltipSx = !tooltipStyle ? overflowStyle.tooltip : false;
41
71
  const finalTooltipSx = tooltipSx || defaultTooltipSx;
@@ -58,7 +88,7 @@ const OverflowableText = styled(
58
88
  ref: element,
59
89
  children: children || text,
60
90
  className,
61
- sx: overflowStyle.overflow
91
+ sx: isMultiLine ? multilineOverflowStyle(maxLineCount) : overflowStyle.overflow
62
92
  }
63
93
  )
64
94
  }
@@ -6,7 +6,7 @@ import { styled } from "@mui/system";
6
6
  import { Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Typography } from "@mui/material";
7
7
  import { TreeView, TreeItem } from "@mui/x-tree-view";
8
8
  import { ChevronRight, ExpandMore, Check } from "@mui/icons-material";
9
- import CancelButton from "../react-hook-form/utils/cancel-button.js";
9
+ import CancelButton from "../inputs/react-hook-form/utils/cancel-button.js";
10
10
  const cssDialogPaper = "dialogPaper";
11
11
  const cssLabelRoot = "labelRoot";
12
12
  const cssLabelText = "labelText";
@@ -1 +1,8 @@
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
+ */
1
7
  export { default, generateTreeViewFinderClass } from './TreeViewFinder';
8
+ export type { TreeViewFinderProps, TreeViewFinderNodeProps, } from './TreeViewFinder';
@@ -1,4 +1,4 @@
1
- import { MergedFormContextProps } from '../react-hook-form/provider/custom-form-provider';
1
+ import { MergedFormContextProps } from '../inputs/react-hook-form/provider/custom-form-provider';
2
2
  import { FieldErrors, UseFormReturn } from 'react-hook-form';
3
3
  import { default as React, FunctionComponent } from 'react';
4
4
 
@@ -16,6 +16,7 @@ interface ICustomMuiDialog {
16
16
  onCancel?: () => void;
17
17
  children: React.ReactNode;
18
18
  isDataFetching?: boolean;
19
+ language?: string;
19
20
  }
20
21
  declare const CustomMuiDialog: FunctionComponent<ICustomMuiDialog>;
21
22
  export default CustomMuiDialog;
@@ -1,9 +1,9 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { FormattedMessage } from "react-intl";
3
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";
4
+ import SubmitButton from "../inputs/react-hook-form/utils/submit-button.js";
5
+ import CancelButton from "../inputs/react-hook-form/utils/cancel-button.js";
6
+ import CustomFormProvider from "../inputs/react-hook-form/provider/custom-form-provider.js";
7
7
  const styles = {
8
8
  dialogPaper: {
9
9
  ".MuiDialog-paper": {
@@ -25,7 +25,8 @@ const CustomMuiDialog = ({
25
25
  disabledSave,
26
26
  removeOptional = false,
27
27
  onCancel,
28
- children
28
+ children,
29
+ language
29
30
  }) => {
30
31
  const { handleSubmit } = formMethods;
31
32
  const handleCancel = (event) => {
@@ -51,6 +52,7 @@ const CustomMuiDialog = ({
51
52
  ...formMethods,
52
53
  validationSchema: formSchema,
53
54
  removeOptional,
55
+ language,
54
56
  children: /* @__PURE__ */ jsxs(
55
57
  Dialog,
56
58
  {
@@ -1,12 +1,12 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useCallback } from "react";
3
3
  import "../../utils/yup-config.js";
4
- import { FieldConstants } from "../filter/constants/field-constants.js";
4
+ import { FieldConstants } from "../../utils/field-constants.js";
5
5
  import { useForm } from "react-hook-form";
6
6
  import { yupResolver } from "@hookform/resolvers/yup";
7
7
  import { useSnackMessage } from "../../hooks/useSnackMessage.js";
8
8
  import CustomMuiDialog from "./custom-mui-dialog.js";
9
- import ExpandingTextField from "../react-hook-form/ExpandingTextField.js";
9
+ import ExpandingTextField from "../inputs/react-hook-form/ExpandingTextField.js";
10
10
  import { Box } from "@mui/material";
11
11
  import * as yup from "yup";
12
12
  const schema = yup.object().shape({
@@ -0,0 +1,14 @@
1
+ import { ElementType } from '../../utils/ElementType.ts';
2
+ import { UUID } from 'crypto';
3
+ import { default as React } from 'react';
4
+
5
+ export interface ModifyElementSelectionProps {
6
+ elementType: ElementType;
7
+ dialogOpeningButtonLabel: string;
8
+ dialogTitleLabel: string;
9
+ dialogMessageLabel: string;
10
+ noElementMessageLabel?: string;
11
+ onElementValidated?: (elementId: UUID) => void;
12
+ }
13
+ declare const ModifyElementSelection: React.FunctionComponent<ModifyElementSelectionProps>;
14
+ export default ModifyElementSelection;
@@ -0,0 +1,108 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useState, useContext, useEffect } from "react";
3
+ import { Grid, Button, Typography } from "@mui/material";
4
+ import { useIntl, FormattedMessage } from "react-intl";
5
+ import { useController } from "react-hook-form";
6
+ import { FilterContext } from "../filter/filter-context.js";
7
+ import { FieldConstants } from "../../utils/field-constants.js";
8
+ import DirectoryItemSelector from "../DirectoryItemSelector/directory-item-selector.js";
9
+ import { ElementType } from "../../utils/ElementType.js";
10
+ const ModifyElementSelection = (props) => {
11
+ const intl = useIntl();
12
+ const [open, setOpen] = useState(false);
13
+ const [activeDirectoryName, setActiveDirectoryName] = useState("");
14
+ const {
15
+ fetchDirectoryContent,
16
+ fetchRootFolders,
17
+ fetchElementsInfos,
18
+ fetchPath
19
+ } = useContext(FilterContext);
20
+ const {
21
+ field: { onChange, value: directory }
22
+ } = useController({
23
+ name: FieldConstants.DIRECTORY
24
+ });
25
+ useEffect(() => {
26
+ if (directory) {
27
+ fetchPath && fetchPath(directory).then((res) => {
28
+ setActiveDirectoryName(
29
+ res.map((element) => element.elementName.trim()).reverse().join("/")
30
+ );
31
+ });
32
+ }
33
+ }, [directory, fetchPath]);
34
+ const handleSelectFolder = () => {
35
+ setOpen(true);
36
+ };
37
+ const handleClose = (nodes) => {
38
+ if (nodes.length) {
39
+ onChange(nodes[0].id);
40
+ if (props.onElementValidated) {
41
+ props.onElementValidated(nodes[0].id);
42
+ }
43
+ }
44
+ setOpen(false);
45
+ };
46
+ return /* @__PURE__ */ jsxs(
47
+ Grid,
48
+ {
49
+ sx: {
50
+ marginTop: "10px",
51
+ display: "flex",
52
+ alignItems: "center"
53
+ },
54
+ children: [
55
+ /* @__PURE__ */ jsx(
56
+ Button,
57
+ {
58
+ onClick: handleSelectFolder,
59
+ variant: "contained",
60
+ sx: {
61
+ padding: "10px 30px"
62
+ },
63
+ color: "primary",
64
+ component: "label",
65
+ children: /* @__PURE__ */ jsx(FormattedMessage, { id: props.dialogOpeningButtonLabel })
66
+ }
67
+ ),
68
+ /* @__PURE__ */ jsx(
69
+ Typography,
70
+ {
71
+ sx: {
72
+ marginLeft: "10px",
73
+ fontWeight: "bold"
74
+ },
75
+ children: activeDirectoryName ? activeDirectoryName : (props == null ? void 0 : props.noElementMessageLabel) ? intl.formatMessage({
76
+ id: props.noElementMessageLabel
77
+ }) : ""
78
+ }
79
+ ),
80
+ /* @__PURE__ */ jsx(
81
+ DirectoryItemSelector,
82
+ {
83
+ open,
84
+ onClose: handleClose,
85
+ types: [props.elementType],
86
+ onlyLeaves: props.elementType !== ElementType.DIRECTORY,
87
+ multiSelect: false,
88
+ validationButtonText: intl.formatMessage({
89
+ id: "confirmDirectoryDialog"
90
+ }),
91
+ title: intl.formatMessage({
92
+ id: props.dialogTitleLabel
93
+ }),
94
+ contentText: intl.formatMessage({
95
+ id: props.dialogMessageLabel
96
+ }),
97
+ fetchDirectoryContent,
98
+ fetchRootFolders,
99
+ fetchElementsInfos
100
+ }
101
+ )
102
+ ]
103
+ }
104
+ );
105
+ };
106
+ export {
107
+ ModifyElementSelection as default
108
+ };
@@ -6,7 +6,7 @@ import { DialogContentText } from "@mui/material";
6
6
  import DialogActions from "@mui/material/DialogActions";
7
7
  import Button from "@mui/material/Button";
8
8
  import { FormattedMessage } from "react-intl";
9
- import CancelButton from "../react-hook-form/utils/cancel-button.js";
9
+ import CancelButton from "../inputs/react-hook-form/utils/cancel-button.js";
10
10
  const PopupConfirmationDialog = ({
11
11
  message,
12
12
  validateButtonLabel,
@@ -18,12 +18,11 @@ interface CriteriaBasedFilterEditionDialogProps {
18
18
  onClose: () => void;
19
19
  broadcastChannel: BroadcastChannel;
20
20
  getFilterById: (id: string) => Promise<any>;
21
- saveFilter: (value: any, t: Record<string, any>) => Promise<void>;
22
21
  selectionForCopy: SelectionCopy;
23
22
  setSelelectionForCopy: (selection: SelectionCopy) => Dispatch<SetStateAction<SelectionCopy>>;
24
23
  activeDirectory?: UUID;
25
24
  elementExists?: elementExistsType;
26
25
  language?: string;
27
26
  }
28
- export declare const CriteriaBasedFilterEditionDialog: FunctionComponent<CriteriaBasedFilterEditionDialogProps>;
27
+ declare const CriteriaBasedFilterEditionDialog: FunctionComponent<CriteriaBasedFilterEditionDialogProps>;
29
28
  export default CriteriaBasedFilterEditionDialog;
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import "../constants/field-constants.js";
3
+ import "../../../utils/field-constants.js";
4
4
  import "./criteria-based-filter-utils.js";
5
5
  import "../../dialogs/custom-mui-dialog.js";
6
6
  import "../../../hooks/useSnackMessage.js";
@@ -8,12 +8,12 @@ import "react-hook-form";
8
8
  import "@hookform/resolvers/yup";
9
9
  import "./criteria-based-filter-form.js";
10
10
  import "../../../utils/yup-config.js";
11
- import { b, b as b2, p } from "../../../chunks/criteria-based-filter-edition-dialog.BEXoNmzz.js";
11
+ import { b, p } from "../../../chunks/criteria-based-filter-edition-dialog.CbhgOSRk.js";
12
12
  import "../constants/filter-constants.js";
13
13
  import "../../../utils/FetchStatus.js";
14
+ import "../../../services/explore.js";
14
15
  import "yup";
15
16
  export {
16
- b as CriteriaBasedFilterEditionDialog,
17
- b2 as default,
17
+ b as default,
18
18
  p as noSelectionForCopy
19
19
  };
@@ -1,10 +1,11 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { f as filterPropertiesYupSchema, F as FreePropertiesTypes, a as FilterProperties } from "../../../chunks/filter-properties.GRon8-ML.js";
3
- import { FieldConstants } from "../constants/field-constants.js";
2
+ import { f as filterPropertiesYupSchema, F as FreePropertiesTypes, a as FilterProperties } from "../../../chunks/filter-properties.B7-q_yPf.js";
3
+ import { FieldConstants } from "../../../utils/field-constants.js";
4
4
  import "../../../utils/yup-config.js";
5
5
  import CriteriaBasedForm from "./criteria-based-form.js";
6
6
  import Grid from "@mui/material/Grid";
7
- import { getCriteriaBasedSchema, getCriteriaBasedFormData } from "../utils/criteria-based-utils.js";
7
+ import { getCriteriaBasedSchema, getCriteriaBasedFormData } from "./criteria-based-filter-utils.js";
8
+ import { FILTER_EQUIPMENTS } from "../utils/filter-form-utils.js";
8
9
  import * as yup from "yup";
9
10
  const criteriaBasedFilterSchema = getCriteriaBasedSchema({
10
11
  [FieldConstants.ENERGY_SOURCE]: yup.string().nullable(),
@@ -20,6 +21,7 @@ const CriteriaBasedFilterForm = () => {
20
21
  /* @__PURE__ */ jsx(
21
22
  CriteriaBasedForm,
22
23
  {
24
+ equipments: FILTER_EQUIPMENTS,
23
25
  defaultValues: criteriaBasedFilterEmptyFormData[FieldConstants.CRITERIA_BASED]
24
26
  }
25
27
  ),
@@ -1,9 +1,15 @@
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
- */
1
+ import { default as yup } from '../../../utils/yup-config';
2
+
3
+ export declare const getCriteriaBasedSchema: (extraFields: any) => {
4
+ criteriaBased: yup.ObjectSchema<{
5
+ [x: string]: any;
6
+ }, yup.AnyObject, {
7
+ [x: string]: any;
8
+ }, "">;
9
+ };
10
+ export declare const getCriteriaBasedFormData: (criteriaValues: any, extraFields: any) => {
11
+ criteriaBased: any;
12
+ };
7
13
  /**
8
14
  * Transform
9
15
  * from obj.equipmentFilterForm.{
@@ -1,8 +1,46 @@
1
- import { FieldConstants } from "../constants/field-constants.js";
2
- import { F as FreePropertiesTypes } from "../../../chunks/filter-properties.GRon8-ML.js";
1
+ import { FieldConstants } from "../../../utils/field-constants.js";
2
+ import { F as FreePropertiesTypes } from "../../../chunks/filter-properties.B7-q_yPf.js";
3
3
  import { PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2, PROPERTY_NAME } from "./filter-property.js";
4
- import { getCriteriaBasedFormData } from "../utils/criteria-based-utils.js";
5
4
  import { FilterType } from "../constants/filter-constants.js";
5
+ import "../../../utils/yup-config.js";
6
+ import { getRangeInputSchema, getRangeInputDataForm, DEFAULT_RANGE_VALUE } from "../../inputs/react-hook-form/range-input.js";
7
+ import * as yup from "yup";
8
+ const getCriteriaBasedSchema = (extraFields) => ({
9
+ [FieldConstants.CRITERIA_BASED]: yup.object().shape({
10
+ [FieldConstants.COUNTRIES]: yup.array().of(yup.string()),
11
+ [FieldConstants.COUNTRIES_1]: yup.array().of(yup.string()),
12
+ [FieldConstants.COUNTRIES_2]: yup.array().of(yup.string()),
13
+ ...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE),
14
+ ...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_1),
15
+ ...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_2),
16
+ ...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_3),
17
+ ...extraFields
18
+ })
19
+ });
20
+ const getCriteriaBasedFormData = (criteriaValues, extraFields) => ({
21
+ [FieldConstants.CRITERIA_BASED]: {
22
+ [FieldConstants.COUNTRIES]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES]) ?? [],
23
+ [FieldConstants.COUNTRIES_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_1]) ?? [],
24
+ [FieldConstants.COUNTRIES_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_2]) ?? [],
25
+ ...getRangeInputDataForm(
26
+ FieldConstants.NOMINAL_VOLTAGE,
27
+ (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE]) ?? DEFAULT_RANGE_VALUE
28
+ ),
29
+ ...getRangeInputDataForm(
30
+ FieldConstants.NOMINAL_VOLTAGE_1,
31
+ (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_1]) ?? DEFAULT_RANGE_VALUE
32
+ ),
33
+ ...getRangeInputDataForm(
34
+ FieldConstants.NOMINAL_VOLTAGE_2,
35
+ (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_2]) ?? DEFAULT_RANGE_VALUE
36
+ ),
37
+ ...getRangeInputDataForm(
38
+ FieldConstants.NOMINAL_VOLTAGE_3,
39
+ (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_3]) ?? DEFAULT_RANGE_VALUE
40
+ ),
41
+ ...extraFields
42
+ }
43
+ });
6
44
  const backToFrontTweak = (response) => {
7
45
  const subProps = response.equipmentFilterForm.substationFreeProperties;
8
46
  const freeProps = response.equipmentFilterForm.freeProperties;
@@ -123,5 +161,7 @@ function isNominalVoltageEmpty(nominalVoltage) {
123
161
  }
124
162
  export {
125
163
  backToFrontTweak,
126
- frontToBackTweak
164
+ frontToBackTweak,
165
+ getCriteriaBasedFormData,
166
+ getCriteriaBasedSchema
127
167
  };
@@ -1,6 +1,8 @@
1
+ import { FormEquipment } from '../utils/filter-form-utils';
1
2
  import { FunctionComponent } from 'react';
2
3
 
3
4
  export interface CriteriaBasedFormProps {
5
+ equipments: Record<string, FormEquipment>;
4
6
  defaultValues: Record<string, any>;
5
7
  }
6
8
  declare const CriteriaBasedForm: FunctionComponent<CriteriaBasedFormProps>;
@@ -1,11 +1,11 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { FieldConstants } from "../constants/field-constants.js";
2
+ import { FieldConstants } from "../../../utils/field-constants.js";
3
3
  import { useFormContext, useWatch } from "react-hook-form";
4
4
  import { Grid } from "@mui/material";
5
- import SelectInput from "../../react-hook-form/select-inputs/select-input.js";
6
- import InputWithPopupConfirmation from "../../react-hook-form/select-inputs/input-with-popup-confirmation.js";
7
- import { FILTER_EQUIPMENTS } from "../utils/criteria-based-utils.js";
5
+ import SelectInput from "../../inputs/react-hook-form/select-inputs/select-input.js";
6
+ import InputWithPopupConfirmation from "../../inputs/react-hook-form/select-inputs/input-with-popup-confirmation.js";
8
7
  const CriteriaBasedForm = ({
8
+ equipments,
9
9
  defaultValues
10
10
  }) => {
11
11
  const { getValues, setValue } = useFormContext();
@@ -29,7 +29,7 @@ const CriteriaBasedForm = ({
29
29
  {
30
30
  Input: SelectInput,
31
31
  name: FieldConstants.EQUIPMENT_TYPE,
32
- options: Object.values(FILTER_EQUIPMENTS),
32
+ options: Object.values(equipments),
33
33
  label: "equipmentType",
34
34
  shouldOpenPopup: openConfirmationPopup,
35
35
  resetOnConfirmation: handleResetOnConfirmation,
@@ -37,7 +37,7 @@ const CriteriaBasedForm = ({
37
37
  validateButtonLabel: "button.changeType"
38
38
  }
39
39
  ) }),
40
- watchEquipmentType && FILTER_EQUIPMENTS[watchEquipmentType].fields.map(
40
+ watchEquipmentType && equipments[watchEquipmentType].fields.map(
41
41
  (equipment, index) => {
42
42
  const EquipmentForm = equipment.renderer;
43
43
  return /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, flexGrow: 1, children: /* @__PURE__ */ jsx(EquipmentForm, { ...equipment.props }) }, index);