UNPKG

@itwin/core-react

Version:

A react component library of iTwin.js UI general purpose components

49 lines 2.51 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Checkbox */ import "./ImageCheckBox.scss"; import classnames from "classnames"; import * as React from "react"; import { Icon } from "../icons/IconComponent.js"; /** ImageCheckBox React component shows a checked or unchecked image * @public * @deprecated in 4.12.0. Use {@link https://itwinui.bentley.com/docs/checkbox iTwinUI checkbox} instead (custom icons are not supported at the moment, but feel free to submit your use cases). */ export class ImageCheckBox extends React.PureComponent { constructor() { super(...arguments); this._onChange = (e) => { if (e && e.stopPropagation) e.stopPropagation(); if (this.props.onClick) { this.props.onClick(e.target.checked); } }; this._onInputClick = (e) => { if (e && e.stopPropagation) e.stopPropagation(); }; this._onLabelClick = (e) => { if (e && e.stopPropagation) e.stopPropagation(); }; } render() { const checkBoxClass = classnames("core-image-checkbox", this.props.className); const imageClass = classnames("image", this.props.border && "image-checkbox-border"); const iconSpec = this.props.checked ? this.props.imageOn : this.props.imageOff; return ( // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/label-has-associated-control, jsx-a11y/no-noninteractive-element-interactions React.createElement("label", { className: checkBoxClass, style: this.props.style, onClick: this._onLabelClick, title: this.props.tooltip }, React.createElement("input", { type: "checkbox", className: this.props.inputClassName, style: this.props.inputStyle, checked: this.props.checked, disabled: this.props.disabled, onChange: this._onChange, onClick: this._onInputClick, ref: this.props.inputRef }), React.createElement("span", { className: imageClass }, React.createElement(Icon, { iconSpec: iconSpec })))); } } //# sourceMappingURL=ImageCheckBox.js.map