@gechiui/components
Version:
UI components for GeChiUI.
67 lines (60 loc) • 1.74 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import { createElement } from "@gechiui/element";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* GeChiUI dependencies
*/
import { useInstanceId } from '@gechiui/compose';
import deprecated from '@gechiui/deprecated';
import { Icon, check } from '@gechiui/icons';
/**
* Internal dependencies
*/
import BaseControl from '../base-control';
export default function CheckboxControl(_ref) {
let {
label,
className,
heading,
checked,
help,
onChange,
...props
} = _ref;
if (heading) {
deprecated('`heading` prop in `CheckboxControl`', {
alternative: 'a separate element to implement a heading',
plugin: 'Gutenberg'
});
}
const instanceId = useInstanceId(CheckboxControl);
const id = `inspector-checkbox-control-${instanceId}`;
const onChangeValue = event => onChange(event.target.checked);
return createElement(BaseControl, {
label: heading,
id: id,
help: help,
className: classnames('components-checkbox-control', className)
}, createElement("span", {
className: "components-checkbox-control__input-container"
}, createElement("input", _extends({
id: id,
className: "components-checkbox-control__input",
type: "checkbox",
value: "1",
onChange: onChangeValue,
checked: checked,
"aria-describedby": !!help ? id + '__help' : undefined
}, props)), checked ? createElement(Icon, {
icon: check,
className: "components-checkbox-control__checked",
role: "presentation"
}) : null), createElement("label", {
className: "components-checkbox-control__label",
htmlFor: id
}, label));
}
//# sourceMappingURL=index.js.map