UNPKG

@parkassist/pa-ui-library

Version:
49 lines 1.29 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import React from "react"; import Palette from "../../constants/Palette"; import { Column, Row } from "../Layout/Flex"; import CheckboxInput from "./CheckboxInput"; import { FontStyles } from "../../index"; const Checkbox = ({ checked, indeterminate, onChange = () => null, disabled = false, color = Palette.LIGHT_BLACK, text, component, size = 24, breakWord, checkboxStyles = {}, textStyles = {} }) => { const handleClick = () => { if (!disabled) { onChange(!checked); } }; return _jsxs(Row, { alignItems: 'center', onClick: handleClick, children: [_jsx(Column, { children: _jsx(CheckboxInput, { disabled: disabled, checked: checked, indeterminate: indeterminate, size: size, color: color, style: checkboxStyles }) }), (text || component) && _jsx(Column, { style: Object.assign({ justifyContent: "center", wordBreak: breakWord && 'break-word', color: disabled ? Palette.DARK_GREY : Palette.LIGHT_BLACK, cursor: !disabled && 'pointer', font: FontStyles.INPUT_FONT }, textStyles), children: component || text })] }); }; export default Checkbox;