# Sverige Personnummer Input

SverigePersonnummerInput is a headless input for entering Sweden's Personnummer, Sweden's national-id identifier. It renders as `<input type="text">` with pattern validation, numeric/letter keyboard hints, and `autocomplete="off"` to protect sensitive identifiers. It is the editable companion to SverigePersonnummerView.

**Status:** beta — implemented and unit-tested in all seven frameworks with an axe-clean demo page; not yet exercised in composed flows.

## Implementation Notes

- Renders as `<input type="text">` with pattern validation
- Format: 12 digits in the format CCYYMMDDZZZQ: CCYYMMDD is the date of birth, ZZZ a serial (odd male, even female), and Q a Luhn check digit
- `autocomplete="off"` to protect sensitive identifiers
- Supports two-way binding on the `value` prop
- Companion to SverigePersonnummerView

## Props

- `label`: string (required) — accessible label via `aria-label`
- `value`: string (default: "") — bindable input value
- `required`: boolean (default: false) — form validation
- `disabled`: boolean (default: false) — disabled state
- `...restProps`: any — additional HTML attributes spread onto the `<input>`

## Usage

```html
<Field
  label="Personal Identity Number"
  required
>
  <SverigePersonnummerInput
    label="Personal Identity Number"
    value="{value}"
    required
  />
  <Hint
    >12 digits in the format CCYYMMDDZZZQ: CCYYMMDD is the date of birth, ZZZ a serial (odd male,
    even female), and Q a Luhn check digit</Hint
  >
  <ErrorMessage>Please enter a valid Personal Identity Number</ErrorMessage>
</Field>
```

## ARIA

- `aria-label={label}` — provides accessible name

## When to Use

- Use in forms collecting Sweden's Personnummer.
- Use with pattern validation matching the documented format.
- Use in administrative or national-id workflows where the identifier is required.

## When Not to Use

- Do not use for displaying read-only identifiers — use `sverige-personnummer-view` instead.
- Do not use for general text input — use `text-input` instead.
- Do not use for other countries' identifiers — use the corresponding country-specific input.

## Headless

This headless component ships zero CSS. The consumer provides all styling targeting the `.sverige-personnummer-input` class hook.

## Testing

- Verify renders an `<input>` with the correct class and `type="text"`
- Verify `aria-label` is set from the `label` prop
- Verify pattern attribute matches the documented format
- Verify `autocomplete="off"`
- Verify value binding works

## Domain Knowledge

National identification number issued by Skatteverket since 1947, twelve digits CCYYMMDDZZZQ in automated data (or ten digits when the century is implicit). CCYYMMDD is the date of birth, ZZZ is the individual serial number whose third digit is odd for males and even for females, and Q is a Luhn check digit.

**Where to find it:** Passports, national ID cards, driving licences, health-care cards, payslips, and tax correspondence; held by the Swedish Tax Agency (Skatteverket).

## Security and privacy

A national identifier is personal data, and often a key to other records.

- The input renders `autocomplete="off"`, so the browser neither saves nor offers the value, and `spellcheck="false"`, so an enhanced spellchecker does not send it to a cloud service. `bin/check-identifier-inputs` keeps both in all nine catalogs.
- Do not log the value, put it in a URL or query string, or send it to analytics or an error tracker; mask it there if it must appear.
- The component stores nothing. Do not keep the value in `localStorage`, `sessionStorage` or a cookie; submit it in the body of a POST over HTTPS.
- A format or checksum check proves the number is well formed, not that it belongs to the person entering it.
- The page decides who may see it: the input does not mask what is typed. Use the matching `-view` to show it back, masked as the service requires.

## Related components

- `sverige-personnummer-view` — a read-only display of Sweden's Personnummer
- `text-input` — a single-line text input field <input type="text">

## Known limitations

None known.

## References

- Wikipedia: https://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)

---

Lily™ and Lily Design System™ are trademarks.
