11import { FieldErrors , UseFormRegister , UseFormSetValue , UseFormWatch } from 'react-hook-form' ;
22import { CreateDialogProps } from './CreateWorkspaceDialogContainer.tsx' ;
33import { useTranslation } from 'react-i18next' ;
4- import { Form , FormGroup , Input , Label , Option , Select , SelectDomRef , Ui5CustomEvent } from '@ui5/webcomponents-react' ;
4+ import {
5+ Form ,
6+ FormGroup ,
7+ Input ,
8+ Label ,
9+ Option ,
10+ Select ,
11+ SelectDomRef ,
12+ Ui5CustomEvent ,
13+ InputDomRef ,
14+ } from '@ui5/webcomponents-react' ;
515import styles from './CreateProjectWorkspaceDialog.module.css' ;
616import React from 'react' ;
717
@@ -58,7 +68,6 @@ export function MetadataForm({
5868 const currentName = watch ?.( 'name' ) ?? '' ;
5969 const currentDisplayName = watch ?.( 'displayName' ) ?? '' ;
6070
61- // Resolve and normalize affixes once (trim + fallback to '')
6271 const resolvedNamePrefix = ( namePrefix || '' ) . trim ( ) ;
6372 const resolvedDisplayNamePrefix = ( displayNamePrefix || '' ) . trim ( ) ;
6473 const resolvedNameSuffix = ( propNameSuffix || '' ) . trim ( ) ;
@@ -74,22 +83,16 @@ export function MetadataForm({
7483 const nameCore = computeCore ( currentName , resolvedNamePrefix , resolvedNameSuffix ) ;
7584 const displayNameCore = computeCore ( currentDisplayName , resolvedDisplayNamePrefix , resolvedDisplayNameSuffix ) ;
7685
77- const onNameCoreInput = ( e : any ) => {
78- const middle =
79- ( e ?. target && typeof e . target . value === 'string' ? e . target . value : undefined ) ??
80- ( e ?. detail && typeof e . detail . value === 'string' ? e . detail . value : '' ) ??
81- '' ;
86+ const onNameCoreInput = ( e : Ui5CustomEvent < InputDomRef , { value : string } > ) => {
87+ const middle = typeof e . detail ?. value === 'string' ? e . detail . value : ( e . target . value ?? '' ) ;
8288 setValue ( 'name' , `${ resolvedNamePrefix } ${ middle } ${ resolvedNameSuffix } ` , {
8389 shouldValidate : true ,
8490 shouldDirty : true ,
8591 } ) ;
8692 } ;
8793
88- const onDisplayNameCoreInput = ( e : any ) => {
89- const middle =
90- ( e ?. target && typeof e . target . value === 'string' ? e . target . value : undefined ) ??
91- ( e ?. detail && typeof e . detail . value === 'string' ? e . detail . value : '' ) ??
92- '' ;
94+ const onDisplayNameCoreInput = ( e : Ui5CustomEvent < InputDomRef , { value : string } > ) => {
95+ const middle = typeof e . detail ?. value === 'string' ? e . detail . value : ( e . target . value ?? '' ) ;
9396 setValue ( 'displayName' , `${ resolvedDisplayNamePrefix } ${ middle } ${ resolvedDisplayNameSuffix } ` , {
9497 shouldValidate : true ,
9598 shouldDirty : true ,
0 commit comments