GoScrobble/web/node_modules/.cache/babel-loader/e7952a42d115297206a7e385fb8eabd4.json

1 line
13 KiB
JSON
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { mapToCssModules } from './utils';\nvar propTypes = {\n className: PropTypes.string,\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,\n label: PropTypes.node,\n valid: PropTypes.bool,\n invalid: PropTypes.bool,\n bsSize: PropTypes.string,\n htmlFor: PropTypes.string,\n cssModule: PropTypes.object,\n onChange: PropTypes.func,\n children: PropTypes.oneOfType([PropTypes.node, PropTypes.array, PropTypes.func]),\n innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func])\n};\n\nvar CustomFileInput = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(CustomFileInput, _React$Component);\n\n function CustomFileInput(props) {\n var _this;\n\n _this = _React$Component.call(this, props) || this;\n _this.state = {\n files: null\n };\n _this.onChange = _this.onChange.bind(_assertThisInitialized(_this));\n return _this;\n }\n\n var _proto = CustomFileInput.prototype;\n\n _proto.onChange = function onChange(e) {\n var input = e.target;\n var onChange = this.props.onChange;\n var files = this.getSelectedFiles(input);\n\n if (typeof onChange === \"function\") {\n onChange.apply(void 0, arguments);\n }\n\n this.setState({\n files: files\n });\n };\n\n _proto.getSelectedFiles = function getSelectedFiles(input) {\n var multiple = this.props.multiple;\n\n if (multiple && input.files) {\n var files = [].slice.call(input.files);\n return files.map(function (file) {\n return file.name;\n }).join(\", \");\n }\n\n if (input.value.indexOf(\"fakepath\") !== -1) {\n var parts = input.value.split(\"\\\\\");\n return parts[parts.length - 1];\n }\n\n return input.value;\n };\n\n _proto.render = function render() {\n var _this$props = this.props,\n className = _this$props.className,\n label = _this$props.label,\n valid = _this$props.valid,\n invalid = _this$props.invalid,\n cssModule = _this$props.cssModule,\n children = _this$props.children,\n bsSize = _this$props.bsSize,\n innerRef = _this$props.innerRef,\n htmlFor = _this$props.htmlFor,\n type = _this$props.type,\n onChange = _this$props.onChange,\n dataBrowse = _this$props.dataBrowse,\n hidden = _this$props.hidden,\n attributes = _objectWithoutPropertiesLoose(_this$props, [\"className\", \"label\", \"valid\", \"invalid\", \"cssModule\", \"children\", \"bsSize\", \"innerRef\", \"htmlFor\", \"type\", \"onChange\", \"dataBrowse\", \"hidden\"]);\n\n var customClass = mapToCssModules(classNames(className, \"custom-file\"), cssModule);\n var validationClassNames = mapToCssModules(classNames(invalid && \"is-invalid\", valid && \"is-valid\"), cssModule);\n var labelHtmlFor = htmlFor || attributes.id;\n var files = this.state.files;\n return /*#__PURE__*/React.createElement(\"div\", {\n className: customClass,\n hidden: hidden || false\n }, /*#__PURE__*/React.createElement(\"input\", _extends({\n type: \"file\"\n }, attributes, {\n ref: innerRef,\n \"aria-invalid\": invalid,\n className: classNames(validationClassNames, mapToCssModules(\"custom-file-input\", cssModule)),\n onChange: this.onChange\n })), /*#__PURE__*/React.createElement(\"label\", {\n className: mapToCssModules(\"custom-file-label\", cssModule),\n htmlFor: labelHtmlFor,\n \"data-browse\": dataBrowse\n }, files || label || \"Choose file\"), children);\n };\n\n return CustomFileInput;\n}(React.Component);\n\nCustomFileInput.propType