@gridsuite/commons-ui 0.35.0 → 0.35.2

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 (116) hide show
  1. package/README.md +2 -2
  2. package/es/components/AuthenticationRouter/AuthenticationRouter.js +102 -0
  3. package/es/components/AuthenticationRouter/index.js +7 -0
  4. package/{lib → es}/components/CardErrorBoundary/card-error-boundary.js +35 -42
  5. package/es/components/CardErrorBoundary/index.js +7 -0
  6. package/es/components/ElementSearchDialog/element-search-dialog.js +120 -0
  7. package/{lib → es}/components/ElementSearchDialog/equipment-item.js +26 -32
  8. package/es/components/ElementSearchDialog/index.js +8 -0
  9. package/es/components/ElementSearchDialog/tag-renderer.js +29 -0
  10. package/{lib → es}/components/FlatParameters/FlatParameters.js +42 -49
  11. package/es/components/FlatParameters/index.js +8 -0
  12. package/es/components/Login/Login.js +79 -0
  13. package/es/components/Login/Logout.js +78 -0
  14. package/es/components/Login/index.js +7 -0
  15. package/es/components/MuiVirtualizedTable/ColumnHeader.js +125 -0
  16. package/{lib → es}/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +18 -25
  17. package/{lib → es}/components/MuiVirtualizedTable/MuiVirtualizedTable.js +88 -99
  18. package/es/components/MuiVirtualizedTable/index.js +9 -0
  19. package/es/components/OverflowableText/index.js +7 -0
  20. package/{lib → es}/components/OverflowableText/overflowable-text.js +22 -30
  21. package/es/components/ReportViewer/index.js +7 -0
  22. package/{lib → es}/components/ReportViewer/log-report-item.js +1 -6
  23. package/{lib → es}/components/ReportViewer/log-report.js +8 -13
  24. package/{lib → es}/components/ReportViewer/log-table.js +14 -24
  25. package/{lib → es}/components/ReportViewer/report-item.js +23 -30
  26. package/{lib → es}/components/ReportViewer/report-tree-view-context.js +3 -9
  27. package/{lib → es}/components/ReportViewer/report-viewer.js +32 -40
  28. package/es/components/ReportViewerDialog/index.js +7 -0
  29. package/es/components/ReportViewerDialog/report-viewer-dialog.js +67 -0
  30. package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +19 -0
  31. package/es/components/SignInCallbackHandler/index.js +7 -0
  32. package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +19 -0
  33. package/es/components/SilentRenewCallbackHandler/index.js +7 -0
  34. package/es/components/SnackbarProvider/SnackbarProvider.js +39 -0
  35. package/es/components/SnackbarProvider/index.js +7 -0
  36. package/es/components/TopBar/TopBar.js +565 -0
  37. package/es/components/TopBar/index.js +7 -0
  38. package/{lib → es}/components/TreeViewFinder/TreeViewFinder.js +59 -66
  39. package/es/components/TreeViewFinder/index.js +7 -0
  40. package/es/components/react-hook-form/autocomplete-input.js +110 -0
  41. package/es/components/react-hook-form/booleans/boolean-input.js +56 -0
  42. package/es/components/react-hook-form/booleans/checkbox-input.js +28 -0
  43. package/es/components/react-hook-form/booleans/switch-input.js +28 -0
  44. package/es/components/react-hook-form/error-management/error-input.js +50 -0
  45. package/es/components/react-hook-form/error-management/field-error-alert.js +22 -0
  46. package/es/components/react-hook-form/error-management/mid-form-error.js +25 -0
  47. package/es/components/react-hook-form/numbers/float-input.js +40 -0
  48. package/es/components/react-hook-form/numbers/integer-input.js +35 -0
  49. package/es/components/react-hook-form/numbers/utils.js +6 -0
  50. package/es/components/react-hook-form/radio-input.js +55 -0
  51. package/es/components/react-hook-form/select-input.js +40 -0
  52. package/es/components/react-hook-form/slider-input.js +48 -0
  53. package/es/components/react-hook-form/text-input.js +100 -0
  54. package/es/components/react-hook-form/utils/field-label.js +15 -0
  55. package/es/components/react-hook-form/utils/functions.js +42 -0
  56. package/es/components/react-hook-form/utils/submit-button.js +25 -0
  57. package/es/components/react-hook-form/utils/text-field-with-adornment.js +92 -0
  58. package/{lib → es}/components/translations/card-error-boundary-en.js +1 -7
  59. package/{lib → es}/components/translations/card-error-boundary-fr.js +1 -7
  60. package/{lib → es}/components/translations/element-search-en.js +1 -7
  61. package/{lib → es}/components/translations/element-search-fr.js +1 -7
  62. package/{lib → es}/components/translations/equipment-search-en.js +1 -7
  63. package/{lib → es}/components/translations/equipment-search-fr.js +1 -7
  64. package/es/components/translations/inputs-en.js +25 -0
  65. package/es/components/translations/inputs-fr.js +25 -0
  66. package/{lib → es}/components/translations/login-en.js +1 -7
  67. package/{lib → es}/components/translations/login-fr.js +1 -7
  68. package/{lib → es}/components/translations/report-viewer-en.js +1 -7
  69. package/{lib → es}/components/translations/report-viewer-fr.js +1 -7
  70. package/{lib → es}/components/translations/table-en.js +1 -7
  71. package/{lib → es}/components/translations/table-fr.js +1 -7
  72. package/{lib → es}/components/translations/top-bar-en.js +1 -7
  73. package/{lib → es}/components/translations/top-bar-fr.js +1 -7
  74. package/{lib → es}/components/translations/treeview-finder-en.js +1 -7
  75. package/{lib → es}/components/translations/treeview-finder-fr.js +1 -7
  76. package/{lib → es}/hooks/useDebounce.js +7 -12
  77. package/{lib → es}/hooks/useIntlRef.js +7 -10
  78. package/{lib → es}/hooks/useSnackMessage.js +9 -13
  79. package/es/index.js +62 -0
  80. package/{lib → es}/utils/AuthService.js +23 -34
  81. package/es/utils/ElementType.js +37 -0
  82. package/{lib → es}/utils/EquipmentType.js +8 -18
  83. package/{lib → es}/utils/UserManagerMock.js +2 -7
  84. package/es/utils/actions.js +65 -0
  85. package/{lib → es}/utils/algos.js +1 -5
  86. package/{lib → es}/utils/styles.js +4 -11
  87. package/package.json +10 -4
  88. package/lib/components/AuthenticationRouter/AuthenticationRouter.js +0 -111
  89. package/lib/components/AuthenticationRouter/index.js +0 -8
  90. package/lib/components/CardErrorBoundary/index.js +0 -8
  91. package/lib/components/ElementSearchDialog/element-search-dialog.js +0 -127
  92. package/lib/components/ElementSearchDialog/index.js +0 -9
  93. package/lib/components/ElementSearchDialog/tag-renderer.js +0 -36
  94. package/lib/components/FlatParameters/index.js +0 -8
  95. package/lib/components/Login/Login.js +0 -86
  96. package/lib/components/Login/Logout.js +0 -85
  97. package/lib/components/Login/index.js +0 -8
  98. package/lib/components/MuiVirtualizedTable/ColumnHeader.js +0 -134
  99. package/lib/components/MuiVirtualizedTable/index.js +0 -12
  100. package/lib/components/OverflowableText/index.js +0 -8
  101. package/lib/components/ReportViewer/index.js +0 -8
  102. package/lib/components/ReportViewerDialog/index.js +0 -8
  103. package/lib/components/ReportViewerDialog/report-viewer-dialog.js +0 -75
  104. package/lib/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -27
  105. package/lib/components/SignInCallbackHandler/index.js +0 -8
  106. package/lib/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -27
  107. package/lib/components/SilentRenewCallbackHandler/index.js +0 -8
  108. package/lib/components/SnackbarProvider/SnackbarProvider.js +0 -45
  109. package/lib/components/SnackbarProvider/index.js +0 -8
  110. package/lib/components/TopBar/TopBar.js +0 -576
  111. package/lib/components/TopBar/index.js +0 -8
  112. package/lib/components/TreeViewFinder/index.js +0 -9
  113. package/lib/index.js +0 -105
  114. package/lib/utils/ElementType.js +0 -45
  115. package/lib/utils/actions.js +0 -83
  116. /package/{lib → es}/components/images/powsybl_logo.svg +0 -0
@@ -1,24 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.generateTreeViewFinderClass = exports["default"] = void 0;
5
- var _react = _interopRequireWildcard(require("react"));
6
- var _reactIntl = require("react-intl");
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
8
- var _styles = require("../../utils/styles");
9
- var _system = require("@mui/system");
10
- var _Dialog = _interopRequireDefault(require("@mui/material/Dialog"));
11
- var _DialogActions = _interopRequireDefault(require("@mui/material/DialogActions"));
12
- var _DialogContent = _interopRequireDefault(require("@mui/material/DialogContent"));
13
- var _DialogContentText = _interopRequireDefault(require("@mui/material/DialogContentText"));
14
- var _DialogTitle = _interopRequireDefault(require("@mui/material/DialogTitle"));
15
- var _Button = _interopRequireDefault(require("@mui/material/Button"));
16
- var _TreeItem = _interopRequireDefault(require("@mui/lab/TreeItem"));
17
- var _TreeView = _interopRequireDefault(require("@mui/lab/TreeView"));
18
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
19
- var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
20
- var _ChevronRight = _interopRequireDefault(require("@mui/icons-material/ChevronRight"));
21
- var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
22
1
  var _defaultStyles;
23
2
  /**
24
3
  * Copyright (c) 2021, RTE (http://www.rte-france.com)
@@ -26,9 +5,25 @@ var _defaultStyles;
26
5
  * License, v. 2.0. If a copy of the MPL was not distributed with this
27
6
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
28
7
  */
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
30
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
8
+
9
+ import React, { useState, useCallback, useEffect } from 'react';
10
+ import { FormattedMessage, useIntl } from 'react-intl';
11
+ import PropTypes from 'prop-types';
12
+ import { toNestedGlobalSelectors, makeComposeClasses } from '../../utils/styles';
13
+ import { styled } from '@mui/system';
14
+ import Dialog from '@mui/material/Dialog';
15
+ import DialogActions from '@mui/material/DialogActions';
16
+ import DialogContent from '@mui/material/DialogContent';
17
+ import DialogContentText from '@mui/material/DialogContentText';
18
+ import DialogTitle from '@mui/material/DialogTitle';
19
+ import Button from '@mui/material/Button';
20
+ import TreeItem from '@mui/lab/TreeItem';
21
+ import TreeView from '@mui/lab/TreeView';
22
+ import Typography from '@mui/material/Typography';
23
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
24
+ import ChevronRightIcon from '@mui/icons-material/ChevronRight';
25
+ import CheckIcon from '@mui/icons-material/Check';
26
+
32
27
  // As a bunch of individual variables to try to make it easier
33
28
  // to track that they are all used. Not sure, maybe group them in an object ?
34
29
  var cssDialogPaper = 'dialogPaper';
@@ -53,11 +48,10 @@ var defaultStyles = (_defaultStyles = {}, _defaultStyles[cssDialogPaper] = {
53
48
  alignItems: 'center',
54
49
  marginRight: '4px'
55
50
  }, _defaultStyles[cssIcon] = {}, _defaultStyles);
56
- var generateTreeViewFinderClass = function generateTreeViewFinderClass(className) {
51
+ export var generateTreeViewFinderClass = function generateTreeViewFinderClass(className) {
57
52
  return "GsiTreeViewFinder-" + className;
58
53
  };
59
- exports.generateTreeViewFinderClass = generateTreeViewFinderClass;
60
- var composeClasses = (0, _styles.makeComposeClasses)(generateTreeViewFinderClass);
54
+ var composeClasses = makeComposeClasses(generateTreeViewFinderClass);
61
55
 
62
56
  /**
63
57
  * This callback type is called `onTreeBrowseCallback` and is displayed as a global symbol.
@@ -92,7 +86,7 @@ var composeClasses = (0, _styles.makeComposeClasses)(generateTreeViewFinderClass
92
86
  * @param {Boolean} [multiselect=false] - Allow/Forbid multiselection on Tree
93
87
  */
94
88
  var TreeViewFinder = function TreeViewFinder(props) {
95
- var intl = (0, _reactIntl.useIntl)();
89
+ var intl = useIntl();
96
90
  var classes = props.classes,
97
91
  title = props.title,
98
92
  contentText = props.contentText,
@@ -107,16 +101,16 @@ var TreeViewFinder = function TreeViewFinder(props) {
107
101
  multiselect = props.multiselect,
108
102
  sortMethod = props.sortMethod,
109
103
  className = props.className;
110
- var _useState = (0, _react.useState)({}),
104
+ var _useState = useState({}),
111
105
  mapPrintedNodes = _useState[0],
112
106
  setMapPrintedNodes = _useState[1];
113
107
 
114
108
  // Controlled expanded for TreeView
115
- var _useState2 = (0, _react.useState)(defaultExpanded),
109
+ var _useState2 = useState(defaultExpanded),
116
110
  expanded = _useState2[0],
117
111
  setExpanded = _useState2[1];
118
112
  // Controlled selected for TreeView
119
- var _useState3 = (0, _react.useState)(defaultSelected),
113
+ var _useState3 = useState(defaultSelected),
120
114
  selected = _useState3[0],
121
115
  setSelected = _useState3[1];
122
116
 
@@ -128,7 +122,7 @@ var TreeViewFinder = function TreeViewFinder(props) {
128
122
  var isLeaf = function isLeaf(node) {
129
123
  return node && node.children === undefined;
130
124
  };
131
- var computeMapPrintedNodes = (0, _react.useCallback)(function (nodes) {
125
+ var computeMapPrintedNodes = useCallback(function (nodes) {
132
126
  var newMapPrintedNodes = {};
133
127
  nodes.forEach(function (node) {
134
128
  newMapPrintedNodes[node.id] = node;
@@ -140,7 +134,7 @@ var TreeViewFinder = function TreeViewFinder(props) {
140
134
  }, []);
141
135
 
142
136
  // Effects
143
- (0, _react.useEffect)(function () {
137
+ useEffect(function () {
144
138
  // compute all mapPrintedNodes here from data prop
145
139
  // if data changes in current expanded nodes
146
140
  var newMapPrintedNodes = computeMapPrintedNodes(data);
@@ -203,12 +197,12 @@ var TreeViewFinder = function TreeViewFinder(props) {
203
197
  if (isSelectable(node) && selected.find(function (nodeId) {
204
198
  return nodeId === node.id;
205
199
  })) {
206
- return /*#__PURE__*/_react["default"].createElement(_Check["default"], {
200
+ return /*#__PURE__*/React.createElement(CheckIcon, {
207
201
  className: composeClasses(classes, cssLabelIcon)
208
202
  });
209
203
  } else {
210
204
  if (node.icon) {
211
- return /*#__PURE__*/_react["default"].createElement("div", {
205
+ return /*#__PURE__*/React.createElement("div", {
212
206
  className: composeClasses(classes, cssLabelIcon)
213
207
  }, node.icon);
214
208
  } else {
@@ -217,9 +211,9 @@ var TreeViewFinder = function TreeViewFinder(props) {
217
211
  }
218
212
  };
219
213
  var renderTreeItemLabel = function renderTreeItemLabel(node) {
220
- return /*#__PURE__*/_react["default"].createElement("div", {
214
+ return /*#__PURE__*/React.createElement("div", {
221
215
  className: composeClasses(classes, cssLabelRoot)
222
- }, getNodeIcon(node), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
216
+ }, getNodeIcon(node), /*#__PURE__*/React.createElement(Typography, {
223
217
  className: composeClasses(classes, cssLabelText)
224
218
  }, node.name));
225
219
  };
@@ -231,14 +225,14 @@ var TreeViewFinder = function TreeViewFinder(props) {
231
225
  if (!node) {
232
226
  return;
233
227
  }
234
- return /*#__PURE__*/_react["default"].createElement(_TreeItem["default"], {
228
+ return /*#__PURE__*/React.createElement(TreeItem, {
235
229
  key: node.id,
236
230
  nodeId: node.id,
237
231
  label: renderTreeItemLabel(node),
238
- expandIcon: showChevron(node) ? /*#__PURE__*/_react["default"].createElement(_ChevronRight["default"], {
232
+ expandIcon: showChevron(node) ? /*#__PURE__*/React.createElement(ChevronRightIcon, {
239
233
  className: composeClasses(classes, cssIcon)
240
234
  }) : null,
241
- collapseIcon: showChevron(node) ? /*#__PURE__*/_react["default"].createElement(_ExpandMore["default"], {
235
+ collapseIcon: showChevron(node) ? /*#__PURE__*/React.createElement(ExpandMoreIcon, {
242
236
  className: composeClasses(classes, cssIcon)
243
237
  }) : null
244
238
  }, Array.isArray(node.children) ? node.children.length ? node.children.sort(sortMethod).map(function (child) {
@@ -246,7 +240,7 @@ var TreeViewFinder = function TreeViewFinder(props) {
246
240
  }) : [false] // Pass non empty Array here to simulate a child then this node isn't considered as a leaf.
247
241
  : null);
248
242
  };
249
- return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
243
+ return /*#__PURE__*/React.createElement(Dialog, {
250
244
  open: open,
251
245
  onClose: function onClose(e, r) {
252
246
  if (r === 'escapeKeyDown' || r === 'backdropClick') {
@@ -259,17 +253,17 @@ var TreeViewFinder = function TreeViewFinder(props) {
259
253
  classes: {
260
254
  paper: composeClasses(classes, cssDialogPaper)
261
255
  }
262
- }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], {
256
+ }, /*#__PURE__*/React.createElement(DialogTitle, {
263
257
  id: "TreeViewFindertitle"
264
258
  }, title ? title : intl.formatMessage({
265
259
  id: 'treeview_finder/finderTitle'
266
260
  }, {
267
261
  multiselect: multiselect
268
- })), /*#__PURE__*/_react["default"].createElement(_DialogContent["default"], null, /*#__PURE__*/_react["default"].createElement(_DialogContentText["default"], null, contentText ? contentText : intl.formatMessage({
262
+ })), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(DialogContentText, null, contentText ? contentText : intl.formatMessage({
269
263
  id: 'treeview_finder/contentText'
270
264
  }, {
271
265
  multiselect: multiselect
272
- })), /*#__PURE__*/_react["default"].createElement(_TreeView["default"]
266
+ })), /*#__PURE__*/React.createElement(TreeView
273
267
  // Controlled props
274
268
  , {
275
269
  expanded: expanded,
@@ -283,7 +277,7 @@ var TreeViewFinder = function TreeViewFinder(props) {
283
277
  multiSelect: multiselect
284
278
  }, data && Array.isArray(data) ? data.sort(sortMethod).map(function (child) {
285
279
  return renderTree(child);
286
- }) : null)), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
280
+ }) : null)), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
287
281
  variant: "contained",
288
282
  style: {
289
283
  "float": 'left',
@@ -293,9 +287,9 @@ var TreeViewFinder = function TreeViewFinder(props) {
293
287
  _onClose([]);
294
288
  setSelected([]);
295
289
  }
296
- }, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
290
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
297
291
  id: "treeview_finder/cancel"
298
- })), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
292
+ })), /*#__PURE__*/React.createElement(Button, {
299
293
  variant: "contained",
300
294
  style: {
301
295
  "float": 'left',
@@ -312,24 +306,24 @@ var TreeViewFinder = function TreeViewFinder(props) {
312
306
  /* TreeViewFinder props list */
313
307
  TreeViewFinder.propTypes = process.env.NODE_ENV !== "production" ? {
314
308
  // Controlled
315
- open: _propTypes["default"].bool.isRequired,
316
- onClose: _propTypes["default"].func,
317
- data: _propTypes["default"].arrayOf(_propTypes["default"].shape({
318
- id: _propTypes["default"].string.isRequired,
319
- name: _propTypes["default"].string.isRequired,
320
- children: _propTypes["default"].array
309
+ open: PropTypes.bool.isRequired,
310
+ onClose: PropTypes.func,
311
+ data: PropTypes.arrayOf(PropTypes.shape({
312
+ id: PropTypes.string.isRequired,
313
+ name: PropTypes.string.isRequired,
314
+ children: PropTypes.array
321
315
  })).isRequired,
322
- onTreeBrowse: _propTypes["default"].func,
316
+ onTreeBrowse: PropTypes.func,
323
317
  //uncontrolled
324
- classes: _propTypes["default"].object,
325
- title: _propTypes["default"].string,
326
- contentText: _propTypes["default"].string,
327
- validationButtonText: _propTypes["default"].string,
328
- defaultSelected: _propTypes["default"].arrayOf(_propTypes["default"].string),
329
- defaultExpanded: _propTypes["default"].arrayOf(_propTypes["default"].string),
330
- onlyLeaves: _propTypes["default"].bool,
331
- multiselect: _propTypes["default"].bool,
332
- sortMethod: _propTypes["default"].func
318
+ classes: PropTypes.object,
319
+ title: PropTypes.string,
320
+ contentText: PropTypes.string,
321
+ validationButtonText: PropTypes.string,
322
+ defaultSelected: PropTypes.arrayOf(PropTypes.string),
323
+ defaultExpanded: PropTypes.arrayOf(PropTypes.string),
324
+ onlyLeaves: PropTypes.bool,
325
+ multiselect: PropTypes.bool,
326
+ sortMethod: PropTypes.func
333
327
  } : {};
334
328
 
335
329
  /* TreeViewFinder props default values */
@@ -341,6 +335,5 @@ TreeViewFinder.defaultProps = {
341
335
  sortMethod: undefined,
342
336
  classes: {}
343
337
  };
344
- var nestedGlobalSelectorsStyles = (0, _styles.toNestedGlobalSelectors)(defaultStyles, generateTreeViewFinderClass);
345
- var _default = (0, _system.styled)(TreeViewFinder)(nestedGlobalSelectorsStyles);
346
- exports["default"] = _default;
338
+ var nestedGlobalSelectorsStyles = toNestedGlobalSelectors(defaultStyles, generateTreeViewFinderClass);
339
+ export default styled(TreeViewFinder)(nestedGlobalSelectorsStyles);
@@ -0,0 +1,7 @@
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 { default, generateTreeViewFinderClass } from './TreeViewFinder';
@@ -0,0 +1,110 @@
1
+ var _excluded = ["name", "label", "options", "outputTransform", "inputTransform", "readOnly", "previousValue", "allowNewValue", "onChangeCallback", "formProps"],
2
+ _excluded2 = ["inputProps"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
+ /**
6
+ * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
+ * This Source Code Form is subject to the terms of the Mozilla Public
8
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
9
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
+ */
11
+
12
+ import React from 'react';
13
+ import PropTypes from 'prop-types';
14
+ import { Autocomplete, TextField } from '@mui/material';
15
+ import { useController, useFormContext } from 'react-hook-form';
16
+ import { genHelperError, genHelperPreviousValue, identity, isFieldRequired } from './utils/functions';
17
+ import FieldLabel from './utils/field-label';
18
+ var AutocompleteInput = function AutocompleteInput(_ref) {
19
+ var name = _ref.name,
20
+ label = _ref.label,
21
+ options = _ref.options,
22
+ _ref$outputTransform = _ref.outputTransform,
23
+ outputTransform = _ref$outputTransform === void 0 ? identity : _ref$outputTransform,
24
+ _ref$inputTransform = _ref.inputTransform,
25
+ inputTransform = _ref$inputTransform === void 0 ? identity : _ref$inputTransform,
26
+ _ref$readOnly = _ref.readOnly,
27
+ readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
28
+ previousValue = _ref.previousValue,
29
+ allowNewValue = _ref.allowNewValue,
30
+ onChangeCallback = _ref.onChangeCallback,
31
+ formProps = _ref.formProps,
32
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
33
+ var _useFormContext = useFormContext(),
34
+ validationSchema = _useFormContext.validationSchema,
35
+ getValues = _useFormContext.getValues,
36
+ removeOptional = _useFormContext.removeOptional;
37
+ var _useController = useController({
38
+ name: name
39
+ }),
40
+ _useController$field = _useController.field,
41
+ onChange = _useController$field.onChange,
42
+ value = _useController$field.value,
43
+ ref = _useController$field.ref,
44
+ error = _useController.fieldState.error;
45
+ var handleChange = function handleChange(value) {
46
+ onChangeCallback && onChangeCallback();
47
+ //if free solo not enabled or if value is not of string type, we call onChange right away
48
+ if (!allowNewValue || typeof value !== 'string') {
49
+ onChange(outputTransform(value));
50
+ return;
51
+ }
52
+
53
+ //otherwise, we check if user input matches with one of the options
54
+ var matchingOption = options.find(function (option) {
55
+ return option.id === value;
56
+ });
57
+ //if it does, we send the matching option to react hook form
58
+ if (matchingOption) {
59
+ onChange(outputTransform(matchingOption));
60
+ return;
61
+ }
62
+
63
+ //otherwise, we send the user input
64
+ onChange(outputTransform(value));
65
+ };
66
+ return /*#__PURE__*/React.createElement(Autocomplete, _extends({
67
+ value: inputTransform(value),
68
+ onChange: function onChange(_, data) {
69
+ return handleChange(data);
70
+ }
71
+ }, allowNewValue && {
72
+ freeSolo: true,
73
+ autoComplete: true,
74
+ blurOnSelect: true,
75
+ autoSelect: false,
76
+ onInputChange: function onInputChange(_, data) {
77
+ handleChange(data);
78
+ }
79
+ }, {
80
+ options: options,
81
+ renderInput: function renderInput(_ref2) {
82
+ var inputProps = _ref2.inputProps,
83
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
84
+ return /*#__PURE__*/React.createElement(TextField, _extends({}, label && {
85
+ label: FieldLabel({
86
+ label: label,
87
+ optional: !isFieldRequired(name, validationSchema, getValues()) && !(props === null || props === void 0 ? void 0 : props.disabled) && !removeOptional
88
+ })
89
+ }, {
90
+ inputRef: ref,
91
+ inputProps: _extends({}, inputProps, {
92
+ readOnly: readOnly
93
+ })
94
+ }, genHelperPreviousValue(previousValue), genHelperError(error === null || error === void 0 ? void 0 : error.message), formProps, rest));
95
+ }
96
+ }, props));
97
+ };
98
+ AutocompleteInput.propTypes = process.env.NODE_ENV !== "production" ? {
99
+ name: PropTypes.string.isRequired,
100
+ label: PropTypes.string,
101
+ options: PropTypes.array.isRequired,
102
+ outputTransform: PropTypes.func,
103
+ inputTransform: PropTypes.func,
104
+ readOnly: PropTypes.bool,
105
+ previousValue: PropTypes.any,
106
+ allowNewValue: PropTypes.bool,
107
+ onChangeCallback: PropTypes.func,
108
+ formProps: PropTypes.object
109
+ } : {};
110
+ export default AutocompleteInput;
@@ -0,0 +1,56 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ /**
3
+ * Copyright (c) 2022, RTE (http://www.rte-france.com)
4
+ * This Source Code Form is subject to the terms of the Mozilla Public
5
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+ */
8
+
9
+ import React, { useCallback } from 'react';
10
+ import PropTypes from 'prop-types';
11
+ import { useIntl } from 'react-intl';
12
+ import FormControlLabel from '@mui/material/FormControlLabel';
13
+ import { useController } from 'react-hook-form';
14
+ var BooleanInput = function BooleanInput(_ref) {
15
+ var name = _ref.name,
16
+ label = _ref.label,
17
+ formProps = _ref.formProps,
18
+ Input = _ref.Input;
19
+ var _useController = useController({
20
+ name: name
21
+ }),
22
+ _useController$field = _useController.field,
23
+ onChange = _useController$field.onChange,
24
+ value = _useController$field.value,
25
+ ref = _useController$field.ref;
26
+ var intl = useIntl();
27
+ var handleChangeValue = useCallback(function (event) {
28
+ onChange(event.target.checked);
29
+ }, [onChange]);
30
+ var CustomInput = /*#__PURE__*/React.createElement(Input, _extends({
31
+ checked: value,
32
+ onChange: function onChange(e) {
33
+ return handleChangeValue(e);
34
+ },
35
+ inputRef: ref,
36
+ inputProps: {
37
+ 'aria-label': 'primary checkbox'
38
+ }
39
+ }, formProps));
40
+ if (label) {
41
+ return /*#__PURE__*/React.createElement(FormControlLabel, {
42
+ control: CustomInput,
43
+ label: intl.formatMessage({
44
+ id: label
45
+ })
46
+ });
47
+ }
48
+ return CustomInput;
49
+ };
50
+ BooleanInput.propTypes = process.env.NODE_ENV !== "production" ? {
51
+ name: PropTypes.string.isRequired,
52
+ label: PropTypes.string,
53
+ formProps: PropTypes.object,
54
+ Input: PropTypes.elementType.isRequired
55
+ } : {};
56
+ export default BooleanInput;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) 2023, 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
+
8
+ import React from 'react';
9
+ import PropTypes from 'prop-types';
10
+ import BooleanInput from './boolean-input';
11
+ import Checkbox from '@mui/material/Checkbox';
12
+ var CheckboxInput = function CheckboxInput(_ref) {
13
+ var name = _ref.name,
14
+ label = _ref.label,
15
+ formProps = _ref.formProps;
16
+ return /*#__PURE__*/React.createElement(BooleanInput, {
17
+ name: name,
18
+ label: label,
19
+ formProps: formProps,
20
+ Input: Checkbox
21
+ });
22
+ };
23
+ CheckboxInput.propTypes = process.env.NODE_ENV !== "production" ? {
24
+ name: PropTypes.string.isRequired,
25
+ label: PropTypes.string,
26
+ formProps: PropTypes.object
27
+ } : {};
28
+ export default CheckboxInput;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) 2023, 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
+
8
+ import React from 'react';
9
+ import PropTypes from 'prop-types';
10
+ import BooleanInput from './boolean-input';
11
+ import Switch from '@mui/material/Switch';
12
+ var SwitchInput = function SwitchInput(_ref) {
13
+ var name = _ref.name,
14
+ label = _ref.label,
15
+ formProps = _ref.formProps;
16
+ return /*#__PURE__*/React.createElement(BooleanInput, {
17
+ name: name,
18
+ label: label,
19
+ formProps: formProps,
20
+ Input: Switch
21
+ });
22
+ };
23
+ SwitchInput.propTypes = process.env.NODE_ENV !== "production" ? {
24
+ name: PropTypes.string.isRequired,
25
+ label: PropTypes.string,
26
+ formProps: PropTypes.object
27
+ } : {};
28
+ export default SwitchInput;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright (c) 2023, 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
+
8
+ import React, { useEffect, useRef } from 'react';
9
+ import { FormattedMessage } from 'react-intl';
10
+ import { useController } from 'react-hook-form';
11
+ var ErrorInput = function ErrorInput(_ref) {
12
+ var name = _ref.name,
13
+ InputField = _ref.InputField;
14
+ var _useController = useController({
15
+ name: name
16
+ }),
17
+ error = _useController.fieldState.error,
18
+ isSubmitting = _useController.formState.isSubmitting;
19
+ var errorRef = useRef(null);
20
+ var errorProps = function errorProps(errorMsg) {
21
+ if (typeof errorMsg === 'string') {
22
+ return {
23
+ id: errorMsg
24
+ };
25
+ } else if (typeof errorMsg === 'object') {
26
+ return {
27
+ id: errorMsg.id,
28
+ values: {
29
+ value: errorMsg.value
30
+ }
31
+ };
32
+ }
33
+ return {};
34
+ };
35
+ useEffect(function () {
36
+ // the scroll should be done only when the form is submitting
37
+ if (error && errorRef.current) {
38
+ errorRef.current.scrollIntoView({
39
+ behavior: 'smooth'
40
+ });
41
+ }
42
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43
+ }, [isSubmitting]);
44
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (error === null || error === void 0 ? void 0 : error.message) && /*#__PURE__*/React.createElement("div", {
45
+ ref: errorRef
46
+ }, /*#__PURE__*/React.createElement(InputField, {
47
+ message: /*#__PURE__*/React.createElement(FormattedMessage, errorProps(error === null || error === void 0 ? void 0 : error.message))
48
+ })));
49
+ };
50
+ export default ErrorInput;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) 2022, 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
+
8
+ import React from 'react';
9
+ import { Alert, Grid } from '@mui/material';
10
+
11
+ // component to display alert when a specific rhf field is in error
12
+ // this component needs to be isolated to avoid too many rerenders
13
+ var FieldErrorAlert = function FieldErrorAlert(_ref) {
14
+ var message = _ref.message;
15
+ return /*#__PURE__*/React.createElement(Grid, {
16
+ item: true,
17
+ xs: 12
18
+ }, /*#__PURE__*/React.createElement(Alert, {
19
+ severity: "error"
20
+ }, message));
21
+ };
22
+ export default FieldErrorAlert;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2023, 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
+
8
+ import React from 'react';
9
+ import Box from '@mui/material/Box';
10
+
11
+ // component to display error message in the middle of dialog
12
+ var MidFormError = function MidFormError(_ref) {
13
+ var message = _ref.message;
14
+ return /*#__PURE__*/React.createElement(Box, {
15
+ sx: function sx(theme) {
16
+ return {
17
+ color: theme.palette.error.main,
18
+ fontSize: 'small',
19
+ marginLeft: theme.spacing(2),
20
+ marginRight: theme.spacing(2)
21
+ };
22
+ }
23
+ }, message);
24
+ };
25
+ export default MidFormError;
@@ -0,0 +1,40 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ /**
3
+ * Copyright (c) 2022, RTE (http://www.rte-france.com)
4
+ * This Source Code Form is subject to the terms of the Mozilla Public
5
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+ */
8
+
9
+ import React from 'react';
10
+ import TextInput from '../text-input';
11
+ import { isFloatNumber } from './utils';
12
+ var FloatInput = function FloatInput(props) {
13
+ var inputTransform = function inputTransform(value) {
14
+ var sanitizedValue = value === null || value === void 0 ? void 0 : value.toString().replace(',', '.');
15
+ if (['-', '.'].includes(sanitizedValue)) {
16
+ return sanitizedValue;
17
+ }
18
+ return sanitizedValue === null || isNaN(sanitizedValue) ? '' : sanitizedValue;
19
+ };
20
+ var outputTransform = function outputTransform(value) {
21
+ if (value === '-') {
22
+ return value;
23
+ }
24
+ if (value === '') {
25
+ return null;
26
+ }
27
+ var tmp = (value === null || value === void 0 ? void 0 : value.replace(',', '.')) || '';
28
+ if (tmp.endsWith('.') || tmp.endsWith('0')) {
29
+ return tmp;
30
+ }
31
+ return parseFloat(tmp) || null;
32
+ };
33
+ return /*#__PURE__*/React.createElement(TextInput, _extends({
34
+ acceptValue: isFloatNumber,
35
+ outputTransform: outputTransform,
36
+ inputTransform: inputTransform
37
+ }, props));
38
+ };
39
+ FloatInput.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, TextInput.propTypes) : {};
40
+ export default FloatInput;