2020-01-21 12:48:42 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import styled from "styled-components";
|
2019-11-25 05:07:27 +00:00
|
|
|
import { ComponentProps } from "components/designSystems/appsmith/BaseComponent";
|
2020-01-21 12:48:42 +00:00
|
|
|
import { Checkbox, Classes } from "@blueprintjs/core";
|
|
|
|
|
|
|
|
|
|
const CheckboxContainer = styled.div`
|
|
|
|
|
&& {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
align-items: center;
|
|
|
|
|
label {
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
2019-09-09 09:08:54 +00:00
|
|
|
class CheckboxComponent extends React.Component<CheckboxComponentProps> {
|
2019-03-21 12:10:32 +00:00
|
|
|
render() {
|
|
|
|
|
return (
|
2020-01-21 12:48:42 +00:00
|
|
|
<CheckboxContainer>
|
|
|
|
|
<Checkbox
|
|
|
|
|
label={this.props.label}
|
|
|
|
|
className={
|
|
|
|
|
this.props.isLoading ? "bp3-skeleton" : Classes.RUNNING_TEXT
|
|
|
|
|
}
|
|
|
|
|
defaultIndeterminate={this.props.defaultCheckedState}
|
|
|
|
|
onChange={this.onCheckChange}
|
|
|
|
|
disabled={this.props.isDisabled}
|
|
|
|
|
/>
|
|
|
|
|
</CheckboxContainer>
|
2019-09-05 17:47:50 +00:00
|
|
|
);
|
2019-03-21 12:10:32 +00:00
|
|
|
}
|
2019-11-05 05:09:50 +00:00
|
|
|
|
|
|
|
|
onCheckChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
this.props.onCheckChange(event.target.value === "true");
|
|
|
|
|
};
|
2019-03-21 12:10:32 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
export interface CheckboxComponentProps extends ComponentProps {
|
2019-09-13 10:45:49 +00:00
|
|
|
label: string;
|
|
|
|
|
defaultCheckedState: boolean;
|
2019-11-05 05:09:50 +00:00
|
|
|
onCheckChange: (isChecked: boolean) => void;
|
2019-12-03 04:41:10 +00:00
|
|
|
isLoading: boolean;
|
2019-03-21 12:10:32 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-05 17:47:50 +00:00
|
|
|
export default CheckboxComponent;
|