"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const cn_ui_1 = require("@cainiaofe/cn-ui");
require("./index.scss");
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
const classnames_1 = __importDefault(require("classnames"));
const { connect, observer, useFieldSchema } = cn_ui_1.formilyReact;
const DropdownFilterItem = connect(observer((props) => {
    const { children } = props;
    const fieldSchema = useFieldSchema();
    const isCompose = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component']) === 'Compose';
    const isRangeDatePicker = ['RangePicker', 'CnRangeDatePickerPro'].includes(fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component']);
    const renderComposePop = () => {
        const properties = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.properties;
        const keys = (0, isPlainObject_1.default)(properties) ? Object.keys(properties) : [];
        return (react_1.default.createElement(react_1.default.Fragment, null, keys.map((key) => (react_1.default.createElement("div", { className: "cn-ai-search-custom-select-popup-container", id: key })))));
    };
    // fix: 日期区间使用本体时，需要增加宽度，来解决遮挡的问题
    const contentCls = (0, classnames_1.default)('cn-ai-dropdown-filter-item__content', {
        'cn-dropdown-filter-item__content__date-range': isRangeDatePicker,
    });
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement("div", { className: contentCls },
            children,
            react_1.default.createElement("div", { className: "cn-search-custom-select-container" },
                react_1.default.createElement("div", { className: "cn-ai-search-custom-select-popup-container", id: fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name }),
                isCompose ? renderComposePop() : null))));
}));
exports.default = DropdownFilterItem;
