Skip to content

Commit 04006df

Browse files
authored
feat: Add disabled prop to FormFieldProps and all form field components with consistent data-disabled attribute on Field wrapper for label dimming (#878)
1 parent c1d888a commit 04006df

92 files changed

Lines changed: 505 additions & 104 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@baseplate-dev/react-generators': patch
3+
---
4+
5+
Add disabled prop to form field component templates with consistent data-disabled attribute on Field wrapper
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@baseplate-dev/ui-components': patch
3+
---
4+
5+
Add disabled prop to FormFieldProps and all form field components with consistent data-disabled attribute on Field wrapper for label dimming

examples/blog-with-auth/apps/admin/baseplate/generated/src/components/ui/checkbox-field.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function CheckboxField({
3636
label,
3737
description,
3838
error,
39+
disabled,
3940
onChange,
4041
value,
4142
className,
@@ -47,11 +48,13 @@ function CheckboxField({
4748
<Field
4849
orientation="horizontal"
4950
data-invalid={!!error || undefined}
51+
data-disabled={disabled ?? undefined}
5052
className={className}
5153
>
5254
<Checkbox
5355
{...props}
5456
id={id}
57+
disabled={disabled}
5558
aria-invalid={!!error}
5659
onCheckedChange={(checked) => {
5760
onChange?.(checked);

examples/blog-with-auth/apps/admin/baseplate/generated/src/components/ui/combobox-field.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export interface ComboboxFieldProps<OptionType>
2828
className?: string;
2929
noResultsText?: React.ReactNode;
3030
placeholder?: string;
31-
disabled?: boolean;
3231
value?: string | null;
3332
onChange?: (value: string | null) => void;
3433
inputValue?: string;
@@ -62,7 +61,11 @@ function ComboboxField<OptionType>({
6261
options.find((o) => getOptionValue(o) === value) ?? null;
6362

6463
return (
65-
<Field data-invalid={!!error} className={className}>
64+
<Field
65+
data-invalid={!!error}
66+
data-disabled={disabled ?? undefined}
67+
className={className}
68+
>
6669
<FieldLabel htmlFor={id}>{label}</FieldLabel>
6770
<Combobox
6871
value={selectedOption}

examples/blog-with-auth/apps/admin/baseplate/generated/src/components/ui/date-picker-field.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { Popover, PopoverContent, PopoverTrigger } from './popover';
1919
export interface DatePickerFieldProps extends FormFieldProps {
2020
className?: string;
2121
wrapperClassName?: string;
22-
disabled?: boolean;
2322
placeholder?: string;
2423
onChange?: (value: string | undefined) => void;
2524
value?: string | undefined;
@@ -100,7 +99,11 @@ function DatePickerField({
10099

101100
if (addWrapper) {
102101
return (
103-
<Field data-invalid={!!error} className={cn('gap-2', wrapperClassName)}>
102+
<Field
103+
data-invalid={!!error}
104+
data-disabled={disabled ?? undefined}
105+
className={cn('gap-2', wrapperClassName)}
106+
>
104107
<FieldLabel htmlFor={id}>{label}</FieldLabel>
105108
{inputComponent}
106109
<FieldDescription>{description}</FieldDescription>

examples/blog-with-auth/apps/admin/baseplate/generated/src/components/ui/date-time-picker-field.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { Popover, PopoverContent, PopoverTrigger } from './popover';
2020
export interface DateTimePickerFieldProps extends FormFieldProps {
2121
className?: string;
2222
wrapperClassName?: string;
23-
disabled?: boolean;
2423
placeholder?: string;
2524
onChange?: (value: string | undefined) => void;
2625
value?: string | undefined;
@@ -177,7 +176,11 @@ function DateTimePickerField({
177176

178177
if (addWrapper) {
179178
return (
180-
<Field data-invalid={!!error} className={cn('gap-2', wrapperClassName)}>
179+
<Field
180+
data-invalid={!!error}
181+
data-disabled={disabled ?? undefined}
182+
className={cn('gap-2', wrapperClassName)}
183+
>
181184
<FieldLabel htmlFor={id}>{label}</FieldLabel>
182185
{inputComponent}
183186
<FieldDescription>{description}</FieldDescription>

examples/blog-with-auth/apps/admin/baseplate/generated/src/components/ui/input-field.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function InputField({
3737
label,
3838
description,
3939
error,
40+
disabled,
4041
onChange,
4142
register,
4243
className,
@@ -45,10 +46,15 @@ function InputField({
4546
}: InputFieldProps): React.ReactElement {
4647
const id = useId();
4748
return (
48-
<Field data-invalid={!!error} className={cn('gap-1.5', className)}>
49+
<Field
50+
data-invalid={!!error}
51+
data-disabled={disabled ?? undefined}
52+
className={cn('gap-1.5', className)}
53+
>
4954
<FieldLabel htmlFor={id}>{label}</FieldLabel>
5055
<Input
5156
id={id}
57+
disabled={disabled}
5258
onChange={
5359
onChange &&
5460
((e) => {

examples/blog-with-auth/apps/admin/baseplate/generated/src/components/ui/multi-combobox-field.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export interface MultiComboboxFieldProps<OptionType>
3131
extends MultiSelectOptionProps<OptionType>, FormFieldProps {
3232
className?: string;
3333
noResultsText?: React.ReactNode;
34-
disabled?: boolean;
3534
}
3635

3736
/**
@@ -62,7 +61,11 @@ function MultiComboboxField<OptionType>({
6261
);
6362

6463
return (
65-
<Field data-invalid={!!error} className={className}>
64+
<Field
65+
data-invalid={!!error}
66+
data-disabled={disabled ?? undefined}
67+
className={className}
68+
>
6669
<FieldLabel htmlFor={id}>{label}</FieldLabel>
6770
<Combobox
6871
multiple

examples/blog-with-auth/apps/admin/baseplate/generated/src/components/ui/select-field.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function SelectField<OptionType>({
3232
label,
3333
description,
3434
error,
35+
disabled,
3536
value,
3637
placeholder,
3738
options,
@@ -47,9 +48,18 @@ function SelectField<OptionType>({
4748
const selectedOption = options.find((o) => getOptionValue(o) === value);
4849

4950
return (
50-
<Field data-invalid={!!error} className={className}>
51+
<Field
52+
data-invalid={!!error}
53+
data-disabled={disabled ?? undefined}
54+
className={className}
55+
>
5156
<FieldLabel htmlFor={triggerId}>{label}</FieldLabel>
52-
<Select value={value} onValueChange={(val) => onChange?.(val)} {...props}>
57+
<Select
58+
value={value}
59+
onValueChange={(val) => onChange?.(val)}
60+
disabled={disabled}
61+
{...props}
62+
>
5363
<SelectTrigger id={triggerId} aria-invalid={!!error}>
5464
<SelectValue placeholder={placeholder}>
5565
{selectedOption ? getOptionLabel(selectedOption) : null}

examples/blog-with-auth/apps/admin/baseplate/generated/src/components/ui/switch-field.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function SwitchField({
3737
label,
3838
description,
3939
error,
40+
disabled,
4041
onChange,
4142
value,
4243
className,
@@ -49,12 +50,14 @@ function SwitchField({
4950
<Field
5051
orientation="horizontal"
5152
data-invalid={!!error}
53+
data-disabled={disabled ?? undefined}
5254
className={className}
5355
id={id}
5456
>
5557
<Switch
5658
{...props}
5759
id={switchId}
60+
disabled={disabled}
5861
onCheckedChange={(checked) => onChange?.(checked)}
5962
checked={value}
6063
aria-invalid={!!error}

0 commit comments

Comments
 (0)