Canonical bases arising from quantum symmetric pairs of Kac-Moody type