UNPKG

react-hichestan-numberinput

Version:

A serie of react components to numbers in input specially persian numbers.

668 lines (530 loc) 29.1 kB
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _objects = _interopRequireDefault(require("shallow-equal/objects")); var _util = require("./util"); var _excluded = ["value", "onChange", "onInput", "onPast", "onKeyDown", "pattern", "inputMode", "type", "ref", "inputRef", "getInputRef", "numberFormat", "defaultValue", "asString", "maxDecimal", "maxDigits", "thousandSeparator", "decimalSeparator"]; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var DecimalInput = /*#__PURE__*/function (_Component) { _inherits(DecimalInput, _Component); var _super = _createSuper(DecimalInput); function DecimalInput(_props) { var _this; _classCallCheck(this, DecimalInput); _this = _super.call(this, _props); _defineProperty(_assertThisInitialized(_this), "defaultThousandSeparator", function () { return ','; }); _defineProperty(_assertThisInitialized(_this), "defaultDecimalSeparator", function () { return '.'; }); _defineProperty(_assertThisInitialized(_this), "readValuesFromProps", function (props) { if (props.value || props.value === 0) { var value = props.value.toString(); return _this.updateValue('', 0, 0, value, props.numberFormat, props.asString); } return { value: undefined, valueToShow: '', selectionStart: undefined, selectionEnd: undefined }; }); _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { // console.log('keyCode: ', event.keyCode, 'key: ', event.key); if (_this.props.disabled || _this.props.readOnly) { event.preventDefault(); } else if (event.keyCode === 8) { //backspace event.preventDefault(); _this.updateState(_this.deleteValue(event.target, -1, _this.props.asString)); } else if (event.keyCode === 46) { //delete event.preventDefault(); _this.updateState(_this.deleteValue(event.target, 1, _this.props.asString)); } else if (event.keyCode >= 48 && event.keyCode <= 57) { //digits event.preventDefault(); // console.log('digit'); _this.updateState(_this.updateElementValue(event.target, (event.keyCode - 48).toString(), _this.props.numberFormat, _this.props.asString)); } else if (event.keyCode >= 96 && event.keyCode <= 105) { //digits event.preventDefault(); // console.log('digit'); _this.updateState(_this.updateElementValue(event.target, (event.keyCode - 96).toString(), _this.props.numberFormat, _this.props.asString)); } else if (event.key >= '۰' && event.key <= '۹' || event.key >= '٠' && event.key <= '٩') { //digits event.preventDefault(); // console.log('digit'); _this.updateState(_this.updateElementValue(event.target, event.key, _this.props.numberFormat, _this.props.asString)); } else if (event.key === _this.decimalSeparator || event.keyCode === 190) { //point event.preventDefault(); if (_this.props.maxDecimal === null || _this.props.maxDecimal === undefined || _this.props.maxDecimal > 0) { _this.updateState(_this.updateElementValue(event.target, _this.decimalSeparator, _this.props.numberFormat, _this.props.asString)); } } else if (event.key === '-' || event.keyCode === 189) { // - event.preventDefault(); _this.updateState(_this.negate()); } else if (event.keyCode >= 35 && event.keyCode <= 40) {//arrows } else if (event.keyCode === 9) {//tab } else if (event.keyCode === 13) { //return _this.hideKeyboard(); } else if ((event.ctrlKey || event.metaKey) && (event.keyCode === 67 || event.keyCode === 86 || event.keyCode === 88)) {//copy/paste/cut } else if ((event.ctrlKey || event.metaKey) && event.keyCode === 82) {//refresh key } else if ((event.ctrlKey || event.metaKey) && event.keyCode === 82) {//refresh key } else if ((event.ctrlKey || event.metaKey) && event.keyCode === 73) {//inspector } else if ((event.ctrlKey || event.metaKey) && event.keyCode === 65) {//select all } else if ((event.ctrlKey || event.metaKey) && event.keyCode === 76) {//location focus } else if (event.keyCode >= 112 && event.keyCode <= 123) {// All other F keys } else if (event.keyCode === 229) {//android bug workaround } else { // console.log('other'); // console.log('keyCode: ', event.keyCode, 'key: ', event.key, 'ctrlKey: ', event.ctrlKey); // this.rr.current.innerText = `keyCode: ${event.keyCode} key: ${event.key} ctrlKey: ${event.ctrlKey}`; event.preventDefault(); } }); _defineProperty(_assertThisInitialized(_this), "hideKeyboard", function () { _this.inputRef.current.blur(); }); _defineProperty(_assertThisInitialized(_this), "handlePaste", function (event) { event.preventDefault(); if (_this.props.disabled || _this.props.readOnly) return; var enteredValue = _this.stripAnyThingButNumber((event.clipboardData || window.clipboardData).getData('text')); if (_this.values.valueToShow !== '') { enteredValue = enteredValue.replace(/[-]/g, ''); } _this.updateState(_this.updateElementValue(event.target, enteredValue, _this.props.numberFormat, _this.props.asString)); }); _defineProperty(_assertThisInitialized(_this), "handleInput", function (event) { if (_this.values.valueToShow === event.target.value) return; if (_this.props.disabled || _this.props.readOnly) return; var enteredValue = _this.stripAnyThingButNumber(event.target.value); var firstHyphenIndex = enteredValue.indexOf('-'); var secondHyphenIndex = enteredValue.indexOf('-', firstHyphenIndex + 1); if (secondHyphenIndex >= 0 || firstHyphenIndex > 0) { _this.updateState(_this.negate()); } else { var selectionStart = event.target.selectionStart; var selectionEnd = event.target.selectionEnd; var newState = _this.updateValue('', selectionStart, selectionEnd, enteredValue, _this.props.numberFormat, _this.props.asString); _this.updateState(newState, true); } }); _defineProperty(_assertThisInitialized(_this), "mapValue", function (value, numberFormat) { if (numberFormat === _util.NUMBER_FORMAT_FARSI) { return (0, _util.mapToFarsi)(value); } else if (numberFormat === _util.NUMBER_FORMAT_LATIN) { return (0, _util.mapToLatin)(value); } return (0, _util.mapToFarsi)(value); }); _defineProperty(_assertThisInitialized(_this), "mapDecimalSeparator", function (value) { return value.replace(_this.decimalSeparatorRegex, _this.decimalSeparator); }); _defineProperty(_assertThisInitialized(_this), "updateState", function (newState, forceFireChange, noFireOnChange) { if (!newState) return; _this.values = newState; var fireOnChangeInTheEnd = false; if (_this.inputRef.current.value !== _this.values.valueToShow) { fireOnChangeInTheEnd = true; _this.inputRef.current.value = _this.values.valueToShow; } if (_this.inputRef.current === document.activeElement) { // console.log('has focus :D'); _this.inputRef.current.setSelectionRange(_this.values.selectionStart, _this.values.selectionEnd); } else {// console.log('has not focus :('); } if (fireOnChangeInTheEnd || forceFireChange) { if (!noFireOnChange) { _this.fireOnChange(); } } }); _defineProperty(_assertThisInitialized(_this), "negate", function () { var _this$values = _this.values, value = _this$values.value, valueToShow = _this$values.valueToShow, valueIsValid = _this$values.valueIsValid, selectionStart = _this$values.selectionStart, selectionEnd = _this$values.selectionEnd; if (value > 0) { value = -value; valueToShow = '-' + valueToShow; selectionStart++; selectionEnd++; } else if (value < 0) { value = -value; valueToShow = valueToShow.substring(1); selectionStart--; selectionEnd--; } else { return; } return { value: value, valueToShow: valueToShow, valueIsValid: valueIsValid, selectionStart: selectionStart, selectionEnd: selectionEnd }; }); _defineProperty(_assertThisInitialized(_this), "updateElementValue", function (element, enteredValue, numberFormat, asString) { var currentValue = element.value; var selectionStart = element.selectionStart; var selectionEnd = element.selectionEnd; return _this.updateValue(currentValue, selectionStart, selectionEnd, enteredValue, numberFormat, asString); }); _defineProperty(_assertThisInitialized(_this), "updateValue", function (currentValue, selectionStart, selectionEnd, enteredValue, numberFormat, asString) { var enteredValueMapped = _this.mapDecimalSeparator(_this.mapValue(enteredValue, numberFormat)); var valueToShow = currentValue; if (enteredValueMapped === _this.decimalSeparator) { var i = valueToShow.indexOf(_this.decimalSeparator); if (i > -1) { return; } } var valueBeforeCursor = valueToShow.substring(0, selectionStart); var valueAfterCursor = valueToShow.substring(selectionEnd); selectionStart -= _this.countThousandSeparator(valueBeforeCursor); valueBeforeCursor = _this.stripThousandSeparator(valueBeforeCursor); valueAfterCursor = _this.stripThousandSeparator(valueAfterCursor); valueToShow = valueBeforeCursor + enteredValueMapped + valueAfterCursor; selectionStart += enteredValueMapped.length; if (typeof _this.props.maxDecimal === 'number') { var _i = valueToShow.indexOf(_this.decimalSeparator); if (_i > -1) { var decimalLength = valueToShow.length - _i - 1; if (decimalLength > _this.props.maxDecimal) { valueToShow = valueToShow.substring(0, _i + (_this.props.maxDecimal ? 1 : 0) + _this.props.maxDecimal); if (selectionStart > valueToShow.length) selectionStart = valueToShow.length; } } } { var latinNumber = (0, _util.mapToLatin)(valueToShow); var _i2 = _this.firstNonZeroDigit(latinNumber, 0); if (_i2 > 0 && valueToShow.length > 1) { valueToShow = valueToShow.substring(_i2); selectionStart -= _i2; } else if (_i2 === 0 && latinNumber.charAt(0) === '.') { valueToShow = _this.mapValue('0', numberFormat) + valueToShow; selectionStart++; } } if (typeof _this.props.maxDigits === 'number') { var _i3 = valueToShow.indexOf(_this.decimalSeparator); var digitsLength = _i3 > -1 ? _i3 : valueToShow.length; if (digitsLength > _this.props.maxDigits) { if (_i3 === -1) { valueToShow = valueToShow.substring(0, _this.props.maxDigits); if (selectionStart > valueToShow.length) selectionStart = valueToShow.length; } else { valueToShow = valueToShow.substring(0, _this.props.maxDigits) + (_i3 === -1 ? '' : valueToShow.substring(_i3)); if (selectionStart > _this.props.maxDigits) selectionStart = _this.props.maxDigits; } } } var separated = _this.addThousandSeparator(valueToShow, selectionStart); valueToShow = separated.valueToShowWithSeparator; selectionStart = separated.selectionStart; selectionEnd = selectionStart; var value = _this.stripThousandSeparator((0, _util.mapToLatin)(valueToShow)); var valueIsValid; if (asString) { var checkValue = Number(value); valueIsValid = typeof checkValue === 'number' || checkValue === undefined || checkValue === null; } else { value = Number(value); valueIsValid = typeof value === 'number' || value === undefined || value === null; } return { value: value, valueToShow: valueToShow, valueIsValid: valueIsValid, selectionStart: selectionStart, selectionEnd: selectionEnd }; }); _defineProperty(_assertThisInitialized(_this), "deleteValue", function (element, qty, asString) { var valueToShow = element.value; var selectionStart = element.selectionStart; var selectionEnd = element.selectionEnd; // console.log({selectionStart, selectionEnd}) if (selectionStart === selectionEnd) { if (qty < 0) { if (selectionStart === 0) return; var valueBeforeCursor = valueToShow.substring(0, selectionStart + qty); var valueAfterCursor = valueToShow.substring(selectionEnd); selectionStart -= _this.countThousandSeparator(valueBeforeCursor); valueBeforeCursor = _this.stripThousandSeparator(valueBeforeCursor); valueAfterCursor = _this.stripThousandSeparator(valueAfterCursor); valueToShow = valueBeforeCursor + valueAfterCursor; selectionStart += qty; } else { if (selectionEnd === valueToShow.length) return; var _valueBeforeCursor = valueToShow.substring(0, selectionStart); var _valueAfterCursor = valueToShow.substring(selectionEnd + qty); selectionStart -= _this.countThousandSeparator(_valueBeforeCursor); _valueBeforeCursor = _this.stripThousandSeparator(_valueBeforeCursor); _valueAfterCursor = _this.stripThousandSeparator(_valueAfterCursor); valueToShow = _valueBeforeCursor + _valueAfterCursor; } } else { var _valueBeforeCursor2 = valueToShow.substring(0, selectionStart); var _valueAfterCursor2 = valueToShow.substring(selectionEnd); selectionStart -= _this.countThousandSeparator(_valueBeforeCursor2); _valueBeforeCursor2 = _this.stripThousandSeparator(_valueBeforeCursor2); _valueAfterCursor2 = _this.stripThousandSeparator(_valueAfterCursor2); valueToShow = _valueBeforeCursor2 + _valueAfterCursor2; } var separated = _this.addThousandSeparator(valueToShow, selectionStart); valueToShow = separated.valueToShowWithSeparator; selectionStart = separated.selectionStart; selectionEnd = selectionStart; var value = _this.stripThousandSeparator((0, _util.mapToLatin)(valueToShow)); var valueIsValid; if (asString) { var checkValue = Number(value); valueIsValid = typeof checkValue === 'number' || checkValue === undefined || checkValue === null; } else { value = Number(value); valueIsValid = typeof value === 'number' || value === undefined || value === null; } return { value: value, valueToShow: valueToShow, valueIsValid: valueIsValid, selectionStart: selectionStart, selectionEnd: selectionEnd }; }); _defineProperty(_assertThisInitialized(_this), "addThousandSeparator", function (valueToShow, selectionStart) { if (_this.thousandSeparator === '') return { valueToShowWithSeparator: valueToShow, selectionStart: selectionStart }; var valueToShowWithSeparator = ''; var alreadFoundDecimalSeparator = false; var alreadyPassedDecimalSeparator = valueToShow.indexOf(_this.decimalSeparator) === -1; var groupCount = 0; for (var i = valueToShow.length - 1; i >= 0; i--) { var c = valueToShow.charAt(i); if (c === _this.decimalSeparator) { if (!alreadFoundDecimalSeparator) { alreadFoundDecimalSeparator = true; valueToShowWithSeparator = c + valueToShowWithSeparator; alreadyPassedDecimalSeparator = true; groupCount = 0; } else { if (i <= selectionStart) { selectionStart--; } } } else { if (alreadyPassedDecimalSeparator && groupCount === 3 && c !== '-') { valueToShowWithSeparator = _this.thousandSeparator + valueToShowWithSeparator; groupCount = 0; if (i < selectionStart - 1) { selectionStart++; } } valueToShowWithSeparator = c + valueToShowWithSeparator; groupCount++; } } return { valueToShowWithSeparator: valueToShowWithSeparator, selectionStart: selectionStart }; }); _defineProperty(_assertThisInitialized(_this), "firstNonZeroDigit", function (value, i) { if (value.charAt(i) === _this.decimalSeparator) { if (i > 0) return i - 1;else return i; } if (value.charAt(i) === '0') return _this.firstNonZeroDigit(value, i + 1); return i; }); _defineProperty(_assertThisInitialized(_this), "countThousandSeparator", function (value) { return _this.thousandSeparator === '' ? 0 : (value.match(_this.thousandSeparatorRegex) || []).length; }); _defineProperty(_assertThisInitialized(_this), "stripThousandSeparator", function (value) { return _this.thousandSeparator === '' ? value : value.replace(_this.thousandSeparatorRegex, ''); }); _defineProperty(_assertThisInitialized(_this), "stripAnyThingButNumber", function (str) { if (!str) return str; return str.toString().replace(_this.numberRegex, ''); }); _defineProperty(_assertThisInitialized(_this), "fireOnChange", function () { if (_this.props.onChange) { _this.props.onChange({ target: { name: _this.props.name, value: _this.values.value } }); } }); var ref = _props.inputRef || _props.getInputRef; if (ref && typeof ref === 'function') { ref = ref(); } _this.inputRef = ref ? ref : /*#__PURE__*/_react.default.createRef(); // this.rr = React.createRef(); _this.thousandSeparator = _props.thousandSeparator === '' ? '' : _props.thousandSeparator || _this.defaultThousandSeparator(); _this.decimalSeparator = _props.decimalSeparator || _this.defaultDecimalSeparator(); _this.thousandSeparatorRegex = new RegExp("[".concat(_this.thousandSeparator, "]"), 'g'); _this.decimalSeparatorRegex = new RegExp("[.".concat(_this.decimalSeparator, "]"), 'g'); _this.numberRegex = new RegExp("[^-1234567890\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9\u06F0.".concat(_this.decimalSeparator, "]"), 'gi'); _this.values = _this.readValuesFromProps(_props); return _this; } _createClass(DecimalInput, [{ key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps, nextState) { if (nextProps.value !== this.values.value || nextProps.numberFormat !== this.props.numberFormat) { this.updateState(this.readValuesFromProps(nextProps), false, true); } if (!(0, _objects.default)(nextProps.style, this.props.style)) { return true; } if (nextProps.className !== this.props.className) { this.inputRef.current.className = nextProps.className; } if (nextProps.disabled !== this.props.disabled) { this.inputRef.current.disabled = nextProps.disabled; } if (nextProps.readOnly !== this.props.readOnly) { this.inputRef.current.readOnly = nextProps.readOnly; } if (nextProps.placeholder !== this.props.placeholder) { this.inputRef.current.placeholder = nextProps.placeholder; } return false; } }, { key: "render", value: function render() { var _this$props = this.props, value = _this$props.value, onChange = _this$props.onChange, onInput = _this$props.onInput, onPast = _this$props.onPast, onKeyDown = _this$props.onKeyDown, pattern = _this$props.pattern, inputMode = _this$props.inputMode, type = _this$props.type, ref = _this$props.ref, inputRef = _this$props.inputRef, getInputRef = _this$props.getInputRef, numberFormat = _this$props.numberFormat, defaultValue = _this$props.defaultValue, asString = _this$props.asString, maxDecimal = _this$props.maxDecimal, maxDigits = _this$props.maxDigits, thousandSeparator = _this$props.thousandSeparator, decimalSeparator = _this$props.decimalSeparator, rest = _objectWithoutProperties(_this$props, _excluded); var valueToShow = this.values.valueToShow; // const localInputMode = this.props.type === 'tel' ? 'tel' : 'numeric'; // as we use type=tel, then we do not need it any more // const localPattern = '[0-9]*'; // it has problem with the form checking, as we insert persian digit, it is not acceptable for the browser return /*#__PURE__*/_react.default.createElement("input", _extends({ ref: this.inputRef, type: "tel" // I tried to use text and using inputMode, but it does not work on Safari // inputMode={localInputMode} // xInputMode={localnputMode} // in firefox OS it is x-inputmode, I do not know how to handle it , dir: "ltr" // pattern={localPattern} , defaultValue: valueToShow, onKeyDown: this.handleKeyDown, onPaste: this.handlePaste, onInput: this.handleInput }, rest)); //<p ref={this.rr} type={"text"}>empty</p></div> } }]); return DecimalInput; }(_react.Component); _defineProperty(DecimalInput, "propTypes", { /** * The ref to pass on the input, if empty it will be created internally */ inputRef: _propTypes.default.any, getInputRef: _propTypes.default.any, /** * The name that will be set while firing the onChange event in the target object */ name: _propTypes.default.string, /** * Callback function that is fired when the cart number value changes. */ onChange: _propTypes.default.func, /** * Override the inline-styles of the root element. */ style: _propTypes.default.object, /** * The css class name of the root element. */ className: _propTypes.default.string, /** * Disables the decimal input. */ disabled: _propTypes.default.bool, /** * makes the decimal input readonly. */ readOnly: _propTypes.default.bool, /** * Callback function that is fired when a click event occurs on the input. */ onClick: _propTypes.default.func, /** * Callback function that is fired when the input gains focus. */ onFocus: _propTypes.default.func, /** * Sets the value for the decimal input. */ value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]), /** * Sets the thousand separator */ thousandSeparator: _propTypes.default.string, /** * Sets the decimal separator */ decimalSeparator: _propTypes.default.string, /** * makes the value string, it is useful for big decimals. */ asString: _propTypes.default.bool, /** * max digits before decimal separator. */ maxDigits: _propTypes.default.number, /** * max digits after decimal separator. */ maxDecimal: _propTypes.default.number }); var _default = DecimalInput; exports.default = _default;