@thanhpv102/simple-image-asset-manager 0.1.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 ADDED
@@ -0,0 +1,16 @@
1
+ # simple-image-asset-manager
2
+
3
+ A comprehensive file/image asset manager modal for easy-email-editor. Supports folder navigation, drag-and-drop upload, image preview/editing, and more.
4
+
5
+ ## Features
6
+ - Browse folders/files
7
+ - Upload via drag-and-drop
8
+ - Create/manage folders
9
+ - Preview images
10
+ - Edit images (crop, resize, rotate)
11
+ - Delete files/folders
12
+ - Select files for use in email templates
13
+
14
+ ## Usage
15
+ See the documentation in the main repo for integration details.
16
+
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+ import { AssetManagerProps } from './types';
3
+ export declare const AssetManager: React.FC<AssetManagerProps>;
package/dist/index.cjs ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),xe=require("antd"),Y=require("@ant-design/icons");var Q={exports:{}},$={};var ce;function ye(){if(ce)return $;ce=1;var d=Symbol.for("react.transitional.element"),E=Symbol.for("react.fragment");function _(y,u,f){var T=null;if(f!==void 0&&(T=""+f),u.key!==void 0&&(T=""+u.key),"key"in u){f={};for(var N in u)N!=="key"&&(f[N]=u[N])}else f=u;return u=f.ref,{$$typeof:d,type:y,key:T,ref:u!==void 0?u:null,props:f}}return $.Fragment=E,$.jsx=_,$.jsxs=_,$}var q={};var ue;function ve(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&(function(){function d(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case v:return"Fragment";case w:return"Profiler";case O:return"StrictMode";case B:return"Suspense";case H:return"SuspenseList";case X:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case h:return"Portal";case g:return e.displayName||"Context";case ee:return(e._context.displayName||"Context")+".Consumer";case G:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return n=e.displayName||null,n!==null?n:d(e.type)||"Memo";case C:n=e._payload,e=e._init;try{return d(e(n))}catch{}}return null}function E(e){return""+e}function _(e){try{E(e);var n=!1}catch{n=!0}if(n){n=console;var i=n.error,l=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",l),E(e)}}function y(e){if(e===v)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===C)return"<...>";try{var n=d(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function u(){var e=j.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function T(e){if(F.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function N(e,n){function i(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function ie(){var e=d(this.type);return o[e]||(o[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function K(e,n,i,l,W,M){var s=i.ref;return e={$$typeof:z,type:e,key:n,props:i,_owner:l},(s!==void 0?s:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:ie}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function V(e,n,i,l,W,M){var s=n.children;if(s!==void 0)if(l)if(I(s)){for(l=0;l<s.length;l++)b(s[l]);Object.freeze&&Object.freeze(s)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(s);if(F.call(n,"key")){s=d(e);var R=Object.keys(n).filter(function(te){return te!=="key"});l=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",Z[s+l]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,l,s,R,s),Z[s+l]=!0)}if(s=null,i!==void 0&&(_(i),s=""+i),T(n)&&(_(n.key),s=""+n.key),"key"in n){i={};for(var U in n)U!=="key"&&(i[U]=n[U])}else i=n;return s&&N(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),K(e,s,i,u(),W,M)}function b(e){J(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===C&&(e._payload.status==="fulfilled"?J(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function J(e){return typeof e=="object"&&e!==null&&e.$$typeof===z}var P=c,z=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),g=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),A=Symbol.for("react.client.reference"),j=P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,I=Array.isArray,x=console.createTask?console.createTask:function(){return null};P={react_stack_bottom_frame:function(e){return e()}};var D,o={},k=P.react_stack_bottom_frame.bind(P,f)(),S=x(y(f)),Z={};q.Fragment=v,q.jsx=function(e,n,i){var l=1e4>j.recentlyCreatedOwnerStacks++;return V(e,n,i,!1,l?Error("react-stack-top-frame"):k,l?x(y(e)):S)},q.jsxs=function(e,n,i){var l=1e4>j.recentlyCreatedOwnerStacks++;return V(e,n,i,!0,l?Error("react-stack-top-frame"):k,l?x(y(e)):S)}})()),q}var fe;function we(){return fe||(fe=1,process.env.NODE_ENV==="production"?Q.exports=ye():Q.exports=ve()),Q.exports}var r=we();function m(d){return d.type==="FILE"}function oe(d){return d.type==="FOLDER"}const je=({accept:d="image/*",request:E,title:_="Asset Manager",upload:y,onCreateFile:u,onDeleteFile:f,onDeleteFolder:T,onUpdateFile:N,onUpdateFolder:ie,onCreateFolder:K,onSelect:V,visible:b=!1,setVisible:J,showUnacceptedFile:P=!1,addFolderEnabled:z=!0})=>{const[h,v]=c.useState(null),[O,w]=c.useState([]),[ee,g]=c.useState(!1),[G,B]=c.useState(null),[H,L]=c.useState(!1),[C,X]=c.useState(""),[A,j]=c.useState(!1),[F,I]=c.useState([]),[x,D]=c.useState(!1),[o,k]=c.useState(null),[S,Z]=c.useState("thumbnail"),e=c.useRef(null),[n,i]=c.useState(window.innerWidth);c.useEffect(()=>{b&&(g(!0),B(null),E(h===null?void 0:h).then(t=>w(t)).catch(t=>B(t?.message||"Failed to load assets")).finally(()=>g(!1)))},[h,b,E]),c.useEffect(()=>{b&&h===null&&I([])},[h,b]),c.useEffect(()=>{const t=()=>i(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);const l=()=>{J(!1),v(null),I([]),B(null)},W=t=>{t===-1?(v(null),I([])):(v(F[t].id),I(F.slice(0,t+1)))},M=async t=>{g(!0),await f({id:t.id}),w(a=>a.filter(p=>p!==t)),g(!1)},s=async t=>{g(!0),await T({id:t.id}),w(a=>a.filter(p=>p!==t)),g(!1)},R=async()=>{if(!C.trim())return;g(!0);const t=await K({name:C,parentFolderId:h});w(a=>[...a,t]),X(""),L(!1),g(!1)},U=async t=>{const a=t.target.files;if(!(!a||a.length===0)){j(!0);for(const p of Array.from(a)){if(d&&!p.type.match(d.replace("*",".*")))continue;const re=await y(p),ne=await u({name:p.name,url:re,parentFolderId:h});w(be=>[...be,ne])}j(!1),e.current&&(e.current.value="")}},te=t=>{t.preventDefault(),D(!0)},pe=t=>{t.preventDefault(),D(!1)},me=async t=>{if(t.preventDefault(),D(!1),!!t.dataTransfer.files){j(!0);for(const a of Array.from(t.dataTransfer.files)){if(d&&!a.type.match(d.replace("*",".*")))continue;const p=await y(a),re=await u({name:a.name,url:p,parentFolderId:h});w(ne=>[...ne,re])}j(!1)}},ae=t=>{k(t)},le=t=>{v(t.id),I(a=>[...a,t]),k(t)},he=()=>{o&&m(o)&&(V(o.url),l())},se=async()=>{o&&(m(o)?(await M(o),k(null)):oe(o)&&(await s(o),k(null)))},de=Math.round(n*.8),ge=Math.round(de*.6);return b?r.jsx(xe.Modal,{open:b,title:r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[r.jsx("span",{children:_}),r.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:0,marginRight:40,marginTop:-10},children:r.jsx("button",{onClick:()=>Z(S==="thumbnail"?"list":"thumbnail"),style:{background:"none",border:"none",cursor:"pointer",padding:0,marginTop:8,fontSize:22,color:"#222",display:"flex",alignItems:"center",transition:"color 0.2s"},title:S==="thumbnail"?"List view":"Thumbnail view",children:S==="thumbnail"?r.jsx(Y.BarsOutlined,{}):r.jsx(Y.AppstoreOutlined,{})})})]}),onCancel:l,footer:null,width:de,styles:{body:{padding:0}},destroyOnHidden:!0,maskClosable:!1,centered:!0,children:r.jsxs("div",{className:"simple-image-asset-manager-modal",style:{padding:24},children:[r.jsxs("div",{className:"modal-body",style:{display:"flex",gap:24},children:[r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{marginBottom:8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap"},children:[r.jsx("span",{className:"breadcrumb",onClick:()=>W(-1),style:{cursor:"pointer",color:"#1890ff",textDecoration:"underline",fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:"All"}),F.map((t,a)=>{const p=a===F.length-1;return r.jsxs("span",{style:{display:"flex",alignItems:"center"},children:[r.jsx("span",{style:{margin:"0 4px",fontWeight:500},children:"/"}),p?r.jsx("span",{className:"breadcrumb",style:{color:"#222",fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name}):r.jsx("span",{className:"breadcrumb",onClick:()=>W(a),style:{cursor:"pointer",color:"#1890ff",textDecoration:"underline",fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]},t.id)})]}),z&&!H&&r.jsxs("button",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",userSelect:"none",fontWeight:500,fontSize:15,padding:"8px 20px",borderRadius:4,background:"#1890ff",color:"#fff",border:"none",boxShadow:"0 2px 8px rgba(24,144,255,0.12)",transition:"background 0.2s, box-shadow 0.2s"},onClick:()=>L(!0),children:[r.jsx("span",{children:"New folder"}),r.jsx(Y.FolderAddOutlined,{style:{fontSize:20}})]})]}),r.jsxs("div",{className:`drop-area${x?" drag-active":""}`,onDrop:me,onDragOver:te,onDragLeave:pe,style:{border:x?"2px solid #1890ff":"2px dashed #aaa",borderRadius:8,padding:32,marginBottom:24,textAlign:"center",background:x?"#e6f7ff":"#fafafa",position:"relative",transition:"border-color 0.3s, background 0.3s"},children:[r.jsx("div",{style:{marginBottom:8,fontWeight:500},children:x?"Drop file here to upload":"Drag & drop files here"}),r.jsx("button",{onClick:()=>e.current?.click(),disabled:A,style:{marginBottom:8,visibility:x?"hidden":"visible",padding:"8px 24px",borderRadius:4,background:A?"#ccc":"#1890ff",color:"#fff",border:"none",cursor:A?"not-allowed":"pointer",fontWeight:500,fontSize:15,boxShadow:A?"none":"0 2px 8px rgba(24,144,255,0.12)",transition:"background 0.2s, box-shadow 0.2s"},children:"Upload"}),r.jsx("input",{ref:e,type:"file",accept:d,style:{display:"none"},multiple:!0,onChange:U}),A&&r.jsx("div",{children:"Uploading..."})]}),ee?r.jsx("div",{children:"Loading..."}):G?r.jsx("div",{className:"error",children:G}):r.jsxs("div",{children:[z&&H&&r.jsxs("div",{style:{marginBottom:16,display:"flex",alignItems:"center",gap:8},children:[r.jsx("input",{value:C,onChange:t=>X(t.target.value),placeholder:"Folder name",style:{padding:"8px 12px",borderRadius:4,border:"1px solid #d9d9d9",fontSize:15,fontWeight:500,outline:"none",transition:"border-color 0.2s",boxSizing:"border-box"},onFocus:t=>t.target.style.borderColor="#1890ff",onBlur:t=>t.target.style.borderColor="#d9d9d9"}),r.jsx("button",{onClick:R,style:{padding:"8px 16px",borderRadius:4,background:"#1890ff",color:"#fff",border:"none",fontWeight:500,fontSize:15,cursor:"pointer",boxShadow:"0 2px 8px rgba(24,144,255,0.12)",transition:"background 0.2s"},children:"Create"}),r.jsx("button",{onClick:()=>L(!1),style:{padding:"8px 16px",borderRadius:4,background:"#f5f5f5",color:"#222",border:"1px solid #d9d9d9",fontWeight:500,fontSize:15,cursor:"pointer",transition:"background 0.2s"},children:"Cancel"})]}),S==="thumbnail"?r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16},children:O.filter(oe).map(t=>r.jsxs("div",{className:"folder-item",style:{cursor:"pointer",width:120,minWidth:120,maxWidth:120,display:"flex",flexDirection:"column",alignItems:"center",padding:8,borderRadius:8,background:"#fafafa",boxSizing:"border-box"},onClick:()=>le(t),children:[t.thumbnail?r.jsx("img",{src:t.thumbnail,alt:t.name,style:{width:64,height:64,objectFit:"cover",borderRadius:4,marginBottom:8,background:"#fff"}}):r.jsx("div",{style:{fontSize:40,width:64,height:64,display:"flex",alignItems:"center",justifyContent:"center",marginBottom:8,background:"#fff",borderRadius:4},children:"📁"}),r.jsx("div",{style:{fontSize:13,fontWeight:500,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]},t.id))}):r.jsx("div",{style:{display:"block",marginBottom:16},children:O.filter(oe).map(t=>r.jsxs("div",{className:"folder-item",style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0",borderBottom:"1px solid #f0f0f0",cursor:"pointer"},onClick:()=>le(t),children:[t.thumbnail?r.jsx("img",{src:t.thumbnail,alt:t.name,style:{width:32,height:32,objectFit:"cover",borderRadius:4,background:"#fff"}}):r.jsx("div",{style:{fontSize:24,width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"#fff",borderRadius:4},children:"📁"}),r.jsx("div",{style:{fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:t.name})]},t.id))}),S==="thumbnail"?r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,marginTop:16},children:O.filter(m).map(t=>{const a=o&&m(o)&&o.id===t.id;return r.jsxs("div",{className:"file-item",style:{cursor:"pointer",width:120,minWidth:120,maxWidth:120,border:"2px solid "+(a?"#1890ff":"transparent"),background:a?"#e6f7ff":"#fafafa",borderRadius:8,boxSizing:"border-box",transition:"border-color 0.2s, background 0.2s",padding:8,display:"flex",flexDirection:"column",alignItems:"center"},onClick:()=>ae(t),children:[r.jsx("img",{src:t.thumbnail||t.url,alt:t.name,style:{width:64,height:64,objectFit:"cover",borderRadius:4,background:"#fff",marginBottom:8}}),r.jsx("div",{style:{fontSize:12,fontWeight:500,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:t.name})]},t.id)})}):r.jsx("div",{style:{display:"block",marginTop:16},children:O.filter(m).map(t=>{const a=o&&m(o)&&o.id===t.id;return r.jsxs("div",{className:"file-item",style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0",borderBottom:"1px solid #f0f0f0",cursor:"pointer",background:a?"#e6f7ff":"#fff"},onClick:()=>ae(t),children:[r.jsx("img",{src:t.thumbnail||t.url,alt:t.name,style:{width:32,height:32,objectFit:"cover",borderRadius:4,background:"#fff"}}),r.jsx("div",{style:{fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:t.name})]},t.id)})})]})]}),o&&r.jsx("div",{style:{width:ge,minWidth:320,transition:"width 2s",overflow:"hidden"},children:r.jsxs("div",{style:{border:"1px solid #eee",borderRadius:8,padding:16,background:"#fff",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",position:"relative"},children:[r.jsx("button",{onClick:()=>k(null),style:{position:"absolute",top:12,right:12,background:"#f5f5f5",border:"none",borderRadius:4,padding:"4px 12px",cursor:"pointer",fontWeight:500,fontSize:14,color:"#222",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Hide"}),m(o)?r.jsxs(r.Fragment,{children:[r.jsx("img",{src:o.thumbnail||o.url,alt:o.name,style:{width:"100%",maxHeight:240,objectFit:"contain",borderRadius:4,marginBottom:16}}),r.jsx("div",{style:{fontWeight:500,marginBottom:8},children:o.name}),r.jsx("div",{style:{fontSize:12,color:"#888",marginBottom:8},children:o.url.startsWith("data:")?"URL: data-uri":r.jsxs(r.Fragment,{children:["URL: ",r.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",children:o.url})]})}),r.jsxs("button",{onClick:se,style:{display:"flex",alignItems:"center",gap:6,color:"#ff4d4f",background:"none",border:"none",cursor:"pointer",fontWeight:500,fontSize:15,marginTop:24},children:[r.jsx(Y.DeleteOutlined,{})," Delete"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:64,marginBottom:16},children:"📁"}),r.jsx("div",{style:{fontWeight:500,marginBottom:8},children:o.name}),r.jsx("div",{style:{fontSize:12,color:"#888",marginBottom:8},children:`Files: ${O.filter(t=>m(t)&&t.parentFolderId===o.id).length}`}),r.jsxs("button",{onClick:se,style:{display:"flex",alignItems:"center",gap:6,color:"#ff4d4f",background:"none",border:"none",cursor:"pointer",fontWeight:500,fontSize:15,marginTop:24},children:[r.jsx(Y.DeleteOutlined,{})," Delete"]})]})]})})]}),r.jsx("div",{className:"modal-footer",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",marginTop:24},children:r.jsx("button",{onClick:he,disabled:!(o&&m(o)),style:{padding:"8px 24px",borderRadius:4,background:o&&m(o)?"#1890ff":"#ccc",color:"#fff",border:"none",cursor:o&&m(o)?"pointer":"not-allowed",fontWeight:500},children:"Select"})})]})}):null};exports.AssetManager=je;
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export { AssetManager } from './AssetManager';
package/dist/index.js ADDED
@@ -0,0 +1,840 @@
1
+ import ye, { useState as u, useRef as ve, useEffect as ne } from "react";
2
+ import { Modal as we } from "antd";
3
+ import { FolderAddOutlined as je, DeleteOutlined as ce, BarsOutlined as ke, AppstoreOutlined as Re } from "@ant-design/icons";
4
+ var Z = { exports: {} }, M = {};
5
+ var fe;
6
+ function Ee() {
7
+ if (fe) return M;
8
+ fe = 1;
9
+ var d = /* @__PURE__ */ Symbol.for("react.transitional.element"), S = /* @__PURE__ */ Symbol.for("react.fragment");
10
+ function _(y, c, f) {
11
+ var T = null;
12
+ if (f !== void 0 && (T = "" + f), c.key !== void 0 && (T = "" + c.key), "key" in c) {
13
+ f = {};
14
+ for (var N in c)
15
+ N !== "key" && (f[N] = c[N]);
16
+ } else f = c;
17
+ return c = f.ref, {
18
+ $$typeof: d,
19
+ type: y,
20
+ key: T,
21
+ ref: c !== void 0 ? c : null,
22
+ props: f
23
+ };
24
+ }
25
+ return M.Fragment = S, M.jsx = _, M.jsxs = _, M;
26
+ }
27
+ var $ = {};
28
+ var ue;
29
+ function Se() {
30
+ return ue || (ue = 1, process.env.NODE_ENV !== "production" && (function() {
31
+ function d(e) {
32
+ if (e == null) return null;
33
+ if (typeof e == "function")
34
+ return e.$$typeof === A ? null : e.displayName || e.name || null;
35
+ if (typeof e == "string") return e;
36
+ switch (e) {
37
+ case v:
38
+ return "Fragment";
39
+ case w:
40
+ return "Profiler";
41
+ case C:
42
+ return "StrictMode";
43
+ case B:
44
+ return "Suspense";
45
+ case G:
46
+ return "SuspenseList";
47
+ case H:
48
+ return "Activity";
49
+ }
50
+ if (typeof e == "object")
51
+ switch (typeof e.tag == "number" && console.error(
52
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
53
+ ), e.$$typeof) {
54
+ case h:
55
+ return "Portal";
56
+ case g:
57
+ return e.displayName || "Context";
58
+ case K:
59
+ return (e._context.displayName || "Context") + ".Consumer";
60
+ case q:
61
+ var n = e.render;
62
+ return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
63
+ case L:
64
+ return n = e.displayName || null, n !== null ? n : d(e.type) || "Memo";
65
+ case O:
66
+ n = e._payload, e = e._init;
67
+ try {
68
+ return d(e(n));
69
+ } catch {
70
+ }
71
+ }
72
+ return null;
73
+ }
74
+ function S(e) {
75
+ return "" + e;
76
+ }
77
+ function _(e) {
78
+ try {
79
+ S(e);
80
+ var n = !1;
81
+ } catch {
82
+ n = !0;
83
+ }
84
+ if (n) {
85
+ n = console;
86
+ var i = n.error, l = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
87
+ return i.call(
88
+ n,
89
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
90
+ l
91
+ ), S(e);
92
+ }
93
+ }
94
+ function y(e) {
95
+ if (e === v) return "<>";
96
+ if (typeof e == "object" && e !== null && e.$$typeof === O)
97
+ return "<...>";
98
+ try {
99
+ var n = d(e);
100
+ return n ? "<" + n + ">" : "<...>";
101
+ } catch {
102
+ return "<...>";
103
+ }
104
+ }
105
+ function c() {
106
+ var e = j.A;
107
+ return e === null ? null : e.getOwner();
108
+ }
109
+ function f() {
110
+ return Error("react-stack-top-frame");
111
+ }
112
+ function T(e) {
113
+ if (F.call(e, "key")) {
114
+ var n = Object.getOwnPropertyDescriptor(e, "key").get;
115
+ if (n && n.isReactWarning) return !1;
116
+ }
117
+ return e.key !== void 0;
118
+ }
119
+ function N(e, n) {
120
+ function i() {
121
+ D || (D = !0, console.error(
122
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
123
+ n
124
+ ));
125
+ }
126
+ i.isReactWarning = !0, Object.defineProperty(e, "key", {
127
+ get: i,
128
+ configurable: !0
129
+ });
130
+ }
131
+ function ie() {
132
+ var e = d(this.type);
133
+ return o[e] || (o[e] = !0, console.error(
134
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
135
+ )), e = this.props.ref, e !== void 0 ? e : null;
136
+ }
137
+ function Q(e, n, i, l, W, U) {
138
+ var s = i.ref;
139
+ return e = {
140
+ $$typeof: z,
141
+ type: e,
142
+ key: n,
143
+ props: i,
144
+ _owner: l
145
+ }, (s !== void 0 ? s : null) !== null ? Object.defineProperty(e, "ref", {
146
+ enumerable: !1,
147
+ get: ie
148
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
149
+ configurable: !1,
150
+ enumerable: !1,
151
+ writable: !0,
152
+ value: 0
153
+ }), Object.defineProperty(e, "_debugInfo", {
154
+ configurable: !1,
155
+ enumerable: !1,
156
+ writable: !0,
157
+ value: null
158
+ }), Object.defineProperty(e, "_debugStack", {
159
+ configurable: !1,
160
+ enumerable: !1,
161
+ writable: !0,
162
+ value: W
163
+ }), Object.defineProperty(e, "_debugTask", {
164
+ configurable: !1,
165
+ enumerable: !1,
166
+ writable: !0,
167
+ value: U
168
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
169
+ }
170
+ function V(e, n, i, l, W, U) {
171
+ var s = n.children;
172
+ if (s !== void 0)
173
+ if (l)
174
+ if (I(s)) {
175
+ for (l = 0; l < s.length; l++)
176
+ x(s[l]);
177
+ Object.freeze && Object.freeze(s);
178
+ } else
179
+ console.error(
180
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
181
+ );
182
+ else x(s);
183
+ if (F.call(n, "key")) {
184
+ s = d(e);
185
+ var E = Object.keys(n).filter(function(ee) {
186
+ return ee !== "key";
187
+ });
188
+ l = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", X[s + l] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
189
+ `A props object containing a "key" prop is being spread into JSX:
190
+ let props = %s;
191
+ <%s {...props} />
192
+ React keys must be passed directly to JSX without using spread:
193
+ let props = %s;
194
+ <%s key={someKey} {...props} />`,
195
+ l,
196
+ s,
197
+ E,
198
+ s
199
+ ), X[s + l] = !0);
200
+ }
201
+ if (s = null, i !== void 0 && (_(i), s = "" + i), T(n) && (_(n.key), s = "" + n.key), "key" in n) {
202
+ i = {};
203
+ for (var Y in n)
204
+ Y !== "key" && (i[Y] = n[Y]);
205
+ } else i = n;
206
+ return s && N(
207
+ i,
208
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
209
+ ), Q(
210
+ e,
211
+ s,
212
+ i,
213
+ c(),
214
+ W,
215
+ U
216
+ );
217
+ }
218
+ function x(e) {
219
+ J(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === O && (e._payload.status === "fulfilled" ? J(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
220
+ }
221
+ function J(e) {
222
+ return typeof e == "object" && e !== null && e.$$typeof === z;
223
+ }
224
+ var P = ye, z = /* @__PURE__ */ Symbol.for("react.transitional.element"), h = /* @__PURE__ */ Symbol.for("react.portal"), v = /* @__PURE__ */ Symbol.for("react.fragment"), C = /* @__PURE__ */ Symbol.for("react.strict_mode"), w = /* @__PURE__ */ Symbol.for("react.profiler"), K = /* @__PURE__ */ Symbol.for("react.consumer"), g = /* @__PURE__ */ Symbol.for("react.context"), q = /* @__PURE__ */ Symbol.for("react.forward_ref"), B = /* @__PURE__ */ Symbol.for("react.suspense"), G = /* @__PURE__ */ Symbol.for("react.suspense_list"), L = /* @__PURE__ */ Symbol.for("react.memo"), O = /* @__PURE__ */ Symbol.for("react.lazy"), H = /* @__PURE__ */ Symbol.for("react.activity"), A = /* @__PURE__ */ Symbol.for("react.client.reference"), j = P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, F = Object.prototype.hasOwnProperty, I = Array.isArray, b = console.createTask ? console.createTask : function() {
225
+ return null;
226
+ };
227
+ P = {
228
+ react_stack_bottom_frame: function(e) {
229
+ return e();
230
+ }
231
+ };
232
+ var D, o = {}, k = P.react_stack_bottom_frame.bind(
233
+ P,
234
+ f
235
+ )(), R = b(y(f)), X = {};
236
+ $.Fragment = v, $.jsx = function(e, n, i) {
237
+ var l = 1e4 > j.recentlyCreatedOwnerStacks++;
238
+ return V(
239
+ e,
240
+ n,
241
+ i,
242
+ !1,
243
+ l ? Error("react-stack-top-frame") : k,
244
+ l ? b(y(e)) : R
245
+ );
246
+ }, $.jsxs = function(e, n, i) {
247
+ var l = 1e4 > j.recentlyCreatedOwnerStacks++;
248
+ return V(
249
+ e,
250
+ n,
251
+ i,
252
+ !0,
253
+ l ? Error("react-stack-top-frame") : k,
254
+ l ? b(y(e)) : R
255
+ );
256
+ };
257
+ })()), $;
258
+ }
259
+ var pe;
260
+ function _e() {
261
+ return pe || (pe = 1, process.env.NODE_ENV === "production" ? Z.exports = Ee() : Z.exports = Se()), Z.exports;
262
+ }
263
+ var t = _e();
264
+ function m(d) {
265
+ return d.type === "FILE";
266
+ }
267
+ function oe(d) {
268
+ return d.type === "FOLDER";
269
+ }
270
+ const Ae = ({
271
+ accept: d = "image/*",
272
+ request: S,
273
+ title: _ = "Asset Manager",
274
+ upload: y,
275
+ onCreateFile: c,
276
+ onDeleteFile: f,
277
+ onDeleteFolder: T,
278
+ onUpdateFile: N,
279
+ onUpdateFolder: ie,
280
+ onCreateFolder: Q,
281
+ onSelect: V,
282
+ visible: x = !1,
283
+ setVisible: J,
284
+ showUnacceptedFile: P = !1,
285
+ addFolderEnabled: z = !0
286
+ }) => {
287
+ const [h, v] = u(null), [C, w] = u([]), [K, g] = u(!1), [q, B] = u(null), [G, L] = u(!1), [O, H] = u(""), [A, j] = u(!1), [F, I] = u([]), [b, D] = u(!1), [o, k] = u(null), [R, X] = u("thumbnail"), e = ve(null), [n, i] = u(window.innerWidth);
288
+ ne(() => {
289
+ x && (g(!0), B(null), S(h === null ? void 0 : h).then((r) => w(r)).catch((r) => B(r?.message || "Failed to load assets")).finally(() => g(!1)));
290
+ }, [h, x, S]), ne(() => {
291
+ x && h === null && I([]);
292
+ }, [h, x]), ne(() => {
293
+ const r = () => i(window.innerWidth);
294
+ return window.addEventListener("resize", r), () => window.removeEventListener("resize", r);
295
+ }, []);
296
+ const l = () => {
297
+ J(!1), v(null), I([]), B(null);
298
+ }, W = (r) => {
299
+ r === -1 ? (v(null), I([])) : (v(F[r].id), I(F.slice(0, r + 1)));
300
+ }, U = async (r) => {
301
+ g(!0), await f({ id: r.id }), w((a) => a.filter((p) => p !== r)), g(!1);
302
+ }, s = async (r) => {
303
+ g(!0), await T({ id: r.id }), w((a) => a.filter((p) => p !== r)), g(!1);
304
+ }, E = async () => {
305
+ if (!O.trim()) return;
306
+ g(!0);
307
+ const r = await Q({ name: O, parentFolderId: h });
308
+ w((a) => [...a, r]), H(""), L(!1), g(!1);
309
+ }, Y = async (r) => {
310
+ const a = r.target.files;
311
+ if (!(!a || a.length === 0)) {
312
+ j(!0);
313
+ for (const p of Array.from(a)) {
314
+ if (d && !p.type.match(d.replace("*", ".*")))
315
+ continue;
316
+ const re = await y(p), te = await c({ name: p.name, url: re, parentFolderId: h });
317
+ w((be) => [...be, te]);
318
+ }
319
+ j(!1), e.current && (e.current.value = "");
320
+ }
321
+ }, ee = (r) => {
322
+ r.preventDefault(), D(!0);
323
+ }, me = (r) => {
324
+ r.preventDefault(), D(!1);
325
+ }, he = async (r) => {
326
+ if (r.preventDefault(), D(!1), !!r.dataTransfer.files) {
327
+ j(!0);
328
+ for (const a of Array.from(r.dataTransfer.files)) {
329
+ if (d && !a.type.match(d.replace("*", ".*")))
330
+ continue;
331
+ const p = await y(a), re = await c({ name: a.name, url: p, parentFolderId: h });
332
+ w((te) => [...te, re]);
333
+ }
334
+ j(!1);
335
+ }
336
+ }, ae = (r) => {
337
+ k(r);
338
+ }, le = (r) => {
339
+ v(r.id), I((a) => [...a, r]), k(r);
340
+ }, ge = () => {
341
+ o && m(o) && (V(o.url), l());
342
+ }, se = async () => {
343
+ o && (m(o) ? (await U(o), k(null)) : oe(o) && (await s(o), k(null)));
344
+ }, de = Math.round(n * 0.8), xe = Math.round(de * 0.6);
345
+ return x ? /* @__PURE__ */ t.jsx(
346
+ we,
347
+ {
348
+ open: x,
349
+ title: /* @__PURE__ */ t.jsxs("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between" }, children: [
350
+ /* @__PURE__ */ t.jsx("span", { children: _ }),
351
+ /* @__PURE__ */ t.jsx("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-end", gap: 0, marginRight: 40, marginTop: -10 }, children: /* @__PURE__ */ t.jsx(
352
+ "button",
353
+ {
354
+ onClick: () => X(R === "thumbnail" ? "list" : "thumbnail"),
355
+ style: {
356
+ background: "none",
357
+ border: "none",
358
+ cursor: "pointer",
359
+ padding: 0,
360
+ marginTop: 8,
361
+ fontSize: 22,
362
+ color: "#222",
363
+ display: "flex",
364
+ alignItems: "center",
365
+ transition: "color 0.2s"
366
+ },
367
+ title: R === "thumbnail" ? "List view" : "Thumbnail view",
368
+ children: R === "thumbnail" ? /* @__PURE__ */ t.jsx(ke, {}) : /* @__PURE__ */ t.jsx(Re, {})
369
+ }
370
+ ) })
371
+ ] }),
372
+ onCancel: l,
373
+ footer: null,
374
+ width: de,
375
+ styles: { body: { padding: 0 } },
376
+ destroyOnHidden: !0,
377
+ maskClosable: !1,
378
+ centered: !0,
379
+ children: /* @__PURE__ */ t.jsxs("div", { className: "simple-image-asset-manager-modal", style: { padding: 24 }, children: [
380
+ /* @__PURE__ */ t.jsxs("div", { className: "modal-body", style: { display: "flex", gap: 24 }, children: [
381
+ /* @__PURE__ */ t.jsxs("div", { style: { flex: 1 }, children: [
382
+ /* @__PURE__ */ t.jsxs("div", { style: { marginBottom: 8, display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
383
+ /* @__PURE__ */ t.jsxs("div", { style: { display: "flex", alignItems: "center", flexWrap: "wrap" }, children: [
384
+ /* @__PURE__ */ t.jsx(
385
+ "span",
386
+ {
387
+ className: "breadcrumb",
388
+ onClick: () => W(-1),
389
+ style: { cursor: "pointer", color: "#1890ff", textDecoration: "underline", fontWeight: 500, maxWidth: 120, display: "inline-block", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" },
390
+ children: "All"
391
+ }
392
+ ),
393
+ F.map((r, a) => {
394
+ const p = a === F.length - 1;
395
+ return /* @__PURE__ */ t.jsxs("span", { style: { display: "flex", alignItems: "center" }, children: [
396
+ /* @__PURE__ */ t.jsx("span", { style: { margin: "0 4px", fontWeight: 500 }, children: "/" }),
397
+ p ? /* @__PURE__ */ t.jsx(
398
+ "span",
399
+ {
400
+ className: "breadcrumb",
401
+ style: { color: "#222", fontWeight: 500, maxWidth: 120, display: "inline-block", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" },
402
+ children: r.name
403
+ }
404
+ ) : /* @__PURE__ */ t.jsx(
405
+ "span",
406
+ {
407
+ className: "breadcrumb",
408
+ onClick: () => W(a),
409
+ style: { cursor: "pointer", color: "#1890ff", textDecoration: "underline", fontWeight: 500, maxWidth: 120, display: "inline-block", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" },
410
+ children: r.name
411
+ }
412
+ )
413
+ ] }, r.id);
414
+ })
415
+ ] }),
416
+ z && !G && /* @__PURE__ */ t.jsxs(
417
+ "button",
418
+ {
419
+ style: {
420
+ display: "flex",
421
+ alignItems: "center",
422
+ gap: 6,
423
+ cursor: "pointer",
424
+ userSelect: "none",
425
+ fontWeight: 500,
426
+ fontSize: 15,
427
+ padding: "8px 20px",
428
+ borderRadius: 4,
429
+ background: "#1890ff",
430
+ color: "#fff",
431
+ border: "none",
432
+ boxShadow: "0 2px 8px rgba(24,144,255,0.12)",
433
+ transition: "background 0.2s, box-shadow 0.2s"
434
+ },
435
+ onClick: () => L(!0),
436
+ children: [
437
+ /* @__PURE__ */ t.jsx("span", { children: "New folder" }),
438
+ /* @__PURE__ */ t.jsx(je, { style: { fontSize: 20 } })
439
+ ]
440
+ }
441
+ )
442
+ ] }),
443
+ /* @__PURE__ */ t.jsxs(
444
+ "div",
445
+ {
446
+ className: `drop-area${b ? " drag-active" : ""}`,
447
+ onDrop: he,
448
+ onDragOver: ee,
449
+ onDragLeave: me,
450
+ style: {
451
+ border: b ? "2px solid #1890ff" : "2px dashed #aaa",
452
+ borderRadius: 8,
453
+ padding: 32,
454
+ marginBottom: 24,
455
+ textAlign: "center",
456
+ background: b ? "#e6f7ff" : "#fafafa",
457
+ position: "relative",
458
+ transition: "border-color 0.3s, background 0.3s"
459
+ },
460
+ children: [
461
+ /* @__PURE__ */ t.jsx("div", { style: {
462
+ marginBottom: 8,
463
+ fontWeight: 500
464
+ }, children: b ? "Drop file here to upload" : "Drag & drop files here" }),
465
+ /* @__PURE__ */ t.jsx(
466
+ "button",
467
+ {
468
+ onClick: () => e.current?.click(),
469
+ disabled: A,
470
+ style: {
471
+ marginBottom: 8,
472
+ visibility: b ? "hidden" : "visible",
473
+ padding: "8px 24px",
474
+ borderRadius: 4,
475
+ background: A ? "#ccc" : "#1890ff",
476
+ color: "#fff",
477
+ border: "none",
478
+ cursor: A ? "not-allowed" : "pointer",
479
+ fontWeight: 500,
480
+ fontSize: 15,
481
+ boxShadow: A ? "none" : "0 2px 8px rgba(24,144,255,0.12)",
482
+ transition: "background 0.2s, box-shadow 0.2s"
483
+ },
484
+ children: "Upload"
485
+ }
486
+ ),
487
+ /* @__PURE__ */ t.jsx(
488
+ "input",
489
+ {
490
+ ref: e,
491
+ type: "file",
492
+ accept: d,
493
+ style: { display: "none" },
494
+ multiple: !0,
495
+ onChange: Y
496
+ }
497
+ ),
498
+ A && /* @__PURE__ */ t.jsx("div", { children: "Uploading..." })
499
+ ]
500
+ }
501
+ ),
502
+ K ? /* @__PURE__ */ t.jsx("div", { children: "Loading..." }) : q ? /* @__PURE__ */ t.jsx("div", { className: "error", children: q }) : /* @__PURE__ */ t.jsxs("div", { children: [
503
+ z && G && /* @__PURE__ */ t.jsxs("div", { style: { marginBottom: 16, display: "flex", alignItems: "center", gap: 8 }, children: [
504
+ /* @__PURE__ */ t.jsx(
505
+ "input",
506
+ {
507
+ value: O,
508
+ onChange: (r) => H(r.target.value),
509
+ placeholder: "Folder name",
510
+ style: {
511
+ padding: "8px 12px",
512
+ borderRadius: 4,
513
+ border: "1px solid #d9d9d9",
514
+ fontSize: 15,
515
+ fontWeight: 500,
516
+ outline: "none",
517
+ transition: "border-color 0.2s",
518
+ boxSizing: "border-box"
519
+ },
520
+ onFocus: (r) => r.target.style.borderColor = "#1890ff",
521
+ onBlur: (r) => r.target.style.borderColor = "#d9d9d9"
522
+ }
523
+ ),
524
+ /* @__PURE__ */ t.jsx(
525
+ "button",
526
+ {
527
+ onClick: E,
528
+ style: {
529
+ padding: "8px 16px",
530
+ borderRadius: 4,
531
+ background: "#1890ff",
532
+ color: "#fff",
533
+ border: "none",
534
+ fontWeight: 500,
535
+ fontSize: 15,
536
+ cursor: "pointer",
537
+ boxShadow: "0 2px 8px rgba(24,144,255,0.12)",
538
+ transition: "background 0.2s"
539
+ },
540
+ children: "Create"
541
+ }
542
+ ),
543
+ /* @__PURE__ */ t.jsx(
544
+ "button",
545
+ {
546
+ onClick: () => L(!1),
547
+ style: {
548
+ padding: "8px 16px",
549
+ borderRadius: 4,
550
+ background: "#f5f5f5",
551
+ color: "#222",
552
+ border: "1px solid #d9d9d9",
553
+ fontWeight: 500,
554
+ fontSize: 15,
555
+ cursor: "pointer",
556
+ transition: "background 0.2s"
557
+ },
558
+ children: "Cancel"
559
+ }
560
+ )
561
+ ] }),
562
+ R === "thumbnail" ? /* @__PURE__ */ t.jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 16 }, children: C.filter(oe).map((r) => /* @__PURE__ */ t.jsxs(
563
+ "div",
564
+ {
565
+ className: "folder-item",
566
+ style: {
567
+ cursor: "pointer",
568
+ width: 120,
569
+ minWidth: 120,
570
+ maxWidth: 120,
571
+ display: "flex",
572
+ flexDirection: "column",
573
+ alignItems: "center",
574
+ padding: 8,
575
+ borderRadius: 8,
576
+ background: "#fafafa",
577
+ boxSizing: "border-box"
578
+ },
579
+ onClick: () => le(r),
580
+ children: [
581
+ r.thumbnail ? /* @__PURE__ */ t.jsx(
582
+ "img",
583
+ {
584
+ src: r.thumbnail,
585
+ alt: r.name,
586
+ style: { width: 64, height: 64, objectFit: "cover", borderRadius: 4, marginBottom: 8, background: "#fff" }
587
+ }
588
+ ) : /* @__PURE__ */ t.jsx("div", { style: { fontSize: 40, width: 64, height: 64, display: "flex", alignItems: "center", justifyContent: "center", marginBottom: 8, background: "#fff", borderRadius: 4 }, children: "📁" }),
589
+ /* @__PURE__ */ t.jsx("div", { style: {
590
+ fontSize: 13,
591
+ fontWeight: 500,
592
+ width: "100%",
593
+ textAlign: "center",
594
+ whiteSpace: "nowrap",
595
+ overflow: "hidden",
596
+ textOverflow: "ellipsis"
597
+ }, children: r.name })
598
+ ]
599
+ },
600
+ r.id
601
+ )) }) : /* @__PURE__ */ t.jsx("div", { style: { display: "block", marginBottom: 16 }, children: C.filter(oe).map((r) => /* @__PURE__ */ t.jsxs(
602
+ "div",
603
+ {
604
+ className: "folder-item",
605
+ style: {
606
+ display: "flex",
607
+ alignItems: "center",
608
+ gap: 12,
609
+ padding: "8px 0",
610
+ borderBottom: "1px solid #f0f0f0",
611
+ cursor: "pointer"
612
+ },
613
+ onClick: () => le(r),
614
+ children: [
615
+ r.thumbnail ? /* @__PURE__ */ t.jsx(
616
+ "img",
617
+ {
618
+ src: r.thumbnail,
619
+ alt: r.name,
620
+ style: { width: 32, height: 32, objectFit: "cover", borderRadius: 4, background: "#fff" }
621
+ }
622
+ ) : /* @__PURE__ */ t.jsx("div", { style: { fontSize: 24, width: 32, height: 32, display: "flex", alignItems: "center", justifyContent: "center", background: "#fff", borderRadius: 4 }, children: "📁" }),
623
+ /* @__PURE__ */ t.jsx("div", { style: {
624
+ fontSize: 14,
625
+ fontWeight: 500,
626
+ whiteSpace: "nowrap",
627
+ overflow: "hidden",
628
+ textOverflow: "ellipsis",
629
+ flex: 1
630
+ }, children: r.name })
631
+ ]
632
+ },
633
+ r.id
634
+ )) }),
635
+ R === "thumbnail" ? /* @__PURE__ */ t.jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 16, marginTop: 16 }, children: C.filter(m).map((r) => {
636
+ const a = o && m(o) && o.id === r.id;
637
+ return /* @__PURE__ */ t.jsxs(
638
+ "div",
639
+ {
640
+ className: "file-item",
641
+ style: {
642
+ cursor: "pointer",
643
+ width: 120,
644
+ minWidth: 120,
645
+ maxWidth: 120,
646
+ border: "2px solid " + (a ? "#1890ff" : "transparent"),
647
+ background: a ? "#e6f7ff" : "#fafafa",
648
+ borderRadius: 8,
649
+ boxSizing: "border-box",
650
+ transition: "border-color 0.2s, background 0.2s",
651
+ padding: 8,
652
+ display: "flex",
653
+ flexDirection: "column",
654
+ alignItems: "center"
655
+ },
656
+ onClick: () => ae(r),
657
+ children: [
658
+ /* @__PURE__ */ t.jsx(
659
+ "img",
660
+ {
661
+ src: r.thumbnail || r.url,
662
+ alt: r.name,
663
+ style: { width: 64, height: 64, objectFit: "cover", borderRadius: 4, background: "#fff", marginBottom: 8 }
664
+ }
665
+ ),
666
+ /* @__PURE__ */ t.jsx("div", { style: {
667
+ fontSize: 12,
668
+ fontWeight: 500,
669
+ width: "100%",
670
+ textAlign: "center",
671
+ whiteSpace: "nowrap",
672
+ overflow: "hidden",
673
+ textOverflow: "ellipsis",
674
+ marginTop: 4
675
+ }, children: r.name })
676
+ ]
677
+ },
678
+ r.id
679
+ );
680
+ }) }) : /* @__PURE__ */ t.jsx("div", { style: { display: "block", marginTop: 16 }, children: C.filter(m).map((r) => {
681
+ const a = o && m(o) && o.id === r.id;
682
+ return /* @__PURE__ */ t.jsxs(
683
+ "div",
684
+ {
685
+ className: "file-item",
686
+ style: {
687
+ display: "flex",
688
+ alignItems: "center",
689
+ gap: 12,
690
+ padding: "8px 0",
691
+ borderBottom: "1px solid #f0f0f0",
692
+ cursor: "pointer",
693
+ background: a ? "#e6f7ff" : "#fff"
694
+ },
695
+ onClick: () => ae(r),
696
+ children: [
697
+ /* @__PURE__ */ t.jsx(
698
+ "img",
699
+ {
700
+ src: r.thumbnail || r.url,
701
+ alt: r.name,
702
+ style: { width: 32, height: 32, objectFit: "cover", borderRadius: 4, background: "#fff" }
703
+ }
704
+ ),
705
+ /* @__PURE__ */ t.jsx("div", { style: {
706
+ fontSize: 14,
707
+ fontWeight: 500,
708
+ whiteSpace: "nowrap",
709
+ overflow: "hidden",
710
+ textOverflow: "ellipsis",
711
+ flex: 1
712
+ }, children: r.name })
713
+ ]
714
+ },
715
+ r.id
716
+ );
717
+ }) })
718
+ ] })
719
+ ] }),
720
+ o && /* @__PURE__ */ t.jsx("div", { style: { width: xe, minWidth: 320, transition: "width 2s", overflow: "hidden" }, children: /* @__PURE__ */ t.jsxs("div", { style: {
721
+ border: "1px solid #eee",
722
+ borderRadius: 8,
723
+ padding: 16,
724
+ background: "#fff",
725
+ height: "100%",
726
+ display: "flex",
727
+ flexDirection: "column",
728
+ alignItems: "center",
729
+ position: "relative"
730
+ }, children: [
731
+ /* @__PURE__ */ t.jsx(
732
+ "button",
733
+ {
734
+ onClick: () => k(null),
735
+ style: {
736
+ position: "absolute",
737
+ top: 12,
738
+ right: 12,
739
+ background: "#f5f5f5",
740
+ border: "none",
741
+ borderRadius: 4,
742
+ padding: "4px 12px",
743
+ cursor: "pointer",
744
+ fontWeight: 500,
745
+ fontSize: 14,
746
+ color: "#222",
747
+ boxShadow: "0 1px 4px rgba(0,0,0,0.08)"
748
+ },
749
+ children: "Hide"
750
+ }
751
+ ),
752
+ m(o) ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
753
+ /* @__PURE__ */ t.jsx("img", { src: o.thumbnail || o.url, alt: o.name, style: { width: "100%", maxHeight: 240, objectFit: "contain", borderRadius: 4, marginBottom: 16 } }),
754
+ /* @__PURE__ */ t.jsx("div", { style: { fontWeight: 500, marginBottom: 8 }, children: o.name }),
755
+ /* @__PURE__ */ t.jsx("div", { style: { fontSize: 12, color: "#888", marginBottom: 8 }, children: o.url.startsWith("data:") ? "URL: data-uri" : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
756
+ "URL: ",
757
+ /* @__PURE__ */ t.jsx("a", { href: o.url, target: "_blank", rel: "noopener noreferrer", children: o.url })
758
+ ] }) }),
759
+ /* @__PURE__ */ t.jsxs(
760
+ "button",
761
+ {
762
+ onClick: se,
763
+ style: {
764
+ display: "flex",
765
+ alignItems: "center",
766
+ gap: 6,
767
+ color: "#ff4d4f",
768
+ background: "none",
769
+ border: "none",
770
+ cursor: "pointer",
771
+ fontWeight: 500,
772
+ fontSize: 15,
773
+ marginTop: 24
774
+ },
775
+ children: [
776
+ /* @__PURE__ */ t.jsx(ce, {}),
777
+ " Delete"
778
+ ]
779
+ }
780
+ )
781
+ ] }) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
782
+ /* @__PURE__ */ t.jsx("div", { style: { fontSize: 64, marginBottom: 16 }, children: "📁" }),
783
+ /* @__PURE__ */ t.jsx("div", { style: { fontWeight: 500, marginBottom: 8 }, children: o.name }),
784
+ /* @__PURE__ */ t.jsx("div", { style: { fontSize: 12, color: "#888", marginBottom: 8 }, children: `Files: ${C.filter((r) => m(r) && r.parentFolderId === o.id).length}` }),
785
+ /* @__PURE__ */ t.jsxs(
786
+ "button",
787
+ {
788
+ onClick: se,
789
+ style: {
790
+ display: "flex",
791
+ alignItems: "center",
792
+ gap: 6,
793
+ color: "#ff4d4f",
794
+ background: "none",
795
+ border: "none",
796
+ cursor: "pointer",
797
+ fontWeight: 500,
798
+ fontSize: 15,
799
+ marginTop: 24
800
+ },
801
+ children: [
802
+ /* @__PURE__ */ t.jsx(ce, {}),
803
+ " Delete"
804
+ ]
805
+ }
806
+ )
807
+ ] })
808
+ ] }) })
809
+ ] }),
810
+ /* @__PURE__ */ t.jsx(
811
+ "div",
812
+ {
813
+ className: "modal-footer",
814
+ style: { display: "flex", justifyContent: "flex-end", alignItems: "center", marginTop: 24 },
815
+ children: /* @__PURE__ */ t.jsx(
816
+ "button",
817
+ {
818
+ onClick: ge,
819
+ disabled: !(o && m(o)),
820
+ style: {
821
+ padding: "8px 24px",
822
+ borderRadius: 4,
823
+ background: o && m(o) ? "#1890ff" : "#ccc",
824
+ color: "#fff",
825
+ border: "none",
826
+ cursor: o && m(o) ? "pointer" : "not-allowed",
827
+ fontWeight: 500
828
+ },
829
+ children: "Select"
830
+ }
831
+ )
832
+ }
833
+ )
834
+ ] })
835
+ }
836
+ ) : null;
837
+ };
838
+ export {
839
+ Ae as AssetManager
840
+ };
@@ -0,0 +1 @@
1
+ .error{color:#c00;margin:1rem 0}
@@ -0,0 +1,44 @@
1
+ export interface FileItem {
2
+ id: string;
3
+ url: string;
4
+ type: "FILE";
5
+ name: string;
6
+ parentFolderId: string | null;
7
+ thumbnail?: string;
8
+ }
9
+ export interface FolderItem {
10
+ id: string;
11
+ name: string;
12
+ type: "FOLDER";
13
+ parentFolderId: string | null;
14
+ thumbnail?: string;
15
+ count?: number;
16
+ }
17
+ export interface AssetManagerProps {
18
+ accept?: string;
19
+ request: (folderId?: string) => Promise<Array<FileItem | FolderItem>>;
20
+ title?: string;
21
+ upload: (blob: Blob) => Promise<string>;
22
+ onCreateFile: (params: {
23
+ name: string;
24
+ url: string;
25
+ parentFolderId: string | null;
26
+ }) => Promise<FileItem>;
27
+ onDeleteFile: (params: {
28
+ id: string;
29
+ }) => Promise<boolean>;
30
+ onDeleteFolder: (params: {
31
+ id: string;
32
+ }) => Promise<boolean>;
33
+ onUpdateFile: (item: FileItem) => Promise<FileItem>;
34
+ onUpdateFolder: (item: FolderItem) => Promise<FolderItem>;
35
+ onCreateFolder: (params: {
36
+ name: string;
37
+ parentFolderId: string | null;
38
+ }) => Promise<FolderItem>;
39
+ onSelect: (url: string) => void;
40
+ visible?: boolean;
41
+ setVisible: React.Dispatch<React.SetStateAction<boolean>>;
42
+ showUnacceptedFile?: boolean;
43
+ addFolderEnabled?: boolean;
44
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@thanhpv102/simple-image-asset-manager",
3
+ "version": "0.1.0",
4
+ "main": "dist/index.cjs",
5
+ "module": "dist/index.js",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "peerDependencies": {
10
+ "react": "^19.0.0",
11
+ "react-dom": "^19.0.0"
12
+ },
13
+ "dependencies": {
14
+ "@ant-design/icons": "^6.1.0",
15
+ "antd": "^6.0.0",
16
+ "cropperjs": "^1.5.13"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^19.0.2",
20
+ "@types/react-dom": "^19.0.2",
21
+ "react": "^19.0.0",
22
+ "react-dom": "^19.0.0",
23
+ "typescript": "^5.0.0",
24
+ "vite": "^7.1.11"
25
+ },
26
+ "license": "MIT",
27
+ "description": "A comprehensive file/image asset manager modal for easy-email-editor.",
28
+ "author": "thanhpv102",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/thanhpv102/easy-email-editor/tree/master/packages/simple-image-asset-manager"
32
+ },
33
+ "keywords": [
34
+ "react",
35
+ "image",
36
+ "asset",
37
+ "manager",
38
+ "modal",
39
+ "easy-email-editor"
40
+ ],
41
+ "exports": {
42
+ ".": {
43
+ "import": "./dist/index.js",
44
+ "require": "./dist/index.cjs"
45
+ }
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "scripts": {
51
+ "build": "vite build",
52
+ "dev": "vite",
53
+ "typecheck": "tsc --noEmit"
54
+ }
55
+ }