Dimensions and bases of hierarchical tensor-product splines