A server-side Vaadin add-on that provides a phone number input field with an integrated country-code selector (flag + dial code). Built on CustomField<String> — no client-side JavaScript required.
- 🏳️ Country flag + dial-code dropdown (25 countries)
- 📞 Combined model value (
+358401234567) - 🔍 Filterable country list (by name, ISO code, or dial code)
- ✅ Automatic whitespace normalization
- 🔁 Round-trip value parsing — set
+447700900123and it selects 🇬🇧 UK automatically - ♿ Inherits Vaadin's built-in validation, read-only, and error states
| Dependency | Version |
|---|---|
| Java | 17+ |
| Vaadin | 23.3+ |
| Maven | 3.8+ |
mvn jetty:run -PdevelopmentOpen http://localhost:8080 — the DemoView showcase page loads automatically.
mvn testRuns CountryNumberTest (value parsing, round-trip, reformat) and CountryNumberEdgeCasesTest (+1 ambiguity, whitespace normalization).
CountryNumber phone = new CountryNumber();
phone.setPlaceholder("Phone number");
phone.addValueChangeListener(e ->
System.out.println("Full number: " + e.getValue()));phone.setCountryCode(CountryCode.UNITED_KINGDOM);
// or by ISO code
phone.setCountryCodeByIso("GB");phone.setValue("+447700900123"); // auto-selects 🇬🇧 UKphone.setInvalid(true);
phone.setErrorMessage("Number is too short");src/
├── main/java/org/vaadin/addons/yahaya/
│ ├── CountryCode.java # Enum of supported countries (ISO, flag, dial code)
│ └── CountryNumber.java # The add-on component (CustomField<String>)
├── main/resources/META-INF/resources/frontend/
│ └── country-number.css # Component styles
└── test/java/org/vaadin/addons/yahaya/
├── DemoView.java # Showcase page (@Route(""))
├── CountryNumberTest.java # Unit tests — parsing & formatting
└── CountryNumberEdgeCasesTest.java # Edge-case tests — +1 ambiguity, whitespace
Test classes live under
src/testand are not packaged into the add-on JAR.
Contributions are welcome! Here's how to get started:
- Open an issue first — describe the bug, fix, or feature you want to work on. This avoids duplicate effort and gives maintainers a chance to provide early feedback.
- Fork & clone the repository.
- Create a branch for your change:
git checkout -b feature/your-feature-name
- Run the demo to make sure the project builds and works:
mvn jetty:run -Pdevelopment
- Make your changes — keep them focused on a single concern.
- Add or update tests for any new or changed behavior.
- Run all tests before committing:
mvn test - Commit with a clear, descriptive message.
- Push your branch and open a pull request against
main.
- Follow existing code style and naming conventions.
- Keep PRs small and reviewable — one feature or fix per PR.
- New public API methods should include usage examples in the PR description.
- All existing tests must continue to pass.