get web closed state working
This commit is contained in:
@@ -51,10 +51,14 @@ export function InternationalPhoneCodeSelect({
|
|||||||
)
|
)
|
||||||
}, [i18n, defaultCountry])
|
}, [i18n, defaultCountry])
|
||||||
|
|
||||||
|
const selected = useMemo(() => {
|
||||||
|
return items.find(item => item.value === value)
|
||||||
|
}, [value, items])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select.Root value={value} onValueChange={onChange}>
|
<Select.Root value={value} onValueChange={onChange}>
|
||||||
<Select.Trigger label={_(msg`Select telephone code`)}>
|
<Select.Trigger label={_(msg`Select telephone code`)}>
|
||||||
<Select.ValueText placeholder="+...">
|
<Select.ValueText placeholder="+..." webOverrideValue={selected}>
|
||||||
{selected => (
|
{selected => (
|
||||||
<>
|
<>
|
||||||
<Flag {...selected} />
|
<Flag {...selected} />
|
||||||
@@ -80,7 +84,7 @@ export function InternationalPhoneCodeSelect({
|
|||||||
{item.code}
|
{item.code}
|
||||||
</Select.ItemText>
|
</Select.ItemText>
|
||||||
</Select.Item>
|
</Select.Item>
|
||||||
{item.value === location?.countryCode && <Select.Separator />}
|
{item.value === defaultCountry && <Select.Separator />}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -122,10 +122,21 @@ export function Trigger({children, label}: TriggerProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ValueText({children: _, style, ...props}: ValueProps) {
|
export function ValueText({
|
||||||
|
children,
|
||||||
|
webOverrideValue,
|
||||||
|
style,
|
||||||
|
...props
|
||||||
|
}: ValueProps) {
|
||||||
|
let content
|
||||||
|
|
||||||
|
if (webOverrideValue && children) {
|
||||||
|
content = children(webOverrideValue)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text style={style}>
|
<Text style={style}>
|
||||||
<RadixSelect.Value {...props} />
|
<RadixSelect.Value {...props}>{content}</RadixSelect.Value>
|
||||||
</Text>
|
</Text>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,13 @@ export type ValueProps = {
|
|||||||
children?: (value: any) => React.ReactNode
|
children?: (value: any) => React.ReactNode
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
style?: StyleProp<TextStyle>
|
style?: StyleProp<TextStyle>
|
||||||
|
/**
|
||||||
|
* By default, web just extracts the component from inside the dropdown and portals it in here.
|
||||||
|
* If you want to override this, pass a value that will then be rendered via `children(value)`
|
||||||
|
*
|
||||||
|
* @platform web
|
||||||
|
*/
|
||||||
|
webOverrideValue?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user