The Near-Infrared Spectrograph (NIRSpec) on the James Webb Space Telescope III. Integral-field spectroscopy