Skip to content

Commit

Permalink
fix(input-wrapper): transform children arguments to object
Browse files Browse the repository at this point in the history
  • Loading branch information
absolemDev committed Nov 23, 2023
1 parent 611572e commit 2762700
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 11 additions & 9 deletions packages/payment-widget/src/interfaces/wrappers.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { ReactElement } from 'react'

import { HandleBlurField } from './fields.interfaces'
import { ReactElement } from 'react'

import { HandleBlurField } from './fields.interfaces'
import { HandleChangeField } from './fields.interfaces'

interface ChildrenInputProps {
name: string
value: string
onChangeNative: HandleChangeField
onBlur: HandleBlurField
errorText: string
}

export interface InputWrapperProps {
name: string
children: (
value: string,
onChange: HandleChangeField,
onBlur: HandleBlurField,
errorText: string
) => ReactElement
children: (props: ChildrenInputProps) => ReactElement
}

export interface ButtonWrapperProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ export const InputWrapper: FC<InputWrapperProps> = ({ name, children }) => {
const translateError = translate(intl, errors[name], errors[name])

if (typeof children === 'function') {
return children(fieldsState as string, handleChange, handleBlur, translateError)
return children({
name,
value: fieldsState as string,
onChangeNative: handleChange,
onBlur: handleBlur,
errorText: translateError,
})
}

return null
Expand Down

0 comments on commit 2762700

Please sign in to comment.