Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #137: @atls/tinkoff-payment-widget работает некорректно в билде на Next проектах #138

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading