Should be fairly easy to port from the legacy version:
https://gitlab.rlp.net/motionbank/applications/systems-frontend/-/blob/release_2_6/src/lib/export/csv.js