Migrating from ghl-ui InputPhone to HighRise InputPhone
This guide will help you migrate from the ghl-ui InputPhone component to the new HighRise InputPhone component.
Component Implementation Changes
Import Changes
diff
- import { UIInputPhone } from '@gohighlevel/ghl-ui'
+ import { HLInputPhone } from '@platform-ui/highrise'
Basic Usage Changes
diff
- <UIInputPhone
- id="phone-input"
- v-model:value="phoneNumber"
- v-model:countryCode="countryCode"
- @isValid="isPhoneValid = $event"
- @nationalFormat="nationalFormat = $event"
- @internationalFormat="internationalFormat = $event"
- />
+ <HLInputPhone
+ id="phone-input"
+ v-model:modelValue="phoneNumber"
+ v-model:countryCode="countryCode"
+ @isValid="isPhoneValid = $event"
+ @nationalFormat="nationalFormat = $event"
+ @internationalFormat="internationalFormat = $event"
+ />
Form Integration Changes
diff
- <UIForm :model="formData" :rules="rules">
- <UIFormItem label="Phone Number" path="phone">
- <UIInputPhone
- id="form-phone"
- v-model:value="formData.phone"
- v-model:countryCode="formData.countryCode"
- @isValid="handlePhoneValidation"
- />
- </UIFormItem>
- </UIForm>
+ <HLForm :model="formData" :rules="rules">
+ <HLFormItem
+ label="Phone Number"
+ path="phone"
+ required
+ >
+ <HLInputPhone
+ id="form-phone"
+ v-model:modelValue="formData.phone"
+ v-model:countryCode="formData.countryCode"
+ @isValid="handlePhoneValidation"
+ />
+ </HLFormItem>
+ </HLForm>
Props Changes
Required Changes
ghl-ui Prop | HighRise Prop | Notes |
---|---|---|
id | id | Required in HighRise |
value | modelValue | Use v-model:modelValue instead of :value |
countryCode | countryCode | No change, use with v-model:countryCode |
New Props in HighRise
Prop | Type | Default | Description |
---|---|---|---|
size | String | 'md' | Size of the input ('sm', 'md', 'lg') |
placeholder | String | - | Placeholder text for the input |
clearable | Boolean | false | Whether the input can be cleared |
loading | Boolean | false | Whether to show a loading indicator |
readonly | Boolean | false | Whether the input is read-only |
New Events in HighRise
Event | Parameters | Description |
---|---|---|
focus | Event | Emitted when the input gains focus |
blur | Event | Emitted when the input loses focus |
clear | - | Emitted when the input is cleared |
Examples
Basic Usage
vue
<template>
<HLInputPhone id="basic-phone" v-model:modelValue="phoneNumber" v-model:countryCode="countryCode" placeholder="Enter phone number" />
</template>
<script setup>
import { ref } from 'vue'
import { HLInputPhone } from '@platform-ui/highrise'
const phoneNumber = ref('')
const countryCode = ref('US')
</script>
With Validation
vue
<template>
<div>
<HLInputPhone
id="validated-phone"
v-model:modelValue="phoneNumber"
v-model:countryCode="countryCode"
@isValid="isPhoneValid = $event"
/>
<p v-if="phoneNumber && !isPhoneValid" class="error-message">Please enter a valid phone number</p>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { HLInputPhone } from '@platform-ui/highrise'
const phoneNumber = ref('')
const countryCode = ref('US')
const isPhoneValid = ref(false)
</script>
With Form Integration
vue
<template>
<HLForm :model="formData" :rules="rules">
<HLFormItem label="Phone Number" path="phone" required validation-status="error" validation-message="Please enter a valid phone number">
<HLInputPhone
id="form-phone"
v-model:modelValue="formData.phone"
v-model:countryCode="formData.countryCode"
@isValid="handlePhoneValidation"
/>
</HLFormItem>
</HLForm>
</template>
<script setup>
import { reactive } from 'vue'
import { HLInputPhone, HLForm, HLFormItem } from '@platform-ui/highrise'
const formData = reactive({
phone: '',
countryCode: 'US',
isPhoneValid: false,
})
const rules = {
phone: {
required: true,
validator: () => {
if (!formData.isPhoneValid) {
return new Error('Please enter a valid phone number')
}
},
trigger: ['blur', 'input'],
},
}
function handlePhoneValidation(isValid) {
formData.isPhoneValid = isValid
}
</script>
Best Practices
- Always provide an
id
prop for accessibility - Use
v-model:value
andv-model:countryCode
for two-way binding - Implement proper form validation when needed
- Use appropriate size variants for different contexts
- Consider mobile responsiveness
- Add proper ARIA labels for accessibility
- Handle validation states appropriately
- Use descriptive placeholders
- Consider using international format for global applications
- Maintain consistent styling with other form components
- Implement proper error handling and feedback
- Use clearable prop when appropriate
- Consider using loading state for async operations
- Handle both national and international formats appropriately
Additional Notes
- The component automatically handles focus states
- Error states are managed through form validation
- Supports keyboard navigation
- Maintains consistent styling with other form components
- Handles disabled states consistently
- Integrates seamlessly with form validation
- Maintains accessibility standards
- Supports custom styling through CSS variables
- Provides clear visual feedback for all states
- Works well on both desktop and mobile devices
- Supports both controlled and uncontrolled modes
- Includes built-in validation support