import _get from "lodash/get";
import * as React from "react";
import { connect } from "react-redux";
import { Typography } from "@webiny/ui/Typography";
import { Grid, Cell } from "@webiny/ui/Grid";
import { Checkbox as CheckboxCmp } from "@webiny/ui/Checkbox";
import { getActiveElement } from "../../../selectors";

var Checkbox = function Checkbox(_ref) {
  var label = _ref.label,
      value = _ref.value,
      updateValue = _ref.updateValue,
      children = _ref.children;
  return /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
    span: 4
  }, /*#__PURE__*/React.createElement(Typography, {
    use: "overline"
  }, label)), /*#__PURE__*/React.createElement(Cell, {
    span: 8
  }, /*#__PURE__*/React.createElement(CheckboxCmp, {
    value: value,
    onChange: updateValue
  }, children)));
};

export default connect(function (state, _ref2) {
  var value = _ref2.value,
      valueKey = _ref2.valueKey,
      defaultValue = _ref2.defaultValue;
  return {
    value: valueKey ? _get(getActiveElement(state), valueKey, defaultValue) : value
  };
})( /*#__PURE__*/React.memo(Checkbox));
//# sourceMappingURL=Checkbox.js.map