@progress/kendo-vue-upload
Version:
9 lines (8 loc) • 2.76 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),a=require("@progress/kendo-vue-common"),b=require("@progress/kendo-vue-intl"),d=require("./messages/main.js"),f=require("./UploadInput.js"),v=require("@progress/kendo-vue-buttons");function g(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const x=t.defineComponent({name:"KendoVueUploadAddButton",props:{addButtonIndex:Number,navigationIndex:Number,notFocusedIndex:Number,tabIndex:Number,async:Object,multiple:Boolean,disabled:Boolean,accept:String,id:String,ariaLabelledBy:String,ariaDescribedBy:String},inject:{kendoLocalizationService:{default:null}},emits:{add:null,click:null},setup(){const e=t.ref(null),n=t.ref(null),o=t.inject("kendoLocalizationService",{});return{elementRef:e,uploadInputRef:n,kendoLocalizationService:o}},created(){this.uploadInputId=a.guid()},mounted(){this.element=this.elementRef,this.uploadInput=this.uploadInputRef},watch:{navigationIndex:function(e,n){this._prevNavigationIndex=n}},updated(){const{navigationIndex:e,addButtonIndex:n,notFocusedIndex:o}=this.$props;e!==this._prevNavigationIndex&&this._prevNavigationIndex!==o&&e===n&&this.element&&this.element.focus()},methods:{focus(){this.element&&this.element.focus()},onClick(){this.actionElement()&&this.actionElement().click(),this.$emit("click",this.$props.addButtonIndex)},onAdd(e){this.$emit("add",e)},onInputMouseDown(e){this.element&&(e.preventDefault(),this.element.focus())},actionElement(){if(this.uploadInput)return this.uploadInput.actionElement()}},render(){const{navigationIndex:e,addButtonIndex:n,tabIndex:o,id:s,async:u,multiple:c,disabled:l,accept:r,ariaLabelledBy:p,ariaDescribedBy:m}=this.$props,i=b.provideLocalizationService(this).toLanguageString(d.select,d.messages[d.select]),h=a.classNames("k-upload-button",e===n?"k-focus":"");return t.createVNode("div",{class:"k-upload-button-wrap"},[t.createVNode(v.Button,{id:s,ref:a.setRef(this,"element"),role:"button",type:"button",disabled:l,ariaLabel:i,class:h,tabIndex:o,"aria-labelledby":p,"aria-describedby":m,onClick:this.onClick},g(i)?i:{default:()=>[i]}),t.createVNode(f.UploadInput,{id:this.uploadInputId,async:u,multiple:c,disabled:l,accept:r,onMousedown:this.onInputMouseDown,onAdd:this.onAdd,ref:I=>{this.uploadInputRef=I}},null)])}});exports.UploadAddButton=x;