const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let antd = require("antd");
//#region src/components/pisellPercent/components/EditView.tsx
/**
* PisellPercent 编辑态视图组件
* 
* 负责渲染编辑态的输入框
* 
* 功能：
* - 百分比输入（后缀显示 %）
* - 可选：滑块调节
* - 滑块和输入框双向同步
* - 实时或失焦校验
* 
* @param props 组件 Props
*/
const EditView = (props) => {
	const { showPercentSymbol = true, showSlider = false, precision = 1, range = [0, 100], min = range[0], max = range[1], step, sliderProps, placeholder = "请输入百分比", disabled, autoFocus, size, keyboard, controls, className, style, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, id, name, onPressEnter } = props;
	const { value, isValid, errors, handleChange, handleBlur, handleFocus } = (0, _pisell_utils.useNumberInputState)(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, {
		min,
		max,
		precision
	}));
	const suffixNode = showPercentSymbol ? "%" : void 0;
	const inputNumberElement = /* @__PURE__ */ react.default.createElement(antd.InputNumber, {
		value: value !== null && value !== void 0 ? value : void 0,
		onChange: handleChange,
		onBlur: handleBlur,
		onFocus: handleFocus,
		onPressEnter: () => onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(value !== null && value !== void 0 ? value : null),
		min,
		max,
		step,
		precision,
		suffix: suffixNode,
		placeholder,
		disabled,
		autoFocus,
		size,
		keyboard,
		controls,
		status: isValid ? void 0 : "error",
		style: showSlider ? void 0 : style,
		"aria-label": ariaLabel,
		"aria-describedby": ariaDescribedBy,
		id,
		name
	});
	if (showSlider) return /* @__PURE__ */ react.default.createElement("div", {
		className: `pisell-percent pisell-percent-edit pisell-percent-with-slider ${className || ""}`,
		style
	}, /* @__PURE__ */ react.default.createElement(antd.Slider, require_objectSpread2._objectSpread2({
		value: value !== null && value !== void 0 ? value : void 0,
		onChange: handleChange,
		min,
		max,
		step,
		disabled
	}, sliderProps)), inputNumberElement, !isValid && errors.length > 0 && /* @__PURE__ */ react.default.createElement("div", { className: "pisell-percent-error" }, errors[0]));
	return /* @__PURE__ */ react.default.createElement("div", { className: `pisell-percent pisell-percent-edit ${className || ""}` }, inputNumberElement, !isValid && errors.length > 0 && /* @__PURE__ */ react.default.createElement("div", { className: "pisell-percent-error" }, errors[0]));
};
//#endregion
exports.default = EditView;
