const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_pisell_components = require("../../theme/pisell-components.js");
const require_EditView = require("./components/EditView.js");
const require_DisabledView = require("./components/DisabledView.js");
const require_ReadOnlyView = require("./components/ReadOnlyView.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let antd = require("antd");
require("./PisellSingleSelect.less");
//#region src/components/pisellSingleSelect/PisellSingleSelect.tsx
/**
* PisellSingleSelect - 单选下拉组件
* 基于 Ant Design Select 封装，提供符合 Pisell 设计规范的单选功能
*/
const PisellSingleSelect = (0, react.forwardRef)((props, ref) => {
	const { value, defaultValue, onChange, disabled, readOnly } = props;
	const selectRef = (0, react.useRef)(null);
	const state = (0, _pisell_utils.useSelectState)({
		value,
		defaultValue,
		onChange,
		mode: "single"
	});
	(0, react.useImperativeHandle)(ref, () => ({
		focus: () => {
			var _selectRef$current;
			return (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.focus();
		},
		blur: () => {
			var _selectRef$current2;
			return (_selectRef$current2 = selectRef.current) === null || _selectRef$current2 === void 0 ? void 0 : _selectRef$current2.blur();
		},
		getValue: () => {
			var _state$value;
			return (_state$value = state.value) !== null && _state$value !== void 0 ? _state$value : null;
		},
		setValue: (newValue) => state.setValue(newValue),
		clearValue: () => state.clearValue()
	}));
	const theme = require_pisell_components.getPisellComponentsThemeConfig();
	if (disabled) return /* @__PURE__ */ react.default.createElement(antd.ConfigProvider, { theme }, /* @__PURE__ */ react.default.createElement(require_DisabledView.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, { ref: selectRef })));
	if (readOnly) return /* @__PURE__ */ react.default.createElement(antd.ConfigProvider, { theme }, /* @__PURE__ */ react.default.createElement(require_ReadOnlyView.default, props));
	return /* @__PURE__ */ react.default.createElement(antd.ConfigProvider, { theme }, /* @__PURE__ */ react.default.createElement(require_EditView.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, {
		state,
		ref: selectRef
	})));
});
PisellSingleSelect.displayName = "PisellSingleSelect";
//#endregion
exports.default = PisellSingleSelect;
