@activecollab/components
Version:
ActiveCollab Components
86 lines • 2.53 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["decimalLength", "decimalSeparator", "disableAbbreviation", "disabled", "disableMacros", "invalid", "step", "thousandSeparator", "value", "onCancel", "onSave", "onEnterKeyPress", "allowEmptyValue", "onChange", "onClick", "limit", "placeholder", "trimDecimals", "min", "max", "onBlur", "update", "shortenThreshold"];
import React, { forwardRef, useRef } from "react";
import { Input } from "./Input";
import { useInputNumber } from "../../hooks";
import { useForkRef } from "../../utils";
export const InputNumber = /*#__PURE__*/forwardRef((_ref, ref) => {
let {
decimalLength = 2,
decimalSeparator = ".",
disableAbbreviation = false,
disabled,
disableMacros = false,
invalid,
step = 1,
thousandSeparator = ",",
value: defaultValue,
onCancel,
onSave,
onEnterKeyPress: externalEnterKeyPress,
allowEmptyValue,
onChange: externalOnChange,
onClick: externalOnClick,
limit,
placeholder,
trimDecimals = true,
min,
max,
onBlur: externalOnBlur,
update = false,
shortenThreshold = 1000
} = _ref,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
const inputRef = useRef(null);
const handleRef = useForkRef(ref, inputRef);
const {
value,
onBlur,
onKeyDown,
onChange,
onClick,
onFocus,
onDoubleClick
} = useInputNumber({
decimalLength,
decimalSeparator,
disableAbbreviation,
disableMacros,
step,
thousandSeparator,
onEnterKeyPress: externalEnterKeyPress,
onChange: externalOnChange,
onClick: externalOnClick,
value: defaultValue,
onCancel,
onSave,
allowEmptyValue,
limit,
trimDecimals,
min,
max,
onBlur: externalOnBlur,
update,
shortenThreshold
}, inputRef);
return /*#__PURE__*/React.createElement(Input, _extends({}, rest, {
ref: handleRef,
placeholder: placeholder,
value: value,
type: "text",
disabled: disabled,
invalid: invalid,
onChange: onChange,
onBlur: onBlur,
onKeyDown: onKeyDown,
onClick: onClick,
onDoubleClick: onDoubleClick,
onFocus: onFocus,
"aria-placeholder": placeholder,
"aria-disabled": disabled,
"aria-invalid": invalid
}));
});
InputNumber.displayName = "InputNumber";
//# sourceMappingURL=InputNumber.js.map