1 line
3.1 KiB
JSON
1 line
3.1 KiB
JSON
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { mapToCssModules } from './utils';\nimport CustomFileInput from './CustomFileInput';\nvar propTypes = {\n className: PropTypes.string,\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,\n type: PropTypes.string.isRequired,\n label: PropTypes.node,\n inline: PropTypes.bool,\n valid: PropTypes.bool,\n invalid: PropTypes.bool,\n bsSize: PropTypes.string,\n htmlFor: PropTypes.string,\n cssModule: PropTypes.object,\n children: PropTypes.oneOfType([PropTypes.node, PropTypes.array, PropTypes.func]),\n innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func])\n};\n\nfunction CustomInput(props) {\n var className = props.className,\n label = props.label,\n inline = props.inline,\n valid = props.valid,\n invalid = props.invalid,\n cssModule = props.cssModule,\n children = props.children,\n bsSize = props.bsSize,\n innerRef = props.innerRef,\n htmlFor = props.htmlFor,\n attributes = _objectWithoutPropertiesLoose(props, [\"className\", \"label\", \"inline\", \"valid\", \"invalid\", \"cssModule\", \"children\", \"bsSize\", \"innerRef\", \"htmlFor\"]);\n\n var type = attributes.type;\n var customClass = mapToCssModules(classNames(className, \"custom-\" + type, bsSize ? \"custom-\" + type + \"-\" + bsSize : false), cssModule);\n var validationClassNames = mapToCssModules(classNames(invalid && 'is-invalid', valid && 'is-valid'), cssModule);\n var labelHtmlFor = htmlFor || attributes.id;\n\n if (type === 'select') {\n var _type = attributes.type,\n rest = _objectWithoutPropertiesLoose(attributes, [\"type\"]);\n\n return React.createElement(\"select\", _extends({}, rest, {\n ref: innerRef,\n className: classNames(validationClassNames, customClass)\n }), children);\n }\n\n if (type === 'file') {\n return React.createElement(CustomFileInput, props);\n }\n\n if (type !== 'checkbox' && type !== 'radio' && type !== 'switch') {\n return React.createElement(\"input\", _extends({}, attributes, {\n ref: innerRef,\n className: classNames(validationClassNames, customClass)\n }));\n }\n\n var wrapperClasses = classNames(customClass, mapToCssModules(classNames('custom-control', {\n 'custom-control-inline': inline\n }), cssModule));\n return React.createElement(\"div\", {\n className: wrapperClasses\n }, React.createElement(\"input\", _extends({}, attributes, {\n type: type === 'switch' ? 'checkbox' : type,\n ref: innerRef,\n className: classNames(validationClassNames, mapToCssModules('custom-control-input', cssModule))\n })), React.createElement(\"label\", {\n className: mapToCssModules('custom-control-label', cssModule),\n htmlFor: labelHtmlFor\n }, label), children);\n}\n\nCustomInput.propTypes = propTypes;\nexport default CustomInput;","map":null,"metadata":{},"sourceType":"module"} |