The invention provides novel poly-substituted 5-membered heterocyclic compounds represented by Formula (IV), or a pharmaceutically acceptable salt, solvate, metabolites, polymorph, ester, tautomer or prodrug thereof, and a composition comprising these compounds. The compounds provided can be used as selective irreversible brutons tyrosine kinase (Btk) inhibitors and is further useful to treat inflammatory, auto immune diseases associated with aberrant B-cell proliferation such as RA (rheumatoid arthritis) and cancers. This invention also provided the preparation of a medicament using of Formula (IV), and methods of preventing or treating diseases associated with excessive Btk activity in mammals, especially humans. Formula (IV)