"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _slate = require("slate");
var _slateReact = require("slate-react");
require("./style.css");
/* eslint-disable react-hooks/rules-of-hooks */

const renderCheckListItem = (_ref, editor) => {
  let {
    attributes,
    children,
    element
  } = _ref;
  const {
    id,
    checked = false
  } = element || {};
  const onChange = event => {
    const checked = event.target.checked;
    const path = _slateReact.ReactEditor.findPath(editor, element);
    _slate.Transforms.setNodes(editor, {
      checked
    }, {
      at: path
    });
  };
  return /*#__PURE__*/_react.default.createElement("div", Object.assign({
    "data-id": id,
    "data-root": "true"
  }, attributes, {
    className: "sf-check-list-item"
  }), /*#__PURE__*/_react.default.createElement("span", {
    contentEditable: false,
    style: {
      marginRight: 6
    }
  }, /*#__PURE__*/_react.default.createElement("input", {
    type: "checkbox",
    onChange: onChange,
    checked: checked
  })), children);
};
var _default = exports.default = renderCheckListItem;