import { forwardRef } from "react"; type AtLeastOne = [T, ...T[]]; export function createWithStateProps( useContexts: AtLeastOne< (prop?: { strict?: boolean }) => { stateProps: React.HTMLAttributes } | null >, options?: { strict?: boolean }, ) { const strict = options?.strict ?? true; return function withStateProps(Component: React.ComponentType

>) { const Node = forwardRef((props, ref) => { const stateProps = {}; for (const useContext of useContexts) { Object.assign(stateProps, useContext({ strict })?.stateProps); } // @ts-ignore return ; }); Node.displayName = Component.displayName || Component.name; return Node; }; }