Skip to content

Commit

Permalink
support search in Select
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Oct 26, 2024
1 parent 1898315 commit b071f73
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions src/components/inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -600,18 +600,23 @@ const NodeInspector: FC = () => {
)}
{type === "enum" && (
<Select
showSearch
disabled={disabled}
onBlur={form.submit}
onChange={form.submit}
>
{arg.options?.map((value, i) => {
return (
<Select.Option key={i} value={value.value}>
{value.name}
</Select.Option>
);
options={(arg.options ?? []).map((option) => {
return {
value: option.value,
label: `${option.name}(${option.value})`,
};
})}
</Select>
filterOption={(value, option) => {
value = value.toUpperCase();
return !!option?.label
.toLocaleUpperCase()
.includes(value.toUpperCase());
}}
/>
)}
</Form.Item>
<MinusCircleOutlined
Expand Down Expand Up @@ -724,15 +729,24 @@ const NodeInspector: FC = () => {
{type === "boolean" && <Switch disabled={disabled} onChange={form.submit} />}
{type === "code" && <Input disabled={disabled} onBlur={form.submit} />}
{type === "enum" && (
<Select disabled={disabled} onBlur={form.submit} onChange={form.submit}>
{arg.options?.map((value, index) => {
return (
<Select.Option key={index} value={value.value}>
{value.name}
</Select.Option>
);
<Select
showSearch
disabled={disabled}
onBlur={form.submit}
onChange={form.submit}
options={(arg.options ?? []).map((option) => {
return {
value: option.value,
label: `${option.name}(${option.value})`,
};
})}
</Select>
filterOption={(value, option) => {
value = value.toUpperCase();
return !!option?.label
.toLocaleUpperCase()
.includes(value.toUpperCase());
}}
/>
)}
</Form.Item>
);
Expand Down

0 comments on commit b071f73

Please sign in to comment.