jadq-x-vue
Version:
Craft AI-driven interfaces effortlessly
2 lines (1 loc) • 3.18 kB
JavaScript
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),a=require("../../chunks/module-chunk.js"),R=require("../../_util/useTemplateRef.js"),c=require("ant-design-vue"),r=require("../../_util/hooks/use-state.js"),b=require("../context.js"),V=require("../SilentUploader.js"),k=require("./FileListCard.js");function E(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!l.isVNode(t)}const v=1,T=l.defineComponent({name:"AXAttachmentsFileList",__name:"FileList",props:{prefixCls:null,items:null,onRemove:{type:Function},overflow:null,upload:null,imageProps:null,listClassName:null,listStyle:null,itemClassName:null,itemStyle:null},setup(t){const i=l.computed(()=>`${t.prefixCls}-list`),u=R.useTemplateRef("file-list-container"),[$,d]=r.default(!1),p=b.useAttachmentContextInject();l.watchEffect(e=>{d(!0),e(()=>{d(!1)})});const[w,f]=r.default(!1),[x,m]=r.default(!1),h=()=>{const e=u.value;e&&(t.overflow==="scrollX"?(f(Math.abs(e.scrollLeft)>=v),m(e.scrollWidth-e.clientWidth-Math.abs(e.scrollLeft)>=v)):t.overflow==="scrollY"&&(f(e.scrollTop!==0),m(e.scrollHeight-e.clientHeight!==e.scrollTop)))};l.watch([()=>t.overflow,()=>t.items.length],()=>{l.nextTick(()=>{h()})},{immediate:!0});const g=e=>{const n=u.value;n&&n.scrollTo({left:n.scrollLeft+e*n.clientWidth,behavior:"smooth"})},y=()=>{g(-1)},N=()=>{g(1)},C=(e,n)=>{const s=e.classList.contains("ant-attachment-list-card-type-preview")?[{width:"0px"},{width:"64px"}]:[{width:"0px"},{width:"236px"}],o=e.animate(s,{duration:300,easing:"ease",fill:"forwards"});o.onfinish=()=>n()},S=(e,n)=>{const s=e.classList.contains("ant-attachment-list-card-type-preview")?[{opacity:1,width:"64px",marginRight:"0px"},{opacity:0,width:"0px",marginRight:"-10px"}]:[{opacity:1,width:"236px",marginRight:"0px"},{opacity:0,width:"0px",marginRight:"-10px",paddingRight:"0px",paddingLeft:"0px"}],o=e.animate(s,{duration:300,easing:"ease",fill:"forwards"});o.onfinish=()=>n()};return()=>{let e;return l.createVNode("div",{class:a.classnames(i.value,{[`${i.value}-overflow-${t.overflow}`]:t.overflow,[`${i.value}-overflow-ping-start`]:w.value,[`${i.value}-overflow-ping-end`]:x.value},t.listClassName),ref:"file-list-container",onScroll:h,style:t.listStyle},[l.createVNode(l.TransitionGroup,{onEnter:C,onLeave:S,css:!1},E(e=t.items.map(n=>l.createVNode(k.default,{key:n.uid,prefixCls:t.prefixCls,item:n,onRemove:t.onRemove,className:a.classnames(t.itemClassName),imageProps:t.imageProps,style:{...t.itemStyle}},null)))?e:{default:()=>[e]}),!p.value.disabled&&l.createVNode(V.default,{upload:t.upload,children:l.createVNode(c.Button,{class:`${i.value}-upload-btn`,type:"dashed"},{default:()=>[l.createVNode(a.PlusOutlined,{class:`${i.value}-upload-btn-icon`},null)]})},null),t.overflow==="scrollX"&&l.createVNode(l.Fragment,null,[l.createVNode(c.Button,{size:"small",shape:"circle",class:`${i.value}-prev-btn`,icon:l.createVNode(a.LeftOutlined,null,null),onClick:y},null),l.createVNode(c.Button,{size:"small",shape:"circle",class:`${i.value}-next-btn`,icon:l.createVNode(a.RightOutlined,null,null),onClick:N},null)])])}}});exports.default=T;