UNPKG

@wulperstudio/cms

Version:
61 lines 2.59 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["variant", "size", "textFieldProps", "label", "backgroundColor", "error", "errorVariant", "errorMessage"]; import React from 'react'; import { Root } from './styled'; import { WrapperInputVariant, InputLabel, ErrorAlert, BaseInputVariant } from '../../base'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; var InputNumberLabelOut = function InputNumberLabelOut(_ref) { var _ref$variant = _ref.variant, variant = _ref$variant === void 0 ? 'divider' : _ref$variant, size = _ref.size, textFieldProps = _ref.textFieldProps, label = _ref.label, backgroundColor = _ref.backgroundColor, error = _ref.error, errorVariant = _ref.errorVariant, errorMessage = _ref.errorMessage, props = _objectWithoutProperties(_ref, _excluded); var _React$useState = React.useState(false), _React$useState2 = _slicedToArray(_React$useState, 2), onFocusInput = _React$useState2[0], setOnFocusInput = _React$useState2[1]; return /*#__PURE__*/_jsxs(Root, { children: [variant === 'labelOut' && label && /*#__PURE__*/_jsx(InputLabel, { variant: variant, htmlFor: props.id, focused: onFocusInput, children: label }), /*#__PURE__*/_jsxs(WrapperInputVariant, { variant: variant, error: error, size: size, backgroundColor: backgroundColor, children: [variant !== 'labelOut' && label && /*#__PURE__*/_jsx(InputLabel, { variant: variant, htmlFor: props.id, focused: onFocusInput, children: label }), /*#__PURE__*/_jsx(BaseInputVariant, _extends({ variant: variant }, textFieldProps, { onFocus: function onFocus(e) { var _textFieldProps$onFoc; setOnFocusInput(true); textFieldProps == null || (_textFieldProps$onFoc = textFieldProps.onFocus) == null || _textFieldProps$onFoc.call(textFieldProps, e); }, onBlur: function onBlur(e) { var _textFieldProps$onBlu; setOnFocusInput(false); textFieldProps == null || (_textFieldProps$onBlu = textFieldProps.onBlur) == null || _textFieldProps$onBlu.call(textFieldProps, e); }, type: "number" }))] }), error && /*#__PURE__*/_jsx(ErrorAlert, { variant: errorVariant, children: errorMessage })] }); }; export default InputNumberLabelOut;