UNPKG

tdesign-vue

Version:
78 lines (74 loc) 3.31 kB
/** * tdesign v1.12.1 * (c) 2025 tdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, toRefs } from '@vue/composition-api'; import { isFunction } from 'lodash-es'; import useDrag from '../hooks/useDrag.js'; import { commonProps } from '../constants.js'; import { renderContent } from '../../utils/render-tnode.js'; import '../../_common/js/upload/utils.js'; import '../../_common/js/log/log.js'; import '@babel/runtime/helpers/readOnlyError'; import '@babel/runtime/helpers/typeof'; import 'vue'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var CustomFile = defineComponent({ name: "UploadCustomFile", props: _objectSpread(_objectSpread({}, commonProps), {}, { dragEvents: Object, draggable: Boolean, dragContent: Function, trigger: Function, triggerUpload: Function, childrenNode: Function }), setup: function setup(props) { var _toRefs = toRefs(props), accept = _toRefs.accept; var drag = useDrag(props.dragEvents, accept); var dragActive = drag.dragActive; return _objectSpread({ dragActive: dragActive }, drag); }, render: function render() { var _this = this, _this$$scopedSlots$de, _this$$scopedSlots; var h = arguments[0]; var renderDragContent = function renderDragContent() { var params = { dragActive: _this.dragActive || false, files: _this.displayFiles }; return h("div", { "class": "".concat(_this.classPrefix, "-upload__dragger ").concat(_this.classPrefix, "-upload__dragger-center"), "on": { "drop": _this.handleDrop, "dragenter": _this.handleDragenter, "dragover": _this.handleDragover, "dragleave": _this.handleDragleave, "click": _this.triggerUpload } }, [h("div", { "class": "".concat(_this.classPrefix, "-upload__trigger") }, [renderContent(_this, "dragContent", "trigger", { params: params }) || isFunction(_this.childrenNode) && _this.childrenNode(params)])]); }; return this.draggable ? renderDragContent() : h("div", { "class": "".concat(this.classPrefix, "-upload__trigger"), "on": { "click": this.triggerUpload } }, [isFunction(this.childrenNode) && this.childrenNode({ files: this.displayFiles }) || ((_this$$scopedSlots$de = (_this$$scopedSlots = this.$scopedSlots)["default"]) === null || _this$$scopedSlots$de === void 0 ? void 0 : _this$$scopedSlots$de.call(_this$$scopedSlots, null))]); } }); export { CustomFile as default }; //# sourceMappingURL=custom-file.js.map