A 7.8-magnitude earthquake has shaken New Zealand, prompting a tsunami warning for parts of the Pacific Ocean.