@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,153 +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) 2021, RTE (http://www.rte-france.com)
|
|
4
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
5
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
10
|
-
import { Autocomplete, Dialog, DialogContent, TextField } from '@mui/material';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
|
-
import { Search, SearchOff } from '@mui/icons-material';
|
|
13
|
-
import { useIntl } from 'react-intl';
|
|
14
|
-
var ElementSearchDialog = function ElementSearchDialog(props) {
|
|
15
|
-
var intl = useIntl();
|
|
16
|
-
var open = props.open,
|
|
17
|
-
onClose = props.onClose,
|
|
18
|
-
searchingLabel = props.searchingLabel,
|
|
19
|
-
onSearchTermChange = props.onSearchTermChange,
|
|
20
|
-
onSelectionChange = props.onSelectionChange,
|
|
21
|
-
elementsFound = props.elementsFound,
|
|
22
|
-
renderElement = props.renderElement,
|
|
23
|
-
searchTermDisabled = props.searchTermDisabled,
|
|
24
|
-
searchTermDisableReason = props.searchTermDisableReason;
|
|
25
|
-
var _useState = useState(false),
|
|
26
|
-
expanded = _useState[0],
|
|
27
|
-
setExpanded = _useState[1];
|
|
28
|
-
var _useState2 = useState(searchTermDisabled && searchTermDisableReason ? {
|
|
29
|
-
label: searchTermDisableReason
|
|
30
|
-
} : null),
|
|
31
|
-
value = _useState2[0],
|
|
32
|
-
setValue = _useState2[1];
|
|
33
|
-
var _useState3 = useState(false),
|
|
34
|
-
loading = _useState3[0],
|
|
35
|
-
setLoading = _useState3[1];
|
|
36
|
-
useEffect(function () {
|
|
37
|
-
setLoading(false);
|
|
38
|
-
}, [elementsFound]);
|
|
39
|
-
useEffect(function () {
|
|
40
|
-
if (!searchTermDisabled || !searchTermDisableReason) {
|
|
41
|
-
setValue(null);
|
|
42
|
-
} else {
|
|
43
|
-
setValue({
|
|
44
|
-
label: searchTermDisableReason
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}, [searchTermDisabled, searchTermDisableReason]);
|
|
48
|
-
|
|
49
|
-
// to reset the value between the dialog closing and opening
|
|
50
|
-
useEffect(function () {
|
|
51
|
-
setValue(function (old) {
|
|
52
|
-
return !open ? null : old;
|
|
53
|
-
});
|
|
54
|
-
}, [open]);
|
|
55
|
-
var handleSearchTermChange = function handleSearchTermChange(term) {
|
|
56
|
-
if (term) {
|
|
57
|
-
setLoading(true);
|
|
58
|
-
onSearchTermChange(term);
|
|
59
|
-
setExpanded(true);
|
|
60
|
-
setValue({
|
|
61
|
-
label: term
|
|
62
|
-
});
|
|
63
|
-
} else {
|
|
64
|
-
setExpanded(false);
|
|
65
|
-
setValue(null);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var handleClose = useCallback(function () {
|
|
69
|
-
setValue(null);
|
|
70
|
-
setExpanded(false);
|
|
71
|
-
onClose();
|
|
72
|
-
}, [onClose]);
|
|
73
|
-
return /*#__PURE__*/React.createElement(Dialog, {
|
|
74
|
-
open: open,
|
|
75
|
-
onClose: handleClose,
|
|
76
|
-
disableRestoreFocus: true,
|
|
77
|
-
"aria-labelledby": "dialog-title-search",
|
|
78
|
-
fullWidth: true
|
|
79
|
-
}, /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(Autocomplete, {
|
|
80
|
-
id: "element-search",
|
|
81
|
-
forcePopupIcon: false,
|
|
82
|
-
open: expanded,
|
|
83
|
-
onClose: function onClose() {
|
|
84
|
-
setExpanded(false);
|
|
85
|
-
},
|
|
86
|
-
fullWidth: true,
|
|
87
|
-
freeSolo: true,
|
|
88
|
-
clearOnBlur: true,
|
|
89
|
-
onInputChange: function onInputChange(_event, value) {
|
|
90
|
-
if (!searchTermDisabled) {
|
|
91
|
-
handleSearchTermChange(value);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
onChange: function onChange(_event, newValue, reason) {
|
|
95
|
-
if (reason === 'selectOption') {
|
|
96
|
-
onSelectionChange(newValue);
|
|
97
|
-
setValue(newValue);
|
|
98
|
-
} else {
|
|
99
|
-
setValue(null);
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
getOptionLabel: function getOptionLabel(option) {
|
|
103
|
-
return option.label;
|
|
104
|
-
},
|
|
105
|
-
isOptionEqualToValue: function isOptionEqualToValue(option, value) {
|
|
106
|
-
return option.id === value.id;
|
|
107
|
-
},
|
|
108
|
-
options: loading ? [] : elementsFound,
|
|
109
|
-
loading: loading,
|
|
110
|
-
autoHighlight: true,
|
|
111
|
-
noOptionsText: intl.formatMessage({
|
|
112
|
-
id: 'element_search/noResult'
|
|
113
|
-
}),
|
|
114
|
-
renderOption: function renderOption(optionProps, element, _ref) {
|
|
115
|
-
var inputValue = _ref.inputValue;
|
|
116
|
-
return renderElement(_extends({}, optionProps, {
|
|
117
|
-
element: element,
|
|
118
|
-
inputValue: inputValue,
|
|
119
|
-
onClose: handleClose
|
|
120
|
-
}));
|
|
121
|
-
},
|
|
122
|
-
renderInput: function renderInput(params) {
|
|
123
|
-
return /*#__PURE__*/React.createElement(TextField, _extends({
|
|
124
|
-
autoFocus: true
|
|
125
|
-
}, params, {
|
|
126
|
-
label: searchingLabel || intl.formatMessage({
|
|
127
|
-
id: 'element_search/label'
|
|
128
|
-
}),
|
|
129
|
-
InputProps: _extends({}, params.InputProps, {
|
|
130
|
-
startAdornment: /*#__PURE__*/React.createElement(React.Fragment, null, searchTermDisabled ? /*#__PURE__*/React.createElement(SearchOff, {
|
|
131
|
-
color: "disabled"
|
|
132
|
-
}) : /*#__PURE__*/React.createElement(Search, {
|
|
133
|
-
color: "disabled"
|
|
134
|
-
}), params.InputProps.startAdornment)
|
|
135
|
-
})
|
|
136
|
-
}));
|
|
137
|
-
},
|
|
138
|
-
value: value,
|
|
139
|
-
disabled: searchTermDisabled
|
|
140
|
-
})));
|
|
141
|
-
};
|
|
142
|
-
ElementSearchDialog.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
143
|
-
open: PropTypes.bool.isRequired,
|
|
144
|
-
onClose: PropTypes.func.isRequired,
|
|
145
|
-
searchingLabel: PropTypes.string,
|
|
146
|
-
onSearchTermChange: PropTypes.func.isRequired,
|
|
147
|
-
onSelectionChange: PropTypes.func.isRequired,
|
|
148
|
-
elementsFound: PropTypes.array.isRequired,
|
|
149
|
-
renderElement: PropTypes.func.isRequired,
|
|
150
|
-
searchTermDisabled: PropTypes.bool,
|
|
151
|
-
searchTermDisableReason: PropTypes.string
|
|
152
|
-
} : {};
|
|
153
|
-
export default ElementSearchDialog;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
var _excluded = ["inputValue", "suffixRenderer", "element", "showsJustText"];
|
|
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) 2022, 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
|
-
import { TagRenderer } from './index';
|
|
11
|
-
import match from 'autosuggest-highlight/match';
|
|
12
|
-
import parse from 'autosuggest-highlight/parse';
|
|
13
|
-
import clsx from 'clsx';
|
|
14
|
-
import { FormattedMessage } from 'react-intl';
|
|
15
|
-
import OverflowableText from '../OverflowableText';
|
|
16
|
-
import React from 'react';
|
|
17
|
-
import { EQUIPMENT_TYPE } from '../../utils/EquipmentType';
|
|
18
|
-
import Box from '@mui/material/Box';
|
|
19
|
-
import { mergeSx } from '../../utils/styles';
|
|
20
|
-
export var EquipmentItem = function EquipmentItem(_ref) {
|
|
21
|
-
var _props$classes, _props$styles, _props$classes2, _props$classes3, _props$styles2, _props$styles3, _props$classes4, _props$styles4;
|
|
22
|
-
var inputValue = _ref.inputValue,
|
|
23
|
-
_ref$suffixRenderer = _ref.suffixRenderer,
|
|
24
|
-
suffixRenderer = _ref$suffixRenderer === void 0 ? TagRenderer : _ref$suffixRenderer,
|
|
25
|
-
element = _ref.element,
|
|
26
|
-
_ref$showsJustText = _ref.showsJustText,
|
|
27
|
-
showsJustText = _ref$showsJustText === void 0 ? false : _ref$showsJustText,
|
|
28
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
29
|
-
var matches = match(element.label, inputValue, {
|
|
30
|
-
insideWords: true,
|
|
31
|
-
findAllOccurrences: true
|
|
32
|
-
});
|
|
33
|
-
var parts = parse(element.label, matches);
|
|
34
|
-
/* override li.key otherwise it will use label which could be duplicated */
|
|
35
|
-
return /*#__PURE__*/React.createElement("li", _extends({
|
|
36
|
-
key: element.key
|
|
37
|
-
}, props), /*#__PURE__*/React.createElement(Box, {
|
|
38
|
-
className: (_props$classes = props.classes) === null || _props$classes === void 0 ? void 0 : _props$classes.equipmentOption,
|
|
39
|
-
sx: (_props$styles = props.styles) === null || _props$styles === void 0 ? void 0 : _props$styles.equipmentOption
|
|
40
|
-
}, !showsJustText && /*#__PURE__*/React.createElement(Box, {
|
|
41
|
-
component: "span",
|
|
42
|
-
className: clsx((_props$classes2 = props.classes) === null || _props$classes2 === void 0 ? void 0 : _props$classes2.equipmentTag, (_props$classes3 = props.classes) === null || _props$classes3 === void 0 ? void 0 : _props$classes3.equipmentTypeTag),
|
|
43
|
-
sx: mergeSx((_props$styles2 = props.styles) === null || _props$styles2 === void 0 ? void 0 : _props$styles2.equipmentTag, (_props$styles3 = props.styles) === null || _props$styles3 === void 0 ? void 0 : _props$styles3.equipmentTypeTag)
|
|
44
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
45
|
-
id: EQUIPMENT_TYPE[element.type].tagLabel
|
|
46
|
-
})), /*#__PURE__*/React.createElement(OverflowableText, {
|
|
47
|
-
text: parts.map(function (e) {
|
|
48
|
-
return e.text;
|
|
49
|
-
}).join(),
|
|
50
|
-
className: (_props$classes4 = props.classes) === null || _props$classes4 === void 0 ? void 0 : _props$classes4.result,
|
|
51
|
-
sx: (_props$styles4 = props.styles) === null || _props$styles4 === void 0 ? void 0 : _props$styles4.result
|
|
52
|
-
}, parts.map(function (part, index) {
|
|
53
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
54
|
-
key: index,
|
|
55
|
-
style: {
|
|
56
|
-
fontWeight: part.highlight ? 'bold' : 'inherit'
|
|
57
|
-
}
|
|
58
|
-
}, part.text);
|
|
59
|
-
})), !showsJustText && suffixRenderer({
|
|
60
|
-
props: props,
|
|
61
|
-
element: element
|
|
62
|
-
})));
|
|
63
|
-
};
|
|
@@ -1,29 +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
|
-
import OverflowableText from '../OverflowableText';
|
|
8
|
-
import clsx from 'clsx';
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import { EQUIPMENT_TYPE } from '../../utils/EquipmentType';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
|
-
import { mergeSx } from '../../utils/styles';
|
|
13
|
-
export var TagRenderer = function TagRenderer(_ref) {
|
|
14
|
-
var props = _ref.props,
|
|
15
|
-
element = _ref.element;
|
|
16
|
-
if (element.type !== EQUIPMENT_TYPE.SUBSTATION.name && element.type !== EQUIPMENT_TYPE.VOLTAGE_LEVEL.name) {
|
|
17
|
-
var _props$classes, _props$classes2, _props$styles, _props$styles2;
|
|
18
|
-
return /*#__PURE__*/React.createElement(OverflowableText, {
|
|
19
|
-
text: element.voltageLevelLabel,
|
|
20
|
-
className: clsx((_props$classes = props.classes) === null || _props$classes === void 0 ? void 0 : _props$classes.equipmentTag, (_props$classes2 = props.classes) === null || _props$classes2 === void 0 ? void 0 : _props$classes2.equipmentVlTag),
|
|
21
|
-
sx: mergeSx((_props$styles = props.styles) === null || _props$styles === void 0 ? void 0 : _props$styles.equipmentTag, (_props$styles2 = props.styles) === null || _props$styles2 === void 0 ? void 0 : _props$styles2.equipmentVlTag)
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
25
|
-
};
|
|
26
|
-
TagRenderer.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
27
|
-
element: PropTypes.object,
|
|
28
|
-
props: PropTypes.object
|
|
29
|
-
} : {};
|
|
@@ -1,448 +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
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
-
/**
|
|
6
|
-
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
7
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
8
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
9
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import React, { useCallback, useState } from 'react';
|
|
13
|
-
import { Autocomplete, Chip, List, ListItem, MenuItem, Select, Switch, TextField, Tooltip, Typography, Divider, IconButton } from '@mui/material';
|
|
14
|
-
import TuneIcon from '@mui/icons-material/Tune';
|
|
15
|
-
import { FormattedMessage, useIntl } from 'react-intl';
|
|
16
|
-
import MultipleSelectionDialog from '../MultipleSelectionDialog/MultipleSelectionDialog';
|
|
17
|
-
var styles = {
|
|
18
|
-
paramList: {
|
|
19
|
-
width: '100%',
|
|
20
|
-
margin: 0
|
|
21
|
-
},
|
|
22
|
-
paramListItem: function paramListItem(theme) {
|
|
23
|
-
return {
|
|
24
|
-
display: 'flex',
|
|
25
|
-
justifyContent: 'space-between',
|
|
26
|
-
gap: theme.spacing(2),
|
|
27
|
-
paddingLeft: 0,
|
|
28
|
-
paddingRight: 0
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
paramName: {
|
|
32
|
-
fontWeight: 'bold',
|
|
33
|
-
minWidth: '30%',
|
|
34
|
-
overflowWrap: 'anywhere'
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var FloatRE = /^-?\d*[.,]?\d*([eE]-?\d*)?$/;
|
|
38
|
-
var IntegerRE = /^-?\d*$/;
|
|
39
|
-
var ListRE = /^\[(.*)]$/;
|
|
40
|
-
var sepRE = /[, ]/;
|
|
41
|
-
export function extractDefault(paramDescription) {
|
|
42
|
-
var d = paramDescription.defaultValue;
|
|
43
|
-
if (paramDescription.type === 'BOOLEAN') {
|
|
44
|
-
return !!d;
|
|
45
|
-
}
|
|
46
|
-
if (paramDescription.type === 'DOUBLE') {
|
|
47
|
-
return d - 0.0;
|
|
48
|
-
}
|
|
49
|
-
if (paramDescription.type === 'INTEGER') {
|
|
50
|
-
return d - 0;
|
|
51
|
-
}
|
|
52
|
-
if (paramDescription.type === 'STRING_LIST') {
|
|
53
|
-
if (Array.isArray(d)) {
|
|
54
|
-
return d;
|
|
55
|
-
}
|
|
56
|
-
var mo = ListRE.exec(d);
|
|
57
|
-
if ((mo === null || mo === void 0 ? void 0 : mo.length) > 1) {
|
|
58
|
-
return mo[1].split(sepRE).map(function (s) {
|
|
59
|
-
return s.trim();
|
|
60
|
-
}).filter(function (s) {
|
|
61
|
-
return !!s;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
return d !== null && d !== void 0 ? d : null;
|
|
67
|
-
}
|
|
68
|
-
function longestCommonPrefix(stringList) {
|
|
69
|
-
if (!(stringList === null || stringList === void 0 ? void 0 : stringList.length)) {
|
|
70
|
-
return '';
|
|
71
|
-
}
|
|
72
|
-
var prefix = stringList.reduce(function (acc, str) {
|
|
73
|
-
return str.length < acc.length ? str : acc;
|
|
74
|
-
});
|
|
75
|
-
for (var _iterator = _createForOfIteratorHelperLoose(stringList), _step; !(_step = _iterator()).done;) {
|
|
76
|
-
var str = _step.value;
|
|
77
|
-
while (str.slice(0, prefix.length) !== prefix) {
|
|
78
|
-
prefix = prefix.slice(0, -1);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return prefix;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Present a "list" of independently editable parameters according to
|
|
86
|
-
* their description, as given by paramsAsArray, with current values as in initValues.
|
|
87
|
-
* @param paramsAsArray [{type,name,possibleValues,defaultValue}]
|
|
88
|
-
* @param initValues {k:v}
|
|
89
|
-
* @param onChange (paramName, newValue, isInEdition)
|
|
90
|
-
* @param variant style variant for TextField, Autocomplete and Select parameter fields
|
|
91
|
-
* @param showSeparator if true, a separator is added between parameters
|
|
92
|
-
* @param selectionWithDialog {(param: {}) => boolean} if true, param with multiple options use dialog for selection
|
|
93
|
-
*/
|
|
94
|
-
export var FlatParameters = function FlatParameters(_ref) {
|
|
95
|
-
var paramsAsArray = _ref.paramsAsArray,
|
|
96
|
-
initValues = _ref.initValues,
|
|
97
|
-
onChange = _ref.onChange,
|
|
98
|
-
_ref$variant = _ref.variant,
|
|
99
|
-
variant = _ref$variant === void 0 ? 'outlined' : _ref$variant,
|
|
100
|
-
_ref$showSeparator = _ref.showSeparator,
|
|
101
|
-
showSeparator = _ref$showSeparator === void 0 ? false : _ref$showSeparator,
|
|
102
|
-
_ref$selectionWithDia = _ref.selectionWithDialog,
|
|
103
|
-
selectionWithDialog = _ref$selectionWithDia === void 0 ? function (param) {
|
|
104
|
-
return false;
|
|
105
|
-
} : _ref$selectionWithDia;
|
|
106
|
-
var intl = useIntl();
|
|
107
|
-
var longestPrefix = longestCommonPrefix(paramsAsArray.map(function (m) {
|
|
108
|
-
return m.name;
|
|
109
|
-
}));
|
|
110
|
-
var lastDotIndex = longestPrefix.lastIndexOf('.');
|
|
111
|
-
var prefix = longestPrefix.slice(0, lastDotIndex + 1);
|
|
112
|
-
var _useState = useState(null),
|
|
113
|
-
uncommitted = _useState[0],
|
|
114
|
-
setUncommitted = _useState[1];
|
|
115
|
-
var _useState2 = useState(null),
|
|
116
|
-
inEditionParam = _useState2[0],
|
|
117
|
-
setInEditionParam = _useState2[1];
|
|
118
|
-
var _useState3 = useState(false),
|
|
119
|
-
openSelector = _useState3[0],
|
|
120
|
-
setOpenSelector = _useState3[1];
|
|
121
|
-
var getTranslatedValue = useCallback(function (prefix, value) {
|
|
122
|
-
return intl.formatMessage({
|
|
123
|
-
id: prefix + '.' + value,
|
|
124
|
-
defaultMessage: value
|
|
125
|
-
});
|
|
126
|
-
}, [intl]);
|
|
127
|
-
var getSelectionDialogName = useCallback(function (paramName) {
|
|
128
|
-
var defaultMessage = intl.formatMessage({
|
|
129
|
-
id: paramName,
|
|
130
|
-
defaultMessage: paramName.slice(prefix.length)
|
|
131
|
-
});
|
|
132
|
-
return intl.formatMessage({
|
|
133
|
-
id: paramName + '.selectionDialog.name',
|
|
134
|
-
defaultMessage: defaultMessage
|
|
135
|
-
});
|
|
136
|
-
}, [intl, prefix.length]);
|
|
137
|
-
var sortPossibleValues = useCallback(function (prefix, values) {
|
|
138
|
-
if (values == null) {
|
|
139
|
-
return [];
|
|
140
|
-
}
|
|
141
|
-
// Sort by translated values
|
|
142
|
-
return values.map(function (value) {
|
|
143
|
-
return {
|
|
144
|
-
id: value,
|
|
145
|
-
message: getTranslatedValue(prefix, value)
|
|
146
|
-
};
|
|
147
|
-
}).sort(function (a, b) {
|
|
148
|
-
return a.message.localeCompare(b.message);
|
|
149
|
-
});
|
|
150
|
-
}, [getTranslatedValue]);
|
|
151
|
-
var onFieldChange = useCallback(function (value, param) {
|
|
152
|
-
var paramName = param.name;
|
|
153
|
-
var isInEdition = inEditionParam === paramName;
|
|
154
|
-
if (isInEdition) {
|
|
155
|
-
setUncommitted(value);
|
|
156
|
-
}
|
|
157
|
-
if (onChange) {
|
|
158
|
-
if (param.type === 'STRING_LIST') {
|
|
159
|
-
onChange(paramName, value ? value.toString() : null, isInEdition);
|
|
160
|
-
} else {
|
|
161
|
-
onChange(paramName, value, isInEdition);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}, [inEditionParam, onChange]);
|
|
165
|
-
var onUncommitted = useCallback(function (param, inEdit) {
|
|
166
|
-
if (inEdit) {
|
|
167
|
-
setInEditionParam(param.name);
|
|
168
|
-
} else {
|
|
169
|
-
if (onChange && uncommitted != null) {
|
|
170
|
-
if (!['INTEGER', 'DOUBLE'].includes(param.type)) {
|
|
171
|
-
onChange(param.name, uncommitted, false);
|
|
172
|
-
} else if (uncommitted) {
|
|
173
|
-
// may give NaN
|
|
174
|
-
onChange(param.name, uncommitted - 0, false);
|
|
175
|
-
} else {
|
|
176
|
-
onChange(param.name, extractDefault(param), false);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
setInEditionParam(null);
|
|
180
|
-
setUncommitted(null);
|
|
181
|
-
}
|
|
182
|
-
}, [uncommitted, onChange]);
|
|
183
|
-
function mixInitAndDefault(param) {
|
|
184
|
-
if (param.name === inEditionParam && uncommitted !== null) {
|
|
185
|
-
return uncommitted;
|
|
186
|
-
} else if (initValues && initValues.hasOwnProperty(param.name)) {
|
|
187
|
-
if (param.type !== 'STRING_LIST') {
|
|
188
|
-
return initValues[param.name];
|
|
189
|
-
}
|
|
190
|
-
var valueList = initValues[param.name];
|
|
191
|
-
if (Array.isArray(valueList)) {
|
|
192
|
-
return valueList;
|
|
193
|
-
}
|
|
194
|
-
// otherwise split string into array
|
|
195
|
-
return valueList ? valueList.split(',').map(function (s) {
|
|
196
|
-
return s.trim();
|
|
197
|
-
}).filter(function (s) {
|
|
198
|
-
return !!s;
|
|
199
|
-
}) : [];
|
|
200
|
-
} else {
|
|
201
|
-
return extractDefault(param);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
var outputTransformFloatString = function outputTransformFloatString(value) {
|
|
205
|
-
return (value === null || value === void 0 ? void 0 : value.replace(',', '.')) || '';
|
|
206
|
-
};
|
|
207
|
-
var getStringListValue = function getStringListValue(allValues, selectValues) {
|
|
208
|
-
if (!selectValues || !selectValues.length) {
|
|
209
|
-
return intl.formatMessage({
|
|
210
|
-
id: 'flat_parameters/none'
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
if (selectValues.length === allValues.length) {
|
|
214
|
-
return intl.formatMessage({
|
|
215
|
-
id: 'flat_parameters/all'
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
return intl.formatMessage({
|
|
219
|
-
id: 'flat_parameters/some'
|
|
220
|
-
});
|
|
221
|
-
};
|
|
222
|
-
var renderField = function renderField(param) {
|
|
223
|
-
var fieldValue = mixInitAndDefault(param);
|
|
224
|
-
switch (param.type) {
|
|
225
|
-
case 'BOOLEAN':
|
|
226
|
-
return /*#__PURE__*/React.createElement(Switch, {
|
|
227
|
-
checked: !!fieldValue,
|
|
228
|
-
onChange: function onChange(e) {
|
|
229
|
-
return onFieldChange(e.target.checked, param);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
case 'DOUBLE':
|
|
233
|
-
var err = isNaN(fieldValue) || typeof fieldValue !== 'number' && !!fieldValue && isNaN(fieldValue - 0);
|
|
234
|
-
return /*#__PURE__*/React.createElement(TextField, {
|
|
235
|
-
size: 'small',
|
|
236
|
-
sx: {
|
|
237
|
-
width: '50%'
|
|
238
|
-
},
|
|
239
|
-
inputProps: {
|
|
240
|
-
style: {
|
|
241
|
-
textAlign: 'right'
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
value: fieldValue,
|
|
245
|
-
onFocus: function onFocus() {
|
|
246
|
-
return onUncommitted(param, true);
|
|
247
|
-
},
|
|
248
|
-
onBlur: function onBlur() {
|
|
249
|
-
return onUncommitted(param, false);
|
|
250
|
-
},
|
|
251
|
-
onChange: function onChange(e) {
|
|
252
|
-
var m = FloatRE.exec(e.target.value);
|
|
253
|
-
if (m) {
|
|
254
|
-
onFieldChange(outputTransformFloatString(e.target.value), param);
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
error: err,
|
|
258
|
-
variant: variant
|
|
259
|
-
});
|
|
260
|
-
case 'INTEGER':
|
|
261
|
-
return /*#__PURE__*/React.createElement(TextField, {
|
|
262
|
-
size: 'small',
|
|
263
|
-
sx: {
|
|
264
|
-
width: '50%'
|
|
265
|
-
},
|
|
266
|
-
inputProps: {
|
|
267
|
-
style: {
|
|
268
|
-
textAlign: 'right'
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
value: fieldValue,
|
|
272
|
-
onFocus: function onFocus() {
|
|
273
|
-
return onUncommitted(param, true);
|
|
274
|
-
},
|
|
275
|
-
onBlur: function onBlur() {
|
|
276
|
-
return onUncommitted(param, false);
|
|
277
|
-
},
|
|
278
|
-
onChange: function onChange(e) {
|
|
279
|
-
var m = IntegerRE.exec(e.target.value);
|
|
280
|
-
if (m) {
|
|
281
|
-
onFieldChange(e.target.value, param);
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
variant: variant
|
|
285
|
-
});
|
|
286
|
-
case 'STRING_LIST':
|
|
287
|
-
if (param.possibleValues) {
|
|
288
|
-
var allOptions = sortPossibleValues(param.name, param.possibleValues).map(function (_ref2) {
|
|
289
|
-
var id = _ref2.id;
|
|
290
|
-
return id;
|
|
291
|
-
});
|
|
292
|
-
var withDialog = selectionWithDialog(param);
|
|
293
|
-
if (withDialog) {
|
|
294
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, {
|
|
295
|
-
value: getStringListValue(allOptions, fieldValue),
|
|
296
|
-
size: 'small',
|
|
297
|
-
variant: variant,
|
|
298
|
-
InputProps: {
|
|
299
|
-
readOnly: true,
|
|
300
|
-
endAdornment: /*#__PURE__*/React.createElement(IconButton, {
|
|
301
|
-
onClick: function onClick() {
|
|
302
|
-
return setOpenSelector(true);
|
|
303
|
-
}
|
|
304
|
-
}, /*#__PURE__*/React.createElement(TuneIcon, null))
|
|
305
|
-
}
|
|
306
|
-
}), /*#__PURE__*/React.createElement(MultipleSelectionDialog, {
|
|
307
|
-
options: allOptions,
|
|
308
|
-
titleId: getSelectionDialogName(param.name),
|
|
309
|
-
open: openSelector,
|
|
310
|
-
getOptionLabel: function getOptionLabel(option) {
|
|
311
|
-
return getTranslatedValue(param.name, option);
|
|
312
|
-
},
|
|
313
|
-
selectedOptions: fieldValue,
|
|
314
|
-
handleClose: function handleClose() {
|
|
315
|
-
return setOpenSelector(false);
|
|
316
|
-
},
|
|
317
|
-
handleValidate: function handleValidate(selectedOptions) {
|
|
318
|
-
onFieldChange(selectedOptions, param);
|
|
319
|
-
setOpenSelector(false);
|
|
320
|
-
}
|
|
321
|
-
}));
|
|
322
|
-
}
|
|
323
|
-
return /*#__PURE__*/React.createElement(Autocomplete, {
|
|
324
|
-
fullWidth: true,
|
|
325
|
-
multiple: true,
|
|
326
|
-
size: 'small',
|
|
327
|
-
options: sortPossibleValues(param.name, param.possibleValues).map(function (v) {
|
|
328
|
-
return v.id;
|
|
329
|
-
}),
|
|
330
|
-
getOptionLabel: function getOptionLabel(option) {
|
|
331
|
-
return getTranslatedValue(param.name, option);
|
|
332
|
-
},
|
|
333
|
-
onChange: function onChange(e, value) {
|
|
334
|
-
return onFieldChange(value, param);
|
|
335
|
-
},
|
|
336
|
-
value: fieldValue,
|
|
337
|
-
renderTags: function renderTags(values, getTagProps) {
|
|
338
|
-
return values.map(function (value, index) {
|
|
339
|
-
return /*#__PURE__*/React.createElement(Chip, _extends({
|
|
340
|
-
label: getTranslatedValue(param.name, value)
|
|
341
|
-
}, getTagProps({
|
|
342
|
-
index: index
|
|
343
|
-
})));
|
|
344
|
-
});
|
|
345
|
-
},
|
|
346
|
-
renderInput: function renderInput(inputProps) {
|
|
347
|
-
return /*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
|
|
348
|
-
variant: variant
|
|
349
|
-
}));
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
} else {
|
|
353
|
-
// no possible values => free user inputs
|
|
354
|
-
return /*#__PURE__*/React.createElement(Autocomplete, {
|
|
355
|
-
multiple: true,
|
|
356
|
-
freeSolo: true,
|
|
357
|
-
autoSelect: true,
|
|
358
|
-
sx: {
|
|
359
|
-
width: '50%'
|
|
360
|
-
},
|
|
361
|
-
options: [],
|
|
362
|
-
size: 'small',
|
|
363
|
-
onChange: function onChange(e, value) {
|
|
364
|
-
return onFieldChange(value, param);
|
|
365
|
-
},
|
|
366
|
-
value: fieldValue,
|
|
367
|
-
renderTags: function renderTags(values, getTagProps) {
|
|
368
|
-
return values.map(function (value, index) {
|
|
369
|
-
return /*#__PURE__*/React.createElement(Chip, _extends({
|
|
370
|
-
id: 'chip_' + value,
|
|
371
|
-
size: 'small',
|
|
372
|
-
label: value
|
|
373
|
-
}, getTagProps({
|
|
374
|
-
index: index
|
|
375
|
-
})));
|
|
376
|
-
});
|
|
377
|
-
},
|
|
378
|
-
renderInput: function renderInput(inputProps) {
|
|
379
|
-
return /*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
|
|
380
|
-
variant: variant
|
|
381
|
-
}));
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
case 'STRING':
|
|
386
|
-
if (param.possibleValues) {
|
|
387
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Select, {
|
|
388
|
-
labelId: param.name,
|
|
389
|
-
value: fieldValue !== null && fieldValue !== void 0 ? fieldValue : '',
|
|
390
|
-
onChange: function onChange(ev) {
|
|
391
|
-
onFieldChange(ev.target.value, param);
|
|
392
|
-
},
|
|
393
|
-
size: "small",
|
|
394
|
-
sx: {
|
|
395
|
-
minWidth: '4em'
|
|
396
|
-
},
|
|
397
|
-
variant: variant
|
|
398
|
-
}, sortPossibleValues(param.name, param.possibleValues).map(function (value) {
|
|
399
|
-
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
400
|
-
key: value.id,
|
|
401
|
-
value: value.id
|
|
402
|
-
}, /*#__PURE__*/React.createElement(Typography, null, value.message));
|
|
403
|
-
})));
|
|
404
|
-
}
|
|
405
|
-
// else fallthrough to default
|
|
406
|
-
default:
|
|
407
|
-
return /*#__PURE__*/React.createElement(TextField, {
|
|
408
|
-
sx: {
|
|
409
|
-
width: '50%'
|
|
410
|
-
},
|
|
411
|
-
size: 'small',
|
|
412
|
-
value: fieldValue || '',
|
|
413
|
-
onFocus: function onFocus() {
|
|
414
|
-
return onUncommitted(param, true);
|
|
415
|
-
},
|
|
416
|
-
onBlur: function onBlur() {
|
|
417
|
-
return onUncommitted(param, false);
|
|
418
|
-
},
|
|
419
|
-
onChange: function onChange(e) {
|
|
420
|
-
return onFieldChange(e.target.value, param);
|
|
421
|
-
},
|
|
422
|
-
variant: variant
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
return /*#__PURE__*/React.createElement(List, {
|
|
427
|
-
sx: styles.paramList
|
|
428
|
-
}, paramsAsArray.map(function (param, index) {
|
|
429
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
430
|
-
key: param.name
|
|
431
|
-
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
432
|
-
sx: styles.paramListItem
|
|
433
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
434
|
-
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
435
|
-
id: param.name + '.desc',
|
|
436
|
-
defaultMessage: param.description
|
|
437
|
-
}),
|
|
438
|
-
enterDelay: 1200,
|
|
439
|
-
key: param.name
|
|
440
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
441
|
-
sx: styles.paramName
|
|
442
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
443
|
-
id: param.name,
|
|
444
|
-
defaultMessage: param.name.slice(prefix.length)
|
|
445
|
-
}))), renderField(param)), showSeparator && index !== paramsAsArray.length - 1 && /*#__PURE__*/React.createElement(Divider, null));
|
|
446
|
-
}));
|
|
447
|
-
};
|
|
448
|
-
export default FlatParameters;
|