Overview
The InternationalTelephoneControl is a
custom PCF (PowerApps Component Framework) control that allows users to input a
phone number with a selectable international dialing code. It combines an input
field with a flag picker modal for selecting country codes, improving the UX
for global phone number entry.
Key Features
·
Phone Input Field: Standard
input field restricted to numeric input (type='tel') for entering phone
numbers.
·
Default Country Code: Displays
a default country code (+92, Pakistan) on initialization unless another is
selected.
·
Country Selector Modal:
Toggleable modal to pick a country. Each country shows:
- National flag
- Country name
- Native name
- Dialing code
·
Live Output Updating: Whenever
the user enters or updates the number, or changes the country code, the
component emits the combined value (e.g., +92 3001234567).
UI Components
Element |
Description |
wrapper |
Main container for the control |
selectedOption |
Shows selected country’s flag and code |
inputElement |
Textbox for entering the phone number |
modal |
Overlay window displaying all countries |
modalContent |
Scrollable list of country options |
toggleButton |
Opens the modal to select country |
Functional Flow
1.
1. Initialization (init)
Initializes the control and calls:
- createUI() to render main input and selected option area.
- createModal() to prepare the modal.
- populateModalOptions() to load country list from countries.
2.
2. Country Selection
Clicking the 🌐 button opens the
modal.
Clicking a country in the modal:
- Sets the selected flag and code via setSelectedCountry().
- Closes the modal.
- Triggers onInputChange().
3.
3. Phone Number Input
Any typing into the input triggers
onInputChange().
Combines current country code with the phone number.
Stores value in currentValue and calls notifyOutputChanged().
4.
4. Output (getOutputs)
Returns phoneNumber: string containing the
full value.
5.
5. Destruction (destroy)
Cleans up DOM by removing modal on control
removal.
Data Bindings
Property |
Direction |
Type |
Description |
phoneNumber |
Output |
string |
Full phone number in international format (+<code>
<number>) |
Dependencies
Countries list (./Countries/countries.ts)
should export an array of objects with the following shape:
{
name: string;
nativeName: string;
code: string; // e.g., '+92'
flag: string; // URL or base64 image
}
Customization Ideas
·
Enable validation for number
format.
·
Limit selectable countries.
·
Support for right-to-left
languages.
·
Keyboard navigation in modal.
Comments
Post a Comment