Skip to content

Commit f4638b7

Browse files
committed
chore: update package version to 1.9.8-beta-4 and enhance country select functionality
1 parent e4c5c94 commit f4638b7

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.9.8-beta-3",
3+
"version": "1.9.8-beta-4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/CountrySelect/CountrySelect.component.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,29 @@ const CountrySelect = ({
3232
searchText,
3333
) => {
3434
const searchValue = searchText.toLowerCase()
35-
const searchCriterion = [option.data.value.name.toLowerCase(), `+${option.data.value.dialCode.toLowerCase()}`]
35+
const searchCriterion = [
36+
option.data.value.name.toLowerCase(),
37+
`+${option.data.value.dialCode.toLowerCase()}`,
38+
option.data.value.iso2.toLowerCase(),
39+
]
3640

3741
return searchCriterion.some((criterion) => criterion.includes(searchValue))
3842
}
3943

4044
const getOptionValue: SelectPickerProps<(typeof countryOptions)[number]['value']>['getOptionValue'] = (option) =>
4145
option.value.iso2
4246

47+
const formatOptionLabel: SelectPickerProps<(typeof countryOptions)[number]['value']>['formatOptionLabel'] = (
48+
data,
49+
formatOptionLabelMeta,
50+
) => {
51+
if (formatOptionLabelMeta.context === 'menu') {
52+
return data.label
53+
}
54+
55+
return `+${data.value.dialCode}`
56+
}
57+
4358
return (
4459
<SelectPicker<(typeof countryOptions)[number]['value'], false>
4560
inputId={`select-picker__country-select--${name}`}
@@ -57,11 +72,12 @@ const CountrySelect = ({
5772
onMenuOpen={onMenuOpen}
5873
icon={
5974
variant === 'selectPhoneCode' && selectedOption?.value?.iso2 ? (
60-
<FlagImage country={selectedOption?.value?.iso2} />
75+
<FlagImage country={selectedOption?.value?.iso2} size={20} />
6176
) : null
6277
}
63-
controlShouldRenderValue={variant !== 'selectPhoneCode'}
78+
formatOptionLabel={formatOptionLabel}
6479
fullWidth
80+
ariaLabel={variant === 'default' ? 'Country' : 'Phone Code'}
6581
/>
6682
)
6783
}

src/Shared/Components/PhoneInput/PhoneInput.component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const PhoneInput = ({
2020
// TODO: There are some issues with argentina country code, need to fix it
2121
const { inputValue, handlePhoneValueChange, inputRef, country, setCountry } = usePhoneInput({
2222
value: phoneValue,
23-
forceDialCode: true,
23+
disableDialCodeAndPrefix: true,
2424
onChange: (data) => {
2525
// So initially this will format the phone or set the dial code to us if no phone is there, but since we expect user to enter phone number, we will ignore the first call
2626
if (!hasValueInitialized.current) {
@@ -51,7 +51,7 @@ const PhoneInput = ({
5151

5252
<div className="flexbox-col dc__gap-4 dc__grid">
5353
<div className="flexbox dc__gap-8 w-100">
54-
<div className={`flexbox dc__mxw-50-per ${isCountrySelectOpen ? 'w-100' : ''}`}>
54+
<div className={`flexbox ${isCountrySelectOpen ? 'dc__mxw-50-per w-100' : 'dc__mnw-100'}`}>
5555
<CountrySelect
5656
placeholder={null}
5757
selectedCountry={country.iso2}
@@ -73,6 +73,7 @@ const PhoneInput = ({
7373
inputRef={inputRef}
7474
error={error}
7575
hideFormFieldInfo
76+
ariaLabel="Phone Number"
7677
fullWidth
7778
/>
7879
</div>

0 commit comments

Comments
 (0)