UNPKG

@progress/kendo-vue-upload

Version:
126 lines (125 loc) 3.67 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 m, inject as h, createVNode as n } from "vue"; import { classNames as f } from "@progress/kendo-vue-common"; import { Button as c } from "@progress/kendo-vue-buttons"; import { UploadFileStatus as e } from "./interfaces/UploadFileStatus.mjs"; import { provideLocalizationService as y } from "@progress/kendo-vue-intl"; import { cancel as l, messages as a, remove as u, retry as d } from "./messages/main.mjs"; import { arrowRotateCwIcon as b, cancelIcon as g, xIcon as B } from "@progress/kendo-svg-icons"; const U = /* @__PURE__ */ m({ name: "KendoVueUploadListActionButton", props: { progress: Number, uid: String, status: Number, async: Object, disabled: Boolean, files: Array }, emits: { cancel: null, retry: null, remove: null }, inject: { kendoLocalizationService: { default: null } }, data() { return { retryFocused: !1, actionFocused: !1 }; }, methods: { actionButtonTitle(t, o) { return t === e.Uploading ? o.toLanguageString(l, a[l]) : o.toLanguageString(u, a[u]); }, retryButtonTitle(t) { return t.toLanguageString(d, a[d]); }, buttonClassNames(t) { return f(this.actionFocused && t === "action" || this.retryFocused && t === "retry" ? "k-focus" : ""); }, onRetryFocus() { this.retryFocused = !0; }, onRetryBlur() { this.retryFocused = !1; }, onActionFocus() { this.actionFocused = !0; }, onActionBlur() { this.actionFocused = !1; }, onActionClick() { const { status: t, uid: o, disabled: s } = this.$props; s || t === e.Removing || (t === e.Uploading ? this.$emit("cancel", o) : this.$emit("remove", o)); }, onRetryClick() { const { uid: t, disabled: o } = this.$props; o || this.$emit("retry", t); } }, setup() { return { kendoLocalizationService: h("kendoLocalizationService", {}) }; }, render() { const { status: t, progress: o } = this.$props, s = t === e.UploadFailed, r = t === e.Uploading, p = (t === e.Uploaded || t === e.Initial) && !this.$props.async.removeUrl, i = y(this); return n("div", { class: "k-upload-actions" }, [r ? n("span", { class: "k-upload-pct" }, [o, "%"]) : void 0, s ? n(c, { type: "button", fillMode: "flat", tabIndex: -1, disabled: this.disabled, class: this.buttonClassNames("retry"), icon: "arrow-rotate-cw-small", svgIcon: b, iconClass: "k-retry", ariaLabel: this.retryButtonTitle(i), title: this.retryButtonTitle(i), onFocus: this.onRetryFocus, onBlur: this.onRetryBlur, onClick: this.onRetryClick }, null) : void 0, p ? void 0 : n(c, { type: "button", fillMode: "flat", tabIndex: -1, disabled: this.disabled, class: this.buttonClassNames("action"), onFocus: this.onActionFocus, onBlur: this.onActionBlur, onClick: this.onActionClick, icon: r ? "deny" : "x", svgIcon: r ? g : B, ariaLabel: this.actionButtonTitle(t, i), title: this.actionButtonTitle(t, i) }, null)]); } }); export { U as UploadListActionButton };