forstok-ui-lib 8.9.1 → 8.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4397,7 +4397,7 @@ function Q(e,t){if(!1===e||null==e)throw new Error(t)}function P(e,t){if(!e){"un
4397
4397
  width: 14px;
4398
4398
  ${eo}
4399
4399
  }
4400
- `,xo=r=>{var{children:n,mode:a}=r,o=O(r,["children","mode"]);const{id:l,width:d}=o;return"image"===a?t(i,{children:[n,e(ao,Object.assign({},"data-idx"in o&&{"data-idx":o["data-idx"]},o["data-detail"]&&{"data-detail":o["data-detail"]},o))]}):t(to,{$width:d,children:[t(io,{htmlFor:l,children:[e(no,{}),e(ro,{children:n})]}),e(ao,Object.assign({},"data-idx"in o&&{"data-idx":o["data-idx"]},o["data-detail"]&&{"data-detail":o["data-detail"]},o))]})},uo=r=>{var{children:n,id:a,name:d,evChange:s,evCreateMessage:c,label:p,subLabel:h,type:g,defaultValue:m,isValidFile:x=!0,evRemove:u}=r,v=O(r,["children","id","name","evChange","evCreateMessage","label","subLabel","type","defaultValue","isValidFile","evRemove"]);const{accept:w}=v,F=C(null),[f,y]=o(),[A,b]=o(!1),[D,E]=o({fileSrc:"",fileType:"",previewKind:"file",fileLabel:""}),B=e=>{e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?b(!0):"dragleave"===e.type&&b(!1)};l((()=>{let e="",t=!0;return(async()=>{let i={fileSrc:"",fileType:"",previewKind:"file",fileLabel:""};if(x){if(f&&f.length){const t=f[0],n=wi(t)||"document";if(i={fileSrc:t.name,fileType:n,previewKind:"file",fileLabel:t.name},"image"===n)e=URL.createObjectURL(t),i={fileSrc:e,fileType:n,previewKind:"image",fileLabel:t.name};else if("video"===n)try{i={fileSrc:await(r=t,new Promise(((t,i)=>{const n=document.createElement("video"),a=document.createElement("source"),o=URL.createObjectURL(r);a.src=o,a.type=r.type,e=o,n.appendChild(a),n.muted=!0,n.playsInline=!0,n.preload="metadata",n.onloadedmetadata=()=>{const e=document.createElement("canvas");e.width=n.videoWidth||720,e.height=n.videoHeight||122,n.currentTime=Math.min(.1,n.duration||0),n.onseeked=()=>{const r=e.getContext("2d");r?(r.drawImage(n,0,0,e.width,e.height),t(e.toDataURL("image/jpeg"))):i(new Error("Canvas context is not available"))}},n.onerror=()=>{i(new Error("Failed to load video"))},n.load()}))),fileType:n,previewKind:"image",fileLabel:t.name}}catch(e){i={fileSrc:t.name,fileType:n,previewKind:"file",fileLabel:t.name}}}else m&&(i={fileSrc:m,fileType:null!=g?g:"image",previewKind:"image"===(null!=g?g:"image")?"image":"file",fileLabel:m.split("/").pop()||m});var r;t&&E(i)}else t&&E(i)})(),()=>{t=!1,e&&URL.revokeObjectURL(e)}}),[m,x,g,f]);const{fileSrc:k,fileType:M,previewKind:z,fileLabel:L}=D;return t(oo,{onDragEnter:B,className:A?"drag-active":"",children:[e(ao,Object.assign({ref:F,id:a,name:d,onChange:e=>{e.preventDefault();const t=e.target;t.files&&t.files[0]&&(s&&s(t.files),y(t.files))}},v)),e(lo,{id:"label-file-dragdrop-upload",htmlFor:a,children:e(so,{children:k?t(co,{children:[t(po,{$backgroundSrc:"image"===z?k:void 0,children:[e("span",{className:"file-type",children:M||"document"}),e("span",{className:"file-name",children:L})]}),void 0!==u&&e("i",{className:"remove-button remove",onClick:e=>{e.preventDefault(),y(void 0),E({fileSrc:"",fileType:"",previewKind:"file",fileLabel:""}),F.current&&(F.current.value=""),null==u||u(e)},title:"Remove File",children:"X"})]}):n?t(go,{children:[e(mo,{}),e("span",{children:n})]}):t(ho,{children:[t("span",{children:[null!=p?p:"Drag & Drop file here to upload, or ",e("aside",{children:"browse"})]}),h&&t(i,{children:[e("br",{}),e("span",{className:"_refSubLabel",children:h})]})]})})}),A&&e(Co,{onDragEnter:B,onDragLeave:B,onDragOver:B,onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),b(!1),e.dataTransfer.files[0]){const t=w?w.split(",").map((e=>e.trim().replace(".",""))):null;for(let i=0;i<e.dataTransfer.files.length;i++){const r=e.dataTransfer.files[i].name.split(".").pop();if((null==t?void 0:t.length)&&r&&!t.includes(r)){const e=Vt("failed","File type is not allowed. Please check again");return c&&c(e),!1}}s&&s(e.dataTransfer.files)}}})]})};function vo({children:t,wrapperId:r="popup-portal"}){const[n,a]=o();return p((()=>{let e=document.getElementById(r),t=!1;return e||(t=!0,e=function(e){const t=document.createElement("div");return t.setAttribute("id",e),document.body.appendChild(t),t}(r)),a(e),()=>{t&&e&&e.parentNode&&e.parentNode.removeChild(e)}}),[r]),void 0===n?e(i,{}):E(t,n)}const wo=r.section`
4400
+ `,xo=r=>{var{children:n,mode:a}=r,o=O(r,["children","mode"]);const{id:l,width:d}=o;return"image"===a?t(i,{children:[n,e(ao,Object.assign({},"data-idx"in o&&{"data-idx":o["data-idx"]},o["data-detail"]&&{"data-detail":o["data-detail"]},o))]}):t(to,{$width:d,children:[t(io,{htmlFor:l,children:[e(no,{}),e(ro,{children:n})]}),e(ao,Object.assign({},"data-idx"in o&&{"data-idx":o["data-idx"]},o["data-detail"]&&{"data-detail":o["data-detail"]},o))]})},uo=r=>{var{children:n,id:a,name:d,evChange:s,evCreateMessage:c,label:p,subLabel:h,type:g,defaultValue:m,isValidFile:x=!0,evRemove:u}=r,v=O(r,["children","id","name","evChange","evCreateMessage","label","subLabel","type","defaultValue","isValidFile","evRemove"]);const{accept:w}=v,F=C(null),[f,y]=o(),[A,b]=o(!1),[D,E]=o({fileSrc:"",fileType:"",previewKind:"file",fileLabel:""}),B=e=>{e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?b(!0):"dragleave"===e.type&&b(!1)};l((()=>{let e="",t=!0;return(async()=>{let i={fileSrc:"",fileType:"",previewKind:"file",fileLabel:""};if(x){if(f&&f.length){const t=f[0],n=wi(t)||"document";if(i={fileSrc:t.name,fileType:n,previewKind:"file",fileLabel:t.name},"image"===n)e=URL.createObjectURL(t),i={fileSrc:e,fileType:n,previewKind:"image",fileLabel:t.name};else if("video"===n)try{i={fileSrc:await(r=t,new Promise(((t,i)=>{const n=document.createElement("video"),a=document.createElement("source"),o=URL.createObjectURL(r);a.src=o,a.type=r.type,e=o,n.appendChild(a),n.muted=!0,n.playsInline=!0,n.preload="metadata",n.onloadedmetadata=()=>{const e=document.createElement("canvas");e.width=n.videoWidth||720,e.height=n.videoHeight||122,n.currentTime=Math.min(.1,n.duration||0),n.onseeked=()=>{const r=e.getContext("2d");r?(r.drawImage(n,0,0,e.width,e.height),t(e.toDataURL("image/jpeg"))):i(new Error("Canvas context is not available"))}},n.onerror=()=>{i(new Error("Failed to load video"))},n.load()}))),fileType:n,previewKind:"image",fileLabel:t.name}}catch(e){i={fileSrc:t.name,fileType:n,previewKind:"file",fileLabel:t.name}}}else m&&(i={fileSrc:m,fileType:null!=g?g:"image",previewKind:"image"===(null!=g?g:"image")?"image":"file",fileLabel:m.split("/").pop()||m});var r;t&&E(i)}else t&&E(i)})(),()=>{t=!1,e&&URL.revokeObjectURL(e)}}),[m,x,g,f]);const{fileSrc:k,fileType:M,previewKind:z,fileLabel:L}=D;return t(oo,{onDragEnter:B,className:A?"drag-active":"",children:[e(ao,Object.assign({ref:F,id:a,name:d,onChange:e=>{e.preventDefault();const t=e.target;t.files&&t.files[0]&&(s&&s(t.files),y(t.files))}},v)),e(lo,{id:"label-file-dragdrop-upload",htmlFor:a,children:e(so,{children:k?t(co,{children:[t(po,{$backgroundSrc:"image"===z?k:void 0,children:[e("span",{className:"file-type",children:M||"document"}),e("span",{className:"file-name",children:L})]}),void 0!==u&&e("i",{className:"remove-button remove-button__active remove",onClick:e=>{e.preventDefault(),y(void 0),E({fileSrc:"",fileType:"",previewKind:"file",fileLabel:""}),F.current&&(F.current.value=""),null==u||u(e)},title:"Remove File",children:t("svg",{fill:"none",stroke:"#70757a",strokeWidth:"2",viewBox:"0 0 24 24",children:[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):n?t(go,{children:[e(mo,{}),e("span",{children:n})]}):t(ho,{children:[t("span",{children:[null!=p?p:"Drag & Drop file here to upload, or ",e("aside",{children:"browse"})]}),h&&t(i,{children:[e("br",{}),e("span",{className:"_refSubLabel",children:h})]})]})})}),A&&e(Co,{onDragEnter:B,onDragLeave:B,onDragOver:B,onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),b(!1),e.dataTransfer.files[0]){const t=w?w.split(",").map((e=>e.trim().replace(".",""))):null;for(let i=0;i<e.dataTransfer.files.length;i++){const r=e.dataTransfer.files[i].name.split(".").pop();if((null==t?void 0:t.length)&&r&&!t.includes(r)){const e=Vt("failed","File type is not allowed. Please check again");return c&&c(e),!1}}s&&s(e.dataTransfer.files)}}})]})};function vo({children:t,wrapperId:r="popup-portal"}){const[n,a]=o();return p((()=>{let e=document.getElementById(r),t=!1;return e||(t=!0,e=function(e){const t=document.createElement("div");return t.setAttribute("id",e),document.body.appendChild(t),t}(r)),a(e),()=>{t&&e&&e.parentNode&&e.parentNode.removeChild(e)}}),[r]),void 0===n?e(i,{}):E(t,n)}const wo=r.section`
4401
4401
  background-color: var(--pri-clr-bg);
4402
4402
  border: 1px solid var(--sec-clr-ln);
4403
4403
  position: fixed;