mobile-more
Version:
基于 antd-mobile v5 扩展移动端 UI 组件
80 lines • 3.35 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["type", "borderAround", "icon", "camera", "bgColor", "className", "style"];
/// <reference path='../../typings.d.ts' />
// ref: https://github.com/umijs/father/issues/227#issuecomment-730857244
import * as React from 'react';
import classnames from 'classnames';
import IconCard from '../../assets/images/icon-card@2x.png';
import IconIdcardFront from '../../assets/images/icon-idcard-front@2x.png';
import IconIdcardBack from '../../assets/images/icon-idcard-back@2x.png';
import IconPhoto from '../../assets/images/icon-photo@2x.png';
import IconLicense from '../../assets/images/icon-license@2x.png';
import { prefixClass } from '../../config';
import "./index.css";
var prefixCls = "".concat(prefixClass, "-image-uploader-uploadType");
// 内置图标配置
var InternalIconConfig = {
license: {
src: IconLicense,
width: 72,
height: 81
},
idcardFront: {
src: IconIdcardFront,
width: 89,
height: 57
},
idcardBack: {
src: IconIdcardBack,
width: 89,
height: 57
},
card: {
src: IconCard,
width: 92,
height: 66
}
};
var UploadType = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
var _ref$type = _ref.type,
type = _ref$type === void 0 ? 'license' : _ref$type,
_ref$borderAround = _ref.borderAround,
borderAround = _ref$borderAround === void 0 ? true : _ref$borderAround,
_ref$icon = _ref.icon,
icon = _ref$icon === void 0 ? '' : _ref$icon,
_ref$camera = _ref.camera,
camera = _ref$camera === void 0 ? true : _ref$camera,
_ref$bgColor = _ref.bgColor,
bgColor = _ref$bgColor === void 0 ? '#e8f1fc' : _ref$bgColor,
className = _ref.className,
style = _ref.style,
restProps = _objectWithoutProperties(_ref, _excluded);
var iconview = React.useMemo(function () {
return icon || (type in InternalIconConfig ? (/*#__PURE__*/React.createElement("img", _objectSpread({}, InternalIconConfig[type]))) : null);
}, [icon, type]);
return /*#__PURE__*/React.createElement("div", _objectSpread({
className: classnames(prefixCls, className),
style: _objectSpread({
background: bgColor
}, style),
ref: ref
}, restProps), /*#__PURE__*/React.createElement("div", {
className: "".concat(prefixCls, "-icon")
}, iconview), camera && /*#__PURE__*/React.createElement("img", {
src: IconPhoto,
className: "".concat(prefixCls, "-camera")
}), borderAround && (/*#__PURE__*/React.createElement("div", {
className: "".concat(prefixCls, "-borderAround")
}, /*#__PURE__*/React.createElement("i", {
className: classnames("".concat(prefixCls, "-borderLine"), "".concat(prefixCls, "-borderTopLeft"))
}), /*#__PURE__*/React.createElement("i", {
className: classnames("".concat(prefixCls, "-borderLine"), "".concat(prefixCls, "-borderTopRight"))
}), /*#__PURE__*/React.createElement("i", {
className: classnames("".concat(prefixCls, "-borderLine"), "".concat(prefixCls, "-borderBottomLeft"))
}), /*#__PURE__*/React.createElement("i", {
className: classnames("".concat(prefixCls, "-borderLine"), "".concat(prefixCls, "-borderBottomRight"))
}))));
});
UploadType.displayName = 'UploadType';
export default UploadType;