@gridsuite/commons-ui 0.46.0 → 0.48.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.
- package/README.md +0 -17
- package/dist/components/AuthenticationRouter/AuthenticationRouter.d.ts +10 -0
- package/dist/components/AuthenticationRouter/AuthenticationRouter.js +147 -0
- package/dist/components/AuthenticationRouter/index.d.ts +1 -0
- package/dist/components/CardErrorBoundary/card-error-boundary.d.ts +18 -0
- package/dist/components/CardErrorBoundary/card-error-boundary.js +110 -0
- package/dist/components/CardErrorBoundary/index.d.ts +1 -0
- package/dist/components/DirectoryItemSelector/directory-item-selector.d.ts +22 -0
- package/dist/components/DirectoryItemSelector/directory-item-selector.js +254 -0
- package/dist/components/ElementSearchDialog/element-search-dialog.d.ts +16 -0
- package/dist/components/ElementSearchDialog/element-search-dialog.js +139 -0
- package/dist/components/ElementSearchDialog/equipment-item.d.ts +16 -0
- package/dist/components/ElementSearchDialog/equipment-item.js +77 -0
- package/dist/components/ElementSearchDialog/index.d.ts +2 -0
- package/dist/components/ElementSearchDialog/tag-renderer.d.ts +11 -0
- package/dist/components/ElementSearchDialog/tag-renderer.js +34 -0
- package/dist/components/FlatParameters/FlatParameters.d.ts +10 -0
- package/dist/components/FlatParameters/FlatParameters.js +411 -0
- package/dist/components/FlatParameters/index.d.ts +1 -0
- package/dist/components/Login/Login.d.ts +5 -0
- package/dist/components/Login/Login.js +78 -0
- package/dist/components/Login/Logout.d.ts +5 -0
- package/dist/components/Login/Logout.js +69 -0
- package/dist/components/Login/index.d.ts +1 -0
- package/dist/components/MuiVirtualizedTable/ColumnHeader.d.ts +4 -0
- package/dist/components/MuiVirtualizedTable/ColumnHeader.js +127 -0
- package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.d.ts +104 -0
- package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +548 -0
- package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.d.ts +131 -0
- package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.js +790 -0
- package/dist/components/MuiVirtualizedTable/index.d.ts +2 -0
- package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.d.ts +10 -0
- package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.js +87 -0
- package/dist/components/MultipleSelectionDialog/index.d.ts +1 -0
- package/dist/components/OverflowableText/index.d.ts +1 -0
- package/dist/components/OverflowableText/overflowable-text.d.ts +2 -0
- package/dist/components/OverflowableText/overflowable-text.js +87 -0
- package/dist/components/ReportViewer/filter-button.d.ts +1 -0
- package/dist/components/ReportViewer/filter-button.js +64 -0
- package/dist/components/ReportViewer/index.d.ts +1 -0
- package/dist/components/ReportViewer/log-report-item.d.ts +68 -0
- package/dist/components/ReportViewer/log-report-item.js +95 -0
- package/dist/components/ReportViewer/log-report.d.ts +21 -0
- package/dist/components/ReportViewer/log-report.js +49 -0
- package/dist/components/ReportViewer/log-table.d.ts +8 -0
- package/dist/components/ReportViewer/log-table.js +131 -0
- package/dist/components/ReportViewer/multi-select-list.d.ts +1 -0
- package/dist/components/ReportViewer/multi-select-list.js +40 -0
- package/dist/components/ReportViewer/report-item.d.ts +13 -0
- package/dist/components/ReportViewer/report-item.js +112 -0
- package/dist/components/ReportViewer/report-tree-view-context.d.ts +2 -0
- package/dist/components/ReportViewer/report-tree-view-context.js +8 -0
- package/dist/components/ReportViewer/report-viewer.d.ts +4 -0
- package/dist/components/ReportViewer/report-viewer.js +158 -0
- package/dist/components/ReportViewerDialog/index.d.ts +1 -0
- package/dist/components/ReportViewerDialog/report-viewer-dialog.d.ts +1 -0
- package/dist/components/ReportViewerDialog/report-viewer-dialog.js +61 -0
- package/dist/components/SignInCallbackHandler/SignInCallbackHandler.d.ts +5 -0
- package/dist/components/SignInCallbackHandler/SignInCallbackHandler.js +13 -0
- package/dist/components/SignInCallbackHandler/index.d.ts +1 -0
- package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.d.ts +5 -0
- package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +16 -0
- package/dist/components/SilentRenewCallbackHandler/index.d.ts +1 -0
- package/dist/components/SnackbarProvider/SnackbarProvider.d.ts +3 -0
- package/dist/components/SnackbarProvider/SnackbarProvider.js +28 -0
- package/dist/components/SnackbarProvider/index.d.ts +1 -0
- package/dist/components/TopBar/AboutDialog.d.ts +24 -0
- package/dist/components/TopBar/AboutDialog.js +467 -0
- package/dist/components/TopBar/GridLogo.d.ts +34 -0
- package/dist/components/TopBar/GridLogo.js +71 -0
- package/dist/components/TopBar/TopBar.d.ts +53 -0
- package/dist/components/TopBar/TopBar.js +679 -0
- package/dist/components/TopBar/index.d.ts +3 -0
- package/dist/components/TreeViewFinder/TreeViewFinder.d.ts +57 -0
- package/dist/components/TreeViewFinder/TreeViewFinder.js +288 -0
- package/dist/components/TreeViewFinder/index.d.ts +1 -0
- package/dist/components/react-hook-form/autocomplete-input.d.ts +30 -0
- package/dist/components/react-hook-form/autocomplete-input.js +96 -0
- package/dist/components/react-hook-form/booleans/boolean-input.d.ts +16 -0
- package/dist/components/react-hook-form/booleans/boolean-input.js +49 -0
- package/dist/components/react-hook-form/booleans/checkbox-input.d.ts +14 -0
- package/dist/components/react-hook-form/booleans/checkbox-input.js +24 -0
- package/dist/components/react-hook-form/booleans/switch-input.d.ts +14 -0
- package/dist/components/react-hook-form/booleans/switch-input.js +24 -0
- package/dist/components/react-hook-form/directory-items-input.d.ts +28 -0
- package/dist/components/react-hook-form/directory-items-input.js +185 -0
- package/dist/components/react-hook-form/error-management/error-input.d.ts +5 -0
- package/dist/components/react-hook-form/error-management/error-input.js +42 -0
- package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +4 -0
- package/dist/components/react-hook-form/error-management/field-error-alert.js +9 -0
- package/dist/components/react-hook-form/error-management/mid-form-error.d.ts +4 -0
- package/dist/components/react-hook-form/error-management/mid-form-error.js +20 -0
- package/dist/components/react-hook-form/numbers/float-input.d.ts +18 -0
- package/dist/components/react-hook-form/numbers/float-input.js +51 -0
- package/dist/components/react-hook-form/numbers/integer-input.d.ts +18 -0
- package/dist/components/react-hook-form/numbers/integer-input.js +36 -0
- package/dist/components/react-hook-form/numbers/utils.d.ts +2 -0
- package/dist/components/react-hook-form/numbers/utils.js +10 -0
- package/dist/components/react-hook-form/radio-input.d.ts +18 -0
- package/dist/components/react-hook-form/radio-input.js +44 -0
- package/{es/components/MultipleSelectionDialog/index.js → dist/components/react-hook-form/raw-read-only-input.d.ts} +3 -2
- package/dist/components/react-hook-form/raw-read-only-input.js +10 -0
- package/dist/components/react-hook-form/select-input.d.ts +17 -0
- package/dist/components/react-hook-form/select-input.js +31 -0
- package/dist/components/react-hook-form/slider-input.d.ts +21 -0
- package/dist/components/react-hook-form/slider-input.js +43 -0
- package/dist/components/react-hook-form/text-input.d.ts +33 -0
- package/dist/components/react-hook-form/text-input.js +94 -0
- package/dist/components/react-hook-form/utils/cancel-button.d.ts +10 -0
- package/dist/components/react-hook-form/utils/cancel-button.js +16 -0
- package/dist/components/react-hook-form/utils/field-label.d.ts +6 -0
- package/dist/components/react-hook-form/utils/field-label.js +12 -0
- package/dist/components/react-hook-form/utils/functions.d.ts +11 -0
- package/dist/components/react-hook-form/utils/functions.js +41 -0
- package/dist/components/react-hook-form/utils/submit-button.d.ts +10 -0
- package/dist/components/react-hook-form/utils/submit-button.js +23 -0
- package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +12 -0
- package/dist/components/react-hook-form/utils/text-field-with-adornment.js +96 -0
- package/{es/components/translations/report-viewer-fr.js → dist/components/translations/card-error-boundary-en.d.ts} +5 -6
- package/dist/components/translations/card-error-boundary-en.js +8 -0
- package/dist/components/translations/card-error-boundary-fr.d.ts +12 -0
- package/dist/components/translations/card-error-boundary-fr.js +8 -0
- package/dist/components/translations/common-button-en.d.ts +5 -0
- package/dist/components/translations/common-button-en.js +7 -0
- package/dist/components/translations/common-button-fr.d.ts +5 -0
- package/dist/components/translations/common-button-fr.js +7 -0
- package/{es/components/translations/element-search-en.js → dist/components/translations/element-search-en.d.ts} +4 -5
- package/dist/components/translations/element-search-en.js +7 -0
- package/dist/components/translations/element-search-fr.d.ts +11 -0
- package/dist/components/translations/element-search-fr.js +7 -0
- package/dist/components/translations/equipment-search-en.d.ts +25 -0
- package/dist/components/translations/equipment-search-en.js +21 -0
- package/dist/components/translations/equipment-search-fr.d.ts +25 -0
- package/dist/components/translations/equipment-search-fr.js +21 -0
- package/{es/components/translations/flat-parameters-en.js → dist/components/translations/flat-parameters-en.d.ts} +5 -6
- package/dist/components/translations/flat-parameters-en.js +8 -0
- package/{es/components/translations/common-button-en.js → dist/components/translations/flat-parameters-fr.d.ts} +5 -5
- package/dist/components/translations/flat-parameters-fr.js +8 -0
- package/dist/components/translations/login-en.d.ts +18 -0
- package/dist/components/translations/login-en.js +14 -0
- package/dist/components/translations/login-fr.d.ts +18 -0
- package/dist/components/translations/login-fr.js +14 -0
- package/{es/components/translations/flat-parameters-fr.js → dist/components/translations/multiple-selection-dialog-en.d.ts} +5 -6
- package/dist/components/translations/multiple-selection-dialog-en.js +8 -0
- package/{es/components/translations/common-button-fr.js → dist/components/translations/multiple-selection-dialog-fr.d.ts} +5 -5
- package/dist/components/translations/multiple-selection-dialog-fr.js +8 -0
- package/{es/components/translations/report-viewer-en.js → dist/components/translations/report-viewer-en.d.ts} +5 -6
- package/dist/components/translations/report-viewer-en.js +8 -0
- package/{es/components/translations/element-search-fr.js → dist/components/translations/report-viewer-fr.d.ts} +5 -5
- package/dist/components/translations/report-viewer-fr.js +8 -0
- package/{es/components/translations/table-en.js → dist/components/translations/table-en.d.ts} +3 -4
- package/dist/components/translations/table-en.js +6 -0
- package/{es/components/translations/table-fr.js → dist/components/translations/table-fr.d.ts} +3 -4
- package/dist/components/translations/table-fr.js +6 -0
- package/dist/components/translations/top-bar-en.d.ts +31 -0
- package/dist/components/translations/top-bar-en.js +27 -0
- package/dist/components/translations/top-bar-fr.d.ts +31 -0
- package/dist/components/translations/top-bar-fr.js +27 -0
- package/dist/components/translations/treeview-finder-en.d.ts +16 -0
- package/dist/components/translations/treeview-finder-en.js +12 -0
- package/dist/components/translations/treeview-finder-fr.d.ts +16 -0
- package/dist/components/translations/treeview-finder-fr.js +12 -0
- package/dist/hooks/useDebounce.d.ts +1 -0
- package/dist/hooks/useDebounce.js +17 -0
- package/{es/components/ElementSearchDialog/index.js → dist/hooks/useIntlRef.d.ts} +2 -2
- package/dist/hooks/useIntlRef.js +13 -0
- package/dist/hooks/useSnackMessage.d.ts +5 -0
- package/dist/hooks/useSnackMessage.js +81 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.js +158 -0
- package/dist/utils/AuthService.d.ts +9 -0
- package/dist/utils/AuthService.js +336 -0
- package/dist/utils/ElementType.d.ts +13 -0
- package/dist/utils/ElementType.js +42 -0
- package/dist/utils/EquipmentType.d.ts +136 -0
- package/dist/utils/EquipmentType.js +132 -0
- package/dist/utils/UserManagerMock.d.ts +34 -0
- package/dist/utils/UserManagerMock.js +85 -0
- package/dist/utils/actions.d.ts +50 -0
- package/dist/utils/actions.js +71 -0
- package/{es/components/CardErrorBoundary/index.js → dist/utils/algos.d.ts} +1 -1
- package/dist/utils/algos.js +24 -0
- package/dist/utils/styles.d.ts +5 -0
- package/dist/utils/styles.js +13 -0
- package/package.json +36 -21
- package/es/components/AuthenticationRouter/AuthenticationRouter.js +0 -102
- package/es/components/AuthenticationRouter/index.js +0 -7
- package/es/components/CardErrorBoundary/card-error-boundary.js +0 -138
- package/es/components/ElementSearchDialog/element-search-dialog.js +0 -153
- package/es/components/ElementSearchDialog/equipment-item.js +0 -63
- package/es/components/ElementSearchDialog/tag-renderer.js +0 -29
- package/es/components/FlatParameters/FlatParameters.js +0 -448
- package/es/components/FlatParameters/index.js +0 -8
- package/es/components/Login/Login.js +0 -79
- package/es/components/Login/Logout.js +0 -78
- package/es/components/Login/index.js +0 -7
- package/es/components/MuiVirtualizedTable/ColumnHeader.js +0 -125
- package/es/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -619
- package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +0 -780
- package/es/components/MuiVirtualizedTable/index.js +0 -9
- package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +0 -95
- package/es/components/OverflowableText/index.js +0 -7
- package/es/components/OverflowableText/overflowable-text.js +0 -81
- package/es/components/ReportViewer/filter-button.js +0 -77
- package/es/components/ReportViewer/index.js +0 -7
- package/es/components/ReportViewer/log-report-item.js +0 -97
- package/es/components/ReportViewer/log-report.js +0 -63
- package/es/components/ReportViewer/log-table.js +0 -130
- package/es/components/ReportViewer/multi-select-list.js +0 -56
- package/es/components/ReportViewer/report-item.js +0 -131
- package/es/components/ReportViewer/report-tree-view-context.js +0 -13
- package/es/components/ReportViewer/report-viewer.js +0 -167
- package/es/components/ReportViewerDialog/index.js +0 -7
- package/es/components/ReportViewerDialog/report-viewer-dialog.js +0 -67
- package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -19
- package/es/components/SignInCallbackHandler/index.js +0 -7
- package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -19
- package/es/components/SilentRenewCallbackHandler/index.js +0 -7
- package/es/components/SnackbarProvider/SnackbarProvider.js +0 -39
- package/es/components/SnackbarProvider/index.js +0 -7
- package/es/components/TopBar/AboutDialog.js +0 -456
- package/es/components/TopBar/GridLogo.js +0 -73
- package/es/components/TopBar/TopBar.js +0 -487
- package/es/components/TopBar/index.js +0 -9
- package/es/components/TreeViewFinder/TreeViewFinder.js +0 -341
- package/es/components/TreeViewFinder/index.js +0 -7
- package/es/components/images/powsybl_logo.svg +0 -35
- package/es/components/react-hook-form/autocomplete-input.js +0 -110
- package/es/components/react-hook-form/booleans/boolean-input.js +0 -56
- package/es/components/react-hook-form/booleans/checkbox-input.js +0 -28
- package/es/components/react-hook-form/booleans/switch-input.js +0 -28
- package/es/components/react-hook-form/error-management/error-input.js +0 -50
- package/es/components/react-hook-form/error-management/field-error-alert.js +0 -22
- package/es/components/react-hook-form/error-management/mid-form-error.js +0 -25
- package/es/components/react-hook-form/numbers/float-input.js +0 -105
- package/es/components/react-hook-form/numbers/integer-input.js +0 -35
- package/es/components/react-hook-form/numbers/utils.js +0 -6
- package/es/components/react-hook-form/radio-input.js +0 -55
- package/es/components/react-hook-form/select-input.js +0 -40
- package/es/components/react-hook-form/slider-input.js +0 -48
- package/es/components/react-hook-form/text-input.js +0 -100
- package/es/components/react-hook-form/utils/cancel-button.js +0 -28
- package/es/components/react-hook-form/utils/field-label.js +0 -15
- package/es/components/react-hook-form/utils/functions.js +0 -42
- package/es/components/react-hook-form/utils/submit-button.js +0 -29
- package/es/components/react-hook-form/utils/text-field-with-adornment.js +0 -92
- package/es/components/translations/card-error-boundary-en.js +0 -13
- package/es/components/translations/card-error-boundary-fr.js +0 -13
- package/es/components/translations/equipment-search-en.js +0 -26
- package/es/components/translations/equipment-search-fr.js +0 -26
- package/es/components/translations/inputs-en.js +0 -25
- package/es/components/translations/inputs-fr.js +0 -25
- package/es/components/translations/login-en.js +0 -19
- package/es/components/translations/login-fr.js +0 -19
- package/es/components/translations/multiple-selection-dialog-en.js +0 -13
- package/es/components/translations/multiple-selection-dialog-fr.js +0 -13
- package/es/components/translations/top-bar-en.js +0 -32
- package/es/components/translations/top-bar-fr.js +0 -32
- package/es/components/translations/treeview-finder-en.js +0 -17
- package/es/components/translations/treeview-finder-fr.js +0 -17
- package/es/hooks/useDebounce.js +0 -26
- package/es/hooks/useIntlRef.js +0 -22
- package/es/hooks/useSnackMessage.js +0 -81
- package/es/index.js +0 -71
- package/es/utils/AuthService.js +0 -312
- package/es/utils/ElementType.js +0 -53
- package/es/utils/EquipmentType.js +0 -133
- package/es/utils/UserManagerMock.js +0 -81
- package/es/utils/actions.js +0 -65
- package/es/utils/algos.js +0 -29
- 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,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;
|