'use client'; import React, { useRef, useEffect, useState, useImperativeHandle } from 'react'; import {BaseProps, useJBInputAttribute,useJBInputEvents} from 'jb-input/react'; import 'jb-payment-input'; // eslint-disable-next-line no-duplicate-imports import {JBPaymentInputWebComponent, PaymentInputType} from 'jb-payment-input'; declare module "react" { // eslint-disable-next-line @typescript-eslint/no-namespace namespace JSX { interface IntrinsicElements { 'jb-payment-input': JBPaymentInputType; } interface JBPaymentInputType extends React.DetailedHTMLProps, JBPaymentInputWebComponent> { "class"?: string, "type"?: string, "label"?:string, "message"?:string, "placeholder"?:string, } } } // eslint-disable-next-line react/display-name const JBPaymentInput = React.forwardRef((props:Props, ref) => { const element = useRef(null); useImperativeHandle( ref, () => (element ? element.current : {}), [element], ); useJBInputAttribute(element,props); useJBInputEvents(element,props); useEffect(() => { element.current.setAttribute('input-type', props.inputType); }, [props.inputType]); useEffect(() => { if( props.separator && typeof props.separator === "string" && props.separator !== ""){ element.current.separatorString = props.separator; } }, [props.separator]); return ( {props.children} ); }); export type Props = BaseProps & { inputType?: PaymentInputType | null, separator?: string | null, }; JBPaymentInput.displayName = "JBPaymentInput"; export {JBPaymentInput};