get web closed state working

This commit is contained in:
Samuel Newman
2025-11-12 18:53:50 +02:00
parent 47aa6c5242
commit 1d53c38f73
3 changed files with 26 additions and 4 deletions
@@ -51,10 +51,14 @@ export function InternationalPhoneCodeSelect({
)
}, [i18n, defaultCountry])
const selected = useMemo(() => {
return items.find(item => item.value === value)
}, [value, items])
return (
<Select.Root value={value} onValueChange={onChange}>
<Select.Trigger label={_(msg`Select telephone code`)}>
<Select.ValueText placeholder="+...">
<Select.ValueText placeholder="+..." webOverrideValue={selected}>
{selected => (
<>
<Flag {...selected} />
@@ -80,7 +84,7 @@ export function InternationalPhoneCodeSelect({
{item.code}
</Select.ItemText>
</Select.Item>
{item.value === location?.countryCode && <Select.Separator />}
{item.value === defaultCountry && <Select.Separator />}
</Fragment>
)}
/>
+13 -2
View File
@@ -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 (
<Text style={style}>
<RadixSelect.Value {...props} />
<RadixSelect.Value {...props}>{content}</RadixSelect.Value>
</Text>
)
}
+7
View File
@@ -126,6 +126,13 @@ export type ValueProps = {
children?: (value: any) => React.ReactNode
placeholder?: string
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
}
/*