'use client'; import React, { useRef, useImperativeHandle, type RefObject } from 'react'; import 'jb-image-input'; import type { JBImageInputWebComponent, JBImageInputConfig, JBImageInputBridge } from 'jb-image-input'; import { type EventProps, useEvents } from './events-hook.js'; import { useJBImageInputAttribute, type JBImageInputAttributes } from './attributes-hook.js'; import type { JBElementStandardProps } from 'jb-core/react'; export type { JBImageInputConfig, JBImageInputBridge }; declare module "react" { namespace JSX { interface IntrinsicElements { 'jb-image-input': JBImageInputType; } interface JBImageInputType extends React.DetailedHTMLProps>, JBImageInputWebComponent> { class?: string, label?: string, message?: string, name?: string, required?: string | boolean, // ref:React.RefObject, } } } export function JBImageInput (props: Props, ref) { const element = useRef>(null); useImperativeHandle( ref, () => (element ? element.current : undefined), [element], ); const {acceptTypes,bridge,config,file,label,maxFileSize,message,multiple,name,required,validationList,value,onChange,onImageSelected,onInit,onLoad,onMaxSizeExceed,uploadType,...otherProps} = props; useJBImageInputAttribute(element, {acceptTypes,bridge,config,file,label,maxFileSize,message,multiple,name,required,validationList,value}); useEvents(element, {onChange,onImageSelected,onInit,onLoad,onMaxSizeExceed}); return ( {props.children} ); }; type ImageInputProps = EventProps & JBImageInputAttributes & { uploadType?: string, ref?: RefObject> } export type Props = ImageInputProps & JBElementStandardProps> JBImageInput.displayName = "JBImageInput";