General approach to state-dependent optical-tweezer traps for polar molecules