Concept:
If \(f:A\to B\) is surjective, then every element of \(B\) must be an image of some element of \(A\). Therefore, \(B\) is the range of the function \(f\).
Step 1: Find \(f(x)\) for \(x\lt 0\).
For \(x\lt 0\),
\[
|x|=-x,\qquad |x-1|=1-x.
\]
Hence,
\[
f(x)=\frac{-x-1}{1-x}
=\frac{x+1}{x-1}.
\]
Let
\[
y=\frac{x+1}{x-1}.
\]
Then,
\[
x=\frac{y+1}{y-1}.
\]
Since \(x\lt 0\), we get
\[
-1\lt y\lt 1.
\]
Thus, the range for \(x\lt 0\) is \((-1,1)\).
Step 2: Find \(f(x)\) for \(0\le x\lt 1\).
For \(0\le x\lt 1\),
\[
|x|=x,\qquad |x-1|=1-x.
\]
Therefore,
\[
f(x)=\frac{x-1}{1-x}=-1.
\]
Hence, \(-1\) belongs to the range.
Step 3: Find \(f(x)\) for \(x\gt 1\).
For \(x\gt 1\),
\[
|x|=x,\qquad |x-1|=x-1.
\]
Therefore,
\[
f(x)=\frac{x-1}{x-1}=1.
\]
Hence, \(1\) belongs to the range.
Step 4: Determine the range of \(f\).
Combining all cases,
\[
\text{Range}(f)=(-1,1)\cup\{-1\}\cup\{1\}=[-1,1].
\]
Since \(f\) is surjective onto \(B\),
\[
B=[-1,1].
\]
\[
\boxed{B=[-1,1]}
\]