1 | import * as React from 'react';
|
2 | export interface UseSwitchParameters {
|
3 | /**
|
4 | * If `true`, the component is checked.
|
5 | */
|
6 | checked?: boolean;
|
7 | /**
|
8 | * The default checked state. Use when the component is not controlled.
|
9 | */
|
10 | defaultChecked?: boolean;
|
11 | /**
|
12 | * If `true`, the component is disabled.
|
13 | */
|
14 | disabled?: boolean;
|
15 | onBlur?: React.FocusEventHandler;
|
16 | /**
|
17 | * Callback fired when the state is changed.
|
18 | *
|
19 | * @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
|
20 | * You can pull out the new value by accessing `event.target.value` (string).
|
21 | * You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
22 | */
|
23 | onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
24 | onFocus?: React.FocusEventHandler;
|
25 | onFocusVisible?: React.FocusEventHandler;
|
26 | /**
|
27 | * If `true`, the component is read only.
|
28 | */
|
29 | readOnly?: boolean;
|
30 | /**
|
31 | * If `true`, the `input` element is required.
|
32 | */
|
33 | required?: boolean;
|
34 | }
|
35 | interface UseSwitchInputSlotOwnProps {
|
36 | checked?: boolean;
|
37 | defaultChecked?: boolean;
|
38 | disabled?: boolean;
|
39 | onBlur: React.FocusEventHandler;
|
40 | onChange: React.ChangeEventHandler<HTMLInputElement>;
|
41 | onFocus: React.FocusEventHandler;
|
42 | readOnly?: boolean;
|
43 | ref: React.RefCallback<HTMLInputElement> | null;
|
44 | required?: boolean;
|
45 | type: React.HTMLInputTypeAttribute;
|
46 | }
|
47 | export type UseSwitchInputSlotProps<TOther = {}> = Omit<TOther, keyof UseSwitchInputSlotOwnProps> & UseSwitchInputSlotOwnProps;
|
48 | export interface UseSwitchReturnValue {
|
49 | /**
|
50 | * If `true`, the component will be checked.
|
51 | */
|
52 | checked: boolean;
|
53 | /**
|
54 | * If `true`, the component will be disabled.
|
55 | */
|
56 | disabled: boolean;
|
57 | /**
|
58 | * If `true`, it indicates that the component is being focused using keyboard.
|
59 | */
|
60 | focusVisible: boolean;
|
61 | /**
|
62 | * Resolver for the input slot's props.
|
63 | * @param externalProps props for the input slot
|
64 | * @returns props that should be spread on the input slot
|
65 | */
|
66 | getInputProps: (externalProps?: React.HTMLAttributes<HTMLInputElement>) => UseSwitchInputSlotProps;
|
67 | /**
|
68 | * Ref to the input slot's DOM node.
|
69 | */
|
70 | inputRef: React.RefCallback<HTMLInputElement> | null;
|
71 | /**
|
72 | * If `true`, the component will be read only.
|
73 | */
|
74 | readOnly: boolean;
|
75 | }
|
76 | export {};
|