Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /*
Copyright (c) 2018-2019 Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
// @flow
import type {OverrideT} from '../helpers/overrides.js';
import {STYLE_TYPE} from './constants.js';
export type LabelPlacementT = 'top' | 'right' | 'bottom' | 'left';
export type StyleTypeT = $Keys<typeof STYLE_TYPE>;
export type OverridesT = {
Checkmark?: OverrideT<*>,
Label?: OverrideT<*>,
Root?: OverrideT<*>,
Input?: OverrideT<*>,
Toggle?: OverrideT<*>,
ToggleInner?: OverrideT<*>,
ToggleTrack?: OverrideT<*>,
};
export type DefaultPropsT = {
children?: React$Node,
checked: boolean,
disabled: boolean,
isError: boolean,
autoFocus: boolean,
isIndeterminate: boolean,
inputRef: {current: HTMLInputElement | null},
checkmarkType: StyleTypeT,
onChange: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onMouseEnter: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onMouseLeave: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onMouseDown: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onMouseUp: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onFocus: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onBlur: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
};
export type PropsT = {
/** Component or String value for label of checkbox. */
children?: React$Node,
overrides?: OverridesT,
/** Check or uncheck the control. */
checked?: boolean,
/** Disable the checkbox from being changed. */
disabled?: boolean,
/** Marks the checkbox as required. */
required?: boolean,
/** Renders checkbox in errored state. */
isError?: boolean,
/** Used to get a ref to the input element. Useful for programmatically focusing the input */
inputRef: {current: HTMLInputElement | null},
/** Focus the checkbox on initial render. */
autoFocus?: boolean,
/** Passed to the input element type attribute */
type?: string,
/** Passed to the input element name attribute */
name?: string,
/** Passed to the input element value attribute */
value?: string,
/** Indicates a 'half' state for the checkmark. In this case, `checked` is ignored. */
isIndeterminate?: boolean,
/** How to position the label relative to the checkbox itself. */
labelPlacement?: LabelPlacementT,
/** Renders UI as checkmark or toggle switch. */
checkmarkType: StyleTypeT,
/** Handler for change events on trigger element. */
onChange?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for mouseenter events on trigger element. */
onMouseEnter: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for mouseleave events on trigger element. */
onMouseLeave: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for mousedown events on trigger element. */
onMouseDown: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for mouseup events on trigger element. */
onMouseUp: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** handler for focus events on trigger element. */
onFocus: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** handler for blur events on trigger element. */
onBlur: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
};
export type StatelessStateT = {
isFocused: boolean,
isHovered: boolean,
isActive: boolean,
};
export type StateT = {
checked?: boolean,
isIndeterminate?: boolean,
};
export type StateReducerT = (
stateType: string,
nextState: StateT,
currentState: StateT,
event: SyntheticInputEvent<HTMLInputElement>,
) => StateT;
export type DefaultStatefulPropsT = {
initialState: StateT,
children?: (*) => React$Node,
stateReducer: StateReducerT,
onChange: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onMouseEnter: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onMouseLeave: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onFocus: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
onBlur: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
};
export type StatefulContainerPropsT = {
overrides?: OverridesT,
/** Component or String value for label of checkbox. */
children?: (*) => React$Node,
/** Defines the components initial state value */
initialState?: StateT,
/** A state change handler. Used to override default state transitions. */
stateReducer: StateReducerT,
/** Handler for change events on trigger element. */
onChange?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for mouseenter events on trigger element. */
onMouseEnter?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for mouseleave events on trigger element. */
onMouseLeave?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for focus events on trigger element. */
onFocus?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for blur events on trigger element. */
onBlur?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Focus the checkbox on initial render. */
autoFocus?: boolean,
};
export type StatefulCheckboxPropsT = {
overrides?: OverridesT,
/** Component or String value for label of checkbox. */
children?: React$Node,
/** Defines the components initial state value */
initialState?: StateT,
/** Focus the checkbox on initial render. */
autoFocus?: boolean,
/** Handler for change events on trigger element. */
onChange?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for mouseenter events on trigger element. */
onMouseEnter?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for mouseleave events on trigger element. */
onMouseLeave?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for focus events on trigger element. */
onFocus?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
/** Handler for blur events on trigger element. */
onBlur?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
};
export type SharedStylePropsT = {
$isFocused: boolean,
$isHovered: boolean,
$isActive: boolean,
$isError: boolean,
$checked: boolean,
$isIndeterminate: boolean,
$required: boolean,
$disabled: boolean,
$value: string,
$checkmarkType: StyleTypeT,
$labelPlacement: LabelPlacementT,
};
|