@gridsuite/commons-ui 0.46.0 → 0.47.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 (183) hide show
  1. package/README.md +0 -17
  2. package/dist/components/AuthenticationRouter/AuthenticationRouter.js +147 -0
  3. package/dist/components/CardErrorBoundary/card-error-boundary.js +110 -0
  4. package/dist/components/ElementSearchDialog/element-search-dialog.js +139 -0
  5. package/dist/components/ElementSearchDialog/equipment-item.js +77 -0
  6. package/dist/components/ElementSearchDialog/tag-renderer.js +34 -0
  7. package/dist/components/FlatParameters/FlatParameters.js +411 -0
  8. package/dist/components/Login/Login.js +78 -0
  9. package/dist/components/Login/Logout.js +69 -0
  10. package/dist/components/MuiVirtualizedTable/ColumnHeader.js +127 -0
  11. package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +548 -0
  12. package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.js +790 -0
  13. package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.js +87 -0
  14. package/dist/components/OverflowableText/overflowable-text.js +87 -0
  15. package/dist/components/ReportViewer/filter-button.js +64 -0
  16. package/dist/components/ReportViewer/log-report-item.js +95 -0
  17. package/dist/components/ReportViewer/log-report.js +49 -0
  18. package/dist/components/ReportViewer/log-table.js +131 -0
  19. package/dist/components/ReportViewer/multi-select-list.js +40 -0
  20. package/dist/components/ReportViewer/report-item.js +112 -0
  21. package/dist/components/ReportViewer/report-tree-view-context.js +8 -0
  22. package/dist/components/ReportViewer/report-viewer.js +158 -0
  23. package/dist/components/ReportViewerDialog/report-viewer-dialog.js +61 -0
  24. package/dist/components/SignInCallbackHandler/SignInCallbackHandler.js +13 -0
  25. package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +16 -0
  26. package/dist/components/SnackbarProvider/SnackbarProvider.js +28 -0
  27. package/dist/components/TopBar/AboutDialog.js +467 -0
  28. package/dist/components/TopBar/GridLogo.js +71 -0
  29. package/dist/components/TopBar/TopBar.js +679 -0
  30. package/dist/components/TreeViewFinder/TreeViewFinder.js +288 -0
  31. package/dist/components/react-hook-form/autocomplete-input.js +96 -0
  32. package/dist/components/react-hook-form/booleans/boolean-input.js +49 -0
  33. package/dist/components/react-hook-form/booleans/checkbox-input.js +24 -0
  34. package/dist/components/react-hook-form/booleans/switch-input.js +24 -0
  35. package/dist/components/react-hook-form/error-management/error-input.js +42 -0
  36. package/dist/components/react-hook-form/error-management/field-error-alert.js +9 -0
  37. package/dist/components/react-hook-form/error-management/mid-form-error.js +20 -0
  38. package/dist/components/react-hook-form/numbers/float-input.js +51 -0
  39. package/dist/components/react-hook-form/numbers/integer-input.js +36 -0
  40. package/dist/components/react-hook-form/numbers/utils.js +10 -0
  41. package/dist/components/react-hook-form/radio-input.js +44 -0
  42. package/dist/components/react-hook-form/select-input.js +31 -0
  43. package/dist/components/react-hook-form/slider-input.js +43 -0
  44. package/dist/components/react-hook-form/text-input.js +94 -0
  45. package/dist/components/react-hook-form/utils/cancel-button.js +16 -0
  46. package/dist/components/react-hook-form/utils/field-label.js +12 -0
  47. package/dist/components/react-hook-form/utils/functions.js +36 -0
  48. package/dist/components/react-hook-form/utils/submit-button.js +23 -0
  49. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +96 -0
  50. package/dist/components/translations/card-error-boundary-en.js +8 -0
  51. package/dist/components/translations/card-error-boundary-fr.js +8 -0
  52. package/dist/components/translations/common-button-en.js +7 -0
  53. package/dist/components/translations/common-button-fr.js +7 -0
  54. package/dist/components/translations/element-search-en.js +7 -0
  55. package/dist/components/translations/element-search-fr.js +7 -0
  56. package/dist/components/translations/equipment-search-en.js +21 -0
  57. package/dist/components/translations/equipment-search-fr.js +21 -0
  58. package/dist/components/translations/flat-parameters-en.js +8 -0
  59. package/dist/components/translations/flat-parameters-fr.js +8 -0
  60. package/dist/components/translations/login-en.js +14 -0
  61. package/dist/components/translations/login-fr.js +14 -0
  62. package/dist/components/translations/multiple-selection-dialog-en.js +8 -0
  63. package/dist/components/translations/multiple-selection-dialog-fr.js +8 -0
  64. package/dist/components/translations/report-viewer-en.js +8 -0
  65. package/dist/components/translations/report-viewer-fr.js +8 -0
  66. package/dist/components/translations/table-en.js +6 -0
  67. package/dist/components/translations/table-fr.js +6 -0
  68. package/dist/components/translations/top-bar-en.js +27 -0
  69. package/dist/components/translations/top-bar-fr.js +27 -0
  70. package/dist/components/translations/treeview-finder-en.js +12 -0
  71. package/dist/components/translations/treeview-finder-fr.js +12 -0
  72. package/dist/hooks/useDebounce.js +17 -0
  73. package/{es/components/ElementSearchDialog/index.js → dist/hooks/useIntlRef.d.ts} +2 -2
  74. package/dist/hooks/useIntlRef.js +13 -0
  75. package/dist/hooks/useSnackMessage.js +81 -0
  76. package/dist/index.d.ts +225 -0
  77. package/dist/index.js +154 -0
  78. package/dist/utils/AuthService.js +336 -0
  79. package/dist/utils/ElementType.js +38 -0
  80. package/dist/utils/EquipmentType.js +132 -0
  81. package/dist/utils/UserManagerMock.js +85 -0
  82. package/dist/utils/actions.js +71 -0
  83. package/dist/utils/algos.js +24 -0
  84. package/dist/utils/styles.js +13 -0
  85. package/package.json +36 -21
  86. package/es/components/AuthenticationRouter/AuthenticationRouter.js +0 -102
  87. package/es/components/AuthenticationRouter/index.js +0 -7
  88. package/es/components/CardErrorBoundary/card-error-boundary.js +0 -138
  89. package/es/components/CardErrorBoundary/index.js +0 -7
  90. package/es/components/ElementSearchDialog/element-search-dialog.js +0 -153
  91. package/es/components/ElementSearchDialog/equipment-item.js +0 -63
  92. package/es/components/ElementSearchDialog/tag-renderer.js +0 -29
  93. package/es/components/FlatParameters/FlatParameters.js +0 -448
  94. package/es/components/FlatParameters/index.js +0 -8
  95. package/es/components/Login/Login.js +0 -79
  96. package/es/components/Login/Logout.js +0 -78
  97. package/es/components/Login/index.js +0 -7
  98. package/es/components/MuiVirtualizedTable/ColumnHeader.js +0 -125
  99. package/es/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -619
  100. package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +0 -780
  101. package/es/components/MuiVirtualizedTable/index.js +0 -9
  102. package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +0 -95
  103. package/es/components/MultipleSelectionDialog/index.js +0 -8
  104. package/es/components/OverflowableText/index.js +0 -7
  105. package/es/components/OverflowableText/overflowable-text.js +0 -81
  106. package/es/components/ReportViewer/filter-button.js +0 -77
  107. package/es/components/ReportViewer/index.js +0 -7
  108. package/es/components/ReportViewer/log-report-item.js +0 -97
  109. package/es/components/ReportViewer/log-report.js +0 -63
  110. package/es/components/ReportViewer/log-table.js +0 -130
  111. package/es/components/ReportViewer/multi-select-list.js +0 -56
  112. package/es/components/ReportViewer/report-item.js +0 -131
  113. package/es/components/ReportViewer/report-tree-view-context.js +0 -13
  114. package/es/components/ReportViewer/report-viewer.js +0 -167
  115. package/es/components/ReportViewerDialog/index.js +0 -7
  116. package/es/components/ReportViewerDialog/report-viewer-dialog.js +0 -67
  117. package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -19
  118. package/es/components/SignInCallbackHandler/index.js +0 -7
  119. package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -19
  120. package/es/components/SilentRenewCallbackHandler/index.js +0 -7
  121. package/es/components/SnackbarProvider/SnackbarProvider.js +0 -39
  122. package/es/components/SnackbarProvider/index.js +0 -7
  123. package/es/components/TopBar/AboutDialog.js +0 -456
  124. package/es/components/TopBar/GridLogo.js +0 -73
  125. package/es/components/TopBar/TopBar.js +0 -487
  126. package/es/components/TopBar/index.js +0 -9
  127. package/es/components/TreeViewFinder/TreeViewFinder.js +0 -341
  128. package/es/components/TreeViewFinder/index.js +0 -7
  129. package/es/components/images/powsybl_logo.svg +0 -35
  130. package/es/components/react-hook-form/autocomplete-input.js +0 -110
  131. package/es/components/react-hook-form/booleans/boolean-input.js +0 -56
  132. package/es/components/react-hook-form/booleans/checkbox-input.js +0 -28
  133. package/es/components/react-hook-form/booleans/switch-input.js +0 -28
  134. package/es/components/react-hook-form/error-management/error-input.js +0 -50
  135. package/es/components/react-hook-form/error-management/field-error-alert.js +0 -22
  136. package/es/components/react-hook-form/error-management/mid-form-error.js +0 -25
  137. package/es/components/react-hook-form/numbers/float-input.js +0 -105
  138. package/es/components/react-hook-form/numbers/integer-input.js +0 -35
  139. package/es/components/react-hook-form/numbers/utils.js +0 -6
  140. package/es/components/react-hook-form/radio-input.js +0 -55
  141. package/es/components/react-hook-form/select-input.js +0 -40
  142. package/es/components/react-hook-form/slider-input.js +0 -48
  143. package/es/components/react-hook-form/text-input.js +0 -100
  144. package/es/components/react-hook-form/utils/cancel-button.js +0 -28
  145. package/es/components/react-hook-form/utils/field-label.js +0 -15
  146. package/es/components/react-hook-form/utils/functions.js +0 -42
  147. package/es/components/react-hook-form/utils/submit-button.js +0 -29
  148. package/es/components/react-hook-form/utils/text-field-with-adornment.js +0 -92
  149. package/es/components/translations/card-error-boundary-en.js +0 -13
  150. package/es/components/translations/card-error-boundary-fr.js +0 -13
  151. package/es/components/translations/common-button-en.js +0 -12
  152. package/es/components/translations/common-button-fr.js +0 -12
  153. package/es/components/translations/element-search-en.js +0 -12
  154. package/es/components/translations/element-search-fr.js +0 -12
  155. package/es/components/translations/equipment-search-en.js +0 -26
  156. package/es/components/translations/equipment-search-fr.js +0 -26
  157. package/es/components/translations/flat-parameters-en.js +0 -13
  158. package/es/components/translations/flat-parameters-fr.js +0 -13
  159. package/es/components/translations/inputs-en.js +0 -25
  160. package/es/components/translations/inputs-fr.js +0 -25
  161. package/es/components/translations/login-en.js +0 -19
  162. package/es/components/translations/login-fr.js +0 -19
  163. package/es/components/translations/multiple-selection-dialog-en.js +0 -13
  164. package/es/components/translations/multiple-selection-dialog-fr.js +0 -13
  165. package/es/components/translations/report-viewer-en.js +0 -13
  166. package/es/components/translations/report-viewer-fr.js +0 -13
  167. package/es/components/translations/table-en.js +0 -11
  168. package/es/components/translations/table-fr.js +0 -11
  169. package/es/components/translations/top-bar-en.js +0 -32
  170. package/es/components/translations/top-bar-fr.js +0 -32
  171. package/es/components/translations/treeview-finder-en.js +0 -17
  172. package/es/components/translations/treeview-finder-fr.js +0 -17
  173. package/es/hooks/useDebounce.js +0 -26
  174. package/es/hooks/useIntlRef.js +0 -22
  175. package/es/hooks/useSnackMessage.js +0 -81
  176. package/es/index.js +0 -71
  177. package/es/utils/AuthService.js +0 -312
  178. package/es/utils/ElementType.js +0 -53
  179. package/es/utils/EquipmentType.js +0 -133
  180. package/es/utils/UserManagerMock.js +0 -81
  181. package/es/utils/actions.js +0 -65
  182. package/es/utils/algos.js +0 -29
  183. package/es/utils/styles.js +0 -35
@@ -1,25 +0,0 @@
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;
@@ -1,105 +0,0 @@
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
-
13
- // toLocaleString never uses exponential notation unlike toString. Avoiding
14
- // exponential notation makes in place normalizing of numbers after each
15
- // keystroke less intrusive: we can almost always normalize to a number that
16
- // uses the same string representation as the intermediate text that the user
17
- // typed. For example, if the user wants to input "625", they will write "6"
18
- // and then "62" and then "625". The intermediate strings are numbers that have
19
- // nothing in common with the final number but their normalization is the
20
- // same as what was typed by the user. With exponential notation, if the user
21
- // wants to input "12.5e21", at the intermediate step of "12.5e2" their input
22
- // is normalized to "1.25e3" and after adding the final "1" they get "12.5e31"
23
- // instead of "12.5e21".
24
- // Note: with 16+ digits, two small problems in the current implementation appear:
25
- // - rounding due to precision causes the cursor to jump at the end.
26
- // - rounding due to precision causes the last digits of the number to jiggle.
27
- // These two problems should be fixable with manual rounding and cursor
28
- // handling if we need it.
29
- var normalizeFixed = function normalizeFixed(number) {
30
- return number.toLocaleString('en-US', {
31
- maximumFractionDigits: 20,
32
- useGrouping: false
33
- });
34
- };
35
- var FloatInput = function FloatInput(props) {
36
- var inputTransform = function inputTransform(value) {
37
- if (typeof value == 'number' && !isNaN(value)) {
38
- // if we have a parsed real number, normalize like we do after each
39
- // keystroke in outputTransform for consistency. We get parsed
40
- // numbers when the data doesn't come from a user edit in the form,
41
- // but from data persisted as a float.
42
- return normalizeFixed(value);
43
- } else {
44
- // The user is editing, leave as is because we already did what we
45
- // need to do in outputTransform after the previous keystroke.
46
- // NOTE: To avoid "bad things" we haven't predicted and be extra
47
- // cautious, we clear the text on NaN, so we need to special case
48
- // known inputs that would be rejected by isNaN but are accepted by
49
- // our acceptValue because they are needed as intermediate strings
50
- // for the user to input useful numbers.
51
- // TODO can we remove the isNaN check and the special cases check?
52
- if (['-', '.'].includes(value)) {
53
- return value;
54
- }
55
- return value === null || isNaN(value) ? '' : value;
56
- }
57
- };
58
- var outputTransform = function outputTransform(value) {
59
- if (value === '-') {
60
- return value;
61
- }
62
- if (value === '') {
63
- return null;
64
- }
65
- var tmp = (value === null || value === void 0 ? void 0 : value.replace(',', '.')) || '';
66
-
67
- // Can't show the normalization to the user when the fractional part
68
- // ends with 0 because normalizing removes the trailing zeroes and prevents
69
- // inputting the required intermediate strings (e.g "1." or "1.0" to input "1.02")
70
- // So we return the user string instead. This has the downside that
71
- // when the user finally writes a non 0 digit at the end, the normalization takes place
72
- // and may startle the user when changing a lot of its input text.
73
- // For example:
74
- // - "1.00000000000000000000000000" and then press any non zero digit
75
- // removes all the zeroes at once
76
- // - "1." or "1.0" and then left arrow to move the cursor to the left and then inputting many digits
77
- // disables all normalization, can write huge numbers that are not rounded like
78
- // - 1231231231241231241231245123124234234123123124234.
79
- // vs 1231231231241231300000000000000000000000000000000
80
- // - 1.4312322342321323434534234235234
81
- // vs 1.4312322342321324
82
- // Note: this is a symmetric problem inputting many zeros
83
- // to the left of a number to allow to input a final leading nonzero
84
- // digit, but users never want to do that, unlike inputting trailing zeroes in the
85
- // fractional part before inputing the final trailing non zero digit
86
- if (tmp.endsWith('.') || tmp.includes('.') && tmp.endsWith('0')) {
87
- return tmp;
88
- }
89
-
90
- // normalize after each user keystroke, needs to be very unintrusive
91
- // otherwise users are surprised when typing doesn't do what they want
92
- // NOTE: the parse should always succeed and produce non-NaN because we
93
- // restrict what the user can type with "acceptValue" but if we
94
- // have a bug just clear the data instead of sending "NaN"
95
- var parsed = parseFloat(tmp);
96
- return isNaN(parsed) ? null : normalizeFixed(parsed);
97
- };
98
- return /*#__PURE__*/React.createElement(TextInput, _extends({
99
- acceptValue: isFloatNumber,
100
- outputTransform: outputTransform,
101
- inputTransform: inputTransform
102
- }, props));
103
- };
104
- FloatInput.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, TextInput.propTypes) : {};
105
- export default FloatInput;
@@ -1,35 +0,0 @@
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;
@@ -1,6 +0,0 @@
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
- };
@@ -1,55 +0,0 @@
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;
@@ -1,40 +0,0 @@
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;
@@ -1,48 +0,0 @@
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;
@@ -1,100 +0,0 @@
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;
@@ -1,28 +0,0 @@
1
- function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
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
- /**
4
- * Copyright (c) 2023, RTE (http://www.rte-france.com)
5
- * This Source Code Form is subject to the terms of the Mozilla Public
6
- * License, v. 2.0. If a copy of the MPL was not distributed with this
7
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
- */
9
-
10
- import React from 'react';
11
- import { Button } from '@mui/material';
12
- import { FormattedMessage } from 'react-intl';
13
- import PropTypes from 'prop-types';
14
- import { useThemeProps } from '@mui/material/styles';
15
- var CancelButton = function CancelButton(_ref) {
16
- var inProps = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
17
- var props = useThemeProps({
18
- props: inProps,
19
- name: 'CancelButton'
20
- });
21
- return /*#__PURE__*/React.createElement(Button, props, /*#__PURE__*/React.createElement(FormattedMessage, {
22
- id: "cancel"
23
- }));
24
- };
25
- CancelButton.propTypes = process.env.NODE_ENV !== "production" ? {
26
- buttonProps: PropTypes.object
27
- } : {};
28
- export default CancelButton;
@@ -1,15 +0,0 @@
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;
@@ -1,42 +0,0 @@
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
- };
@@ -1,29 +0,0 @@
1
- function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
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
- /**
4
- * Copyright (c) 2022, RTE (http://www.rte-france.com)
5
- * This Source Code Form is subject to the terms of the Mozilla Public
6
- * License, v. 2.0. If a copy of the MPL was not distributed with this
7
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
- */
9
-
10
- import React from 'react';
11
- import { Button } from '@mui/material';
12
- import { useFormState } from 'react-hook-form';
13
- import { FormattedMessage } from 'react-intl';
14
- import PropTypes from 'prop-types';
15
- var SubmitButton = function SubmitButton(_ref) {
16
- var _buttonProps$disabled;
17
- var buttonProps = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
18
- var _useFormState = useFormState(),
19
- isDirty = _useFormState.isDirty;
20
- return /*#__PURE__*/React.createElement(Button, _extends({}, buttonProps, {
21
- disabled: !isDirty || ((_buttonProps$disabled = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.disabled) !== null && _buttonProps$disabled !== void 0 ? _buttonProps$disabled : false)
22
- }), /*#__PURE__*/React.createElement(FormattedMessage, {
23
- id: "validate"
24
- }));
25
- };
26
- SubmitButton.propTypes = process.env.NODE_ENV !== "production" ? {
27
- buttonProps: PropTypes.object
28
- } : {};
29
- export default SubmitButton;
@@ -1,92 +0,0 @@
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,13 +0,0 @@
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 card_error_boundary_en = {
9
- 'card_error_boundary/title': 'Sorry, unexpected error :(',
10
- 'card_error_boundary/content': 'Please reload, or close and reopen this application, or contact support.',
11
- 'card_error_boundary/expandederrorheader': 'Error message (and see more information in the developper console):'
12
- };
13
- export default card_error_boundary_en;
@@ -1,13 +0,0 @@
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 card_error_boundary_fr = {
9
- 'card_error_boundary/title': 'Désolé, erreur inattendue :(',
10
- 'card_error_boundary/content': 'Veuillez recharger, ou fermer et réouvrir cette application, ou contacter le support.',
11
- 'card_error_boundary/expandederrorheader': "Message d'erreur (et voir plus d'informations dans la console developpeur):"
12
- };
13
- export default card_error_boundary_fr;