|
| 1 | +import * as React from 'react'; |
| 2 | + |
| 3 | +import { |
| 4 | + PCRColors, |
| 5 | + PCRColorsOutline, |
| 6 | + RadioCheckboxVariants, |
| 7 | + RadioCheckboxFillModes, |
| 8 | + RadioCheckboxAnimations, |
| 9 | + SwitchFillModes, |
| 10 | +} from './types'; |
| 11 | + |
| 12 | +export type BaseProps<S> = React.HTMLAttributes<HTMLInputElement> & { |
| 13 | + /** |
| 14 | + * The current checkbox state. |
| 15 | + */ |
| 16 | + state: S; |
| 17 | + |
| 18 | + /** |
| 19 | + * Dispatch method from React.useState or `this.setState` from class component. |
| 20 | + */ |
| 21 | + setState: React.Dispatch<React.SetStateAction<S>>; |
| 22 | + |
| 23 | + /** |
| 24 | + * A label to show in the Checkbox. This can be any JSX node or string. |
| 25 | + */ |
| 26 | + children?: React.ReactNode; |
| 27 | + |
| 28 | + /** |
| 29 | + * Specify one of the colors. |
| 30 | + */ |
| 31 | + color?: PCRColors | PCRColorsOutline; |
| 32 | + |
| 33 | + /** |
| 34 | + * Specify one of the variants. |
| 35 | + */ |
| 36 | + variant?: RadioCheckboxVariants; |
| 37 | + |
| 38 | + /** |
| 39 | + * Specify one of the fill modes. |
| 40 | + */ |
| 41 | + fill?: RadioCheckboxFillModes | SwitchFillModes; |
| 42 | + |
| 43 | + /** |
| 44 | + * Specify one of the animations. |
| 45 | + */ |
| 46 | + animation?: RadioCheckboxAnimations; |
| 47 | + |
| 48 | + /** |
| 49 | + * Pass an icon to render. |
| 50 | + */ |
| 51 | + icon?: React.ReactComponentElement<any, HTMLElement>; |
| 52 | + |
| 53 | + /** |
| 54 | + * Runs inside the default onChange handler for the Checkbox. |
| 55 | + */ |
| 56 | + onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void; |
| 57 | + |
| 58 | + /** |
| 59 | + * Set the checkbox as disabled. |
| 60 | + */ |
| 61 | + disabled?: boolean; |
| 62 | + |
| 63 | + /** |
| 64 | + * Set the checkbox as locked. This will also set the |
| 65 | + * `aria-disabled` attribute to `true`. |
| 66 | + */ |
| 67 | + locked?: boolean; |
| 68 | + |
| 69 | + /** |
| 70 | + * Pass additional class names to the `.pretty` div. |
| 71 | + */ |
| 72 | + className?: string; |
| 73 | + |
| 74 | + /** |
| 75 | + * Set the value of the input field. |
| 76 | + */ |
| 77 | + value?: string; |
| 78 | + |
| 79 | + /** |
| 80 | + * Make the checkbox, radio, or switcher bigger. |
| 81 | + */ |
| 82 | + bigger?: boolean; |
| 83 | +}; |
0 commit comments