UNPKG

@progress/kendo-vue-upload

Version:
111 lines (110 loc) 3.01 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { defineComponent as h, ref as f, createVNode as s, h as R } from "vue"; import { canUseDOM as v, classNames as y, getTemplate as C, setRef as g } from "@progress/kendo-vue-common"; import { UploadFileStatus as i } from "./interfaces/UploadFileStatus.mjs"; import { UploadListSingleItem as k } from "./UploadListSingleItem.mjs"; import { UploadListMultiItem as b } from "./UploadListMultiItem.mjs"; import x from "./utils/utils.mjs"; const S = /* @__PURE__ */ h({ name: "KendoVueUploadListGroup", props: { files: Array, async: Object, disabled: Boolean, navigationIndex: Number, list: [String, Function, Object], index: Number }, emits: { cancel: null, click: null, retry: null, remove: null }, mounted() { this._element = this.elementRef; }, updated() { const { navigationIndex: e, index: n } = this.$props; e === n && this._element && v && document.activeElement !== this._element && this._element.focus(); }, methods: { onClick() { this.$emit("click", this.$props.index); }, onRetry(e) { this.$emit("retry", e); }, onRemove(e) { this.$emit("remove", e); }, onCancel(e) { this.$emit("cancel", e); } }, setup() { return { elementRef: f(null) }; }, render() { const { files: e, async: n, disabled: o, navigationIndex: r, index: m } = this.$props, t = e[0], d = t.status === i.Uploaded || t.status === i.Initial, l = x.filesHaveValidationErrors(e), c = t.status === i.UploadFailed || t.status === i.RemoveFailed, p = y("k-file", { "k-file-invalid": l, "k-file-error": c || l, "k-file-progress": t.status === i.Uploading, "k-file-success": d, "k-focus": r === m }); let a; const u = e.length === 1 ? s(k, { files: e, async: n, disabled: o, onCancel: this.onCancel, onRemove: this.onRemove, onRetry: this.onRetry }, null) : s(b, { files: e, async: n, disabled: o, onCancel: this.onCancel, onRemove: this.onRemove, onRetry: this.onRetry }, null); return a = C.call(this, { h: R, template: this.$props.list, defaultRendering: u, additionalProps: this.$props, additionalListeners: { retry: this.onRetry, remove: this.onRemove, cancel: this.onCancel } }), s("li", { ref: g(this, "element"), class: p, "data-uid": t.uid, tabindex: -1, onClick: this.onClick }, [a]); } }); export { S as UploadListGroup };