Wikipedia defines hat-trick as,
A hat-trick occurs in cricket when a bowler dismisses three batsmen with consecutive deliveries. The deliveries may be interrupted by an over bowled by another bowler from the other end of the pitch or the other team's innings, but must be three consecutive deliveries by the individual bowler. Only wickets attributed to the bowler count towards a hat-trick; run outs do not count.
The Concise Oxford English Dictionary defines a hat-trick as:
[...] the taking of three wickets by the same bowler with successive balls
The term hat-trick in cricket has no official definition by its governing bodies, but is a term used by the media and cricket aficionados to describe three wickets (that are claimed by the bowler) in three consecutive deliveries. It is left to each one's perspective if a hat-trick is annulled if three wickets are separated by a wide, but a vast majority would believe that having a wide in between three wickets is NOT a hat-trick, as implied by the definitions above. This is because though the wide delivery is illegal, it still is a delivery, implying that three batsmen are not dismissed in three consecutive deliveries.
The same is the case for a no-ball.