Skip to content

Commit 94e8b1b

Browse files
committed
feat: add disabled states for other input components
1 parent 7062169 commit 94e8b1b

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

src/components/checkbox-input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export const CheckboxField = makeFieldComponent({
1616
});
1717

1818
export interface CheckboxInputOptions
19-
extends FormInputProps<HTMLInputElement, boolean> {}
19+
extends FormInputProps<HTMLInputElement, boolean> {
20+
disabled?: boolean;
21+
}
2022

2123
export type CheckboxInputProps = WithOverride<
2224
ComponentProps<'div'>,
@@ -30,6 +32,7 @@ export function CheckboxInput(props: CheckboxInputProps) {
3032
<_Checkbox
3133
checked={props.value}
3234
onChange={value => props.onChange?.(value)}
35+
disabled={props.disabled}
3336
{...rest}
3437
>
3538
<_Checkbox.Input

src/components/forms.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function FormLabel(props: FormLabelProps) {
115115
return (
116116
<label
117117
{...others}
118-
data-disabled={props.disabled}
118+
data-disabled={props.disabled || null}
119119
class={cn(labelVariants(), others.class)}
120120
for={props.for}
121121
>
@@ -135,7 +135,7 @@ export function FormError(props: FormErrorProps) {
135135
return (
136136
<small
137137
{...others}
138-
data-disabled={props.disabled}
138+
data-disabled={props.disabled || null}
139139
class={cn(labelVariants({ error: true }), others.class)}
140140
>
141141
{props.children}
@@ -154,7 +154,7 @@ export function FormDescription(props: FormDescriptionProps) {
154154
return (
155155
<small
156156
{...others}
157-
data-disabled={props.disabled}
157+
data-disabled={props.disabled || null}
158158
class={cn(
159159
labelVariants({ description: true, label: false }),
160160
'mt-1',

src/components/number-input.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const NumberField = makeFieldComponent({
2323
interface NumberInputOptions
2424
extends FormInputProps<HTMLInputElement, number> {
2525
placeholder?: string;
26+
disabled?: boolean;
2627
}
2728

2829
export type NumberInputProps = WithOverride<
@@ -42,6 +43,7 @@ export function NumberInput(props: NumberInputProps) {
4243
return (
4344
<_NumberField
4445
rawValue={local.value}
46+
disabled={local.disabled}
4547
class={cn(
4648
'relative rounded-md transition-shadow focus-within:outline-none focus-within:ring-[1.5px] focus-within:ring-ring',
4749
local.class,

src/components/select-input.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ interface SelectInputOptions<T>
5151
placeholder?: string;
5252
options: SelectOption<T>[];
5353
required?: boolean;
54+
disabled?: boolean;
5455
}
5556

5657
export type SelectInputProps<T> = WithOverride<
@@ -73,6 +74,7 @@ export function SelectInput<T>(props: SelectInputProps<T>) {
7374
return (
7475
<_Select
7576
{...rest}
77+
disabled={props.disabled}
7678
options={props.options}
7779
optionValue="value"
7880
optionTextValue={option =>

src/components/switch-input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export const SwitchField = makeFieldComponent({
1616
});
1717

1818
export interface SwitchInputOptions
19-
extends FormInputProps<HTMLInputElement, boolean> {}
19+
extends FormInputProps<HTMLInputElement, boolean> {
20+
disabled?: boolean;
21+
}
2022

2123
export type SwitchInputProps = WithOverride<
2224
ComponentProps<'div'>,
@@ -30,6 +32,7 @@ export function SwitchInput(props: SwitchInputProps) {
3032
<_Switch
3133
checked={local.value}
3234
onChange={val => local.onChange?.(val)}
35+
disabled={local.disabled}
3336
{...rest}
3437
>
3538
<_Switch.Input

0 commit comments

Comments
 (0)