Skip to content

Commit d35147c

Browse files
committed
Update field
1 parent 17eb69f commit d35147c

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import { useFormContext } from '@wpsocio/form';
2-
import { FormField as FormFieldUI } from '@wpsocio/ui/wp/form';
2+
import {
3+
type ControllerProps,
4+
type FieldPath,
5+
type FieldValues,
6+
FormField as FormFieldUI,
7+
} from '@wpsocio/ui/wp/form';
38

4-
export const FormField: React.FC<React.ComponentProps<typeof FormFieldUI>> = (
5-
props,
6-
) => {
7-
const { control } = useFormContext();
9+
export const FormField = <
10+
TFieldValues extends FieldValues = FieldValues,
11+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
12+
>({
13+
...props
14+
}: ControllerProps<TFieldValues, TName>) => {
15+
const { control } = useFormContext<TFieldValues>();
816

917
return <FormFieldUI control={control} {...props} />;
1018
};

packages/js/ui/src/icons/wp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export {
66
check,
77
cloud,
88
trash,
9+
edit,
910
} from '@wordpress/icons';

packages/js/ui/src/wp/form/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,5 @@ export {
190190
FormMessage,
191191
FormField,
192192
};
193+
194+
export type { ControllerProps, FieldPath, FieldValues };

packages/js/ui/src/wrappers/select.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import * as React from 'react';
2-
3-
import { cn } from '../lib/utils.js';
42
import {
53
SelectContent,
64
SelectGroup,
@@ -10,6 +8,7 @@ import {
108
Select as SelectUI,
119
SelectValue,
1210
} from '../components/select.js';
11+
import { cn } from '../lib/utils.js';
1312
import { Spinner } from './spinner.js';
1413
import type { OptionProps } from './types.js';
1514

@@ -75,7 +74,7 @@ export const Select = React.forwardRef<HTMLButtonElement, SelectProps>(
7574
portalContainer={portalContainer || getPortalContainer()}
7675
>
7776
{options.map((option) => (
78-
<React.Fragment key={option.label}>
77+
<React.Fragment key={JSON.stringify(option)}>
7978
{(() => {
8079
if ('options' in option && Array.isArray(option.options)) {
8180
return (

0 commit comments

Comments
 (0)