DocSpace-client/packages/components/text-input/input.js

40 lines
747 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,
2022-09-22 12:20:27 +00:00
guide,
2021-02-25 21:19:45 +00:00
fontWeight,
isBold,
2021-03-05 14:41:55 +00:00
forwardedRef,
2021-04-13 12:18:33 +00:00
className,
2022-01-25 07:56:51 +00:00
theme,
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`}
2022-09-22 12:20:27 +00:00
keepCharPositions={true}
guide={false}
2021-04-13 12:18:33 +00:00
{...props}
/>
2021-02-25 21:19:45 +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;