Skip to content

Commit 798e4f7

Browse files
Copilothotlong
andcommitted
Fix prop spread order in field widgets
Move {...props} before explicit props to allow proper overriding Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 759966e commit 798e4f7

14 files changed

Lines changed: 16 additions & 25 deletions

packages/fields/src/widgets/BooleanField.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ export function BooleanField({ value, onChange, field, readonly, ...props }: Fie
1717
return (
1818
<div className="flex items-center space-x-2">
1919
<Checkbox
20+
{...props}
2021
id={id}
2122
checked={!!value}
2223
onCheckedChange={(checked) => onChange(!!checked)}
2324
disabled={readonly}
24-
className={props.className}
25-
{...props}
2625
/>
2726
<Label htmlFor={id}>{label}</Label>
2827
</div>
@@ -32,12 +31,11 @@ export function BooleanField({ value, onChange, field, readonly, ...props }: Fie
3231
return (
3332
<div className="flex items-center space-x-2">
3433
<Switch
34+
{...props}
3535
id={id}
3636
checked={!!value}
3737
onCheckedChange={onChange}
3838
disabled={readonly}
39-
className={props.className}
40-
{...props}
4139
/>
4240
<Label htmlFor={id}>{label}</Label>
4341
</div>

packages/fields/src/widgets/CurrencyField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export function CurrencyField({ value, onChange, field, readonly, errorMessage,
4444
{currency === 'USD' ? '$' : currency}
4545
</span>
4646
<Input
47+
{...props}
4748
type="number"
4849
value={value ?? ''}
4950
onChange={(e) => {
@@ -56,7 +57,6 @@ export function CurrencyField({ value, onChange, field, readonly, errorMessage,
5657
className={`pl-8 ${className || ''}`}
5758
step={Math.pow(10, -precision).toFixed(precision)}
5859
aria-invalid={!!errorMessage}
59-
{...props}
6060
/>
6161
</div>
6262
);

packages/fields/src/widgets/DateField.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ export function DateField({ value, onChange, field, readonly, ...props }: FieldW
99

1010
return (
1111
<Input
12+
{...props}
1213
type="date"
1314
value={value || ''}
1415
onChange={(e) => onChange(e.target.value)}
1516
disabled={readonly}
16-
className={props.className}
17-
{...props}
1817
/>
1918
);
2019
}

packages/fields/src/widgets/DateTimeField.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ export function DateTimeField({ value, onChange, field, readonly, ...props }: Fi
1515

1616
return (
1717
<Input
18+
{...props}
1819
type="datetime-local"
1920
value={value || ''}
2021
onChange={(e) => onChange(e.target.value)}
2122
disabled={readonly}
22-
className={props.className}
23-
{...props}
2423
/>
2524
);
2625
}

packages/fields/src/widgets/EmailField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export function EmailField({ value, onChange, field, readonly, errorMessage, ...
1818

1919
return (
2020
<Input
21+
{...props}
2122
type="email"
2223
value={value || ''}
2324
onChange={(e) => onChange(e.target.value)}
2425
placeholder={config?.placeholder || 'email@example.com'}
2526
disabled={readonly}
2627
aria-invalid={!!errorMessage}
27-
{...props}
2828
/>
2929
);
3030
}

packages/fields/src/widgets/NumberField.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function NumberField({ value, onChange, field, readonly, ...props }: Fiel
1313

1414
return (
1515
<Input
16+
{...props}
1617
type="number"
1718
value={value ?? ''}
1819
onChange={(e) => {
@@ -22,8 +23,6 @@ export function NumberField({ value, onChange, field, readonly, ...props }: Fiel
2223
placeholder={numberField?.placeholder}
2324
disabled={readonly}
2425
step={precision ? Math.pow(10, -precision) : 'any'}
25-
className={props.className}
26-
{...props}
2726
/>
2827
);
2928
}

packages/fields/src/widgets/PasswordField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export function PasswordField({ value, onChange, field, readonly, className, ...
1515
return (
1616
<div className="relative">
1717
<Input
18+
{...props}
1819
type={showPassword ? 'text' : 'password'}
1920
value={value || ''}
2021
onChange={(e) => onChange(e.target.value)}
2122
placeholder={config?.placeholder}
2223
disabled={readonly}
2324
className={`pr-10 ${className || ''}`}
24-
{...props}
2525
/>
2626
<Button
2727
type="button"

packages/fields/src/widgets/PercentField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function PercentField({ value, onChange, field, readonly, errorMessage, c
3131
return (
3232
<div className="relative">
3333
<Input
34+
{...props}
3435
type="number"
3536
value={displayValue}
3637
onChange={handleChange}
@@ -39,7 +40,6 @@ export function PercentField({ value, onChange, field, readonly, errorMessage, c
3940
className={`pr-8 ${className || ''}`}
4041
step={Math.pow(10, -precision).toFixed(precision)}
4142
aria-invalid={!!errorMessage}
42-
{...props}
4343
/>
4444
<span className="absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500">
4545
%

packages/fields/src/widgets/PhoneField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export function PhoneField({ value, onChange, field, readonly, errorMessage, ...
1818

1919
return (
2020
<Input
21+
{...props}
2122
type="tel"
2223
value={value || ''}
2324
onChange={(e) => onChange(e.target.value)}
2425
placeholder={config?.placeholder || '(555) 123-4567'}
2526
disabled={readonly}
2627
aria-invalid={!!errorMessage}
27-
{...props}
2828
/>
2929
);
3030
}

packages/fields/src/widgets/SelectField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export function SelectField({ value, onChange, field, readonly, ...props }: Fiel
2020

2121
return (
2222
<Select
23+
{...props}
2324
value={value}
2425
onValueChange={onChange}
2526
disabled={readonly}
26-
{...props}
2727
>
2828
<SelectTrigger className={props.className}>
2929
<SelectValue placeholder={config?.placeholder || "Select an option"} />

0 commit comments

Comments
 (0)