/* * 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 /* eslint-disable max-classes-per-file, @typescript-eslint/no-empty-interface */ import classNames from "classnames"; import * as React from "react"; import { polyfill } from "react-lifecycles-compat"; import { AbstractPureComponent2, Alignment, Classes, IRef, refHandler, setRef } from "../../common"; import { DISPLAYNAME_PREFIX, HTMLInputProps, Props } from "../../common/props"; // eslint-disable-next-line deprecation/deprecation export type ControlProps = IControlProps; /** @deprecated use ControlProps */ export interface IControlProps extends Props, 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?: IRef; /** 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 `