/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

import { __extends } from 'tslib';
import React__default from 'react';
import { themeable, localeable } from 'amis-core';
import DropDownSelection from '../DropDownSelection.js';
import ChainedDropdownSelection from '../ChainedDropdownSelection.js';

var option2value = function (item) { return item.name; };
var ConditionField = /** @class */ (function (_super) {
    __extends(ConditionField, _super);
    function ConditionField() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ConditionField.prototype.render = function () {
        var _a = this.props, onChange = _a.onChange, value = _a.value, cx = _a.classnames, disabled = _a.disabled, translate = _a.translate, searchable = _a.searchable, _b = _a.selectMode, selectMode = _b === void 0 ? 'list' : _b, options = _a.options, loadingConfig = _a.loadingConfig, testIdBuilder = _a.testIdBuilder;
        return selectMode === 'chained' ? (React__default.createElement(ChainedDropdownSelection, { multiple: false, classnames: cx, translate: translate, options: options, value: value, valueField: "name", option2value: option2value, searchable: searchable, disabled: disabled, testIdBuilder: testIdBuilder === null || testIdBuilder === void 0 ? void 0 : testIdBuilder.getChild('s-chained'), onChange: function (value) {
                onChange(Array.isArray(value) ? value[0] : value);
            } })) : selectMode === 'tree' ? (React__default.createElement(DropDownSelection, { className: 'is-scrollable', classnames: cx, translate: translate, multiple: false, option2value: option2value, searchable: searchable, disabled: disabled, valueField: 'name', mode: 'tree', options: options, value: value, loadingConfig: loadingConfig, testIdBuilder: testIdBuilder === null || testIdBuilder === void 0 ? void 0 : testIdBuilder.getChild('s-tree'), onChange: function (value) {
                onChange(value);
            } })) : (React__default.createElement(DropDownSelection, { classnames: cx, translate: translate, options: options, value: value, valueField: 'name', option2value: option2value, searchable: searchable, disabled: disabled, testIdBuilder: testIdBuilder === null || testIdBuilder === void 0 ? void 0 : testIdBuilder.getChild('s-default'), onChange: function (value) {
                return onChange(Array.isArray(value) ? value[0] : value);
            } }));
    };
    return ConditionField;
}(React__default.Component));
var ConditionField$1 = themeable(localeable(ConditionField));

export { ConditionField, ConditionField$1 as default };
