"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DroppableWidget = void 0;
var reactive_vue_1 = require("@formily/reactive-vue");
var hooks_1 = require("../../hooks");
var NodeTitleWidget_1 = require("../NodeTitleWidget");
var NodeActionsWidget_1 = require("../NodeActionsWidget");
require("./styles.less");
var vue_demi_1 = require("vue-demi");
var shared_1 = require("@designable/shared");
exports.DroppableWidget = (0, reactive_vue_1.observer)((0, vue_demi_1.defineComponent)({
    name: 'DnDroppableWidget',
    props: {
        node: { type: Object },
        height: {},
        actions: { type: Array },
        placeholder: { type: Boolean, default: true },
        hasChildren: { type: Boolean, default: undefined }
    },
    inheritAttrs: false,
    setup: function (props, _a) {
        var attrs = _a.attrs, slots = _a.slots;
        var nodeRef = (0, hooks_1.useTreeNode)();
        var nodeIdRef = (0, hooks_1.useNodeIdProps)(props.node);
        return function () {
            var _a, _b, _c, _d, _e;
            var target = (_a = props.node) !== null && _a !== void 0 ? _a : nodeRef.value;
            if (!target)
                return;
            var children = (_b = slots.default) === null || _b === void 0 ? void 0 : _b.call(slots);
            var hasChildren = (_c = props.hasChildren) !== null && _c !== void 0 ? _c : (((_d = target.children) === null || _d === void 0 ? void 0 : _d.length) > 0 && children);
            return (<div {...nodeIdRef.value} {...attrs} class={attrs.class}>
            {hasChildren ? (children) : props.placeholder ? (<div style={{ height: (0, shared_1.isStr)(props.height) ? props.height : props.height + 'px' }} class="dn-droppable-placeholder">
                <NodeTitleWidget_1.NodeTitleWidget node={target}/>
              </div>) : (children)}
            {((_e = props.actions) === null || _e === void 0 ? void 0 : _e.length) ? (<NodeActionsWidget_1.NodeActionsWidget>
                {props.actions.map(function (action, key) { return (<NodeActionsWidget_1.NodeActionsWidget.Action {...action} key={key}/>); })}
              </NodeActionsWidget_1.NodeActionsWidget>) : null}
          </div>);
        };
    }
}));
//# sourceMappingURL=index.jsx.map