UNPKG

@progress/kendo-vue-upload

Version:
115 lines (114 loc) 3.4 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 I, ref as r, inject as b, createVNode as a, isVNode as B } from "vue"; import { classNames as l } from "@progress/kendo-vue-common"; import { provideLocalizationService as C } from "@progress/kendo-vue-intl"; import { Button as d } from "@progress/kendo-vue-buttons"; import { clearSelectedFiles as u, messages as p, uploadSelectedFiles as m } from "./messages/main.mjs"; function f(e) { return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !B(e); } const $ = /* @__PURE__ */ I({ name: "KendoVueUploadActionButtons", props: { disabled: Boolean, navigationIndex: Number, clearButtonIndex: Number, uploadButtonIndex: Number, actionsLayout: String }, inject: { kendoLocalizationService: { default: null } }, emits: { clear: null, click: null, upload: null }, created() { this._prevNavigationIndex = void 0; }, setup() { const e = r(null), t = r(null), n = b("kendoLocalizationService", {}); return { uploadElementRef: e, clearElementRef: t, kendoLocalizationService: n }; }, mounted() { this._clearElement = this.clearElementRef, this._uploadElement = this.uploadElementRef; }, watch: { navigationIndex: function(e, t) { this._prevNavigationIndex = t; } }, updated() { const { navigationIndex: e, clearButtonIndex: t, uploadButtonIndex: n } = this.$props; e !== this._prevNavigationIndex && (e === t && this._clearElement && this._clearElement.focus(), e === n && this._uploadElement && this._uploadElement.focus()); }, methods: { onClearClick() { this.$props.disabled || this.$emit("clear"); }, onUploadClick() { this.$props.disabled || (this.$emit("click", this.$props.uploadButtonIndex), this.$emit("upload")); } }, render() { let e, t; const { disabled: n, navigationIndex: s, clearButtonIndex: h, uploadButtonIndex: k, actionsLayout: o } = this.$props, c = C(this), v = l("k-actions", { "k-actions-start": o === "start", "k-actions-center": o === "center", "k-actions-end": o === "end", "k-actions-stretched": o === "stretched" }), x = l("k-clear-selected", s === h ? "k-focus" : ""), g = l("k-upload-selected", s === k ? "k-focus" : ""); return a("div", { class: v }, [a(d, { type: "button", ref: (i) => { this.clearElementRef = i; }, disabled: n, class: x, tabIndex: -1, onClick: this.onClearClick }, f(e = c.toLanguageString(u, p[u])) ? e : { default: () => [e] }), a(d, { type: "button", ref: (i) => { this.uploadElementRef = i; }, disabled: n, themeColor: "primary", class: g, tabIndex: -1, onClick: this.onUploadClick }, f(t = c.toLanguageString(m, p[m])) ? t : { default: () => [t] })]); } }); export { $ as UploadActionButtons };