@activecollab/components
Version:
ActiveCollab Components
92 lines • 3.74 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 _ref$decimalLength = _ref.decimalLength,
decimalLength = _ref$decimalLength === void 0 ? 2 : _ref$decimalLength,
_ref$decimalSeparator = _ref.decimalSeparator,
decimalSeparator = _ref$decimalSeparator === void 0 ? "." : _ref$decimalSeparator,
_ref$disableAbbreviat = _ref.disableAbbreviation,
disableAbbreviation = _ref$disableAbbreviat === void 0 ? false : _ref$disableAbbreviat,
disabled = _ref.disabled,
_ref$disableMacros = _ref.disableMacros,
disableMacros = _ref$disableMacros === void 0 ? false : _ref$disableMacros,
invalid = _ref.invalid,
_ref$step = _ref.step,
step = _ref$step === void 0 ? 1 : _ref$step,
_ref$thousandSeparato = _ref.thousandSeparator,
thousandSeparator = _ref$thousandSeparato === void 0 ? "," : _ref$thousandSeparato,
defaultValue = _ref.value,
onCancel = _ref.onCancel,
onSave = _ref.onSave,
externalEnterKeyPress = _ref.onEnterKeyPress,
allowEmptyValue = _ref.allowEmptyValue,
externalOnChange = _ref.onChange,
externalOnClick = _ref.onClick,
limit = _ref.limit,
placeholder = _ref.placeholder,
_ref$trimDecimals = _ref.trimDecimals,
trimDecimals = _ref$trimDecimals === void 0 ? true : _ref$trimDecimals,
min = _ref.min,
max = _ref.max,
externalOnBlur = _ref.onBlur,
_ref$update = _ref.update,
update = _ref$update === void 0 ? false : _ref$update,
_ref$shortenThreshold = _ref.shortenThreshold,
shortenThreshold = _ref$shortenThreshold === void 0 ? 1000 : _ref$shortenThreshold,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
const inputRef = useRef(null);
const handleRef = useForkRef(ref, inputRef);
const _useInputNumber = 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),
value = _useInputNumber.value,
onBlur = _useInputNumber.onBlur,
onKeyDown = _useInputNumber.onKeyDown,
onChange = _useInputNumber.onChange,
onClick = _useInputNumber.onClick,
onFocus = _useInputNumber.onFocus,
onDoubleClick = _useInputNumber.onDoubleClick;
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