/* * Copyright 2016 Palantir Technologies, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // we need some empty interfaces to show up in docs // HACKHACK: these components should go in separate files // tslint:disable max-classes-per-file no-empty-interface import classNames from "classnames"; import * as React from "react"; import { polyfill } from "react-lifecycles-compat"; import { AbstractPureComponent2, Alignment, Classes } from "../../common"; import { DISPLAYNAME_PREFIX, HTMLInputProps, IProps } from "../../common/props"; import { safeInvoke } from "../../common/utils"; export interface IControlProps extends IProps, HTMLInputProps { // NOTE: HTML props are duplicated here to provide control-specific documentation /** * Alignment of the indicator within container. * @default Alignment.LEFT */ alignIndicator?: Alignment; /** Whether the control is checked. */ checked?: boolean; /** JSX label for the control. */ children?: React.ReactNode; /** Whether the control is initially checked (uncontrolled mode). */ defaultChecked?: boolean; /** Whether the control is non-interactive. */ disabled?: boolean; /** Ref handler that receives HTML `` element backing this component. */ inputRef?: (ref: HTMLInputElement | null) => any; /** Whether the control should appear as an inline element. */ inline?: boolean; /** * Text label for the control. * * Use `children` or `labelElement` to supply JSX content. This prop actually supports JSX elements, * but TypeScript will throw an error because `HTMLAttributes` only allows strings. */ label?: string; /** * JSX Element label for the control. * * This prop is a workaround for TypeScript consumers as the type definition for `label` only * accepts strings. JavaScript consumers can provide a JSX element directly to `label`. */ labelElement?: React.ReactNode; /** Whether this control should use large styles. */ large?: boolean; /** Event handler invoked when input value is changed. */ onChange?: React.FormEventHandler; /** * Name of the HTML tag that wraps the checkbox. * * By default a `