acud
Version:
acg react 组件库
78 lines • 4.18 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
/**
* @file InputNumber 数字输入框
* @author zhongziyan
*/
var __rest = this && this.__rest || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
import classNames from 'classnames';
import React from 'react';
import UpOutlined from "acud-icon/es/icons/OutlinedUp";
import DownOutlined from "acud-icon/es/icons/OutlinedDown";
import OutlinedMinus from "acud-icon/es/icons/OutlinedMinus";
import OutlinedPlus from "acud-icon/es/icons/OutlinedPlus";
import { ConfigContext } from '../config-provider';
import SizeContext from '../config-provider/SizeContext';
import Popover from '../popover';
import RcInputNumber from './src';
var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
var _React$useContext = React.useContext(ConfigContext),
getPrefixCls = _React$useContext.getPrefixCls,
direction = _React$useContext.direction;
var size = React.useContext(SizeContext);
var className = props.className,
customizeSize = props.size,
customizePrefixCls = props.prefixCls,
_props$bordered = props.bordered,
bordered = _props$bordered === void 0 ? true : _props$bordered,
readOnly = props.readOnly,
warning = props.warning,
warningPopover = props.warningPopover,
warningText = props.warningText,
_props$symmetryMode = props.symmetryMode,
symmetryMode = _props$symmetryMode === void 0 ? false : _props$symmetryMode,
style = props.style,
others = __rest(props, ["className", "size", "prefixCls", "bordered", "readOnly", "warning", "warningPopover", "warningText", "symmetryMode", "style"]);
var prefixCls = getPrefixCls('input-number', customizePrefixCls);
var UpIcon = symmetryMode ? OutlinedPlus : UpOutlined;
var DownIcon = symmetryMode ? OutlinedMinus : DownOutlined;
var upIcon = /*#__PURE__*/React.createElement(UpIcon, {
className: "".concat(prefixCls, "-handler-up-inner")
});
var downIcon = /*#__PURE__*/React.createElement(DownIcon, {
className: "".concat(prefixCls, "-handler-down-inner")
});
var mergeSize = customizeSize || size || 'middle';
var inputNumberClass = classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-lg"), mergeSize === 'large'), "".concat(prefixCls, "-sm"), mergeSize === 'small'), "".concat(prefixCls, "-rtl"), direction === 'rtl'), "".concat(prefixCls, "-readonly"), readOnly), "".concat(prefixCls, "-borderless"), !bordered), "".concat(prefixCls, "-warning"), warning || warningPopover), "".concat(prefixCls, "-symmetry"), symmetryMode), className);
var inputWrapperClass = classNames(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-lg"), mergeSize === 'large'), "".concat(prefixCls, "-sm"), mergeSize === 'small'), "".concat(prefixCls, "-md"), mergeSize === 'middle'), "".concat(prefixCls, "-wrapper"));
return /*#__PURE__*/React.createElement(Popover, {
content: /*#__PURE__*/React.createElement("span", {
className: "".concat(prefixCls, "-warning-popover-text")
}, warningText),
placement: "bottom",
visible: warningPopover && !!warningText,
trigger: "none"
}, /*#__PURE__*/React.createElement("div", {
className: inputWrapperClass,
style: style
}, /*#__PURE__*/React.createElement(RcInputNumber, _extends({
ref: ref,
className: inputNumberClass,
upHandler: upIcon,
downHandler: downIcon,
prefixCls: prefixCls,
readOnly: readOnly,
style: style,
symmetryMode: symmetryMode
}, others)), warning && warningText && /*#__PURE__*/React.createElement("div", {
className: "".concat(prefixCls, "-warning-text")
}, warningText)));
});
export default InputNumber;