Skip to content

Commit 94a0179

Browse files
committed
fix: add disabled prop support to various field components for enhanced flexibility
1 parent a8b9f87 commit 94a0179

28 files changed

+36
-37
lines changed

packages/fields/src/widgets/AddressField.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function AddressField({ value, onChange, field, readonly, ...props }: Fie
5151
value={address.street || ''}
5252
onChange={(e) => handleFieldChange('street', e.target.value)}
5353
placeholder="123 Main St"
54-
disabled={readonly}
54+
disabled={readonly || props.disabled}
5555
className={props.className}
5656
/>
5757
</div>
@@ -65,7 +65,7 @@ export function AddressField({ value, onChange, field, readonly, ...props }: Fie
6565
value={address.city || ''}
6666
onChange={(e) => handleFieldChange('city', e.target.value)}
6767
placeholder="San Francisco"
68-
disabled={readonly}
68+
disabled={readonly || props.disabled}
6969
/>
7070
</div>
7171

@@ -77,7 +77,7 @@ export function AddressField({ value, onChange, field, readonly, ...props }: Fie
7777
value={address.state || ''}
7878
onChange={(e) => handleFieldChange('state', e.target.value)}
7979
placeholder="CA"
80-
disabled={readonly}
80+
disabled={readonly || props.disabled}
8181
/>
8282
</div>
8383
</div>
@@ -91,7 +91,7 @@ export function AddressField({ value, onChange, field, readonly, ...props }: Fie
9191
value={address.zipCode || ''}
9292
onChange={(e) => handleFieldChange('zipCode', e.target.value)}
9393
placeholder="94102"
94-
disabled={readonly}
94+
disabled={readonly || props.disabled}
9595
/>
9696
</div>
9797

@@ -103,7 +103,7 @@ export function AddressField({ value, onChange, field, readonly, ...props }: Fie
103103
value={address.country || ''}
104104
onChange={(e) => handleFieldChange('country', e.target.value)}
105105
placeholder="United States"
106-
disabled={readonly}
106+
disabled={readonly || props.disabled}
107107
/>
108108
</div>
109109
</div>

packages/fields/src/widgets/AvatarField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function AvatarField({ value, onChange, field, readonly, ...props }: Fiel
9696
variant="outline"
9797
size="sm"
9898
onClick={() => fileInputRef.current?.click()}
99-
disabled={readonly}
99+
disabled={readonly || props.disabled}
100100
>
101101
<Upload className="w-4 h-4 mr-2" />
102102
{value ? 'Change' : 'Upload'} Avatar

packages/fields/src/widgets/BooleanField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function BooleanField({ value, onChange, field, readonly, ...props }: Fie
2121
id={id}
2222
checked={!!value}
2323
onCheckedChange={(checked) => onChange(!!checked)}
24-
disabled={readonly}
24+
disabled={readonly || props.disabled}
2525
/>
2626
<Label htmlFor={id}>{label}</Label>
2727
</div>
@@ -35,7 +35,7 @@ export function BooleanField({ value, onChange, field, readonly, ...props }: Fie
3535
id={id}
3636
checked={!!value}
3737
onCheckedChange={onChange}
38-
disabled={readonly}
38+
disabled={readonly || props.disabled}
3939
/>
4040
<Label htmlFor={id}>{label}</Label>
4141
</div>

packages/fields/src/widgets/CodeField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function CodeField({ value, onChange, field, readonly, ...props }: FieldW
2525
value={value || ''}
2626
onChange={(e) => onChange(e.target.value)}
2727
placeholder={config?.placeholder || `// Write ${language} code here...`}
28-
disabled={readonly}
28+
disabled={readonly || props.disabled}
2929
className={`font-mono text-sm ${props.className}`}
3030
rows={12}
3131
spellCheck={false}

packages/fields/src/widgets/ColorField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export function ColorField({ value, onChange, field, readonly, ...props }: Field
2727
type="color"
2828
value={value || '#000000'}
2929
onChange={(e) => onChange(e.target.value)}
30-
disabled={readonly}
30+
disabled={readonly || props.disabled}
3131
className="w-10 h-10 rounded border border-input cursor-pointer"
3232
/>
3333
<Input
3434
type="text"
3535
value={value || ''}
3636
onChange={(e) => onChange(e.target.value)}
3737
placeholder={colorField?.placeholder || '#000000'}
38-
disabled={readonly}
38+
disabled={readonly || props.disabled}
3939
className={props.className}
4040
pattern="^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"
4141
/>

packages/fields/src/widgets/CurrencyField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function CurrencyField({ value, onChange, field, readonly, errorMessage,
5353
}}
5454
onBlur={handleBlur}
5555
placeholder={currencyField?.placeholder || '0.00'}
56-
disabled={readonly}
56+
disabled={readonly || props.disabled}
5757
className={`pl-8 ${className || ''}`}
5858
step={Math.pow(10, -precision).toFixed(precision)}
5959
aria-invalid={!!errorMessage}

packages/fields/src/widgets/DateField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function DateField({ value, onChange, field, readonly, ...props }: FieldW
1313
type="date"
1414
value={value || ''}
1515
onChange={(e) => onChange(e.target.value)}
16-
disabled={readonly}
16+
disabled={readonly || props.disabled}
1717
/>
1818
);
1919
}

packages/fields/src/widgets/DateTimeField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function DateTimeField({ value, onChange, field, readonly, ...props }: Fi
1919
type="datetime-local"
2020
value={value || ''}
2121
onChange={(e) => onChange(e.target.value)}
22-
disabled={readonly}
22+
disabled={readonly || props.disabled}
2323
/>
2424
);
2525
}

packages/fields/src/widgets/EmailField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function EmailField({ value, onChange, field, readonly, errorMessage, ...
2323
value={value || ''}
2424
onChange={(e) => onChange(e.target.value)}
2525
placeholder={config?.placeholder || 'email@example.com'}
26-
disabled={readonly}
26+
disabled={readonly || props.disabled}
2727
aria-invalid={!!errorMessage}
2828
/>
2929
);

packages/fields/src/widgets/GeolocationField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function GeolocationField({ value, onChange, field, readonly, ...props }:
121121
value={location.latitude ?? ''}
122122
onChange={(e) => handleFieldChange('latitude', e.target.value)}
123123
placeholder="37.7749"
124-
disabled={readonly}
124+
disabled={readonly || props.disabled}
125125
step="any"
126126
className={props.className}
127127
/>
@@ -135,7 +135,7 @@ export function GeolocationField({ value, onChange, field, readonly, ...props }:
135135
value={location.longitude ?? ''}
136136
onChange={(e) => handleFieldChange('longitude', e.target.value)}
137137
placeholder="-122.4194"
138-
disabled={readonly}
138+
disabled={readonly || props.disabled}
139139
step="any"
140140
/>
141141
</div>

0 commit comments

Comments
 (0)