Repository navigation
EmptyValueTag
Renders a value or a fallback dash placeholder for empty or missing values.
Tables, detail views, and summary cards often display fields that may be empty. Rather than rendering a blank space (which users may confuse with a rendering glitch or missing data), this component consistently shows a dash (-). It also normalises the many flavours of "empty" in JavaScript — null, undefined, empty string, and whitespace-only string — into the same visual output.
| Name | Type | Required | Description |
|---|---|---|---|
value |
string | number | null | undefined |
No | Value to display. Null, undefined, or empty strings render a dash. |
import EmptyValueTag from '@/components/core/Tags/EmptyValueTag';
<EmptyValueTag value="Permit 123" />;
<EmptyValueTag value={42} />;
<EmptyValueTag value={null} />;
<EmptyValueTag value="" />;The component applies a strict emptiness check before rendering:
- If
valueis notnull, notundefined, not'', and not a whitespace-only string → renders<span>{value}</span>. - Otherwise → renders
<span data-testid="empty-value">-</span>.
Key edge cases:
-
0(zero) is rendered as-is because it passes the null/undefined/empty-string checks. - Whitespace-only strings like
" "are treated as empty. - Numeric values are coerced to string by React and rendered normally.
<EmptyValueTag value="Active" />
<!-- Renders: <span>Active</span> --><EmptyValueTag value={0} />
<!-- Renders: <span>0</span> (zero is a valid value, not empty) -->
<EmptyValueTag value={null} />
<!-- Renders: <span data-testid="empty-value">-</span> -->- The
data-testid="empty-value"attribute on the fallback span enables stable test assertions. - The component has no styling of its own — the surrounding context determines presentation.
- There are no dependencies beyond React.
- The component does not truncate long strings. Use a separate utility for that.
- There is no
maxLengthor ellipsis behaviour.
-
codes/frontend/core/Tags/PrecisionNumberTag— delegates to EmptyValueTag for empty/invalid input.
- PrecisionNumberTag — number formatter that uses EmptyValueTag for its fallback state.
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository