handy-uploader 2.0.3 → 3.0.0
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/README.md +186 -300
- package/dist/components/handyUploader.vue.d.ts +3 -3
- package/dist/composables/deprecation.d.ts +2 -0
- package/dist/composables/useErrorHandler.d.ts +4 -0
- package/dist/composables/useFileUpload.d.ts +5 -0
- package/dist/core/attachments.d.ts +91 -0
- package/dist/core/fileUtils.d.ts +56 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/videoThumbnail.d.ts +32 -0
- package/dist/handy-uploader.cjs +1 -0
- package/dist/handy-uploader.css +1 -1
- package/dist/handy-uploader.mjs +1110 -0
- package/dist/language-CYpPw-mk.mjs +551 -0
- package/dist/language-fvWXvWRx.js +1 -0
- package/dist/lib/index.d.ts +8 -19
- package/dist/lib/language.d.ts +3 -0
- package/dist/lib/shared.d.ts +5 -0
- package/dist/lib/vuetify.d.ts +15 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/utils/fileUtils.d.ts +1 -56
- package/dist/vue/components/HandyDialog.vue.d.ts +31 -0
- package/dist/vue/components/HandyDropzone.vue.d.ts +38 -0
- package/dist/vue/components/HandyFileIcon.vue.d.ts +9 -0
- package/dist/vue/components/HandyFileList.vue.d.ts +65 -0
- package/dist/vue/components/HandyIcon.vue.d.ts +10 -0
- package/dist/vue/components/HandyUploader.vue.d.ts +137 -0
- package/dist/vue/index.d.ts +9 -0
- package/dist/vue/types.d.ts +5 -0
- package/dist/vue/useUploader.d.ts +46 -0
- package/dist/vuetify.cjs +1 -0
- package/dist/vuetify.mjs +1870 -0
- package/package.json +31 -7
- package/dist/handy-uploader.es.js +0 -2308
- package/dist/handy-uploader.umd.js +0 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { DocumentAttachment } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Framework-agnostic attachment pipeline: read selected files, then validate and
|
|
4
|
+
* prepare them for the attachment list. Nothing here touches Vue, Vuetify or i18n —
|
|
5
|
+
* errors come back as codes so each UI layer can render its own messages.
|
|
6
|
+
*/
|
|
7
|
+
export type AttachmentErrorCode = 'maxFileCount' | 'maxFileSize' | 'invalidFormat' | 'fileType';
|
|
8
|
+
export interface AttachmentError {
|
|
9
|
+
code: AttachmentErrorCode;
|
|
10
|
+
fileName?: string;
|
|
11
|
+
limit?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PrepareOptions {
|
|
14
|
+
/** Number of attachments already in the list. */
|
|
15
|
+
currentCount: number;
|
|
16
|
+
maxFileCount: number;
|
|
17
|
+
/** Maximum size per file, in bytes. */
|
|
18
|
+
maxFileSize: number;
|
|
19
|
+
imageCompressor?: boolean;
|
|
20
|
+
/** JPEG quality between 0 and 1. */
|
|
21
|
+
imageCompressLevel?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface PrepareResult {
|
|
24
|
+
accepted: DocumentAttachment[];
|
|
25
|
+
errors: AttachmentError[];
|
|
26
|
+
}
|
|
27
|
+
export type CompressFn = (dataUrl: string, quality: number) => Promise<string>;
|
|
28
|
+
/** Extensions that imageCompressor re-encodes as JPEG. */
|
|
29
|
+
export declare const COMPRESSIBLE_EXTENSIONS: string[];
|
|
30
|
+
/** Splits "my.report.pdf" into { name: "my.report", format: "pdf" }. */
|
|
31
|
+
export declare function splitFileName(fileName: string): {
|
|
32
|
+
name: string;
|
|
33
|
+
format: string;
|
|
34
|
+
};
|
|
35
|
+
/** Joins a base name and extension back together ("README" stays "README"). */
|
|
36
|
+
export declare function joinFileName(name: string, format: string): string;
|
|
37
|
+
/** Size in bytes of the data a base64 string decodes to. */
|
|
38
|
+
export declare function base64ByteLength(base64: string): number;
|
|
39
|
+
/**
|
|
40
|
+
* Checks a file against an `accept` string in the same format as the HTML attribute
|
|
41
|
+
* (".pdf,image/*,application/zip"). An empty string or "*" accepts everything.
|
|
42
|
+
*/
|
|
43
|
+
export declare function matchesAccept(file: {
|
|
44
|
+
name: string;
|
|
45
|
+
type?: string;
|
|
46
|
+
}, accept?: string): boolean;
|
|
47
|
+
/** Splits files into those matching `accept` and a `fileType` error for each other one. */
|
|
48
|
+
export declare function filterByAccept(files: File[], accept?: string): {
|
|
49
|
+
accepted: File[];
|
|
50
|
+
errors: AttachmentError[];
|
|
51
|
+
};
|
|
52
|
+
export interface PrecheckOptions {
|
|
53
|
+
currentCount: number;
|
|
54
|
+
maxFileCount: number;
|
|
55
|
+
/** Maximum size per file, in bytes. */
|
|
56
|
+
maxFileSize: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Applies the count and size limits using File metadata only, before any file is read,
|
|
60
|
+
* so oversized or surplus files never get loaded into memory.
|
|
61
|
+
*/
|
|
62
|
+
export declare function precheckFiles(files: File[], { currentCount, maxFileCount, maxFileSize }: PrecheckOptions): {
|
|
63
|
+
accepted: File[];
|
|
64
|
+
errors: AttachmentError[];
|
|
65
|
+
};
|
|
66
|
+
/** Formats a byte count as "12.3 KB" / "4.5 MB", with translatable unit labels. */
|
|
67
|
+
export declare function formatBytes(bytes: number, units?: {
|
|
68
|
+
kb: string;
|
|
69
|
+
mb: string;
|
|
70
|
+
}): string;
|
|
71
|
+
/** Reads a Blob as a data URL. */
|
|
72
|
+
export declare function readFileAsDataUrl(file: Blob): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Turns selected files into staged attachments (base name, extension as format, raw
|
|
75
|
+
* base64, size in bytes). Files that cannot be read are skipped.
|
|
76
|
+
*/
|
|
77
|
+
export declare function readFiles(files: File[]): Promise<DocumentAttachment[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Re-encodes an image data URL as JPEG at the given quality (0–1). Transparent areas
|
|
80
|
+
* are filled with white, since JPEG has no alpha channel. Browser only.
|
|
81
|
+
*/
|
|
82
|
+
export declare function compressDataUrl(dataUrl: string, quality: number): Promise<string>;
|
|
83
|
+
/**
|
|
84
|
+
* Validates staged attachments against the limits and converts them to the shape that
|
|
85
|
+
* is stored in the attachment list. Stops at the file-count limit; skips files that are
|
|
86
|
+
* too large or cannot be processed.
|
|
87
|
+
*
|
|
88
|
+
* With imageCompressor on, JPEG/PNG/WebP images are re-encoded as JPEG; the result is
|
|
89
|
+
* kept only if it is smaller, in which case the stored format becomes "jpg".
|
|
90
|
+
*/
|
|
91
|
+
export declare function prepareAttachments(staged: DocumentAttachment[], options: PrepareOptions, compress?: CompressFn): Promise<PrepareResult>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { FileSizeResult, FileIconProps, MimeType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Formats file size into human-readable format with appropriate color coding
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatFileSize(size: number): FileSizeResult;
|
|
6
|
+
/**
|
|
7
|
+
* Determines file type based on file extension or MIME type
|
|
8
|
+
*/
|
|
9
|
+
export declare function getFileType(fileName: string, mimeType?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Gets appropriate icon and color for file type (legacy function for backward compatibility)
|
|
12
|
+
*/
|
|
13
|
+
export declare function getFileIcon(fileName: string, mimeType?: string): FileIconProps;
|
|
14
|
+
/**
|
|
15
|
+
* Gets detailed icon and color for specific file extension
|
|
16
|
+
*/
|
|
17
|
+
export declare function getDetailedFileIcon(fileName: string): {
|
|
18
|
+
icon: string;
|
|
19
|
+
color: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Gets only the icon name for a file extension
|
|
23
|
+
*/
|
|
24
|
+
export declare function getFileIconName(fileName: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Gets only the color for a file extension
|
|
27
|
+
*/
|
|
28
|
+
export declare function getFileIconColor(fileName: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if file is an image type
|
|
31
|
+
*/
|
|
32
|
+
export declare function isImageFile(fileName: string, mimeType?: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Validates file size against maximum allowed size
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateFileSize(fileSize: number, maxSize: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Validates file count against maximum allowed count
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateFileCount(currentCount: number, maxCount: number): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Gets MIME type from file extension
|
|
43
|
+
*/
|
|
44
|
+
export declare function getMimeTypeFromExtension(fileName: string): MimeType;
|
|
45
|
+
/**
|
|
46
|
+
* Constructs proper data URL for base64 image data
|
|
47
|
+
*/
|
|
48
|
+
export declare function constructImageDataUrl(base64: string | undefined, format: string | undefined): string;
|
|
49
|
+
/**
|
|
50
|
+
* Compresses image using canvas
|
|
51
|
+
*/
|
|
52
|
+
export declare function compressImage(file: File, quality?: number, maxWidth?: number, maxHeight?: number): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Converts file to base64 string
|
|
55
|
+
*/
|
|
56
|
+
export declare function fileToBase64(file: File): Promise<string>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FileData } from '../types';
|
|
2
|
+
type VideoSource = Pick<FileData, 'name' | 'format' | 'base64'>;
|
|
3
|
+
/** Builds a playable data URL for a stored video attachment. */
|
|
4
|
+
export declare function getVideoDataUrl(file: VideoSource): string;
|
|
5
|
+
/**
|
|
6
|
+
* Captures a frame (at 1s or 10% of the duration, whichever is earlier) and returns
|
|
7
|
+
* it as a JPEG data URL. Browser only.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateVideoThumbnail(file: VideoSource): Promise<string>;
|
|
10
|
+
export interface VideoThumbnailCache {
|
|
11
|
+
/** Returns the cached thumbnail, or starts generating it and returns undefined. */
|
|
12
|
+
get(file: VideoSource): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Drops a cached thumbnail (e.g. its <img> failed to load) and notifies, so the UI
|
|
15
|
+
* re-renders and the next get() regenerates it. After one retry the file is given up on.
|
|
16
|
+
*/
|
|
17
|
+
invalidate(file: VideoSource): void;
|
|
18
|
+
/** Frees thumbnails of files that are no longer shown. */
|
|
19
|
+
retain(files: VideoSource[]): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Key from name, total length and the end of the data. The first bytes of a video are
|
|
23
|
+
* the container header, which is often identical across clips from the same device.
|
|
24
|
+
*/
|
|
25
|
+
export declare function videoThumbnailKey(file: VideoSource): string;
|
|
26
|
+
/**
|
|
27
|
+
* Caches generated thumbnails and de-duplicates in-flight work. `onUpdate` fires when a
|
|
28
|
+
* thumbnail becomes available or is invalidated, so a UI layer can re-render (bump a Vue
|
|
29
|
+
* ref, set React state, …). Failed generations are retried once, then given up on.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createVideoThumbnailCache(onUpdate: () => void, generate?: (file: VideoSource) => Promise<string>): VideoThumbnailCache;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),c=require("./language-fvWXvWRx.js"),j={maxFileSize:5*1024*1024,maxFileCount:10,accept:"",imageCompressor:!1,imageCompressLevel:.8};function W(t,C={}){const f=()=>({...j,...typeof C=="function"?C():e.unref(C)}),n=e.ref(!1),h=e.ref([]),b=e.computed(()=>t.value.length),p=e.computed(()=>b.value<f().maxFileCount);let E=Promise.resolve();function d(m){const u=E.then(async()=>{n.value=!0;try{return await m()}finally{n.value=!1}});return E=u.catch(()=>{}),u}const B=m=>typeof m=="function"?m():m;async function z(m,u){const v=f(),V=c.filterByAccept(m,v.accept),s=c.precheckFiles(V.accepted,{currentCount:t.value.length+B(u),maxFileCount:v.maxFileCount,maxFileSize:v.maxFileSize});return{staged:await c.readFiles(s.accepted),errors:[...V.errors,...s.errors]}}async function r(m){const u=f(),v=await c.prepareAttachments(m,{currentCount:t.value.length,maxFileCount:u.maxFileCount,maxFileSize:u.maxFileSize,imageCompressor:u.imageCompressor,imageCompressLevel:u.imageCompressLevel});return v.accepted.length>0&&(t.value=[...t.value,...v.accepted]),v}function w(m,u=0){const v=Array.from(m);return d(async()=>{const V=await z(v,u);return h.value=V.errors,V.staged})}function F(m){return d(async()=>{const u=await r(m);return h.value=u.errors,u.accepted})}function y(m){const u=Array.from(m);return d(async()=>{const v=await z(u,0),V=await r(v.staged);return h.value=[...v.errors,...V.errors],V.accepted})}function N(m){t.value=t.value.filter((u,v)=>v!==m)}function L(m,u){t.value=t.value.map((v,V)=>V===m?{file:{...v.file,...u}}:v)}function H(){t.value=[]}function T(){h.value=[]}return{isProcessing:n,errors:h,count:b,canAddMore:p,options:e.computed(f),add:y,stage:w,commit:F,remove:N,update:L,clear:H,dismissErrors:T}}const Z=["width","height"],ee=["d"],_=e.defineComponent({__name:"HandyIcon",props:{name:{},size:{default:20}},setup(t){const C={trash:"M9 3h6l1 1h4v2H4V4h4l1-1zM6 7h12l-1 13a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L6 7zm4 3v9h1.5v-9H10zm3.5 0v9H15v-9h-1.5z",pencil:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",chevron:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z",close:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z",play:"M8 5v14l11-7L8 5z",upload:"M5 20h14v-2H5v2zM12 4 6.5 9.5l1.42 1.42L11 7.83V16h2V7.83l3.08 3.09L17.5 9.5 12 4z",disk:"M6 2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm6 4a5 5 0 1 0 0 10 5 5 0 0 0 0-10zm0 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4zM7 18a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"};return(f,n)=>(e.openBlock(),e.createElementBlock("svg",{class:"hu-icon",viewBox:"0 0 24 24",width:t.size,height:t.size,fill:"currentColor","aria-hidden":"true",focusable:"false"},[e.createElementVNode("path",{d:C[t.name]},null,8,ee)],8,Z))}}),te={class:"hu-dialog__panel"},le={class:"hu-dialog__header"},ae=["aria-label"],oe={class:"hu-dialog__body"},ne={key:0,class:"hu-dialog__actions"},I=e.defineComponent({__name:"HandyDialog",props:{open:{type:Boolean},title:{default:""},closeLabel:{default:"Close"},size:{default:"medium"}},emits:["update:open"],setup(t,{emit:C}){const f=t,n=C,h=`hu-dialog-title-${Math.random().toString(36).slice(2,10)}`,b=e.ref(null);function p(d){const B=b.value;B&&(d&&!B.open?typeof B.showModal=="function"?B.showModal():B.setAttribute("open",""):!d&&B.open&&(typeof B.close=="function"?B.close():B.removeAttribute("open")))}function E(){n("update:open",!1)}return e.watch(()=>f.open,p),e.onMounted(()=>p(f.open)),(d,B)=>(e.openBlock(),e.createElementBlock("dialog",{ref_key:"el",ref:b,class:e.normalizeClass(["hu-dialog",`hu-dialog--${t.size}`]),"aria-labelledby":h,onCancel:e.withModifiers(E,["prevent"])},[e.createElementVNode("div",te,[e.createElementVNode("header",le,[e.createElementVNode("h2",{id:h,class:"hu-dialog__title"},e.toDisplayString(t.title),1),e.createElementVNode("button",{type:"button",class:"hu-icon-button","aria-label":t.closeLabel,onClick:E},[e.createVNode(_,{name:"close"})],8,ae)]),e.createElementVNode("div",oe,[e.renderSlot(d.$slots,"default")]),d.$slots.actions?(e.openBlock(),e.createElementBlock("footer",ne,[e.renderSlot(d.$slots,"actions")])):e.createCommentVNode("",!0)])],34))}}),ie=["accept","multiple","disabled"],se={class:"hu-dropzone__label"},ce={key:0,class:"hu-dropzone__hint"},P=e.defineComponent({__name:"HandyDropzone",props:{accept:{default:""},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},label:{default:"Choose files"},hint:{default:""}},emits:["files"],setup(t,{expose:C,emit:f}){const n=t,h=f,b=e.ref(null),p=e.ref(!1);let E=0;function d(){n.disabled||(E++,p.value=!0)}function B(){E=Math.max(0,E-1),E===0&&(p.value=!1)}function z(F){var N;if(E=0,p.value=!1,n.disabled)return;const y=Array.from(((N=F.dataTransfer)==null?void 0:N.files)??[]);y.length>0&&h("files",n.multiple?y:y.slice(0,1))}function r(F){const y=F.target,N=Array.from(y.files??[]);y.value="",N.length>0&&h("files",N)}function w(){var F;(F=b.value)==null||F.click()}return C({open:w}),(F,y)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["hu-dropzone",{"hu-dropzone--active":p.value,"hu-dropzone--disabled":t.disabled}]),onDragenter:e.withModifiers(d,["prevent"]),onDragover:y[0]||(y[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:e.withModifiers(B,["prevent"]),onDrop:e.withModifiers(z,["prevent"])},[e.createElementVNode("input",{ref_key:"input",ref:b,class:"hu-visually-hidden",type:"file",accept:t.accept||void 0,multiple:t.multiple,disabled:t.disabled,onChange:r},null,40,ie),e.renderSlot(F.$slots,"default",{isDragging:p.value},()=>[e.createElementVNode("span",se,e.toDisplayString(t.label),1),t.hint?(e.openBlock(),e.createElementBlock("span",ce,e.toDisplayString(t.hint),1)):e.createCommentVNode("",!0)])],34))}}),re=["data-hu-type","width","height","aria-label"],ue=["font-size"],M=e.defineComponent({__name:"HandyFileIcon",props:{fileName:{},size:{default:48}},setup(t){const C=t,f=e.computed(()=>c.getFileType(C.fileName)),n=e.computed(()=>c.splitFileName(C.fileName).format.slice(0,4).toUpperCase());return(h,b)=>(e.openBlock(),e.createElementBlock("svg",{class:"hu-file-icon","data-hu-type":f.value,viewBox:"0 0 40 48",width:t.size*40/48,height:t.size,role:"img","aria-label":n.value||"file"},[b[0]||(b[0]=e.createElementVNode("path",{d:"M4 0h22l14 14v30a4 4 0 0 1-4 4H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z",fill:"currentColor"},null,-1)),b[1]||(b[1]=e.createElementVNode("path",{d:"M26 0v10a4 4 0 0 0 4 4h10z",fill:"#fff","fill-opacity":"0.45"},null,-1)),e.createElementVNode("text",{x:"20",y:"37","text-anchor":"middle","font-family":"system-ui, sans-serif","font-weight":"700","font-size":n.value.length>3?8.5:10,fill:"#fff"},e.toDisplayString(n.value),9,ue)],8,re))}}),de={key:0},me={class:"hu-table"},fe={key:0,class:"hu-table__thumb",scope:"col"},pe={scope:"col"},he={scope:"col",class:"hu-table__size"},ve={key:1,scope:"col",class:"hu-table__actions"},ge={key:0,class:"hu-table__thumb"},be={class:"hu-thumb hu-thumb--small"},ye=["src","onError"],ke=["title"],Be={class:"hu-table__size"},Ce=["data-hu-size"],Ee={key:1},Ne={class:"hu-actions"},Ve=["aria-label","title","onClick"],Fe=["aria-label","title","onClick"],$e={key:0,class:"hu-card__media"},De=["src","onError"],ze={key:2,class:"hu-play","aria-hidden":"true"},Se={class:"hu-card__content"},_e={class:"hu-card__info"},we=["title"],Te={class:"hu-chip"},xe={key:0,class:"hu-thumb"},Ae=["src","onError"],Le={key:1,class:"hu-card__actions"},Me=["aria-label","title","onClick"],He=["aria-label","title","onClick"],Ue=["aria-expanded","aria-label","onClick"],Ie={key:2,class:"hu-card__details"},Oe=["aria-label"],Pe={key:1,class:"hu-description"},R=e.defineComponent({__name:"HandyFileList",props:{files:{},t:{},view:{default:"thumbnail"},thumb:{type:Boolean,default:!0},cols:{default:3},cardType:{default:"default"},editable:{type:Boolean,default:!0},removable:{type:Boolean,default:!0},tableThumbColumn:{type:Boolean,default:!0},tableFixedHeader:{type:Boolean,default:!0},tableHeight:{default:400}},emits:["remove","edit"],setup(t,{emit:C}){const f=t,n=C,h=e.useSlots(),b=e.computed(()=>f.removable||f.editable||!!h.actions),p=e.computed(()=>Math.max(1,Math.round(12/Math.min(12,Math.max(1,f.cols))))),E=e.ref(0),d=c.createVideoThumbnailCache(()=>E.value++),B=new WeakMap,z=s=>c.getFileType(s.file.name),r=e.ref(new WeakSet);function w(s){if(z(s)==="video"){d.invalidate(s.file);return}const g=new WeakSet([s.file]);for(const a of f.files)r.value.has(a.file)&&g.add(a.file);r.value=g}function F(s){if(!f.thumb||!s.file.base64||r.value.has(s.file))return;const g=z(s);if(g==="image"){let a=B.get(s.file);return a||(a=c.constructImageDataUrl(s.file.base64,s.file.format),B.set(s.file,a)),a}if(g==="video")return d.get(s.file)}const y=e.computed(()=>(E.value,f.files.map(F)));e.watch(()=>f.files,s=>d.retain(s.map(g=>g.file)));const N=e.ref(new WeakSet),L=s=>N.value.has(s.file);function H(s){const g=new WeakSet;for(const a of f.files)a.file!==s.file&&N.value.has(a.file)&&g.add(a.file);N.value.has(s.file)||g.add(s.file),N.value=g}const T=s=>{var g;return(((g=s.file.tags)==null?void 0:g.length)??0)>0||!!s.file.description},m=s=>Number(s.file.size)||0,u=s=>c.formatBytes(m(s),f.t.size);function v(s){const g=m(s)/1048576;return g<1?"small":g<5?"medium":"large"}const V=(s,g)=>`${g}-${s.file.name}-${s.file.size}`;return(s,g)=>t.files.length===0?(e.openBlock(),e.createElementBlock("div",de,[e.renderSlot(s.$slots,"empty")])):t.view==="table"?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["hu-table-wrap",{"hu-table-wrap--fixed":t.tableFixedHeader}]),style:e.normalizeStyle(t.tableFixedHeader?{maxHeight:`${t.tableHeight}px`}:void 0)},[e.createElementVNode("table",me,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[t.tableThumbColumn?(e.openBlock(),e.createElementBlock("th",fe,e.toDisplayString(t.t.table.thumb),1)):e.createCommentVNode("",!0),e.createElementVNode("th",pe,e.toDisplayString(t.t.table.name),1),e.createElementVNode("th",he,e.toDisplayString(t.t.table.size),1),b.value?(e.openBlock(),e.createElementBlock("th",ve,e.toDisplayString(t.t.table.action.action),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.files,(a,k)=>(e.openBlock(),e.createElementBlock("tr",{key:V(a,k)},[t.tableThumbColumn?(e.openBlock(),e.createElementBlock("td",ge,[e.createElementVNode("span",be,[y.value[k]?(e.openBlock(),e.createElementBlock("img",{key:0,src:y.value[k],alt:"",onError:S=>w(a)},null,40,ye)):(e.openBlock(),e.createBlock(M,{key:1,"file-name":a.file.name,size:36},null,8,["file-name"]))])])):e.createCommentVNode("",!0),e.createElementVNode("td",{class:"hu-file__name",title:a.file.name},e.toDisplayString(a.file.name),9,ke),e.createElementVNode("td",Be,[e.createElementVNode("span",{class:"hu-chip","data-hu-size":v(a)},e.toDisplayString(u(a)),9,Ce)]),b.value?(e.openBlock(),e.createElementBlock("td",Ee,[e.createElementVNode("div",Ne,[e.renderSlot(s.$slots,"actions",{attachment:a,index:k}),t.editable?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"hu-icon-button hu-icon-button--edit","aria-label":`${t.t.edit} ${a.file.name}`,title:t.t.edit,onClick:S=>n("edit",k)},[e.createVNode(_,{name:"pencil",size:18})],8,Ve)):e.createCommentVNode("",!0),t.removable?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"hu-icon-button hu-icon-button--danger","aria-label":`${t.t.delete} ${a.file.name}`,title:t.t.table.action.deleteTooltip,onClick:S=>n("remove",k)},[e.createVNode(_,{name:"trash",size:18})],8,Fe)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)]))),128))])])],6)):(e.openBlock(),e.createElementBlock("ul",{key:2,class:e.normalizeClass(["hu-files",`hu-files--${t.view}`]),style:e.normalizeStyle(t.view==="thumbnail"?{"--hu-columns":p.value}:void 0)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.files,(a,k)=>(e.openBlock(),e.createElementBlock("li",{key:V(a,k),class:e.normalizeClass(["hu-card",[`hu-card--${t.cardType}`,`hu-card--${t.view}`]])},[e.renderSlot(s.$slots,"item",{attachment:a,index:k,remove:()=>n("remove",k)},()=>{var S;return[t.view==="thumbnail"?(e.openBlock(),e.createElementBlock("div",$e,[y.value[k]?(e.openBlock(),e.createElementBlock("img",{key:0,src:y.value[k],alt:"",class:e.normalizeClass(z(a)==="video"?"hu-media--cover":"hu-media--contain"),onError:$=>w(a)},null,42,De)):(e.openBlock(),e.createBlock(M,{key:1,"file-name":a.file.name,size:96},null,8,["file-name"])),z(a)==="video"?(e.openBlock(),e.createElementBlock("span",ze,[e.createVNode(_,{name:"play",size:28})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",Se,[e.createElementVNode("div",_e,[e.createElementVNode("span",{class:"hu-file__name",title:a.file.name},e.toDisplayString(a.file.name),9,we),e.createElementVNode("span",Te,[t.view==="simple"?(e.openBlock(),e.createBlock(_,{key:0,name:"disk",size:14})):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(u(a)),1)])]),t.view==="simple"?(e.openBlock(),e.createElementBlock("span",xe,[y.value[k]?(e.openBlock(),e.createElementBlock("img",{key:0,src:y.value[k],alt:"",onError:$=>w(a)},null,40,Ae)):(e.openBlock(),e.createBlock(M,{key:1,"file-name":a.file.name,size:60},null,8,["file-name"]))])):e.createCommentVNode("",!0)]),b.value||T(a)?(e.openBlock(),e.createElementBlock("div",Le,[e.renderSlot(s.$slots,"actions",{attachment:a,index:k}),t.removable?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"hu-icon-button hu-icon-button--danger","aria-label":`${t.t.delete} ${a.file.name}`,title:t.t.delete,onClick:$=>n("remove",k)},[e.createVNode(_,{name:"trash"})],8,Me)):e.createCommentVNode("",!0),t.editable?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"hu-icon-button hu-icon-button--edit","aria-label":`${t.t.edit} ${a.file.name}`,title:t.t.edit,onClick:$=>n("edit",k)},[e.createVNode(_,{name:"pencil"})],8,He)):e.createCommentVNode("",!0),T(a)?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"hu-icon-button hu-details-toggle","aria-expanded":L(a),"aria-label":`${t.t.fileDescription} / ${t.t.fileTags}`,onClick:$=>H(a)},[e.createVNode(_,{name:"chevron"})],8,Ue)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),L(a)?(e.openBlock(),e.createElementBlock("div",Ie,[(S=a.file.tags)!=null&&S.length?(e.openBlock(),e.createElementBlock("ul",{key:0,class:"hu-tags","aria-label":t.t.fileTags},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.file.tags??[],$=>(e.openBlock(),e.createElementBlock("li",{key:$,class:"hu-tag"},e.toDisplayString($),1))),128))],8,Oe)):e.createCommentVNode("",!0),a.file.description?(e.openBlock(),e.createElementBlock("p",Pe,e.toDisplayString(a.file.description),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]})],2))),128))],6))}}),Re=["dir"],je={key:0,class:"hu-toolbar"},We={class:"hu-badge-wrap"},qe=["disabled"],Xe=["data-hu-full","aria-label"],Ye={key:1,class:"hu-alert",role:"alert"},Ge=["aria-label"],Je={key:0,class:"hu-status",role:"status"},Ke={key:1,class:"hu-alert hu-alert--inline",role:"alert"},Qe={key:2,class:"hu-staged"},Ze={class:"hu-staged__fields"},et={key:0,class:"hu-field"},tt={class:"hu-field__label"},lt={class:"hu-field__row"},at=["onUpdate:modelValue"],ot={key:0,class:"hu-field__suffix"},nt={key:1,class:"hu-file__name"},it={key:2,class:"hu-field"},st={class:"hu-field__label"},ct=["value","onInput"],rt={key:3,class:"hu-field"},ut={class:"hu-field__label"},dt={class:"hu-tag-picker"},mt=["onUpdate:modelValue","value"],ft=["aria-label","onClick"],pt=["disabled"],ht={key:0,class:"hu-edit"},vt={class:"hu-staged__fields"},gt={key:0,class:"hu-field"},bt={class:"hu-field__label"},yt={key:1,class:"hu-field"},kt={class:"hu-field__label"},Bt={key:2,class:"hu-field"},Ct={class:"hu-field__label"},Et={class:"hu-tag-picker"},Nt=["value"],Vt={class:"hu-dialog__message"},q=e.defineComponent({__name:"HandyUploader",props:{documentAttachment:{default:()=>[]},lang:{default:"en"},maxFileSize:{default:5242880},fileUploaderType:{default:"thumbnail"},maxFileCount:{default:10},badgeCounter:{type:Boolean,default:!0},btnColor:{default:"info"},imageCompressor:{type:Boolean,default:!1},imageCompressLevel:{default:.8},fileAccept:{default:""},thumb:{type:Boolean,default:!0},tableThumbColumn:{type:Boolean,default:!0},tableFixedHeader:{type:Boolean,default:!0},tableHeight:{default:400},rtlSupport:{type:Boolean,default:!1},changeFileName:{type:Boolean,default:!1},addFileDescription:{type:Boolean,default:!1},addFileTag:{type:Boolean,default:!1},tags:{default:()=>[]},customLang:{default:null},insertPermission:{type:Boolean,default:!0},cols:{default:3},editPermission:{type:Boolean,default:!0},deletePermission:{type:Boolean,default:!0},cardType:{default:"default"}},emits:["updateDocumentAttachment","update:documentAttachment","add","remove","error","updateCardType","updateBadgeCounter","updateMaxFileCount","updateMaxFileSize","updateImageCompressor","updateImageCompressLevel","updateFileAccept","updateThumb","updateChangeFileName","updateAddFileDescription","updateAddFileTag","updateTableThumbColumn","updateTableFixedHeader","updateTableHeight","updateLang"],setup(t,{expose:C,emit:f}){const n=t,h=f,b=e.ref(0),p=e.computed(()=>(b.value,[...n.documentAttachment]));e.watch(()=>n.documentAttachment,()=>b.value++,{deep:!1});const E=e.computed({get:()=>p.value,set:i=>{const l=n.documentAttachment;if(Object.isFrozen(l)||e.isReadonly(l)){h("updateDocumentAttachment",i),h("update:documentAttachment",i);return}l.splice(0,l.length,...i),b.value++,h("updateDocumentAttachment",l),h("update:documentAttachment",l)}}),d=W(E,()=>({maxFileSize:n.maxFileSize,maxFileCount:n.maxFileCount,accept:n.fileAccept,imageCompressor:n.imageCompressor,imageCompressLevel:n.imageCompressLevel})),B={cardType:"updateCardType",badgeCounter:"updateBadgeCounter",maxFileCount:"updateMaxFileCount",maxFileSize:"updateMaxFileSize",imageCompressor:"updateImageCompressor",imageCompressLevel:"updateImageCompressLevel",fileAccept:"updateFileAccept",thumb:"updateThumb",changeFileName:"updateChangeFileName",addFileDescription:"updateAddFileDescription",addFileTag:"updateAddFileTag",tableThumbColumn:"updateTableThumbColumn",tableFixedHeader:"updateTableFixedHeader",tableHeight:"updateTableHeight",lang:"updateLang"};for(const[i,l]of Object.entries(B))e.watch(()=>n[i],o=>h(l,o));const z={fileTypeAlert:"File type is not allowed",invalidFileAlert:"File could not be processed",dropHint:"or drag and drop here"},r=e.computed(()=>{const i=n.customLang??c.languages;return{...z,...c.languages.en,...i[n.lang]}}),w=e.computed(()=>n.rtlSupport||n.lang==="fa"||n.lang==="ar"),F=e.computed(()=>{const i=`${p.value.length+u.value.length}/${n.maxFileCount}`,l=c.formatBytes(n.maxFileSize,r.value.size);return`${r.value.dropHint} · ${i} · ≤ ${l}`}),y={primary:"#1976d2",secondary:"#424242",accent:"#82b1ff",error:"#ff5252",info:"#2196f3",success:"#4caf50",warning:"#fb8c00"},N=e.computed(()=>{const i=y[n.btnColor]??n.btnColor;return i?{"--hu-button-bg":i}:void 0}),L=e.computed(()=>n.changeFileName||n.addFileDescription||n.addFileTag&&n.tags.length>0);function H(i){const l=i.fileName?`${i.fileName}: `:"";switch(i.code){case"maxFileCount":return`${r.value.maxFileCountAlert} ${i.limit}`;case"maxFileSize":return`${l}${r.value.maxFileSizeAlert} ${c.formatBytes(i.limit??0,r.value.size)}`;case"fileType":return`${l}${r.value.fileTypeAlert}`;default:return`${l}${r.value.invalidFileAlert}`}}const T=e.computed(()=>d.errors.value.map(H));e.watch(d.errors,i=>{i.length>0&&h("error",i)});const m=e.ref(!1),u=e.ref([]);let v=0;function V(){v++,u.value=[],d.dismissErrors(),m.value=!0}async function s(i){const l=v,o=await d.stage(i,()=>u.value.length);l===v&&m.value&&u.value.push(...o)}async function g(){const i=await d.commit(u.value);i.length>0&&h("add",i),u.value=[],m.value=!1}async function a(i){const l=await d.add(i);return l.length>0&&h("add",l),l}function k(i){const l=p.value[i];l&&(d.remove(i),h("remove",l,i))}e.watch(m,i=>{i||(v++,u.value=[])});const S=e.ref(!1),$=e.ref(null),D=e.reactive({name:"",description:"",tags:[]});function Y(i){var o;const l=(o=p.value[i])==null?void 0:o.file;l&&($.value=i,D.name=l.name,D.description=l.description??"",D.tags=[...l.tags??[]],S.value=!0)}function G(){$.value!==null&&d.update($.value,{...n.changeFileName?{name:D.name}:{},...n.addFileDescription?{description:D.description}:{},...n.addFileTag?{tags:[...D.tags]}:{}}),S.value=!1}const U=e.ref(!1),O=e.ref(null);function J(i){O.value=i,U.value=!0}function K(){O.value!==null&&k(O.value),U.value=!1}return C({add:a,remove:k,update:d.update,clear:d.clear,openInsert:V}),(i,l)=>(e.openBlock(),e.createElementBlock("div",{class:"hu-uploader",dir:w.value?"rtl":void 0},[t.insertPermission?(e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("span",We,[e.createElementVNode("button",{type:"button",class:"hu-button hu-button--primary",style:e.normalizeStyle(N.value),disabled:!e.unref(d).canAddMore.value,onClick:V},[e.createVNode(_,{name:"upload",size:18}),e.createTextVNode(" "+e.toDisplayString(r.value.insertFile),1)],12,qe),t.badgeCounter&&p.value.length>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"hu-count","data-hu-full":p.value.length>=t.maxFileCount,"aria-label":`${p.value.length} / ${t.maxFileCount}`},e.toDisplayString(p.value.length),9,Xe)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),T.value.length>0&&!m.value?(e.openBlock(),e.createElementBlock("div",Ye,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,(o,x)=>(e.openBlock(),e.createElementBlock("li",{key:x},e.toDisplayString(o),1))),128))]),e.createElementVNode("button",{type:"button",class:"hu-icon-button","aria-label":r.value.deleteDialog.cancel,onClick:l[0]||(l[0]=(...o)=>e.unref(d).dismissErrors&&e.unref(d).dismissErrors(...o))},[e.createVNode(_,{name:"close",size:16})],8,Ge)])):e.createCommentVNode("",!0),e.createVNode(R,{files:p.value,t:r.value,view:t.fileUploaderType,thumb:t.thumb,cols:t.cols,"card-type":t.cardType,editable:t.editPermission&&L.value,removable:t.deletePermission,"table-thumb-column":t.tableThumbColumn,"table-fixed-header":t.tableFixedHeader,"table-height":t.tableHeight,onRemove:J,onEdit:Y},e.createSlots({empty:e.withCtx(()=>[e.renderSlot(i.$slots,"empty")]),_:2},[i.$slots.item?{name:"item",fn:e.withCtx(o=>[e.renderSlot(i.$slots,"item",e.normalizeProps(e.guardReactiveProps(o)))]),key:"0"}:void 0,i.$slots.actions?{name:"actions",fn:e.withCtx(o=>[e.renderSlot(i.$slots,"actions",e.normalizeProps(e.guardReactiveProps(o)))]),key:"1"}:void 0]),1032,["files","t","view","thumb","cols","card-type","editable","removable","table-thumb-column","table-fixed-header","table-height"]),e.createVNode(I,{open:m.value,"onUpdate:open":l[2]||(l[2]=o=>m.value=o),title:r.value.insertNewFile,"close-label":r.value.deleteDialog.cancel},{actions:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"hu-button",onClick:l[1]||(l[1]=o=>m.value=!1)},e.toDisplayString(r.value.deleteDialog.cancel),1),e.createElementVNode("button",{type:"button",class:"hu-button hu-button--primary",style:e.normalizeStyle(N.value),disabled:u.value.length===0||e.unref(d).isProcessing.value,onClick:g},e.toDisplayString(r.value.add),13,pt)]),default:e.withCtx(()=>[e.createVNode(P,{accept:t.fileAccept,disabled:u.value.length+p.value.length>=t.maxFileCount,label:r.value.insertFile,hint:F.value,onFiles:s},null,8,["accept","disabled","label","hint"]),e.unref(d).isProcessing.value?(e.openBlock(),e.createElementBlock("p",Je,"…")):e.createCommentVNode("",!0),T.value.length>0?(e.openBlock(),e.createElementBlock("ul",Ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,(o,x)=>(e.openBlock(),e.createElementBlock("li",{key:x},e.toDisplayString(o),1))),128))])):e.createCommentVNode("",!0),u.value.length>0?(e.openBlock(),e.createElementBlock("ul",Qe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,(o,x)=>(e.openBlock(),e.createElementBlock("li",{key:x,class:"hu-staged__item"},[e.createVNode(M,{"file-name":e.unref(c.joinFileName)(o.file.name,o.file.format),size:40},null,8,["file-name"]),e.createElementVNode("div",Ze,[t.changeFileName?(e.openBlock(),e.createElementBlock("label",et,[e.createElementVNode("span",tt,e.toDisplayString(r.value.fileName),1),e.createElementVNode("span",lt,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A=>o.file.name=A,class:"hu-input",type:"text"},null,8,at),[[e.vModelText,o.file.name]]),o.file.format?(e.openBlock(),e.createElementBlock("span",ot,"."+e.toDisplayString(o.file.format),1)):e.createCommentVNode("",!0)])])):(e.openBlock(),e.createElementBlock("span",nt,e.toDisplayString(e.unref(c.joinFileName)(o.file.name,o.file.format)),1)),t.addFileDescription?(e.openBlock(),e.createElementBlock("label",it,[e.createElementVNode("span",st,e.toDisplayString(r.value.fileDescription),1),e.createElementVNode("textarea",{class:"hu-input",rows:"2",value:o.file.description??"",onInput:A=>o.file.description=A.target.value},null,40,ct)])):e.createCommentVNode("",!0),t.addFileTag&&t.tags.length?(e.openBlock(),e.createElementBlock("fieldset",rt,[e.createElementVNode("legend",ut,e.toDisplayString(r.value.fileTags),1),e.createElementVNode("span",dt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.tags,A=>(e.openBlock(),e.createElementBlock("label",{key:A,class:"hu-tag hu-tag--selectable"},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":Q=>o.file.tags=Q,type:"checkbox",value:A},null,8,mt),[[e.vModelCheckbox,o.file.tags]]),e.createTextVNode(" "+e.toDisplayString(A),1)]))),128))])])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"hu-icon-button","aria-label":`${r.value.delete} ${e.unref(c.joinFileName)(o.file.name,o.file.format)}`,onClick:A=>u.value.splice(x,1)},[e.createVNode(_,{name:"close",size:18})],8,ft)]))),128))])):e.createCommentVNode("",!0)]),_:1},8,["open","title","close-label"]),e.createVNode(I,{open:S.value,"onUpdate:open":l[7]||(l[7]=o=>S.value=o),title:r.value.edit,"close-label":r.value.deleteDialog.cancel},{actions:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"hu-button",onClick:l[6]||(l[6]=o=>S.value=!1)},e.toDisplayString(r.value.deleteDialog.cancel),1),e.createElementVNode("button",{type:"button",class:"hu-button hu-button--primary",style:e.normalizeStyle(N.value),onClick:G},e.toDisplayString(r.value.edit),5)]),default:e.withCtx(()=>[$.value!==null&&p.value[$.value]?(e.openBlock(),e.createElementBlock("div",ht,[e.createElementVNode("div",vt,[t.changeFileName?(e.openBlock(),e.createElementBlock("label",gt,[e.createElementVNode("span",bt,e.toDisplayString(r.value.fileName),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":l[3]||(l[3]=o=>D.name=o),class:"hu-input",type:"text"},null,512),[[e.vModelText,D.name]])])):e.createCommentVNode("",!0),t.addFileDescription?(e.openBlock(),e.createElementBlock("label",yt,[e.createElementVNode("span",kt,e.toDisplayString(r.value.fileDescription),1),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":l[4]||(l[4]=o=>D.description=o),class:"hu-input",rows:"3"},null,512),[[e.vModelText,D.description]])])):e.createCommentVNode("",!0),t.addFileTag&&t.tags.length?(e.openBlock(),e.createElementBlock("fieldset",Bt,[e.createElementVNode("legend",Ct,e.toDisplayString(r.value.fileTags),1),e.createElementVNode("span",Et,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.tags,o=>(e.openBlock(),e.createElementBlock("label",{key:o,class:"hu-tag hu-tag--selectable"},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":l[5]||(l[5]=x=>D.tags=x),type:"checkbox",value:o},null,8,Nt),[[e.vModelCheckbox,D.tags]]),e.createTextVNode(" "+e.toDisplayString(o),1)]))),128))])])):e.createCommentVNode("",!0)]),e.createVNode(M,{"file-name":p.value[$.value].file.name,size:60},null,8,["file-name"])])):e.createCommentVNode("",!0)]),_:1},8,["open","title","close-label"]),e.createVNode(I,{open:U.value,"onUpdate:open":l[9]||(l[9]=o=>U.value=o),title:r.value.delete,"close-label":r.value.deleteDialog.cancel,size:"small"},{actions:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"hu-button",onClick:l[8]||(l[8]=o=>U.value=!1)},e.toDisplayString(r.value.deleteDialog.cancel),1),e.createElementVNode("button",{type:"button",class:"hu-button hu-button--danger-solid",onClick:K},e.toDisplayString(r.value.delete),1)]),default:e.withCtx(()=>[e.createElementVNode("p",Vt,e.toDisplayString(r.value.deleteDialog.message),1)]),_:1},8,["open","title","close-label"])],8,Re))}}),X={HandyUploader:q,HandyDropzone:P,HandyFileList:R};function Ft(t){for(const[C,f]of Object.entries(X))t.component(C,f)}exports.COMPRESSIBLE_EXTENSIONS=c.COMPRESSIBLE_EXTENSIONS;exports.base64ByteLength=c.base64ByteLength;exports.compressDataUrl=c.compressDataUrl;exports.compressImage=c.compressImage;exports.constructImageDataUrl=c.constructImageDataUrl;exports.createVideoThumbnailCache=c.createVideoThumbnailCache;exports.fileToBase64=c.fileToBase64;exports.filterByAccept=c.filterByAccept;exports.formatBytes=c.formatBytes;exports.formatFileSize=c.formatFileSize;exports.generateVideoThumbnail=c.generateVideoThumbnail;exports.getFileIcon=c.getFileIcon;exports.getFileType=c.getFileType;exports.getMimeTypeFromExtension=c.getMimeTypeFromExtension;exports.getVideoDataUrl=c.getVideoDataUrl;exports.isImageFile=c.isImageFile;exports.joinFileName=c.joinFileName;exports.languageData=c.languages;exports.matchesAccept=c.matchesAccept;exports.precheckFiles=c.precheckFiles;exports.prepareAttachments=c.prepareAttachments;exports.readFileAsDataUrl=c.readFileAsDataUrl;exports.readFiles=c.readFiles;exports.splitFileName=c.splitFileName;exports.validateFileCount=c.validateFileCount;exports.validateFileSize=c.validateFileSize;exports.DEFAULT_UPLOADER_OPTIONS=j;exports.HandyDialog=I;exports.HandyDropzone=P;exports.HandyFileIcon=M;exports.HandyFileList=R;exports.HandyUploader=q;exports.default=X;exports.install=Ft;exports.useUploader=W;
|
package/dist/handy-uploader.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.table-row[data-v-d05b814b]:hover{background-color:#0000000a}.v-table[data-v-d05b814b]{border-radius:8px}.v-table th[data-v-d05b814b]{font-weight:600;background-color:#00000005}.file-card[data-v-f7000da4]{transition:all .3s ease;border-radius:12px!important;overflow:hidden;display:flex;flex-direction:column}.file-card[data-v-f7000da4]:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0000001a!important}.thumbnail-container[data-v-f7000da4]{border-radius:8px;overflow:hidden;box-shadow:0 2px 8px #0000001a}.v-card-title[data-v-f7000da4]{word-break:break-word;display:flex;align-items:center;justify-content:center}.v-chip[data-v-f7000da4]{font-weight:500}.v-btn[data-v-f7000da4]{transition:all .2s ease}.v-btn[data-v-f7000da4]:hover{transform:scale(1.1)}
|
|
1
|
+
.hu-uploader{--hu-font: inherit;--hu-text: #1f2328;--hu-muted: #656d76;--hu-surface: #ffffff;--hu-surface-alt: #f5f5f5;--hu-border: #d0d7de;--hu-primary: #2196f3;--hu-primary-soft: #e3f2fd;--hu-button-bg: var(--hu-primary);--hu-button-text: #ffffff;--hu-danger: #e53935;--hu-danger-soft: #ffebee;--hu-success: #43a047;--hu-warning: #fb8c00;--hu-chip: #009688;--hu-radius: 12px;--hu-gap: 16px;--hu-media-height: 200px;--hu-shadow: 0 2px 4px rgb(0 0 0 / .08), 0 1px 10px rgb(0 0 0 / .06);--hu-shadow-raised: 0 8px 24px rgb(0 0 0 / .16);--hu-focus-ring: 0 0 0 3px color-mix(in srgb, var(--hu-primary) 40%, transparent);display:flex;flex-direction:column;gap:var(--hu-gap);font-family:var(--hu-font);color:var(--hu-text)}.hu-dark .hu-uploader,.hu-uploader.hu-dark{--hu-text: #e6edf3;--hu-muted: #8d96a0;--hu-surface: #161b22;--hu-surface-alt: #0d1117;--hu-border: #30363d;--hu-primary: #4493f8;--hu-primary-soft: #121d2f;--hu-danger: #f85149;--hu-danger-soft: #25171c;--hu-shadow: 0 0 0 1px #30363d;--hu-shadow-raised: 0 8px 24px rgb(0 0 0 / .5)}.hu-visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.hu-icon{flex:none}.hu-button{display:inline-flex;align-items:center;gap:6px;padding:8px 16px;border:1px solid var(--hu-border);border-radius:6px;background:var(--hu-surface);color:var(--hu-text);font:inherit;font-size:.875rem;font-weight:500;letter-spacing:.02em;cursor:pointer}.hu-button:disabled{opacity:.5;cursor:not-allowed}.hu-button:focus-visible,.hu-icon-button:focus-visible,.hu-input:focus-visible{outline:none;box-shadow:var(--hu-focus-ring)}.hu-button--primary{border-color:transparent;background:var(--hu-button-bg);color:var(--hu-button-text);text-transform:uppercase;box-shadow:0 2px 4px #0003}.hu-button--danger-solid{border-color:transparent;background:var(--hu-danger);color:#fff}.hu-icon-button{display:inline-grid;place-items:center;width:36px;height:36px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--hu-muted);cursor:pointer;transition:background-color .15s,transform .15s}.hu-icon-button:hover{background:color-mix(in srgb,currentColor 12%,transparent);transform:scale(1.08)}.hu-icon-button--danger{color:var(--hu-danger)}.hu-icon-button--edit{color:var(--hu-success)}.hu-toolbar{display:flex}.hu-badge-wrap{position:relative;display:inline-flex}.hu-count{position:absolute;inset-block-start:-8px;inset-inline-end:-10px;display:grid;place-items:center;min-width:20px;height:20px;padding:0 5px;border:2px solid var(--hu-surface);border-radius:10px;background:var(--hu-success);color:#fff;font-size:.75rem;font-weight:600}.hu-count[data-hu-full=true]{background:var(--hu-danger)}.hu-alert{display:flex;align-items:flex-start;gap:8px;margin:0;padding:8px 12px;border-radius:8px;background:var(--hu-danger-soft);color:var(--hu-danger);font-size:.875rem}.hu-alert ul,.hu-alert--inline{flex:1;margin:0;padding-inline-start:18px}.hu-alert--inline{display:block;padding-inline-start:28px}.hu-status{margin:0;color:var(--hu-muted)}.hu-dropzone{position:relative;display:flex;flex-direction:column;align-items:center;gap:4px;padding:28px 16px;border:2px dashed var(--hu-border);border-radius:10px;background:var(--hu-surface-alt);text-align:center;cursor:pointer;transition:border-color .15s,background-color .15s}.hu-dropzone:hover,.hu-dropzone--active{border-color:var(--hu-primary);background:var(--hu-primary-soft)}.hu-dropzone:has(input:focus-visible){box-shadow:var(--hu-focus-ring)}.hu-dropzone--disabled{opacity:.55;cursor:not-allowed}.hu-dropzone__label{font-weight:600;color:var(--hu-primary)}.hu-dropzone__hint{font-size:.8125rem;color:var(--hu-muted)}.hu-files{display:grid;gap:var(--hu-gap);margin:0;padding:0;list-style:none}.hu-files--thumbnail{grid-template-columns:repeat(var(--hu-columns, 4),minmax(0,1fr))}.hu-files--simple{grid-template-columns:repeat(auto-fill,minmax(260px,1fr))}@media(max-width:960px){.hu-files--thumbnail{grid-template-columns:repeat(min(var(--hu-columns, 4),2),minmax(0,1fr))}}@media(max-width:600px){.hu-files--thumbnail{grid-template-columns:minmax(0,1fr)}}.hu-card{display:flex;flex-direction:column;min-width:0;overflow:hidden;border-radius:var(--hu-radius);background:var(--hu-surface);box-shadow:var(--hu-shadow);transition:transform .2s,box-shadow .2s}.hu-card:hover{transform:translateY(-2px);box-shadow:var(--hu-shadow-raised)}.hu-card--outlined{border:1px solid var(--hu-border);box-shadow:none}.hu-card--raised{box-shadow:var(--hu-shadow-raised)}.hu-card--shaped{border-radius:24px 4px}.hu-card--tile{border-radius:0}.hu-card__media{position:relative;display:flex;align-items:center;justify-content:center;height:var(--hu-media-height);overflow:hidden;background:var(--hu-surface-alt)}.hu-media--contain{max-width:100%;max-height:100%;object-fit:contain}.hu-media--cover{width:100%;height:100%;object-fit:cover}.hu-play{position:absolute;display:grid;place-items:center;width:60px;height:60px;border-radius:50%;background:#000000b3;color:#fff}.hu-card__content{display:flex;gap:12px;align-items:center;padding:12px 16px 4px}.hu-card--simple .hu-card__content{flex:1;min-height:112px}.hu-card__info{display:flex;flex:1;flex-direction:column;align-items:flex-start;gap:8px;min-width:0}.hu-file__name{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}.hu-chip{display:inline-flex;align-items:center;gap:4px;padding:2px 10px;border-radius:16px;background:color-mix(in srgb,var(--hu-chip) 14%,transparent);color:var(--hu-chip);font-size:.8125rem;font-weight:500;white-space:nowrap}.hu-card--simple .hu-chip{background:var(--hu-chip);color:#fff}.hu-chip[data-hu-size=small]{--hu-chip: var(--hu-success)}.hu-chip[data-hu-size=medium]{--hu-chip: var(--hu-warning)}.hu-chip[data-hu-size=large]{--hu-chip: var(--hu-danger)}.hu-thumb{display:grid;flex:none;place-items:center;width:80px;height:80px;overflow:hidden;border-radius:8px}.hu-thumb img{width:100%;height:100%;object-fit:cover}.hu-thumb--small{width:44px;height:44px;border-radius:6px}.hu-card__actions{display:flex;align-items:center;gap:4px;margin-top:auto;padding:4px 8px 8px;border-top:1px solid var(--hu-border)}.hu-details-toggle{margin-inline-start:auto}.hu-details-toggle .hu-icon{transition:transform .2s}.hu-details-toggle[aria-expanded=true] .hu-icon{transform:rotate(180deg)}.hu-card__details{padding:8px 16px 14px;border-top:1px solid var(--hu-border)}.hu-tags,.hu-tag-picker{display:flex;flex-wrap:wrap;gap:6px;margin:0;padding:0;list-style:none}.hu-tag{display:inline-flex;align-items:center;gap:4px;padding:2px 10px;border-radius:16px;background:var(--hu-surface-alt);border:1px solid var(--hu-border);font-size:.8125rem}.hu-tag--selectable{cursor:pointer}.hu-tag--selectable:has(input:checked){border-color:var(--hu-primary);background:var(--hu-primary-soft);color:var(--hu-primary)}.hu-description{margin:8px 0 0;color:var(--hu-muted);font-size:.875rem;text-align:justify}.hu-file-icon{color:#757575}.hu-file-icon[data-hu-type=image]{color:#5e35b1}.hu-file-icon[data-hu-type=document]{color:#e53935}.hu-file-icon[data-hu-type=spreadsheet]{color:#00897b}.hu-file-icon[data-hu-type=presentation]{color:#ef6c00}.hu-file-icon[data-hu-type=video]{color:#ef5350}.hu-file-icon[data-hu-type=audio]{color:#8e24aa}.hu-file-icon[data-hu-type=archive]{color:#9e9d24}.hu-table-wrap{overflow:auto;border-radius:8px;background:var(--hu-surface);box-shadow:var(--hu-shadow)}.hu-table{width:100%;border-collapse:collapse;font-size:.875rem}.hu-table th,.hu-table td{padding:10px 12px;border-bottom:1px solid var(--hu-border);text-align:start;vertical-align:middle}.hu-table th{background:var(--hu-surface-alt);font-weight:600}.hu-table-wrap--fixed th{position:sticky;top:0;z-index:1}.hu-table tbody tr:hover{background:color-mix(in srgb,var(--hu-text) 4%,transparent)}.hu-table__thumb{width:68px}.hu-table__size{width:110px}.hu-table__actions{width:100px}.hu-table .hu-file__name{max-width:0;width:100%}.hu-actions{display:flex;gap:2px}.hu-dialog{position:fixed;top:0;right:0;bottom:0;left:0;margin:auto;height:fit-content;width:min(560px,calc(100vw - 32px));max-height:calc(100vh - 64px);padding:0;border:0;border-radius:12px;background:var(--hu-surface);color:var(--hu-text);font-family:var(--hu-font);box-shadow:0 12px 40px #0000004d}.hu-dialog--small{width:min(400px,calc(100vw - 32px))}.hu-dialog::backdrop{background:#00000073}.hu-dialog__panel{display:flex;flex-direction:column;max-height:inherit}.hu-dialog__header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 12px 4px 20px}.hu-dialog__title{margin:0;font-size:1.125rem;font-weight:600}.hu-dialog__body{display:flex;flex-direction:column;gap:12px;padding:8px 20px 12px;overflow:auto}.hu-dialog__actions{display:flex;justify-content:flex-end;gap:8px;padding:12px 20px 16px}.hu-dialog__message{margin:0}.hu-staged{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;list-style:none}.hu-staged__item,.hu-edit{display:flex;align-items:flex-start;gap:12px;padding:10px;border:1px solid var(--hu-border);border-radius:8px}.hu-edit{border:0;padding:0}.hu-staged__fields{display:flex;flex:1;flex-direction:column;gap:10px;min-width:0}.hu-field{display:flex;flex-direction:column;gap:4px;margin:0;padding:0;border:0;min-width:0}.hu-field__label{padding:0;color:var(--hu-muted);font-size:.75rem;font-weight:500}.hu-field__row{display:flex;align-items:center;gap:4px}.hu-field__suffix{color:var(--hu-muted)}.hu-input{width:100%;min-width:0;padding:8px 10px;border:1px solid var(--hu-border);border-radius:6px;background:var(--hu-surface);color:var(--hu-text);font:inherit;font-size:.875rem;resize:vertical}.table-row[data-v-d05b814b]:hover{background-color:#0000000a}.v-table[data-v-d05b814b]{border-radius:8px}.v-table th[data-v-d05b814b]{font-weight:600;background-color:#00000005}.file-card[data-v-f7000da4]{transition:all .3s ease;border-radius:12px!important;overflow:hidden;display:flex;flex-direction:column}.file-card[data-v-f7000da4]:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0000001a!important}.thumbnail-container[data-v-f7000da4]{border-radius:8px;overflow:hidden;box-shadow:0 2px 8px #0000001a}.v-card-title[data-v-f7000da4]{word-break:break-word;display:flex;align-items:center;justify-content:center}.v-chip[data-v-f7000da4]{font-weight:500}.v-btn[data-v-f7000da4]{transition:all .2s ease}.v-btn[data-v-f7000da4]:hover{transform:scale(1.1)}
|