@gridsuite/commons-ui 0.35.5 → 0.36.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.
@@ -21,32 +21,51 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
21
21
  elementsFound = props.elementsFound,
22
22
  renderElement = props.renderElement,
23
23
  searchTermDisabled = props.searchTermDisabled,
24
- initialSearchTerm = props.initialSearchTerm;
24
+ searchTermDisableReason = props.searchTermDisableReason;
25
25
  var _useState = useState(false),
26
26
  expanded = _useState[0],
27
27
  setExpanded = _useState[1];
28
- var _useState2 = useState(false),
29
- loading = _useState2[0],
30
- setLoading = _useState2[1];
28
+ var _useState2 = useState(searchTermDisabled && searchTermDisableReason ? {
29
+ label: searchTermDisableReason
30
+ } : null),
31
+ value = _useState2[0],
32
+ setValue = _useState2[1];
33
+ var _useState3 = useState(false),
34
+ loading = _useState3[0],
35
+ setLoading = _useState3[1];
31
36
  useEffect(function () {
32
37
  setLoading(false);
33
38
  }, [elementsFound]);
39
+ useEffect(function () {
40
+ if (!searchTermDisabled || !searchTermDisableReason) {
41
+ setValue(null);
42
+ } else {
43
+ setValue({
44
+ label: searchTermDisableReason
45
+ });
46
+ }
47
+ }, [searchTermDisabled, searchTermDisableReason]);
34
48
  var handleSearchTermChange = function handleSearchTermChange(term) {
35
49
  if (term) {
36
50
  setLoading(true);
37
51
  onSearchTermChange(term);
38
52
  setExpanded(true);
53
+ setValue({
54
+ label: term
55
+ });
39
56
  } else {
40
57
  setExpanded(false);
58
+ setValue(null);
41
59
  }
42
60
  };
43
61
  var handleClose = useCallback(function () {
62
+ setValue(null);
44
63
  setExpanded(false);
45
64
  onClose();
46
65
  }, [onClose]);
47
66
  return /*#__PURE__*/React.createElement(Dialog, {
48
67
  open: open,
49
- onClose: onClose,
68
+ onClose: handleClose,
50
69
  disableRestoreFocus: true,
51
70
  "aria-labelledby": "dialog-title-search",
52
71
  fullWidth: true
@@ -58,13 +77,15 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
58
77
  setExpanded(false);
59
78
  },
60
79
  fullWidth: true,
80
+ freeSolo: true,
61
81
  onInputChange: function onInputChange(_event, value) {
62
82
  if (!searchTermDisabled) {
63
83
  handleSearchTermChange(value);
64
84
  }
65
85
  },
66
86
  onChange: function onChange(_event, newValue) {
67
- return onSelectionChange(newValue);
87
+ onSelectionChange(newValue);
88
+ setValue(null);
68
89
  },
69
90
  getOptionLabel: function getOptionLabel(option) {
70
91
  return option.label;
@@ -100,9 +121,7 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
100
121
  })
101
122
  }));
102
123
  },
103
- defaultValue: searchTermDisabled ? {
104
- label: initialSearchTerm
105
- } : null,
124
+ value: value,
106
125
  disabled: searchTermDisabled
107
126
  })));
108
127
  };
@@ -115,6 +134,6 @@ ElementSearchDialog.propTypes = process.env.NODE_ENV !== "production" ? {
115
134
  elementsFound: PropTypes.array.isRequired,
116
135
  renderElement: PropTypes.func.isRequired,
117
136
  searchTermDisabled: PropTypes.bool,
118
- initialSearchTerm: PropTypes.string
137
+ searchTermDisableReason: PropTypes.string
119
138
  } : {};
120
139
  export default ElementSearchDialog;
@@ -75,7 +75,7 @@ OverflowableText.propTypes = process.env.NODE_ENV !== "production" ? {
75
75
  text: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),
76
76
  tooltipStyle: PropTypes.string,
77
77
  tooltipSx: PropTypes.object,
78
- sx: PropTypes.object,
78
+ sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.func]),
79
79
  className: PropTypes.string
80
80
  } : {};
81
81
  export default OverflowableText;
@@ -183,7 +183,7 @@ var TopBar = function TopBar(_ref2) {
183
183
  onLanguageClick = _ref2.onLanguageClick,
184
184
  language = _ref2.language,
185
185
  searchTermDisabled = _ref2.searchTermDisabled,
186
- initialSearchTerm = _ref2.initialSearchTerm;
186
+ searchTermDisableReason = _ref2.searchTermDisableReason;
187
187
  var _React$useState = React.useState(null),
188
188
  anchorElSettingsMenu = _React$useState[0],
189
189
  setAnchorElSettingsMenu = _React$useState[1];
@@ -260,7 +260,7 @@ var TopBar = function TopBar(_ref2) {
260
260
  useEffect(function () {
261
261
  if (user && withElementsSearch && !searchDisabled) {
262
262
  var openSearch = function openSearch(e) {
263
- if (e.ctrlKey && e.key === 'F') {
263
+ if (e.ctrlKey && e.shiftKey && (e.key === 'F' || e.key === 'f')) {
264
264
  e.preventDefault();
265
265
  setDialogSearchOpen(true);
266
266
  }
@@ -312,7 +312,7 @@ var TopBar = function TopBar(_ref2) {
312
312
  elementsFound: elementsFound,
313
313
  renderElement: renderElement,
314
314
  searchTermDisabled: searchTermDisabled,
315
- initialSearchTerm: initialSearchTerm
315
+ searchTermDisableReason: searchTermDisableReason
316
316
  }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
317
317
  color: "inherit",
318
318
  onClick: handleClickElementSearch,
@@ -560,6 +560,6 @@ TopBar.propTypes = process.env.NODE_ENV !== "production" ? {
560
560
  onLanguageClick: PropTypes.func.isRequired,
561
561
  language: PropTypes.string.isRequired,
562
562
  searchTermDisabled: PropTypes.bool,
563
- initialSearchTerm: PropTypes.string
563
+ searchTermDisableReason: PropTypes.string
564
564
  } : {};
565
565
  export default TopBar;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.35.5",
3
+ "version": "0.36.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
- "npm": "<=6",
7
- "node": ">=12 <=14"
6
+ "npm": ">=9",
7
+ "node": ">=18"
8
8
  },
9
9
  "exports": "es/index.js",
10
10
  "module": "es/index.js",
@@ -41,7 +41,7 @@
41
41
  "@mui/lab": "^5.0.0-alpha.72",
42
42
  "@mui/material": "^5.5.0",
43
43
  "@hookform/resolvers": "^3.0.0",
44
- "notistack": "^2.0.3",
44
+ "notistack": "^3.0.0",
45
45
  "react-router-dom": "^6.0.0",
46
46
  "react": "^18.0.0",
47
47
  "react-dom": "^18.0.0",
@@ -71,7 +71,7 @@
71
71
  "eslint-plugin-prettier": "^4.0.0",
72
72
  "eslint-plugin-react": "^7.21.0",
73
73
  "eslint-plugin-react-hooks": "^4.1.2",
74
- "notistack": "^2.0.3",
74
+ "notistack": "^3.0.0",
75
75
  "nwb": "^0.25.x",
76
76
  "prettier": "^2.0.0",
77
77
  "puppeteer": "^17.0.0",