"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireWildcard(require("react"));

var _mobxReactLite = require("mobx-react-lite");

var _EventManager = require("../../../lib/_util/EventManager");

var _TableStore = require("./TableStore");

var _CheckBox = _interopRequireDefault(require("../check-box/CheckBox"));

var SelectionTreeBox = function SelectionTreeBox(props) {
  var record = props.record;
  var handleChange = (0, _react.useCallback)(function (value) {
    var dataSet = record.dataSet;

    if (dataSet) {
      if (value) {
        dataSet.treeSelect(record);
      } else {
        dataSet.treeUnSelect(record);
      }
    }
  }, [record]);
  return /*#__PURE__*/_react["default"].createElement(_CheckBox["default"], {
    checked: record.isSelected,
    onChange: handleChange,
    onClick: _EventManager.stopPropagation,
    disabled: !record.selectable,
    "data-selection-key": _TableStore.SELECTION_KEY,
    indeterminate: record.isSelectionIndeterminate,
    value: true
  });
};

SelectionTreeBox.displayName = 'SelectionTreeBox';

var _default = (0, _mobxReactLite.observer)(SelectionTreeBox);

exports["default"] = _default;
//# sourceMappingURL=SelectionTreeBox.js.map
