Skip to content

Commit

Permalink
Refactor #4431 - For Checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ulasturann committed Aug 11, 2023
1 parent f27c314 commit b2e8c7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/lib/checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const Checkbox = React.memo(
props,
state: {
focused: focusedState
},
context: {
checked: props.checked === props.trueValue,
disabled: props.disabled
}
});

Expand Down
17 changes: 17 additions & 0 deletions components/lib/checkbox/checkbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export declare type CheckboxPassThroughType<T> = PassThroughType<T, CheckboxPass
export interface CheckboxPassThroughMethodOptions {
props: CheckboxProps;
state: CheckboxState;
context: CheckboxContext;
}

/**
Expand Down Expand Up @@ -55,6 +56,22 @@ export interface CheckboxPassThroughOptions {
hiddenInput?: CheckboxPassThroughType<React.HTMLAttributes<HTMLInputElement>>;
}

/**
* Defines current options in Checkbox component.
*/
export interface CheckboxContext {
/**
* Current checked state of the item as a boolean.
* @defaultValue false
*/
checked: boolean;
/**
* Current disabled state of the item as a boolean.
* @defaultValue false
*/
disabled: boolean;
}

/**
* Defines current inline state in Checkbox component.
*/
Expand Down

0 comments on commit b2e8c7d

Please sign in to comment.