@@ -101,10 +101,29 @@ export type InputProps = {
101101export const Input = createFC < InputProps , { isFormElement : boolean } > (
102102 ( props ) => {
103103 const {
104+ id : id_ ,
105+ className,
106+ label,
107+ required,
108+ error,
109+ readOnly,
110+ cols,
111+ type,
112+ bare,
113+ value,
114+ defaultValue,
115+ htmlReadOnly,
116+ iconLeft,
117+ iconRight,
118+ addonLeft,
119+ addonRight,
104120 symbolPattern,
121+ elementRef,
122+ inputRef,
105123 onKeyDown : onKeyDown_ ,
106124 onChange : onChange_ ,
107125 onValueChange,
126+ ...rprops
108127 } = props ;
109128
110129 useInitComponentStyle ( ) ;
@@ -129,55 +148,8 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
129148 prevValueRef . current = e . target . value ;
130149 } ) ;
131150
132- const {
133- id : id_ ,
134- label,
135- required,
136- error,
137- readOnly,
138- cols,
139- elementRef,
140- ...rprops
141- } = props ;
142151 const id = useFormElementId ( id_ , 'input' ) ;
143152 const { isFieldSetColumn } = useContext ( FieldSetColumnContext ) ;
144- if ( isFieldSetColumn || label || required || error || cols ) {
145- const formElemProps = {
146- id,
147- label,
148- required,
149- error,
150- readOnly,
151- cols,
152- elementRef,
153- } ;
154- return (
155- < FormElement { ...formElemProps } >
156- < Input { ...{ id, readOnly, ...rprops } } />
157- </ FormElement >
158- ) ;
159- }
160-
161- const {
162- className,
163- inputRef,
164- type,
165- bare,
166- value,
167- defaultValue,
168- htmlReadOnly,
169- iconLeft,
170- iconRight,
171- addonLeft,
172- addonRight,
173- // eslint-disable-next-line @typescript-eslint/no-unused-vars
174- onChange : _unused_1 ,
175- // eslint-disable-next-line @typescript-eslint/no-unused-vars
176- onValueChange : _unused_2 ,
177- // eslint-disable-next-line @typescript-eslint/no-unused-vars
178- onKeyDown : _unused_3 ,
179- ...rprops2
180- } = rprops ;
181153 const inputClassNames = classnames (
182154 className ,
183155 bare ? 'slds-input_bare' : 'slds-input'
@@ -200,12 +172,13 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
200172 value = { value }
201173 defaultValue = { defaultValue }
202174 readOnly = { htmlReadOnly }
203- { ...rprops2 }
175+ { ...rprops }
204176 onChange = { onChange }
205177 onKeyDown = { onKeyDown }
206178 />
207179 ) ;
208180
181+ let contentElem = inputElem ;
209182 if ( iconLeft || iconRight || addonLeft || addonRight ) {
210183 const wrapperClassName = classnames (
211184 'slds-form-element__control' ,
@@ -215,7 +188,7 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
215188 { 'slds-input-has-icon_right' : iconRight } ,
216189 { 'slds-input-has-fixed-addon' : addonLeft || addonRight }
217190 ) ;
218- return (
191+ contentElem = (
219192 < div className = { wrapperClassName } >
220193 { addonLeft ? < InputAddon content = { addonLeft } /> : undefined }
221194 { iconLeft ? < InputIcon icon = { iconLeft } align = 'left' /> : undefined }
@@ -225,7 +198,19 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
225198 </ div >
226199 ) ;
227200 }
228- return inputElem ;
201+ if ( isFieldSetColumn || label || required || error || cols ) {
202+ const formElemProps = {
203+ id,
204+ label,
205+ required,
206+ error,
207+ readOnly,
208+ cols,
209+ elementRef,
210+ } ;
211+ return < FormElement { ...formElemProps } > { contentElem } </ FormElement > ;
212+ }
213+ return contentElem ;
229214 } ,
230215 { isFormElement : true }
231216) ;
0 commit comments