Skip to content

Commit 81e3804

Browse files
authored
Extract ToggleStateProps type to use only what is needed in useToggleState (#3836)
* Extract `ToggleStateProps` type to use only what is needed in `useToggleState`
1 parent 89c42a8 commit 81e3804

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/@react-stately/toggle/src/useToggleState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {ToggleProps} from '@react-types/checkbox';
13+
import {ToggleStateOptions} from '@react-types/checkbox';
1414
import {useControlledState} from '@react-stately/utils';
1515

16-
export interface ToggleStateOptions extends Omit<ToggleProps, 'children'> {}
16+
export type {ToggleStateOptions};
1717

1818
export interface ToggleState {
1919
/** Whether the toggle is selected. */

packages/@react-types/checkbox/src/index.d.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ import {
3030
} from '@react-types/shared';
3131
import {ReactElement, ReactNode} from 'react';
3232

33-
export interface ToggleProps extends InputBase, Validation<boolean>, FocusableProps {
34-
/**
35-
* The label for the element.
36-
*/
37-
children?: ReactNode,
33+
export interface ToggleStateOptions extends InputBase {
3834
/**
3935
* Whether the element should be selected (uncontrolled).
4036
*/
@@ -46,7 +42,14 @@ export interface ToggleProps extends InputBase, Validation<boolean>, FocusablePr
4642
/**
4743
* Handler that is called when the element's selection state changes.
4844
*/
49-
onChange?: (isSelected: boolean) => void,
45+
onChange?: (isSelected: boolean) => void
46+
}
47+
48+
export interface ToggleProps extends ToggleStateOptions, Validation, FocusableProps {
49+
/**
50+
* The label for the element.
51+
*/
52+
children?: ReactNode,
5053
/**
5154
* The value of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefvalue).
5255
*/

0 commit comments

Comments
 (0)