66 */
77import { LimitsTagChip } from './limits-tag-chip' ;
88import { Autocomplete , AutocompleteRenderInputParams , Box , Stack , TextField , IconButton } from '@mui/material' ;
9- import { useCallback , useState } from 'react' ;
9+ import { useCallback , useMemo , useState } from 'react' ;
1010import { AddCircle , Delete } from '@mui/icons-material' ;
11- import { LimitsPropertyName } from './limits-constants' ;
1211import { useIntl } from 'react-intl' ;
1312import { LimitsProperty } from '../../../services/network-modification-types' ;
1413import { useFormContext , useWatch } from 'react-hook-form' ;
14+ import { usePredefinedProperties } from '@gridsuite/commons-ui' ;
1515
1616export interface LimitsPropertiesSideStackProps {
1717 formName : string ;
@@ -28,6 +28,11 @@ export function LimitsPropertiesSideStack({ formName, disabled }: Readonly<Limit
2828 const [ editorError , setEditorError ] = useState < string > ( '' ) ;
2929 const intl = useIntl ( ) ;
3030
31+ const [ predefinedProperties ] = usePredefinedProperties ( 'limitsGroup' ) ;
32+ const predefinedPropertiesNames = useMemo ( ( ) => {
33+ return Object . keys ( predefinedProperties ?? { } ) . sort ( ( a , b ) => a . localeCompare ( b ) ) ;
34+ } , [ predefinedProperties ] ) ;
35+
3136 const handleKeyPress = useCallback (
3237 ( event : React . KeyboardEvent < HTMLInputElement > ) => {
3338 if ( event . key === 'Enter' ) {
@@ -94,7 +99,7 @@ export function LimitsPropertiesSideStack({ formName, disabled }: Readonly<Limit
9499 onMouseLeave = { ( ) => setHovered ( false ) }
95100 >
96101 < Autocomplete
97- options = { Object . values ( LimitsPropertyName ) }
102+ options = { Object . values ( predefinedPropertiesNames ) }
98103 size = "small"
99104 onChange = { ( event , value ) => handleOnChange ( value ?? '' ) }
100105 renderInput = { ( params : AutocompleteRenderInputParams ) => (
0 commit comments