refactor(tab): rewrite tab directive (fixes #593, fixes #709, fixes #736, fixes #772)