Skip to content

Commit ddcd213

Browse files
Copilothotlong
andcommitted
Fix inputType prop warning in field widgets
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 5b381b3 commit ddcd213

11 files changed

Lines changed: 59 additions & 26 deletions

packages/fields/src/widgets/BooleanField.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ export function BooleanField({ value, onChange, field, readonly, ...props }: Fie
1515
return <span className="text-sm">{value ? 'Yes' : 'No'}</span>;
1616
}
1717

18+
// Filter out non-DOM props
19+
const { inputType, ...domProps } = props as any;
20+
1821
if (widget === 'checkbox') {
1922
return (
2023
<div className="flex items-center space-x-2">
2124
<Checkbox
22-
{...props}
25+
{...domProps}
2326
id={id}
2427
checked={!!value}
2528
onCheckedChange={(checked) => onChange(!!checked)}
26-
disabled={readonly || props.disabled}
29+
disabled={readonly || domProps.disabled}
2730
/>
2831
<Label htmlFor={id}>{label}</Label>
2932
</div>
@@ -33,11 +36,11 @@ export function BooleanField({ value, onChange, field, readonly, ...props }: Fie
3336
return (
3437
<div className="flex items-center space-x-2">
3538
<Switch
36-
{...props}
39+
{...domProps}
3740
id={id}
3841
checked={!!value}
3942
onCheckedChange={onChange}
40-
disabled={readonly || props.disabled}
43+
disabled={readonly || domProps.disabled}
4144
/>
4245
<Label htmlFor={id}>{label}</Label>
4346
</div>

packages/fields/src/widgets/DateField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ export function DateField({ value, onChange, field, readonly, ...props }: FieldW
77
return <span className="text-sm">{value ? new Date(value).toLocaleDateString() : '-'}</span>;
88
}
99

10+
// Filter out non-DOM props
11+
const { inputType, ...domProps } = props as any;
12+
1013
return (
1114
<Input
12-
{...props}
15+
{...domProps}
1316
type="date"
1417
value={value || ''}
1518
onChange={(e) => onChange(e.target.value)}
16-
disabled={readonly || props.disabled}
19+
disabled={readonly || domProps.disabled}
1720
/>
1821
);
1922
}

packages/fields/src/widgets/DateTimeField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ export function DateTimeField({ value, onChange, field, readonly, ...props }: Fi
1313
);
1414
}
1515

16+
// Filter out non-DOM props
17+
const { inputType, ...domProps } = props as any;
18+
1619
return (
1720
<Input
18-
{...props}
21+
{...domProps}
1922
type="datetime-local"
2023
value={value || ''}
2124
onChange={(e) => onChange(e.target.value)}
22-
disabled={readonly || props.disabled}
25+
disabled={readonly || domProps.disabled}
2326
/>
2427
);
2528
}

packages/fields/src/widgets/EmailField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ export function EmailField({ value, onChange, field, readonly, errorMessage, ...
1616
);
1717
}
1818

19+
// Filter out non-DOM props
20+
const { inputType, ...domProps } = props as any;
21+
1922
return (
2023
<Input
21-
{...props}
24+
{...domProps}
2225
type="email"
2326
value={value || ''}
2427
onChange={(e) => onChange(e.target.value)}
2528
placeholder={config?.placeholder || 'email@example.com'}
26-
disabled={readonly || props.disabled}
29+
disabled={readonly || domProps.disabled}
2730
aria-invalid={!!errorMessage}
2831
/>
2932
);

packages/fields/src/widgets/NumberField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ export function NumberField({ value, onChange, field, readonly, ...props }: Fiel
1111
const numberField = (field || (props as any).schema) as NumberFieldMetadata;
1212
const precision = numberField?.precision;
1313

14+
// Filter out non-DOM props
15+
const { inputType, ...domProps } = props as any;
16+
1417
return (
1518
<Input
16-
{...props}
19+
{...domProps}
1720
type="number"
1821
value={value ?? ''}
1922
onChange={(e) => {
2023
const val = e.target.value;
2124
onChange(val === '' ? (null as any) : Number(val));
2225
}}
2326
placeholder={numberField?.placeholder}
24-
disabled={readonly || props.disabled}
27+
disabled={readonly || domProps.disabled}
2528
step={precision ? Math.pow(10, -precision) : 'any'}
2629
/>
2730
);

packages/fields/src/widgets/PasswordField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ export function PasswordField({ value, onChange, field, readonly, className, ...
1212
return <span className="text-sm">••••••••</span>;
1313
}
1414

15+
// Filter out non-DOM props
16+
const { inputType, ...domProps } = props as any;
17+
1518
return (
1619
<div className="relative">
1720
<Input
18-
{...props}
21+
{...domProps}
1922
type={showPassword ? 'text' : 'password'}
2023
value={value || ''}
2124
onChange={(e) => onChange(e.target.value)}
2225
placeholder={config?.placeholder}
23-
disabled={readonly || props.disabled}
26+
disabled={readonly || domProps.disabled}
2427
className={`pr-10 ${className || ''}`}
2528
/>
2629
<Button

packages/fields/src/widgets/PhoneField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ export function PhoneField({ value, onChange, field, readonly, errorMessage, ...
1616
);
1717
}
1818

19+
// Filter out non-DOM props
20+
const { inputType, ...domProps } = props as any;
21+
1922
return (
2023
<Input
21-
{...props}
24+
{...domProps}
2225
type="tel"
2326
value={value || ''}
2427
onChange={(e) => onChange(e.target.value)}
2528
placeholder={config?.placeholder || '(555) 123-4567'}
26-
disabled={readonly || props.disabled}
29+
disabled={readonly || domProps.disabled}
2730
aria-invalid={!!errorMessage}
2831
/>
2932
);

packages/fields/src/widgets/TextAreaField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ export function TextAreaField({ value, onChange, field, readonly, errorMessage,
1515
const rows = textareaField?.rows || 4;
1616
const maxLength = textareaField?.max_length;
1717

18+
// Filter out non-DOM props
19+
const { inputType, ...domProps } = props as any;
20+
1821
return (
1922
<div className="relative">
2023
<Textarea
21-
{...props}
24+
{...domProps}
2225
value={value || ''}
2326
onChange={(e) => onChange(e.target.value)}
2427
placeholder={textareaField?.placeholder}
25-
disabled={readonly || props.disabled}
28+
disabled={readonly || domProps.disabled}
2629
rows={rows}
2730
maxLength={maxLength}
2831
aria-invalid={!!errorMessage}

packages/fields/src/widgets/TextField.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,29 @@ export function TextField({ value, onChange, field, readonly, ...props }: FieldW
1313
// Cast for rows property
1414
const rows = (fieldData as unknown as TextareaFieldMetadata)?.rows;
1515

16+
// Filter out non-DOM props
17+
const { inputType, ...domProps } = props as any;
18+
1619
if (rows && rows > 1) {
1720
return (
1821
<Textarea
19-
{...props}
22+
{...domProps}
2023
value={value || ''}
2124
onChange={(e) => onChange(e.target.value)}
2225
placeholder={fieldData?.placeholder}
23-
disabled={readonly || props.disabled}
26+
disabled={readonly || domProps.disabled}
2427
/>
2528
);
2629
}
2730

2831
return (
2932
<Input
30-
{...props}
33+
{...domProps}
3134
type={fieldData?.type === 'password' ? 'password' : 'text'}
3235
value={value || ''}
3336
onChange={(e) => onChange(e.target.value)}
3437
placeholder={fieldData?.placeholder}
35-
disabled={readonly || props.disabled}
38+
disabled={readonly || domProps.disabled}
3639
/>
3740
);
3841
}

packages/fields/src/widgets/TimeField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ export function TimeField({ value, onChange, field, readonly, ...props }: FieldW
77
return <span className="text-sm">{value || '-'}</span>;
88
}
99

10+
// Filter out non-DOM props
11+
const { inputType, ...domProps } = props as any;
12+
1013
return (
1114
<Input
12-
{...props}
15+
{...domProps}
1316
type="time"
1417
value={value || ''}
1518
onChange={(e) => onChange(e.target.value)}
16-
disabled={readonly || props.disabled}
19+
disabled={readonly || domProps.disabled}
1720
/>
1821
);
1922
}

0 commit comments

Comments
 (0)