DocSpace-buildtools/packages/asc-web-components/text-input/input.js

37 lines
702 B
JavaScript
Raw Normal View History

import React from "react";
import MaskedInput from "react-text-mask";
/* eslint-disable no-unused-vars, react/prop-types */
const Input = ({
2021-02-25 21:19:45 +00:00
isAutoFocussed,
isDisabled,
isReadOnly,
hasError,
hasWarning,
scale,
withBorder,
keepCharPositions,
fontWeight,
isBold,
2021-03-05 14:41:55 +00:00
forwardedRef,
2021-04-13 12:18:33 +00:00
className,
2021-02-25 21:19:45 +00:00
...props
2021-03-05 14:41:55 +00:00
}) => {
const rest = {};
if (isAutoFocussed) rest.autoFocus = true;
if (forwardedRef) rest.ref = forwardedRef;
return props.mask != null ? (
2021-04-13 12:18:33 +00:00
<MaskedInput
className={`${className} not-selectable`}
keepCharPositions
{...props}
/>
2021-02-25 21:19:45 +00:00
) : (
2021-04-13 12:18:33 +00:00
<input className={`${className} not-selectable`} {...props} {...rest} />
2021-02-25 21:19:45 +00:00
);
2021-03-05 14:41:55 +00:00
};
2021-02-25 21:19:45 +00:00
export default Input;