@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.
Files changed (271) hide show
  1. package/README.md +0 -17
  2. package/dist/components/AuthenticationRouter/AuthenticationRouter.d.ts +10 -0
  3. package/dist/components/AuthenticationRouter/AuthenticationRouter.js +147 -0
  4. package/dist/components/AuthenticationRouter/index.d.ts +1 -0
  5. package/dist/components/CardErrorBoundary/card-error-boundary.d.ts +18 -0
  6. package/dist/components/CardErrorBoundary/card-error-boundary.js +110 -0
  7. package/dist/components/CardErrorBoundary/index.d.ts +1 -0
  8. package/dist/components/DirectoryItemSelector/directory-item-selector.d.ts +22 -0
  9. package/dist/components/DirectoryItemSelector/directory-item-selector.js +254 -0
  10. package/dist/components/ElementSearchDialog/element-search-dialog.d.ts +16 -0
  11. package/dist/components/ElementSearchDialog/element-search-dialog.js +139 -0
  12. package/dist/components/ElementSearchDialog/equipment-item.d.ts +16 -0
  13. package/dist/components/ElementSearchDialog/equipment-item.js +77 -0
  14. package/dist/components/ElementSearchDialog/index.d.ts +2 -0
  15. package/dist/components/ElementSearchDialog/tag-renderer.d.ts +11 -0
  16. package/dist/components/ElementSearchDialog/tag-renderer.js +34 -0
  17. package/dist/components/FlatParameters/FlatParameters.d.ts +10 -0
  18. package/dist/components/FlatParameters/FlatParameters.js +411 -0
  19. package/dist/components/FlatParameters/index.d.ts +1 -0
  20. package/dist/components/Login/Login.d.ts +5 -0
  21. package/dist/components/Login/Login.js +78 -0
  22. package/dist/components/Login/Logout.d.ts +5 -0
  23. package/dist/components/Login/Logout.js +69 -0
  24. package/dist/components/Login/index.d.ts +1 -0
  25. package/dist/components/MuiVirtualizedTable/ColumnHeader.d.ts +4 -0
  26. package/dist/components/MuiVirtualizedTable/ColumnHeader.js +127 -0
  27. package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.d.ts +104 -0
  28. package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +548 -0
  29. package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.d.ts +131 -0
  30. package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.js +790 -0
  31. package/dist/components/MuiVirtualizedTable/index.d.ts +2 -0
  32. package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.d.ts +10 -0
  33. package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.js +87 -0
  34. package/dist/components/MultipleSelectionDialog/index.d.ts +1 -0
  35. package/dist/components/OverflowableText/index.d.ts +1 -0
  36. package/dist/components/OverflowableText/overflowable-text.d.ts +2 -0
  37. package/dist/components/OverflowableText/overflowable-text.js +87 -0
  38. package/dist/components/ReportViewer/filter-button.d.ts +1 -0
  39. package/dist/components/ReportViewer/filter-button.js +64 -0
  40. package/dist/components/ReportViewer/index.d.ts +1 -0
  41. package/dist/components/ReportViewer/log-report-item.d.ts +68 -0
  42. package/dist/components/ReportViewer/log-report-item.js +95 -0
  43. package/dist/components/ReportViewer/log-report.d.ts +21 -0
  44. package/dist/components/ReportViewer/log-report.js +49 -0
  45. package/dist/components/ReportViewer/log-table.d.ts +8 -0
  46. package/dist/components/ReportViewer/log-table.js +131 -0
  47. package/dist/components/ReportViewer/multi-select-list.d.ts +1 -0
  48. package/dist/components/ReportViewer/multi-select-list.js +40 -0
  49. package/dist/components/ReportViewer/report-item.d.ts +13 -0
  50. package/dist/components/ReportViewer/report-item.js +112 -0
  51. package/dist/components/ReportViewer/report-tree-view-context.d.ts +2 -0
  52. package/dist/components/ReportViewer/report-tree-view-context.js +8 -0
  53. package/dist/components/ReportViewer/report-viewer.d.ts +4 -0
  54. package/dist/components/ReportViewer/report-viewer.js +158 -0
  55. package/dist/components/ReportViewerDialog/index.d.ts +1 -0
  56. package/dist/components/ReportViewerDialog/report-viewer-dialog.d.ts +1 -0
  57. package/dist/components/ReportViewerDialog/report-viewer-dialog.js +61 -0
  58. package/dist/components/SignInCallbackHandler/SignInCallbackHandler.d.ts +5 -0
  59. package/dist/components/SignInCallbackHandler/SignInCallbackHandler.js +13 -0
  60. package/dist/components/SignInCallbackHandler/index.d.ts +1 -0
  61. package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.d.ts +5 -0
  62. package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +16 -0
  63. package/dist/components/SilentRenewCallbackHandler/index.d.ts +1 -0
  64. package/dist/components/SnackbarProvider/SnackbarProvider.d.ts +3 -0
  65. package/dist/components/SnackbarProvider/SnackbarProvider.js +28 -0
  66. package/dist/components/SnackbarProvider/index.d.ts +1 -0
  67. package/dist/components/TopBar/AboutDialog.d.ts +24 -0
  68. package/dist/components/TopBar/AboutDialog.js +467 -0
  69. package/dist/components/TopBar/GridLogo.d.ts +34 -0
  70. package/dist/components/TopBar/GridLogo.js +71 -0
  71. package/dist/components/TopBar/TopBar.d.ts +53 -0
  72. package/dist/components/TopBar/TopBar.js +679 -0
  73. package/dist/components/TopBar/index.d.ts +3 -0
  74. package/dist/components/TreeViewFinder/TreeViewFinder.d.ts +57 -0
  75. package/dist/components/TreeViewFinder/TreeViewFinder.js +288 -0
  76. package/dist/components/TreeViewFinder/index.d.ts +1 -0
  77. package/dist/components/react-hook-form/autocomplete-input.d.ts +30 -0
  78. package/dist/components/react-hook-form/autocomplete-input.js +96 -0
  79. package/dist/components/react-hook-form/booleans/boolean-input.d.ts +16 -0
  80. package/dist/components/react-hook-form/booleans/boolean-input.js +49 -0
  81. package/dist/components/react-hook-form/booleans/checkbox-input.d.ts +14 -0
  82. package/dist/components/react-hook-form/booleans/checkbox-input.js +24 -0
  83. package/dist/components/react-hook-form/booleans/switch-input.d.ts +14 -0
  84. package/dist/components/react-hook-form/booleans/switch-input.js +24 -0
  85. package/dist/components/react-hook-form/directory-items-input.d.ts +28 -0
  86. package/dist/components/react-hook-form/directory-items-input.js +185 -0
  87. package/dist/components/react-hook-form/error-management/error-input.d.ts +5 -0
  88. package/dist/components/react-hook-form/error-management/error-input.js +42 -0
  89. package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +4 -0
  90. package/dist/components/react-hook-form/error-management/field-error-alert.js +9 -0
  91. package/dist/components/react-hook-form/error-management/mid-form-error.d.ts +4 -0
  92. package/dist/components/react-hook-form/error-management/mid-form-error.js +20 -0
  93. package/dist/components/react-hook-form/numbers/float-input.d.ts +18 -0
  94. package/dist/components/react-hook-form/numbers/float-input.js +51 -0
  95. package/dist/components/react-hook-form/numbers/integer-input.d.ts +18 -0
  96. package/dist/components/react-hook-form/numbers/integer-input.js +36 -0
  97. package/dist/components/react-hook-form/numbers/utils.d.ts +2 -0
  98. package/dist/components/react-hook-form/numbers/utils.js +10 -0
  99. package/dist/components/react-hook-form/radio-input.d.ts +18 -0
  100. package/dist/components/react-hook-form/radio-input.js +44 -0
  101. package/{es/components/MultipleSelectionDialog/index.js → dist/components/react-hook-form/raw-read-only-input.d.ts} +3 -2
  102. package/dist/components/react-hook-form/raw-read-only-input.js +10 -0
  103. package/dist/components/react-hook-form/select-input.d.ts +17 -0
  104. package/dist/components/react-hook-form/select-input.js +31 -0
  105. package/dist/components/react-hook-form/slider-input.d.ts +21 -0
  106. package/dist/components/react-hook-form/slider-input.js +43 -0
  107. package/dist/components/react-hook-form/text-input.d.ts +33 -0
  108. package/dist/components/react-hook-form/text-input.js +94 -0
  109. package/dist/components/react-hook-form/utils/cancel-button.d.ts +10 -0
  110. package/dist/components/react-hook-form/utils/cancel-button.js +16 -0
  111. package/dist/components/react-hook-form/utils/field-label.d.ts +6 -0
  112. package/dist/components/react-hook-form/utils/field-label.js +12 -0
  113. package/dist/components/react-hook-form/utils/functions.d.ts +11 -0
  114. package/dist/components/react-hook-form/utils/functions.js +41 -0
  115. package/dist/components/react-hook-form/utils/submit-button.d.ts +10 -0
  116. package/dist/components/react-hook-form/utils/submit-button.js +23 -0
  117. package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +12 -0
  118. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +96 -0
  119. package/{es/components/translations/report-viewer-fr.js → dist/components/translations/card-error-boundary-en.d.ts} +5 -6
  120. package/dist/components/translations/card-error-boundary-en.js +8 -0
  121. package/dist/components/translations/card-error-boundary-fr.d.ts +12 -0
  122. package/dist/components/translations/card-error-boundary-fr.js +8 -0
  123. package/dist/components/translations/common-button-en.d.ts +5 -0
  124. package/dist/components/translations/common-button-en.js +7 -0
  125. package/dist/components/translations/common-button-fr.d.ts +5 -0
  126. package/dist/components/translations/common-button-fr.js +7 -0
  127. package/{es/components/translations/element-search-en.js → dist/components/translations/element-search-en.d.ts} +4 -5
  128. package/dist/components/translations/element-search-en.js +7 -0
  129. package/dist/components/translations/element-search-fr.d.ts +11 -0
  130. package/dist/components/translations/element-search-fr.js +7 -0
  131. package/dist/components/translations/equipment-search-en.d.ts +25 -0
  132. package/dist/components/translations/equipment-search-en.js +21 -0
  133. package/dist/components/translations/equipment-search-fr.d.ts +25 -0
  134. package/dist/components/translations/equipment-search-fr.js +21 -0
  135. package/{es/components/translations/flat-parameters-en.js → dist/components/translations/flat-parameters-en.d.ts} +5 -6
  136. package/dist/components/translations/flat-parameters-en.js +8 -0
  137. package/{es/components/translations/common-button-en.js → dist/components/translations/flat-parameters-fr.d.ts} +5 -5
  138. package/dist/components/translations/flat-parameters-fr.js +8 -0
  139. package/dist/components/translations/login-en.d.ts +18 -0
  140. package/dist/components/translations/login-en.js +14 -0
  141. package/dist/components/translations/login-fr.d.ts +18 -0
  142. package/dist/components/translations/login-fr.js +14 -0
  143. package/{es/components/translations/flat-parameters-fr.js → dist/components/translations/multiple-selection-dialog-en.d.ts} +5 -6
  144. package/dist/components/translations/multiple-selection-dialog-en.js +8 -0
  145. package/{es/components/translations/common-button-fr.js → dist/components/translations/multiple-selection-dialog-fr.d.ts} +5 -5
  146. package/dist/components/translations/multiple-selection-dialog-fr.js +8 -0
  147. package/{es/components/translations/report-viewer-en.js → dist/components/translations/report-viewer-en.d.ts} +5 -6
  148. package/dist/components/translations/report-viewer-en.js +8 -0
  149. package/{es/components/translations/element-search-fr.js → dist/components/translations/report-viewer-fr.d.ts} +5 -5
  150. package/dist/components/translations/report-viewer-fr.js +8 -0
  151. package/{es/components/translations/table-en.js → dist/components/translations/table-en.d.ts} +3 -4
  152. package/dist/components/translations/table-en.js +6 -0
  153. package/{es/components/translations/table-fr.js → dist/components/translations/table-fr.d.ts} +3 -4
  154. package/dist/components/translations/table-fr.js +6 -0
  155. package/dist/components/translations/top-bar-en.d.ts +31 -0
  156. package/dist/components/translations/top-bar-en.js +27 -0
  157. package/dist/components/translations/top-bar-fr.d.ts +31 -0
  158. package/dist/components/translations/top-bar-fr.js +27 -0
  159. package/dist/components/translations/treeview-finder-en.d.ts +16 -0
  160. package/dist/components/translations/treeview-finder-en.js +12 -0
  161. package/dist/components/translations/treeview-finder-fr.d.ts +16 -0
  162. package/dist/components/translations/treeview-finder-fr.js +12 -0
  163. package/dist/hooks/useDebounce.d.ts +1 -0
  164. package/dist/hooks/useDebounce.js +17 -0
  165. package/{es/components/ElementSearchDialog/index.js → dist/hooks/useIntlRef.d.ts} +2 -2
  166. package/dist/hooks/useIntlRef.js +13 -0
  167. package/dist/hooks/useSnackMessage.d.ts +5 -0
  168. package/dist/hooks/useSnackMessage.js +81 -0
  169. package/dist/index.d.ts +234 -0
  170. package/dist/index.js +158 -0
  171. package/dist/utils/AuthService.d.ts +9 -0
  172. package/dist/utils/AuthService.js +336 -0
  173. package/dist/utils/ElementType.d.ts +13 -0
  174. package/dist/utils/ElementType.js +42 -0
  175. package/dist/utils/EquipmentType.d.ts +136 -0
  176. package/dist/utils/EquipmentType.js +132 -0
  177. package/dist/utils/UserManagerMock.d.ts +34 -0
  178. package/dist/utils/UserManagerMock.js +85 -0
  179. package/dist/utils/actions.d.ts +50 -0
  180. package/dist/utils/actions.js +71 -0
  181. package/{es/components/CardErrorBoundary/index.js → dist/utils/algos.d.ts} +1 -1
  182. package/dist/utils/algos.js +24 -0
  183. package/dist/utils/styles.d.ts +5 -0
  184. package/dist/utils/styles.js +13 -0
  185. package/package.json +36 -21
  186. package/es/components/AuthenticationRouter/AuthenticationRouter.js +0 -102
  187. package/es/components/AuthenticationRouter/index.js +0 -7
  188. package/es/components/CardErrorBoundary/card-error-boundary.js +0 -138
  189. package/es/components/ElementSearchDialog/element-search-dialog.js +0 -153
  190. package/es/components/ElementSearchDialog/equipment-item.js +0 -63
  191. package/es/components/ElementSearchDialog/tag-renderer.js +0 -29
  192. package/es/components/FlatParameters/FlatParameters.js +0 -448
  193. package/es/components/FlatParameters/index.js +0 -8
  194. package/es/components/Login/Login.js +0 -79
  195. package/es/components/Login/Logout.js +0 -78
  196. package/es/components/Login/index.js +0 -7
  197. package/es/components/MuiVirtualizedTable/ColumnHeader.js +0 -125
  198. package/es/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -619
  199. package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +0 -780
  200. package/es/components/MuiVirtualizedTable/index.js +0 -9
  201. package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +0 -95
  202. package/es/components/OverflowableText/index.js +0 -7
  203. package/es/components/OverflowableText/overflowable-text.js +0 -81
  204. package/es/components/ReportViewer/filter-button.js +0 -77
  205. package/es/components/ReportViewer/index.js +0 -7
  206. package/es/components/ReportViewer/log-report-item.js +0 -97
  207. package/es/components/ReportViewer/log-report.js +0 -63
  208. package/es/components/ReportViewer/log-table.js +0 -130
  209. package/es/components/ReportViewer/multi-select-list.js +0 -56
  210. package/es/components/ReportViewer/report-item.js +0 -131
  211. package/es/components/ReportViewer/report-tree-view-context.js +0 -13
  212. package/es/components/ReportViewer/report-viewer.js +0 -167
  213. package/es/components/ReportViewerDialog/index.js +0 -7
  214. package/es/components/ReportViewerDialog/report-viewer-dialog.js +0 -67
  215. package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -19
  216. package/es/components/SignInCallbackHandler/index.js +0 -7
  217. package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -19
  218. package/es/components/SilentRenewCallbackHandler/index.js +0 -7
  219. package/es/components/SnackbarProvider/SnackbarProvider.js +0 -39
  220. package/es/components/SnackbarProvider/index.js +0 -7
  221. package/es/components/TopBar/AboutDialog.js +0 -456
  222. package/es/components/TopBar/GridLogo.js +0 -73
  223. package/es/components/TopBar/TopBar.js +0 -487
  224. package/es/components/TopBar/index.js +0 -9
  225. package/es/components/TreeViewFinder/TreeViewFinder.js +0 -341
  226. package/es/components/TreeViewFinder/index.js +0 -7
  227. package/es/components/images/powsybl_logo.svg +0 -35
  228. package/es/components/react-hook-form/autocomplete-input.js +0 -110
  229. package/es/components/react-hook-form/booleans/boolean-input.js +0 -56
  230. package/es/components/react-hook-form/booleans/checkbox-input.js +0 -28
  231. package/es/components/react-hook-form/booleans/switch-input.js +0 -28
  232. package/es/components/react-hook-form/error-management/error-input.js +0 -50
  233. package/es/components/react-hook-form/error-management/field-error-alert.js +0 -22
  234. package/es/components/react-hook-form/error-management/mid-form-error.js +0 -25
  235. package/es/components/react-hook-form/numbers/float-input.js +0 -105
  236. package/es/components/react-hook-form/numbers/integer-input.js +0 -35
  237. package/es/components/react-hook-form/numbers/utils.js +0 -6
  238. package/es/components/react-hook-form/radio-input.js +0 -55
  239. package/es/components/react-hook-form/select-input.js +0 -40
  240. package/es/components/react-hook-form/slider-input.js +0 -48
  241. package/es/components/react-hook-form/text-input.js +0 -100
  242. package/es/components/react-hook-form/utils/cancel-button.js +0 -28
  243. package/es/components/react-hook-form/utils/field-label.js +0 -15
  244. package/es/components/react-hook-form/utils/functions.js +0 -42
  245. package/es/components/react-hook-form/utils/submit-button.js +0 -29
  246. package/es/components/react-hook-form/utils/text-field-with-adornment.js +0 -92
  247. package/es/components/translations/card-error-boundary-en.js +0 -13
  248. package/es/components/translations/card-error-boundary-fr.js +0 -13
  249. package/es/components/translations/equipment-search-en.js +0 -26
  250. package/es/components/translations/equipment-search-fr.js +0 -26
  251. package/es/components/translations/inputs-en.js +0 -25
  252. package/es/components/translations/inputs-fr.js +0 -25
  253. package/es/components/translations/login-en.js +0 -19
  254. package/es/components/translations/login-fr.js +0 -19
  255. package/es/components/translations/multiple-selection-dialog-en.js +0 -13
  256. package/es/components/translations/multiple-selection-dialog-fr.js +0 -13
  257. package/es/components/translations/top-bar-en.js +0 -32
  258. package/es/components/translations/top-bar-fr.js +0 -32
  259. package/es/components/translations/treeview-finder-en.js +0 -17
  260. package/es/components/translations/treeview-finder-fr.js +0 -17
  261. package/es/hooks/useDebounce.js +0 -26
  262. package/es/hooks/useIntlRef.js +0 -22
  263. package/es/hooks/useSnackMessage.js +0 -81
  264. package/es/index.js +0 -71
  265. package/es/utils/AuthService.js +0 -312
  266. package/es/utils/ElementType.js +0 -53
  267. package/es/utils/EquipmentType.js +0 -133
  268. package/es/utils/UserManagerMock.js +0 -81
  269. package/es/utils/actions.js +0 -65
  270. package/es/utils/algos.js +0 -29
  271. package/es/utils/styles.js +0 -35
@@ -1,341 +0,0 @@
1
- var _defaultStyles;
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) 2021, 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, { useState, useCallback, useEffect } from 'react';
11
- import { useIntl } from 'react-intl';
12
- import PropTypes from 'prop-types';
13
- import { toNestedGlobalSelectors, makeComposeClasses } from '../../utils/styles';
14
- import { styled } from '@mui/system';
15
- import Dialog from '@mui/material/Dialog';
16
- import DialogActions from '@mui/material/DialogActions';
17
- import DialogContent from '@mui/material/DialogContent';
18
- import DialogContentText from '@mui/material/DialogContentText';
19
- import DialogTitle from '@mui/material/DialogTitle';
20
- import Button from '@mui/material/Button';
21
- import TreeItem from '@mui/lab/TreeItem';
22
- import TreeView from '@mui/lab/TreeView';
23
- import Typography from '@mui/material/Typography';
24
- import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
25
- import ChevronRightIcon from '@mui/icons-material/ChevronRight';
26
- import CheckIcon from '@mui/icons-material/Check';
27
- import CancelButton from '../react-hook-form/utils/cancel-button';
28
-
29
- // As a bunch of individual variables to try to make it easier
30
- // to track that they are all used. Not sure, maybe group them in an object ?
31
- var cssDialogPaper = 'dialogPaper';
32
- var cssLabelRoot = 'labelRoot';
33
- var cssLabelText = 'labelText';
34
- var cssLabelIcon = 'labelIcon';
35
- var cssIcon = 'icon';
36
-
37
- // converted to nested rules
38
- var defaultStyles = (_defaultStyles = {}, _defaultStyles[cssDialogPaper] = {
39
- minWidth: '50%'
40
- }, _defaultStyles[cssLabelRoot] = {
41
- display: 'flex',
42
- alignContent: 'center',
43
- alignItems: 'center'
44
- }, _defaultStyles[cssLabelText] = {
45
- fontWeight: 'inherit',
46
- flexGrow: 1
47
- }, _defaultStyles[cssLabelIcon] = {
48
- display: 'flex',
49
- alignContent: 'center',
50
- alignItems: 'center',
51
- marginRight: '4px'
52
- }, _defaultStyles[cssIcon] = {}, _defaultStyles);
53
- export var generateTreeViewFinderClass = function generateTreeViewFinderClass(className) {
54
- return "GsiTreeViewFinder-" + className;
55
- };
56
- var composeClasses = makeComposeClasses(generateTreeViewFinderClass);
57
-
58
- /**
59
- * This callback type is called `onTreeBrowseCallback` and is displayed as a global symbol.
60
- *
61
- * @callback onTreeBrowseCallback
62
- * @param {string} nodeId The id of the node clicked
63
- */
64
-
65
- /**
66
- * TreeViewFinder documentation :
67
- * Component to choose elements in a flat list or a Tree data structure
68
- * It is flexible and allow controlled props to let Parent component manage
69
- * data.
70
- *
71
- * @param {Object} classes - Deprecated, use sx or styled instead. - Otherwise, CSS classes, please use withStyles API from MaterialUI
72
- * @param {String} [title] - Title of the Dialog
73
- * @param {String} [contentText] - Content text of the Dialog
74
- * @param {Boolean} open - dialog state boolean handler (Controlled)
75
- * @param {EventListener} onClose - onClose callback to call when closing dialog
76
- * @param {Object[]} data - data to feed the component (Controlled).
77
- * @param {String} data[].id - Uuid of the object in Tree
78
- * @param {String} data[].parentId - Uuid of the parent node in Tree
79
- * @param {String} data[].name - name of the node to print in Tree
80
- * @param {String} data[].icon - JSX of an icon to display next a node
81
- * @param {String} data[].childrenCount - number of children
82
- * @param {Object[]} [data[].children] - array of children nodes, if undefined, the node is a leaf.
83
- * @callback onTreeBrowse - callback to update data prop when walk into Tree
84
- * @param {Array} [defaultSelected=[]] - selected items at mount (Uncontrolled)
85
- * @param {Array} [defaultExpanded=[]] - ids of the expanded items at mount (Uncontrolled)
86
- * @param {String} [validationButtonText=default text] - Customized Validation Button text (default: Add N Elements)
87
- * @param {Boolean} [onlyLeaves=true] - Allow/Forbid selection only on leaves
88
- * @param {Boolean} [multiselect=false] - Allow/Forbid multiselection on Tree
89
- * @param {Object} [cancelButtonProps] - The cancel button props
90
- */
91
- var TreeViewFinder = function TreeViewFinder(props) {
92
- var intl = useIntl();
93
- var classes = props.classes,
94
- title = props.title,
95
- contentText = props.contentText,
96
- open = props.open,
97
- data = props.data,
98
- defaultExpanded = props.defaultExpanded,
99
- defaultSelected = props.defaultSelected,
100
- _onClose = props.onClose,
101
- onTreeBrowse = props.onTreeBrowse,
102
- validationButtonText = props.validationButtonText,
103
- onlyLeaves = props.onlyLeaves,
104
- multiselect = props.multiselect,
105
- sortMethod = props.sortMethod,
106
- className = props.className,
107
- cancelButtonProps = props.cancelButtonProps;
108
- var _useState = useState({}),
109
- mapPrintedNodes = _useState[0],
110
- setMapPrintedNodes = _useState[1];
111
-
112
- // Controlled expanded for TreeView
113
- var _useState2 = useState(defaultExpanded),
114
- expanded = _useState2[0],
115
- setExpanded = _useState2[1];
116
- // Controlled selected for TreeView
117
- var _useState3 = useState(defaultSelected),
118
- selected = _useState3[0],
119
- setSelected = _useState3[1];
120
-
121
- /* Utilities */
122
- var isSelectable = function isSelectable(node) {
123
- return onlyLeaves ? isLeaf(node) : true; // otherwise everything is selectable
124
- };
125
-
126
- var isLeaf = function isLeaf(node) {
127
- return node && node.children === undefined;
128
- };
129
- var computeMapPrintedNodes = useCallback(function (nodes) {
130
- var newMapPrintedNodes = {};
131
- nodes.forEach(function (node) {
132
- newMapPrintedNodes[node.id] = node;
133
- if (!isLeaf(node)) {
134
- Object.assign(newMapPrintedNodes, computeMapPrintedNodes(node.children));
135
- }
136
- });
137
- return newMapPrintedNodes;
138
- }, []);
139
-
140
- // Effects
141
- useEffect(function () {
142
- // compute all mapPrintedNodes here from data prop
143
- // if data changes in current expanded nodes
144
- var newMapPrintedNodes = computeMapPrintedNodes(data);
145
- console.debug('data updated, new mapPrintedNodes (nbNodes = ', Object.keys(newMapPrintedNodes).length, ') : ', newMapPrintedNodes);
146
- setMapPrintedNodes(newMapPrintedNodes);
147
- }, [data, computeMapPrintedNodes]);
148
- var computeSelectedNodes = function computeSelectedNodes() {
149
- return selected.map(function (nodeId) {
150
- return mapPrintedNodes[nodeId];
151
- });
152
- };
153
- var handleNodeToggle = function handleNodeToggle(e, nodeIds) {
154
- // onTreeBrowse proc only on last node clicked and only when expanded
155
- nodeIds.every(function (nodeId) {
156
- if (!expanded.includes(nodeId)) {
157
- // proc onTreeBrowse here
158
- onTreeBrowse && onTreeBrowse(nodeId);
159
- return false; // break loop to call onTreeBrowse only once
160
- }
161
-
162
- return true;
163
- });
164
- setExpanded(nodeIds);
165
- // will proc onNodeSelect then ...
166
- };
167
-
168
- /* User Interaction management */
169
- var handleNodeSelect = function handleNodeSelect(e, values) {
170
- // Default management
171
- if (multiselect) {
172
- setSelected(values.filter(function (nodeId) {
173
- return isSelectable(mapPrintedNodes[nodeId]);
174
- }));
175
- } else {
176
- // Toggle selection to allow unselection
177
- if (selected.includes(values)) {
178
- setSelected([]);
179
- } else {
180
- setSelected(isSelectable(mapPrintedNodes[values]) ? [values] : []);
181
- }
182
- }
183
- };
184
-
185
- /* Render utilities */
186
- var getValidationButtonText = function getValidationButtonText() {
187
- if (validationButtonText) {
188
- return validationButtonText;
189
- } else {
190
- return intl.formatMessage({
191
- id: 'treeview_finder/addElementsValidation'
192
- }, {
193
- nbElements: selected.length
194
- });
195
- }
196
- };
197
- var getNodeIcon = function getNodeIcon(node) {
198
- if (!node) {
199
- return null;
200
- }
201
- if (isSelectable(node) && selected.find(function (nodeId) {
202
- return nodeId === node.id;
203
- })) {
204
- return /*#__PURE__*/React.createElement(CheckIcon, {
205
- className: composeClasses(classes, cssLabelIcon)
206
- });
207
- } else {
208
- if (node.icon) {
209
- return /*#__PURE__*/React.createElement("div", {
210
- className: composeClasses(classes, cssLabelIcon)
211
- }, node.icon);
212
- } else {
213
- return null;
214
- }
215
- }
216
- };
217
- var renderTreeItemLabel = function renderTreeItemLabel(node) {
218
- return /*#__PURE__*/React.createElement("div", {
219
- className: composeClasses(classes, cssLabelRoot)
220
- }, getNodeIcon(node), /*#__PURE__*/React.createElement(Typography, {
221
- className: composeClasses(classes, cssLabelText)
222
- }, node.name));
223
- };
224
- var showChevron = function showChevron(node) {
225
- // by defaut show Chevron if childrenCount is null or undefined otherwise only if > 0
226
- return !!(node.childrenCount == null || node.childrenCount && node.childrenCount > 0);
227
- };
228
- var renderTree = function renderTree(node) {
229
- if (!node) {
230
- return;
231
- }
232
- return /*#__PURE__*/React.createElement(TreeItem, {
233
- key: node.id,
234
- nodeId: node.id,
235
- label: renderTreeItemLabel(node),
236
- expandIcon: showChevron(node) ? /*#__PURE__*/React.createElement(ChevronRightIcon, {
237
- className: composeClasses(classes, cssIcon)
238
- }) : null,
239
- collapseIcon: showChevron(node) ? /*#__PURE__*/React.createElement(ExpandMoreIcon, {
240
- className: composeClasses(classes, cssIcon)
241
- }) : null
242
- }, Array.isArray(node.children) ? node.children.length ? node.children.sort(sortMethod).map(function (child) {
243
- return renderTree(child);
244
- }) : [false] // Pass non empty Array here to simulate a child then this node isn't considered as a leaf.
245
- : null);
246
- };
247
- return /*#__PURE__*/React.createElement(Dialog, {
248
- open: open,
249
- onClose: function onClose(e, r) {
250
- if (r === 'escapeKeyDown' || r === 'backdropClick') {
251
- _onClose([]);
252
- setSelected([]);
253
- }
254
- },
255
- "aria-labelledby": "TreeViewFindertitle",
256
- className: className,
257
- classes: {
258
- paper: composeClasses(classes, cssDialogPaper)
259
- }
260
- }, /*#__PURE__*/React.createElement(DialogTitle, {
261
- id: "TreeViewFindertitle"
262
- }, title ? title : intl.formatMessage({
263
- id: 'treeview_finder/finderTitle'
264
- }, {
265
- multiselect: multiselect
266
- })), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(DialogContentText, null, contentText ? contentText : intl.formatMessage({
267
- id: 'treeview_finder/contentText'
268
- }, {
269
- multiselect: multiselect
270
- })), /*#__PURE__*/React.createElement(TreeView
271
- // Controlled props
272
- , {
273
- expanded: expanded,
274
- selected: selected
275
- // events
276
- ,
277
- onNodeToggle: handleNodeToggle,
278
- onNodeSelect: handleNodeSelect
279
- // Uncontrolled props
280
- ,
281
- multiSelect: multiselect
282
- }, data && Array.isArray(data) ? data.sort(sortMethod).map(function (child) {
283
- return renderTree(child);
284
- }) : null)), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(CancelButton, _extends({
285
- style: {
286
- "float": 'left',
287
- margin: '5px'
288
- },
289
- onClick: function onClick() {
290
- _onClose([]);
291
- setSelected([]);
292
- }
293
- }, cancelButtonProps)), /*#__PURE__*/React.createElement(Button, {
294
- variant: "outlined",
295
- style: {
296
- "float": 'left',
297
- margin: '5px'
298
- },
299
- onClick: function onClick() {
300
- _onClose(computeSelectedNodes());
301
- setSelected([]);
302
- },
303
- disabled: selected.length === 0
304
- }, getValidationButtonText())));
305
- };
306
-
307
- /* TreeViewFinder props list */
308
- TreeViewFinder.propTypes = process.env.NODE_ENV !== "production" ? {
309
- // Controlled
310
- open: PropTypes.bool.isRequired,
311
- onClose: PropTypes.func,
312
- data: PropTypes.arrayOf(PropTypes.shape({
313
- id: PropTypes.string.isRequired,
314
- name: PropTypes.string.isRequired,
315
- children: PropTypes.array
316
- })).isRequired,
317
- onTreeBrowse: PropTypes.func,
318
- //uncontrolled
319
- classes: PropTypes.object,
320
- title: PropTypes.string,
321
- contentText: PropTypes.string,
322
- validationButtonText: PropTypes.string,
323
- defaultSelected: PropTypes.arrayOf(PropTypes.string),
324
- defaultExpanded: PropTypes.arrayOf(PropTypes.string),
325
- onlyLeaves: PropTypes.bool,
326
- multiselect: PropTypes.bool,
327
- sortMethod: PropTypes.func,
328
- cancelButtonProps: PropTypes.object
329
- } : {};
330
-
331
- /* TreeViewFinder props default values */
332
- TreeViewFinder.defaultProps = {
333
- defaultSelected: [],
334
- defaultExpanded: [],
335
- onlyLeaves: true,
336
- multiselect: false,
337
- sortMethod: undefined,
338
- classes: {}
339
- };
340
- var nestedGlobalSelectorsStyles = toNestedGlobalSelectors(defaultStyles, generateTreeViewFinderClass);
341
- export default styled(TreeViewFinder)(nestedGlobalSelectorsStyles);
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright (c) 2021, RTE (http://www.rte-france.com)
3
- * This Source Code Form is subject to the terms of the Mozilla Public
4
- * License, v. 2.0. If a copy of the MPL was not distributed with this
5
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
- */
7
- export { default, generateTreeViewFinderClass } from './TreeViewFinder';
@@ -1,35 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
- viewBox="0 0 114 114" style="enable-background:new 0 0 114 114;" xml:space="preserve">
5
- <style type="text/css">
6
- .st0{fill:#FFB259;}
7
- .st1{fill:#6F2277;}
8
- .st2{fill:#FD495C;}
9
- .st3{fill:#009ADE;}
10
- .st4{fill:#003764;}
11
- </style>
12
- <g>
13
- <polygon class="st0" points="33.7,45.7 56.2,34.3 78.6,45.7 56.2,57.1 "/>
14
- <polygon class="st1" points="33.7,45.7 56.2,57.1 56.2,79.9 33.7,68.5 "/>
15
- <polygon class="st2" points="78.6,45.7 78.6,68.5 56.2,79.9 56.2,57.1 "/>
16
- <polygon class="st0" points="67.4,62.8 89.9,51.4 112.3,62.8 89.9,74.2 "/>
17
- <polygon class="st1" points="67.4,62.8 89.9,74.2 89.9,97.1 67.4,85.6 "/>
18
- <polygon class="st2" points="112.3,62.8 112.3,85.6 89.9,97.1 89.9,74.2 "/>
19
- <polygon class="st0" points="0,62.8 22.5,51.4 44.9,62.8 22.5,74.2 "/>
20
- <polygon class="st1" points="0,62.8 22.5,74.2 22.5,97.1 0,85.6 "/>
21
- <polygon class="st2" points="44.9,62.8 44.9,85.6 22.5,97.1 22.5,74.2 "/>
22
- <polygon class="st0" points="33.7,79.9 56.2,68.5 78.6,79.9 56.2,91.3 "/>
23
- <polygon class="st1" points="33.7,79.9 56.2,91.3 56.2,114.2 33.7,102.8 "/>
24
- <polygon class="st2" points="78.6,79.9 78.6,102.8 56.2,114.2 56.2,91.3 "/>
25
- <polygon class="st0" points="33.7,11.4 56.2,0 78.6,11.4 56.2,22.8 "/>
26
- <polygon class="st1" points="33.7,11.4 56.2,22.8 56.2,45.7 33.7,34.3 "/>
27
- <polygon class="st2" points="78.6,11.4 78.6,34.3 56.2,45.7 56.2,22.8 "/>
28
- <polygon class="st0" points="67.4,28.5 89.9,17.1 112.3,28.5 89.9,40 "/>
29
- <polygon class="st1" points="67.4,28.5 89.9,40 89.9,62.8 67.4,51.4 "/>
30
- <polygon class="st2" points="112.3,28.5 112.3,51.4 89.9,62.8 89.9,40 "/>
31
- <polygon class="st0" points="0,28.5 22.5,17.1 44.9,28.5 22.5,40 "/>
32
- <polygon class="st1" points="0,28.5 22.5,40 22.5,62.8 0,51.4 "/>
33
- <polygon class="st2" points="44.9,28.5 44.9,51.4 22.5,62.8 22.5,40 "/>
34
- </g>
35
- </svg>
@@ -1,110 +0,0 @@
1
- var _excluded = ["name", "label", "options", "outputTransform", "inputTransform", "readOnly", "previousValue", "allowNewValue", "onChangeCallback", "formProps"],
2
- _excluded2 = ["inputProps"];
3
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
- /**
6
- * Copyright (c) 2022, RTE (http://www.rte-france.com)
7
- * This Source Code Form is subject to the terms of the Mozilla Public
8
- * License, v. 2.0. If a copy of the MPL was not distributed with this
9
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
- */
11
-
12
- import React from 'react';
13
- import PropTypes from 'prop-types';
14
- import { Autocomplete, TextField } from '@mui/material';
15
- import { useController, useFormContext } from 'react-hook-form';
16
- import { genHelperError, genHelperPreviousValue, identity, isFieldRequired } from './utils/functions';
17
- import FieldLabel from './utils/field-label';
18
- var AutocompleteInput = function AutocompleteInput(_ref) {
19
- var name = _ref.name,
20
- label = _ref.label,
21
- options = _ref.options,
22
- _ref$outputTransform = _ref.outputTransform,
23
- outputTransform = _ref$outputTransform === void 0 ? identity : _ref$outputTransform,
24
- _ref$inputTransform = _ref.inputTransform,
25
- inputTransform = _ref$inputTransform === void 0 ? identity : _ref$inputTransform,
26
- _ref$readOnly = _ref.readOnly,
27
- readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
28
- previousValue = _ref.previousValue,
29
- allowNewValue = _ref.allowNewValue,
30
- onChangeCallback = _ref.onChangeCallback,
31
- formProps = _ref.formProps,
32
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
33
- var _useFormContext = useFormContext(),
34
- validationSchema = _useFormContext.validationSchema,
35
- getValues = _useFormContext.getValues,
36
- removeOptional = _useFormContext.removeOptional;
37
- var _useController = useController({
38
- name: name
39
- }),
40
- _useController$field = _useController.field,
41
- onChange = _useController$field.onChange,
42
- value = _useController$field.value,
43
- ref = _useController$field.ref,
44
- error = _useController.fieldState.error;
45
- var handleChange = function handleChange(value) {
46
- onChangeCallback && onChangeCallback();
47
- //if free solo not enabled or if value is not of string type, we call onChange right away
48
- if (!allowNewValue || typeof value !== 'string') {
49
- onChange(outputTransform(value));
50
- return;
51
- }
52
-
53
- //otherwise, we check if user input matches with one of the options
54
- var matchingOption = options.find(function (option) {
55
- return option.id === value;
56
- });
57
- //if it does, we send the matching option to react hook form
58
- if (matchingOption) {
59
- onChange(outputTransform(matchingOption));
60
- return;
61
- }
62
-
63
- //otherwise, we send the user input
64
- onChange(outputTransform(value));
65
- };
66
- return /*#__PURE__*/React.createElement(Autocomplete, _extends({
67
- value: inputTransform(value),
68
- onChange: function onChange(_, data) {
69
- return handleChange(data);
70
- }
71
- }, allowNewValue && {
72
- freeSolo: true,
73
- autoComplete: true,
74
- blurOnSelect: true,
75
- autoSelect: false,
76
- onInputChange: function onInputChange(_, data) {
77
- handleChange(data);
78
- }
79
- }, {
80
- options: options,
81
- renderInput: function renderInput(_ref2) {
82
- var inputProps = _ref2.inputProps,
83
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
84
- return /*#__PURE__*/React.createElement(TextField, _extends({}, label && {
85
- label: FieldLabel({
86
- label: label,
87
- optional: !isFieldRequired(name, validationSchema, getValues()) && !(props === null || props === void 0 ? void 0 : props.disabled) && !removeOptional
88
- })
89
- }, {
90
- inputRef: ref,
91
- inputProps: _extends({}, inputProps, {
92
- readOnly: readOnly
93
- })
94
- }, genHelperPreviousValue(previousValue), genHelperError(error === null || error === void 0 ? void 0 : error.message), formProps, rest));
95
- }
96
- }, props));
97
- };
98
- AutocompleteInput.propTypes = process.env.NODE_ENV !== "production" ? {
99
- name: PropTypes.string.isRequired,
100
- label: PropTypes.string,
101
- options: PropTypes.array.isRequired,
102
- outputTransform: PropTypes.func,
103
- inputTransform: PropTypes.func,
104
- readOnly: PropTypes.bool,
105
- previousValue: PropTypes.any,
106
- allowNewValue: PropTypes.bool,
107
- onChangeCallback: PropTypes.func,
108
- formProps: PropTypes.object
109
- } : {};
110
- export default AutocompleteInput;
@@ -1,56 +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, { useCallback } from 'react';
10
- import PropTypes from 'prop-types';
11
- import { useIntl } from 'react-intl';
12
- import FormControlLabel from '@mui/material/FormControlLabel';
13
- import { useController } from 'react-hook-form';
14
- var BooleanInput = function BooleanInput(_ref) {
15
- var name = _ref.name,
16
- label = _ref.label,
17
- formProps = _ref.formProps,
18
- Input = _ref.Input;
19
- var _useController = useController({
20
- name: name
21
- }),
22
- _useController$field = _useController.field,
23
- onChange = _useController$field.onChange,
24
- value = _useController$field.value,
25
- ref = _useController$field.ref;
26
- var intl = useIntl();
27
- var handleChangeValue = useCallback(function (event) {
28
- onChange(event.target.checked);
29
- }, [onChange]);
30
- var CustomInput = /*#__PURE__*/React.createElement(Input, _extends({
31
- checked: value,
32
- onChange: function onChange(e) {
33
- return handleChangeValue(e);
34
- },
35
- inputRef: ref,
36
- inputProps: {
37
- 'aria-label': 'primary checkbox'
38
- }
39
- }, formProps));
40
- if (label) {
41
- return /*#__PURE__*/React.createElement(FormControlLabel, {
42
- control: CustomInput,
43
- label: intl.formatMessage({
44
- id: label
45
- })
46
- });
47
- }
48
- return CustomInput;
49
- };
50
- BooleanInput.propTypes = process.env.NODE_ENV !== "production" ? {
51
- name: PropTypes.string.isRequired,
52
- label: PropTypes.string,
53
- formProps: PropTypes.object,
54
- Input: PropTypes.elementType.isRequired
55
- } : {};
56
- export default BooleanInput;
@@ -1,28 +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 BooleanInput from './boolean-input';
11
- import Checkbox from '@mui/material/Checkbox';
12
- var CheckboxInput = function CheckboxInput(_ref) {
13
- var name = _ref.name,
14
- label = _ref.label,
15
- formProps = _ref.formProps;
16
- return /*#__PURE__*/React.createElement(BooleanInput, {
17
- name: name,
18
- label: label,
19
- formProps: formProps,
20
- Input: Checkbox
21
- });
22
- };
23
- CheckboxInput.propTypes = process.env.NODE_ENV !== "production" ? {
24
- name: PropTypes.string.isRequired,
25
- label: PropTypes.string,
26
- formProps: PropTypes.object
27
- } : {};
28
- export default CheckboxInput;
@@ -1,28 +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 BooleanInput from './boolean-input';
11
- import Switch from '@mui/material/Switch';
12
- var SwitchInput = function SwitchInput(_ref) {
13
- var name = _ref.name,
14
- label = _ref.label,
15
- formProps = _ref.formProps;
16
- return /*#__PURE__*/React.createElement(BooleanInput, {
17
- name: name,
18
- label: label,
19
- formProps: formProps,
20
- Input: Switch
21
- });
22
- };
23
- SwitchInput.propTypes = process.env.NODE_ENV !== "production" ? {
24
- name: PropTypes.string.isRequired,
25
- label: PropTypes.string,
26
- formProps: PropTypes.object
27
- } : {};
28
- export default SwitchInput;
@@ -1,50 +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, { useEffect, useRef } from 'react';
9
- import { FormattedMessage } from 'react-intl';
10
- import { useController } from 'react-hook-form';
11
- var ErrorInput = function ErrorInput(_ref) {
12
- var name = _ref.name,
13
- InputField = _ref.InputField;
14
- var _useController = useController({
15
- name: name
16
- }),
17
- error = _useController.fieldState.error,
18
- isSubmitting = _useController.formState.isSubmitting;
19
- var errorRef = useRef(null);
20
- var errorProps = function errorProps(errorMsg) {
21
- if (typeof errorMsg === 'string') {
22
- return {
23
- id: errorMsg
24
- };
25
- } else if (typeof errorMsg === 'object') {
26
- return {
27
- id: errorMsg.id,
28
- values: {
29
- value: errorMsg.value
30
- }
31
- };
32
- }
33
- return {};
34
- };
35
- useEffect(function () {
36
- // the scroll should be done only when the form is submitting
37
- if (error && errorRef.current) {
38
- errorRef.current.scrollIntoView({
39
- behavior: 'smooth'
40
- });
41
- }
42
- // eslint-disable-next-line react-hooks/exhaustive-deps
43
- }, [isSubmitting]);
44
- return /*#__PURE__*/React.createElement(React.Fragment, null, (error === null || error === void 0 ? void 0 : error.message) && /*#__PURE__*/React.createElement("div", {
45
- ref: errorRef
46
- }, /*#__PURE__*/React.createElement(InputField, {
47
- message: /*#__PURE__*/React.createElement(FormattedMessage, errorProps(error === null || error === void 0 ? void 0 : error.message))
48
- })));
49
- };
50
- export default ErrorInput;
@@ -1,22 +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
- import React from 'react';
9
- import { Alert, Grid } from '@mui/material';
10
-
11
- // component to display alert when a specific rhf field is in error
12
- // this component needs to be isolated to avoid too many rerenders
13
- var FieldErrorAlert = function FieldErrorAlert(_ref) {
14
- var message = _ref.message;
15
- return /*#__PURE__*/React.createElement(Grid, {
16
- item: true,
17
- xs: 12
18
- }, /*#__PURE__*/React.createElement(Alert, {
19
- severity: "error"
20
- }, message));
21
- };
22
- export default FieldErrorAlert;