shineout
Version:
Shein 前端组件库
66 lines (56 loc) • 1.83 kB
JavaScript
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
// obsolete code
import React from 'react';
import { PureComponent } from '../component';
import { uploadClass } from './styles';
import Drop from './Drop';
import { accept as attrAccept } from '../utils';
var Dragger =
/*#__PURE__*/
function (_PureComponent) {
_inheritsLoose(Dragger, _PureComponent);
function Dragger(props) {
var _this;
_this = _PureComponent.call(this, props) || this;
_this.handleDrop = _this.handleDrop.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
var _proto = Dragger.prototype;
_proto.getMatchedFile = function getMatchedFile(files) {
if (files === void 0) {
files = [];
}
var accept = this.props.accept;
return Array.prototype.slice.call(files).filter(function (file) {
return attrAccept(file, accept);
});
};
_proto.handleDrop = function handleDrop(files) {
var addFile = this.props.addFile;
addFile({
files: files,
fromDragger: true
});
};
_proto.render = function render() {
var _this$props = this.props,
children = _this$props.children,
disabled = _this$props.disabled,
multiple = _this$props.multiple,
limit = _this$props.limit,
accept = _this$props.accept;
return React.createElement(Drop, {
className: uploadClass('dragger-wrapper'),
drop: true,
disabled: disabled,
multiple: multiple || limit > 1,
accept: accept,
onDrop: this.handleDrop
}, React.createElement("div", {
className: uploadClass('dragger-area', disabled && 'disabled')
}, children));
};
return Dragger;
}(PureComponent);
export default Dragger;