@gridsuite/commons-ui 0.35.1 → 0.35.3

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 +20 -29
  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 +11 -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
@@ -0,0 +1,35 @@
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 { isIntegerNumber } from './utils';
12
+ var IntegerInput = function IntegerInput(props) {
13
+ var inputTransform = function inputTransform(value) {
14
+ if ('-' === value) {
15
+ return value;
16
+ }
17
+ return value === null || isNaN(value) ? '' : value.toString();
18
+ };
19
+ var outputTransform = function outputTransform(value) {
20
+ if (value === '-') {
21
+ return value;
22
+ }
23
+ if (value === '0') {
24
+ return 0;
25
+ }
26
+ return parseInt(value) || null;
27
+ };
28
+ return /*#__PURE__*/React.createElement(TextInput, _extends({
29
+ acceptValue: isIntegerNumber,
30
+ outputTransform: outputTransform,
31
+ inputTransform: inputTransform
32
+ }, props));
33
+ };
34
+ IntegerInput.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, TextInput.propTypes) : {};
35
+ export default IntegerInput;
@@ -0,0 +1,6 @@
1
+ export var isIntegerNumber = function isIntegerNumber(val) {
2
+ return /^-?[0-9]*$/.test(val);
3
+ };
4
+ export var isFloatNumber = function isFloatNumber(val) {
5
+ return /^-?[0-9]*[.,]?[0-9]*$/.test(val);
6
+ };
@@ -0,0 +1,55 @@
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) 2023, 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 PropTypes from 'prop-types';
11
+ import FormControl from '@mui/material/FormControl';
12
+ import { FormControlLabel, FormLabel, Radio, RadioGroup } from '@mui/material';
13
+ import { FormattedMessage } from 'react-intl';
14
+ import { useController } from 'react-hook-form';
15
+ import FieldLabel from './utils/field-label';
16
+ var RadioInput = function RadioInput(_ref) {
17
+ var name = _ref.name,
18
+ label = _ref.label,
19
+ id = _ref.id,
20
+ options = _ref.options,
21
+ formProps = _ref.formProps;
22
+ var _useController = useController({
23
+ name: name
24
+ }),
25
+ _useController$field = _useController.field,
26
+ onChange = _useController$field.onChange,
27
+ value = _useController$field.value;
28
+ return /*#__PURE__*/React.createElement(FormControl, null, label && /*#__PURE__*/React.createElement(FormLabel, {
29
+ id: id !== null && id !== void 0 ? id : label
30
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
31
+ id: label
32
+ })), /*#__PURE__*/React.createElement(RadioGroup, _extends({
33
+ row: true,
34
+ "aria-labelledby": id !== null && id !== void 0 ? id : label,
35
+ value: value,
36
+ onChange: onChange
37
+ }, formProps), options.map(function (option) {
38
+ return /*#__PURE__*/React.createElement(FormControlLabel, {
39
+ control: /*#__PURE__*/React.createElement(Radio, null),
40
+ value: option.id,
41
+ key: option.id,
42
+ label: /*#__PURE__*/React.createElement(FieldLabel, {
43
+ label: option.label
44
+ })
45
+ });
46
+ })));
47
+ };
48
+ RadioInput.propTypes = process.env.NODE_ENV !== "production" ? {
49
+ name: PropTypes.string.isRequired,
50
+ label: PropTypes.string,
51
+ id: PropTypes.string,
52
+ options: PropTypes.array.isRequired,
53
+ formProps: PropTypes.object
54
+ } : {};
55
+ export default RadioInput;
@@ -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 PropTypes from 'prop-types';
11
+ import AutocompleteInput from './autocomplete-input';
12
+ import { useIntl } from 'react-intl';
13
+ var SelectInput = function SelectInput(props) {
14
+ var intl = useIntl();
15
+ var inputTransform = function inputTransform(value) {
16
+ return props.options.find(function (option) {
17
+ return (option === null || option === void 0 ? void 0 : option.id) === value;
18
+ }) || null;
19
+ };
20
+ var outputTransform = function outputTransform(value) {
21
+ var _value$id;
22
+ return (_value$id = value === null || value === void 0 ? void 0 : value.id) !== null && _value$id !== void 0 ? _value$id : null;
23
+ };
24
+ return /*#__PURE__*/React.createElement(AutocompleteInput, _extends({
25
+ getOptionLabel: function getOptionLabel(option) {
26
+ return (option === null || option === void 0 ? void 0 : option.label) ? intl.formatMessage({
27
+ id: option === null || option === void 0 ? void 0 : option.label
28
+ }) // If the option has a label property, display the label using internationalization
29
+ : option === null || option === void 0 ? void 0 : option.id; // If the option doesn't have a label property, display the ID instead
30
+ },
31
+
32
+ inputTransform: inputTransform,
33
+ outputTransform: outputTransform,
34
+ readOnly: true
35
+ }, props));
36
+ };
37
+ SelectInput.propTypes = process.env.NODE_ENV !== "production" ? _extends({
38
+ options: PropTypes.array.isRequired
39
+ }, AutocompleteInput.propTypes) : {};
40
+ export default SelectInput;
@@ -0,0 +1,48 @@
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 { Slider } from '@mui/material';
11
+ import { useController } from 'react-hook-form';
12
+ import { identity } from './utils/functions';
13
+ var SliderInput = function SliderInput(_ref) {
14
+ var name = _ref.name,
15
+ min = _ref.min,
16
+ max = _ref.max,
17
+ step = _ref.step,
18
+ _ref$size = _ref.size,
19
+ size = _ref$size === void 0 ? 'small' : _ref$size,
20
+ _ref$onValueChange = _ref.onValueChange,
21
+ onValueChange = _ref$onValueChange === void 0 ? identity : _ref$onValueChange;
22
+ var _useController = useController({
23
+ name: name
24
+ }),
25
+ _useController$field = _useController.field,
26
+ onChange = _useController$field.onChange,
27
+ value = _useController$field.value;
28
+ var handleValueChange = function handleValueChange(e) {
29
+ onChange(onValueChange(e.target.value));
30
+ };
31
+ return /*#__PURE__*/React.createElement(Slider, {
32
+ size: size,
33
+ min: min,
34
+ max: max,
35
+ step: step,
36
+ value: value,
37
+ onChange: handleValueChange
38
+ });
39
+ };
40
+ SliderInput.propTypes = process.env.NODE_ENV !== "production" ? {
41
+ name: PropTypes.string.isRequired,
42
+ min: PropTypes.number.isRequired,
43
+ max: PropTypes.number.isRequired,
44
+ step: PropTypes.number.isRequired,
45
+ size: PropTypes.string,
46
+ onValueChange: PropTypes.func
47
+ } : {};
48
+ export default SliderInput;
@@ -0,0 +1,100 @@
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 PropTypes from 'prop-types';
11
+ import { IconButton, InputAdornment, TextField } from '@mui/material';
12
+ import ClearIcon from '@mui/icons-material/Clear';
13
+ import { useController, useFormContext } from 'react-hook-form';
14
+ import TextFieldWithAdornment from './utils/text-field-with-adornment';
15
+ import FieldLabel from './utils/field-label';
16
+ import { genHelperError, genHelperPreviousValue, identity, isFieldRequired } from './utils/functions';
17
+ var TextInput = function TextInput(_ref) {
18
+ var name = _ref.name,
19
+ label = _ref.label,
20
+ labelValues = _ref.labelValues,
21
+ id = _ref.id,
22
+ adornment = _ref.adornment,
23
+ customAdornment = _ref.customAdornment,
24
+ _ref$outputTransform = _ref.outputTransform,
25
+ outputTransform = _ref$outputTransform === void 0 ? identity : _ref$outputTransform,
26
+ _ref$inputTransform = _ref.inputTransform,
27
+ inputTransform = _ref$inputTransform === void 0 ? identity : _ref$inputTransform,
28
+ _ref$acceptValue = _ref.acceptValue,
29
+ acceptValue = _ref$acceptValue === void 0 ? function () {
30
+ return true;
31
+ } : _ref$acceptValue,
32
+ previousValue = _ref.previousValue,
33
+ clearable = _ref.clearable,
34
+ formProps = _ref.formProps;
35
+ var _useFormContext = useFormContext(),
36
+ validationSchema = _useFormContext.validationSchema,
37
+ getValues = _useFormContext.getValues,
38
+ removeOptional = _useFormContext.removeOptional;
39
+ var _useController = useController({
40
+ name: name
41
+ }),
42
+ _useController$field = _useController.field,
43
+ onChange = _useController$field.onChange,
44
+ value = _useController$field.value,
45
+ ref = _useController$field.ref,
46
+ error = _useController.fieldState.error;
47
+ var Field = adornment ? TextFieldWithAdornment : TextField;
48
+ var handleClearValue = function handleClearValue() {
49
+ onChange(outputTransform(''));
50
+ };
51
+ var handleValueChanged = function handleValueChanged(e) {
52
+ if (acceptValue(e.target.value)) {
53
+ onChange(outputTransform(e.target.value));
54
+ }
55
+ };
56
+ var transformedValue = inputTransform(value);
57
+ var fieldLabel = !label ? null : FieldLabel({
58
+ label: label,
59
+ values: labelValues,
60
+ optional: !isFieldRequired(name, validationSchema, getValues()) && !(formProps === null || formProps === void 0 ? void 0 : formProps.disabled) && !removeOptional
61
+ });
62
+ return /*#__PURE__*/React.createElement(Field, _extends({
63
+ key: id ? id : label,
64
+ size: "small",
65
+ fullWidth: true,
66
+ id: id ? id : label,
67
+ label: fieldLabel
68
+ }, adornment && {
69
+ adornmentPosition: adornment.position,
70
+ adornmentText: adornment === null || adornment === void 0 ? void 0 : adornment.text
71
+ }, {
72
+ value: transformedValue,
73
+ onChange: handleValueChanged,
74
+ InputProps: {
75
+ endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
76
+ position: "end"
77
+ }, clearable && transformedValue !== undefined && transformedValue !== '' && /*#__PURE__*/React.createElement(IconButton, {
78
+ onClick: handleClearValue
79
+ }, /*#__PURE__*/React.createElement(ClearIcon, null)), customAdornment && _extends({}, customAdornment))
80
+ },
81
+ inputRef: ref
82
+ }, clearable && adornment && {
83
+ handleClearValue: handleClearValue
84
+ }, genHelperPreviousValue(previousValue, adornment), genHelperError(error === null || error === void 0 ? void 0 : error.message), formProps));
85
+ };
86
+ TextInput.propTypes = process.env.NODE_ENV !== "production" ? {
87
+ name: PropTypes.string,
88
+ label: PropTypes.string,
89
+ labelValues: PropTypes.object,
90
+ id: PropTypes.string,
91
+ adornment: PropTypes.object,
92
+ customAdornment: PropTypes.object,
93
+ outputTransform: PropTypes.func,
94
+ inputTransform: PropTypes.func,
95
+ acceptValue: PropTypes.func,
96
+ previousValue: PropTypes.any,
97
+ clearable: PropTypes.bool,
98
+ formProps: PropTypes.object
99
+ } : {};
100
+ export default TextInput;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ var FieldLabel = function FieldLabel(_ref) {
4
+ var label = _ref.label,
5
+ optional = _ref.optional,
6
+ _ref$values = _ref.values,
7
+ values = _ref$values === void 0 ? undefined : _ref$values;
8
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
9
+ id: label,
10
+ values: values
11
+ }), optional && /*#__PURE__*/React.createElement(FormattedMessage, {
12
+ id: "Optional"
13
+ }));
14
+ };
15
+ export default FieldLabel;
@@ -0,0 +1,42 @@
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
+ import React from 'react';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import { getIn } from 'yup';
5
+ export function genHelperPreviousValue(previousValue, adornment) {
6
+ return _extends({}, (previousValue || previousValue === 0) && {
7
+ error: false,
8
+ helperText: previousValue + (adornment ? ' ' + (adornment === null || adornment === void 0 ? void 0 : adornment.text) : '')
9
+ });
10
+ }
11
+ export function genHelperError() {
12
+ for (var _len = arguments.length, errors = new Array(_len), _key = 0; _key < _len; _key++) {
13
+ errors[_key] = arguments[_key];
14
+ }
15
+ var inError = errors.find(function (e) {
16
+ return e;
17
+ });
18
+ if (inError) {
19
+ return {
20
+ error: true,
21
+ helperText: /*#__PURE__*/React.createElement(FormattedMessage, {
22
+ id: inError
23
+ })
24
+ };
25
+ }
26
+ return {};
27
+ }
28
+ export function identity(x) {
29
+ return x;
30
+ }
31
+ export var isFieldRequired = function isFieldRequired(fieldName, schema, values) {
32
+ var _fieldSchema$describe;
33
+ var _ref = getIn(schema, fieldName, values) || {},
34
+ fieldSchema = _ref.schema,
35
+ parentValues = _ref.parent;
36
+ return ((_fieldSchema$describe = fieldSchema.describe({
37
+ parent: parentValues
38
+ })) === null || _fieldSchema$describe === void 0 ? void 0 : _fieldSchema$describe.optional) === false;
39
+
40
+ //static way, not working when using "when" in schema, but does not need form values
41
+ //return yup.reach(schema, fieldName)?.exclusiveTests?.required === true;
42
+ };
@@ -0,0 +1,25 @@
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 { Button } from '@mui/material';
10
+ import { useFormState } from 'react-hook-form';
11
+ import { FormattedMessage } from 'react-intl';
12
+ var SubmitButton = function SubmitButton(_ref) {
13
+ var onClick = _ref.onClick,
14
+ _ref$disabled = _ref.disabled,
15
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
16
+ var _useFormState = useFormState(),
17
+ isDirty = _useFormState.isDirty;
18
+ return /*#__PURE__*/React.createElement(Button, {
19
+ onClick: onClick,
20
+ disabled: !isDirty || disabled
21
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
22
+ id: "validate"
23
+ }));
24
+ };
25
+ export default SubmitButton;
@@ -0,0 +1,92 @@
1
+ var _excluded = ["adornmentPosition", "adornmentText", "value", "variant", "handleClearValue"];
2
+ 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); }
3
+ 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; }
4
+ /**
5
+ * Copyright (c) 2021, RTE (http://www.rte-france.com)
6
+ * This Source Code Form is subject to the terms of the Mozilla Public
7
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
8
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ import React, { useCallback, useState } from 'react';
12
+ import PropTypes from 'prop-types';
13
+ import ClearIcon from '@mui/icons-material/Clear';
14
+ import { TextField } from '@mui/material';
15
+ import IconButton from '@mui/material/IconButton';
16
+ import InputAdornment from '@mui/material/InputAdornment';
17
+ var TextFieldWithAdornment = function TextFieldWithAdornment(props) {
18
+ var adornmentPosition = props.adornmentPosition,
19
+ adornmentText = props.adornmentText,
20
+ value = props.value,
21
+ variant = props.variant,
22
+ handleClearValue = props.handleClearValue,
23
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded);
24
+ var _useState = useState(false),
25
+ isFocused = _useState[0],
26
+ setIsFocused = _useState[1];
27
+ var getAdornmentStyle = useCallback(function (variant) {
28
+ if (variant === 'filled') {
29
+ return {
30
+ alignItems: 'start',
31
+ marginBottom: '0.4em'
32
+ };
33
+ }
34
+ if (variant === 'standard') {
35
+ return {
36
+ marginBottom: '0.3em'
37
+ };
38
+ }
39
+ return undefined;
40
+ }, []);
41
+ var getClearAdornment = useCallback(function (position) {
42
+ return /*#__PURE__*/React.createElement(InputAdornment, {
43
+ position: position
44
+ }, /*#__PURE__*/React.createElement(IconButton, {
45
+ onClick: handleClearValue
46
+ }, /*#__PURE__*/React.createElement(ClearIcon, null)));
47
+ }, [handleClearValue]);
48
+ var getTextAdornment = useCallback(function (position) {
49
+ return /*#__PURE__*/React.createElement(InputAdornment, {
50
+ position: position,
51
+ sx: getAdornmentStyle(variant)
52
+ }, adornmentText);
53
+ }, [adornmentText, getAdornmentStyle, variant]);
54
+ var withEndAdornmentText = useCallback(function () {
55
+ return value !== '' || isFocused ? {
56
+ startAdornment: value && handleClearValue ? getClearAdornment('start') : undefined,
57
+ endAdornment: getTextAdornment('end'),
58
+ sx: {
59
+ textAlign: 'end'
60
+ }
61
+ } : undefined;
62
+ }, [value, handleClearValue, getClearAdornment, isFocused, getTextAdornment]);
63
+ var withStartAdornmentText = useCallback(function () {
64
+ return value !== '' || isFocused ? {
65
+ startAdornment: getTextAdornment('start'),
66
+ endAdornment: value && handleClearValue && getClearAdornment('end'),
67
+ sx: {
68
+ textAlign: 'start'
69
+ }
70
+ } : undefined;
71
+ }, [value, handleClearValue, getClearAdornment, isFocused, getTextAdornment]);
72
+ return /*#__PURE__*/React.createElement(TextField, _extends({}, otherProps, {
73
+ //TODO move at the end like other inputs ?
74
+ variant: variant,
75
+ value: value,
76
+ InputProps: adornmentPosition === 'start' ? withStartAdornmentText() : withEndAdornmentText(),
77
+ onFocus: function onFocus(e) {
78
+ return setIsFocused(true);
79
+ },
80
+ onBlur: function onBlur(e) {
81
+ return setIsFocused(false);
82
+ }
83
+ }));
84
+ };
85
+ TextFieldWithAdornment.propTypes = process.env.NODE_ENV !== "production" ? {
86
+ adornmentPosition: PropTypes.string.isRequired,
87
+ adornmentText: PropTypes.string.isRequired,
88
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
89
+ variant: PropTypes.string,
90
+ handleClearValue: PropTypes.func
91
+ } : {};
92
+ export default TextFieldWithAdornment;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
1
  /**
6
2
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
3
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -14,6 +10,4 @@ var card_error_boundary_en = {
14
10
  'card_error_boundary/content': 'Please reload, or close and reopen this application, or contact support.',
15
11
  'card_error_boundary/expandederrorheader': 'Error message (and see more information in the developper console):'
16
12
  };
17
- var _default = card_error_boundary_en;
18
- exports["default"] = _default;
19
- module.exports = exports.default;
13
+ export default card_error_boundary_en;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
1
  /**
6
2
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
3
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -14,6 +10,4 @@ var card_error_boundary_fr = {
14
10
  'card_error_boundary/content': 'Veuillez recharger, ou fermer et réouvrir cette application, ou contacter le support.',
15
11
  'card_error_boundary/expandederrorheader': "Message d'erreur (et voir plus d'informations dans la console developpeur):"
16
12
  };
17
- var _default = card_error_boundary_fr;
18
- exports["default"] = _default;
19
- module.exports = exports.default;
13
+ export default card_error_boundary_fr;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
1
  /**
6
2
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
3
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -13,6 +9,4 @@ var element_search_en = {
13
9
  'element_search/label': 'Search for an element',
14
10
  'element_search/noResult': 'No result'
15
11
  };
16
- var _default = element_search_en;
17
- exports["default"] = _default;
18
- module.exports = exports.default;
12
+ export default element_search_en;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
1
  /**
6
2
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
3
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -13,6 +9,4 @@ var element_search_fr = {
13
9
  'element_search/label': 'Rechercher un élément',
14
10
  'element_search/noResult': 'Aucun résultat'
15
11
  };
16
- var _default = element_search_fr;
17
- exports["default"] = _default;
18
- module.exports = exports.default;
12
+ export default element_search_fr;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
1
  /**
6
2
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
3
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -27,6 +23,4 @@ var equipment_search_en = {
27
23
  'equipment_search/substationTag': 'SUBSTATION',
28
24
  'equipment_search/busTag': 'BUS'
29
25
  };
30
- var _default = equipment_search_en;
31
- exports["default"] = _default;
32
- module.exports = exports.default;
26
+ export default equipment_search_en;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
1
  /**
6
2
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
3
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -27,6 +23,4 @@ var equipment_search_fr = {
27
23
  'equipment_search/substationTag': 'SITE',
28
24
  'equipment_search/busTag': 'NOEUD'
29
25
  };
30
- var _default = equipment_search_fr;
31
- exports["default"] = _default;
32
- module.exports = exports.default;
26
+ export default equipment_search_fr;
@@ -0,0 +1,25 @@
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
+ var inputs_en = {
9
+ 'inputs/kiki': 'Kylian Mbappe',
10
+ 'inputs/ney': 'Neymar',
11
+ 'inputs/lapulga': 'Lionel Messi',
12
+ 'inputs/ibra': 'Zlatan Ibrahimovic',
13
+ 'inputs/float': 'Float',
14
+ 'inputs/integer': 'Integer',
15
+ 'inputs/radio': 'Radio',
16
+ 'inputs/select': 'Select',
17
+ 'inputs/slider': 'Slider',
18
+ 'inputs/text': 'Text',
19
+ 'inputs/autocomplete': 'Autocomplete',
20
+ 'inputs/boolean': 'Boolean',
21
+ 'inputs/checkbox': 'Checkbox',
22
+ 'inputs/switch': 'Switch',
23
+ Optional: 'Optional'
24
+ };
25
+ export default inputs_en;
@@ -0,0 +1,25 @@
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
+ var inputs_fr = {
9
+ 'inputs/kiki': 'Kylian Mbappe',
10
+ 'inputs/ney': 'Neymar',
11
+ 'inputs/lapulga': 'Lionel Messi',
12
+ 'inputs/ibra': 'Zlatan Ibrahimovic',
13
+ 'inputs/float': 'Float',
14
+ 'inputs/integer': 'Integer',
15
+ 'inputs/radio': 'Radio',
16
+ 'inputs/select': 'Select',
17
+ 'inputs/slider': 'Slider',
18
+ 'inputs/text': 'Text',
19
+ 'inputs/autocomplete': 'Autocomplete',
20
+ 'inputs/boolean': 'Boolean',
21
+ 'inputs/checkbox': 'Checkbox',
22
+ 'inputs/switch': 'Switch',
23
+ Optional: 'Optional'
24
+ };
25
+ export default inputs_fr;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
1
  /**
6
2
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
3
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -20,6 +16,4 @@ var login_en = {
20
16
  'login/errorInLogoutMessage': 'An unexpected error occured during user logout for {userName}.',
21
17
  'login/logout': 'Logout'
22
18
  };
23
- var _default = login_en;
24
- exports["default"] = _default;
25
- module.exports = exports.default;
19
+ export default login_en;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
1
  /**
6
2
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
3
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -20,6 +16,4 @@ var login_fr = {
20
16
  'login/errorInLogoutMessage': "Une erreur s'est produite pendant la déconnexion de l'utilisateur {userName}.",
21
17
  'login/logout': 'Se déconnecter'
22
18
  };
23
- var _default = login_fr;
24
- exports["default"] = _default;
25
- module.exports = exports.default;
19
+ export default login_fr;