primereact
Version:
PrimeReact is an open source UI library for React featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime
200 lines (193 loc) • 5.76 kB
TypeScript
/**
*
* InputSwitch is used to select a boolean value.
*
* [Live Demo](https://www.primereact.org/inputswitch/)
*
* @module inputswitch
*
*/
import * as React from 'react';
import { ComponentHooks } from '../componentbase/componentbase';
import { PassThroughOptions } from '../passthrough';
import { TooltipPassThroughOptions } from '../tooltip/tooltip';
import { TooltipOptions } from '../tooltip/tooltipoptions';
import { FormBooleanEvent } from '../ts-helpers';
import { PassThroughType } from '../utils/utils';
export declare type InputSwitchPassThroughType<T> = PassThroughType<T, InputSwitchPassThroughMethodOptions>;
/**
* Custom passthrough(pt) option method.
*/
export interface InputSwitchPassThroughMethodOptions {
props: InputSwitchProps;
}
/**
* Custom passthrough(pt) options.
* @see {@link InputSwitchProps.pt}
*/
export interface InputSwitchPassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: InputSwitchPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
/**
* Uses to pass attributes to the slider's DOM element.
*/
slider?: InputSwitchPassThroughType<React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes to the input's DOM element.
*/
input?: InputSwitchPassThroughType<React.HTMLAttributes<HTMLInputElement>>;
/**
* Uses to pass attributes tooltip's DOM element.
* @type {TooltipPassThroughOptions}
*/
tooltip?: TooltipPassThroughOptions;
/**
* Used to manage all lifecycle hooks
* @see {@link ComponentHooks}
*/
hooks?: ComponentHooks;
}
/**
* Custom change event.
* @see {@link InputSwitchProps.onChange}
* @extends {FormBooleanEvent}
* @event
*/
interface InputSwitchChangeEvent extends FormBooleanEvent {}
/**
* Defines valid properties in InputMask component. In addition to these, all properties of HTMLDivElement can be used in this component.
* @group Properties
*/
export interface InputSwitchProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'onChange' | 'ref'> {
/**
* Unique identifier of the element.
*/
id?: string | undefined;
/**
* When present, it specifies that the component should automatically get focus on load.
* @defaultValue false
*/
autoFocus?: boolean | undefined;
/**
* Reference of the input element.
*/
inputRef?: React.Ref<HTMLInputElement> | undefined;
/**
* Inline style of the element.
*/
style?: React.CSSProperties | undefined;
/**
* Style class of the element.
*/
className?: string | undefined;
/**
* Identifier of the input element.
*/
inputId?: string | undefined;
/**
* Name of the input element.
*/
name?: string | undefined;
/**
* Index of the element in tabbing order.
*/
tabIndex?: number | undefined;
/**
* Specifies whether a inputswitch should be checked or not.
* @defaultValue false
*/
checked: boolean;
/**
* Value in checked state.
* @defaultValue true
*/
trueValue?: any;
/**
* Value in unchecked state.
* @defaultValue false
*/
falseValue?: any;
/**
* When present, it specifies that the component should have invalid state style.
* @defaultValue false
*/
invalid?: boolean | undefined;
/**
* When present, it specifies that the component should be disabled.
* @defaultValue false
*/
disabled?: boolean | undefined;
/**
* Content of the tooltip.
*/
tooltip?: string | undefined;
/**
* Configuration of the tooltip, refer to the tooltip documentation for more information.
* @type {TooltipOptions}
*/
tooltipOptions?: TooltipOptions | undefined;
/**
* Callback to invoke on value change.
* @param {InputSwitchChangeEvent} event - Custom change event
*/
onChange?(event: InputSwitchChangeEvent): void;
/**
* Callback to invoke when the element receives focus.
* @param {React.FocusEvent<HTMLInputElement>} event - Browser event
*/
onFocus?(event: React.FocusEvent<HTMLInputElement>): void;
/**
* Callback to invoke when the element loses focus.
* @param {React.FocusEvent<HTMLInputElement>} event - Browser event
*/
onBlur?(event: React.FocusEvent<HTMLInputElement>): void;
/**
* Used to get the child elements of the component.
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {InputSwitchPassThroughOptions}
*/
pt?: InputSwitchPassThroughOptions;
/**
* Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
}
/**
* **PrimeReact - InputSwitch**
*
* _InputSwitch is used to select a boolean value._
*
* [Live Demo](https://www.primereact.org/inputswitch/)
* --- ---
* 
*
* @group Component
*/
export declare class InputSwitch extends React.Component<InputSwitchProps, any> {
/**
* Used to focus the component.
*/
public focus(): void;
/**
* Used to get container element.
* @return {HTMLDivElement} Container element
*/
public getElement(): HTMLDivElement;
/**
* Used to get input element.
* @return {HTMLInputElement} Input element
*/
public getInput(): HTMLInputElement;
}