Skip to content

Commit 2325033

Browse files
committed
listfield prettier
1 parent c835062 commit 2325033

File tree

1 file changed

+35
-35
lines changed
  • frontend/packages/pydantic-forms/src/components/fields

1 file changed

+35
-35
lines changed

frontend/packages/pydantic-forms/src/components/fields/ListField.tsx

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,45 @@
66
import React, { useState } from 'react';
77

88
import {
9-
PydanticFormControlledElementProps,
10-
PydanticFormFieldOption,
9+
PydanticFormControlledElementProps,
10+
PydanticFormFieldOption,
1111
} from '@/types';
1212

1313
export const ListField = ({
14-
value,
15-
onChange,
16-
onBlur,
17-
disabled,
18-
pydanticFormField,
14+
value,
15+
onChange,
16+
onBlur,
17+
disabled,
18+
pydanticFormField,
1919
}: PydanticFormControlledElementProps & {
20-
options?: Array<{ value: string; label: string }>;
20+
options?: Array<{ value: string; label: string }>;
2121
}) => {
22-
const [listItems, setListItems] = useState(value || []);
22+
const [listItems, setListItems] = useState(value || []);
2323

24-
return (
25-
<div>
26-
<select
27-
onBlur={onBlur}
28-
disabled={disabled}
29-
value={listItems}
30-
onChange={(e) => {
31-
const selectedValues = Array.from(
32-
e.currentTarget.selectedOptions,
33-
(option) => option.value
34-
);
35-
setListItems(selectedValues);
36-
onChange(selectedValues);
37-
}}
38-
multiple
39-
>
40-
{pydanticFormField.options.map(
41-
(option: PydanticFormFieldOption) => (
42-
<option key={option.value} value={option.label}>
43-
{option.label}
44-
</option>
45-
)
46-
)}
47-
</select>
48-
</div>
49-
);
24+
return (
25+
<div>
26+
<select
27+
onBlur={onBlur}
28+
disabled={disabled}
29+
value={listItems}
30+
onChange={(e) => {
31+
const selectedValues = Array.from(
32+
e.currentTarget.selectedOptions,
33+
(option) => option.value,
34+
);
35+
setListItems(selectedValues);
36+
onChange(selectedValues);
37+
}}
38+
multiple
39+
>
40+
{pydanticFormField.options.map(
41+
(option: PydanticFormFieldOption) => (
42+
<option key={option.value} value={option.label}>
43+
{option.label}
44+
</option>
45+
),
46+
)}
47+
</select>
48+
</div>
49+
);
5050
};

0 commit comments

Comments
 (0)