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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
var React = require('react');
var amisCore = require('amis-core');
var DropDownSelection = require('../DropDownSelection.js');
var ChainedDropdownSelection = require('../ChainedDropdownSelection.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
(__react_jsx__["default"] || __react_jsx__).Fragment;
var option2value = function (item) { return item.name; };
var ConditionField = /** @class */ (function (_super) {
    tslib.__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' ? (_J$X_(ChainedDropdownSelection["default"], { 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' ? (_J$X_(DropDownSelection["default"], { 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);
            } })) : (_J$X_(DropDownSelection["default"], { 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["default"].Component));
var ConditionField$1 = amisCore.themeable(amisCore.localeable(ConditionField));

exports.ConditionField = ConditionField;
exports["default"] = ConditionField$1;
