Skip to content

Commit

Permalink
Merge pull request #138 from atls/hotfix/wrapper
Browse files Browse the repository at this point in the history
Issue #137: @atls/tinkoff-payment-widget работает некорректно в билде на Next проектах
  • Loading branch information
TorinAsakura authored Dec 9, 2023
2 parents b772b8a + d69d394 commit 6012d1e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
8 changes: 2 additions & 6 deletions packages/payment-widget/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
export {
Widget,
ButtonWrapper,
InputWrapper,
} from './ui'
export { Widget, ButtonWrapper, InputWrapper } from './ui'
export {
Settings,
Styles,
AdditionalField,
Receipt,
ReceiptItem,
DirectionFields,
} from './interfaces'
} from './interfaces'
export * from './enums'
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Condition } from '@atls-ui-parts/condition'
import { Condition } from '@atls-ui-parts/condition'

import React from 'react'
import { FC } from 'react'
import React from 'react'
import { FC } from 'react'

import { ButtonType } from '../../enums'
import { ButtonWrapperProps } from '../../interfaces'
import { useForm } from '../form'
import { ButtonType } from '../../enums'
import { NameWrapperComponent } from '../../enums'
import { ButtonWrapperProps } from '../../interfaces'
import { useForm } from '../form'

export const ButtonWrapper: FC<ButtonWrapperProps> = ({ children }) => {
const ButtonWrapper: FC<ButtonWrapperProps> = ({ children }) => {
const { disabled, isLoaded } = useForm()

return (
Expand All @@ -19,3 +20,7 @@ export const ButtonWrapper: FC<ButtonWrapperProps> = ({ children }) => {
</Condition>
)
}

ButtonWrapper.displayName = NameWrapperComponent.ButtonWrapper

export { ButtonWrapper }
21 changes: 13 additions & 8 deletions packages/payment-widget/src/ui/wrapper/input-wrapper.component.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Condition } from '@atls-ui-parts/condition'
import { Condition } from '@atls-ui-parts/condition'

import React from 'react'
import { FC } from 'react'
import { useIntl } from 'react-intl'
import React from 'react'
import { FC } from 'react'
import { useIntl } from 'react-intl'

import { InputWrapperProps } from '../../interfaces'
import { translate } from '../../utils/translate.util'
import { useForm } from '../form'
import { NameWrapperComponent } from '../../enums'
import { InputWrapperProps } from '../../interfaces'
import { translate } from '../../utils/translate.util'
import { useForm } from '../form'

export const InputWrapper: FC<InputWrapperProps> = ({ name, children }) => {
const InputWrapper: FC<InputWrapperProps> = ({ name, children }) => {
const { fieldsState, handleChange, handleBlur, errors } = useForm()
const intl = useIntl()
const translateError = translate(intl, errors[name], errors[name])
Expand All @@ -25,3 +26,7 @@ export const InputWrapper: FC<InputWrapperProps> = ({ name, children }) => {
</Condition>
)
}

InputWrapper.displayName = NameWrapperComponent.InputWrapper

export { InputWrapper }
12 changes: 6 additions & 6 deletions packages/payment-widget/src/utils/is-custom-element.util.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ReactNode } from 'react'
import { JSXElementConstructor } from 'react'
import { isValidElement } from 'react'
import { FunctionComponent } from 'react'
import { ReactNode } from 'react'
import { isValidElement } from 'react'

import { NameWrapperComponent } from '../enums'
import { NameWrapperComponent } from '../enums'

export const isCustomElement = (nameNode: NameWrapperComponent, node: ReactNode): boolean =>
isValidElement(node)
? (node.type as JSXElementConstructor<any>).name === nameNode &&
isValidElement(node) && typeof node.type === 'function'
? (node.type as FunctionComponent).displayName === nameNode &&
typeof node.props.children === 'function'
: false

0 comments on commit 6012d1e

Please sign in to comment.