UNPKG

@progress/kendo-vue-upload

Version:
104 lines (103 loc) 2.58 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 f, ref as m, createVNode as h } from "vue"; import { setRef as y } from "@progress/kendo-vue-common"; import { provideLocalizationService as b } from "@progress/kendo-vue-intl"; import { messages as o, select as s, selectTitle as g, selectNoFilesTitle as S } from "./messages/main.mjs"; const w = /(chrome)[ \/]([\w.]+)/i, R = /(webkit)[ \/]([\w.]+)/i, A = /* @__PURE__ */ f({ name: "KendoVueUploadInput", props: { async: Object, id: String, multiple: { type: Boolean, default: void 0 }, disabled: { type: Boolean, default: void 0 }, accept: { type: String, default: void 0 }, hasFiles: { type: Boolean, default: !1 }, ariaLabelledBy: { type: String, default: void 0 }, ariaDescribedBy: { type: String, default: void 0 } }, emits: { mousedown: null, add: null }, inject: { kendoLocalizationService: { default: null } }, mounted() { this._input = this.inputRef; }, methods: { onMouseDown(e) { this.$emit("mousedown", e); }, onAdd() { const e = navigator.userAgent, t = this._input; t && (t.files && this.$emit("add", t.files), !e.match(w) && e.match(R) || (t.type = "", t.type = "file")); }, actionElement() { return this._input; } }, setup() { return { inputRef: m(null) }; }, render() { const { multiple: e, async: t, disabled: l, accept: d, hasFiles: u, ariaLabelledBy: i, ariaDescribedBy: r } = this.$props, n = b(this), a = u ? g : S, c = n.toLanguageString(a, o[a]), p = n.toLanguageString(s, o[s]); return h("input", { ref: y(this, "input"), id: this.id, class: "k-hidden", autocomplete: "off", name: t.saveField, accept: d, type: "file", tabindex: -1, multiple: e, disabled: l, onChange: this.onAdd, onMousedown: this.onMouseDown, title: c, "aria-label": i !== void 0 ? void 0 : p, "aria-labelledby": i, "aria-describedby": r }, null); } }); export { A as UploadInput };