@chaibuilder/pages 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{B4MFY5CR-B0gjiEA3.js → B4MFY5CR-BZLbrbU9.js} +1 -1
- package/dist/{B4MFY5CR-0MVmdo7C.cjs → B4MFY5CR-CrFfLRY2.cjs} +1 -1
- package/dist/{HO4MOOFI-r2V7_ve4.cjs → HO4MOOFI-CpUW02ii.cjs} +1 -1
- package/dist/{HO4MOOFI-CIV6iAkb.js → HO4MOOFI-DgTndXY6.js} +2 -2
- package/dist/{HUY7CZI3-Chau07Me.js → HUY7CZI3-B-83eNUU.js} +2 -2
- package/dist/{HUY7CZI3-D-0djGVi.cjs → HUY7CZI3-COZlEkVr.cjs} +1 -1
- package/dist/digital-asset-manager-DZTV3jDX.cjs +1 -0
- package/dist/{digital-asset-manager-CBaY202W.js → digital-asset-manager-cGBJUg2A.js} +104 -104
- package/dist/index-B3cE059x.cjs +2 -0
- package/dist/{index-CSVDtkP9.js → index-CCLkatX6.js} +744 -712
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/digital-asset-manager-BopT8BhD.cjs +0 -1
- package/dist/index-Cv2dcnN-.cjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-CrFfLRY2.cjs"),t=require("./index-B3cE059x.cjs");var s=c=>{const[r,o]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),l=t.getPreferredColorScheme(),a=t.createMemo(()=>{const n=r.theme_preference||e.THEME_PREFERENCE;return n!=="system"?n:l()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:c,get children(){return t.createComponent(e.PiPProvider,{localStore:r,setLocalStore:o,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.Devtools,{localStore:r,setLocalStore:o})}})}})}})},u=s;exports.default=u;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-
|
|
2
|
-
import { g as d, c as f, a as e } from "./index-
|
|
1
|
+
import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-BZLbrbU9.js";
|
|
2
|
+
import { g as d, c as f, a as e } from "./index-CCLkatX6.js";
|
|
3
3
|
var p = (a) => {
|
|
4
4
|
const [r, t] = c({
|
|
5
5
|
prefix: "TanstackQueryDevtools"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./B4MFY5CR-
|
|
2
|
-
import { g as v, c as C, a as e } from "./index-
|
|
1
|
+
import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./B4MFY5CR-BZLbrbU9.js";
|
|
2
|
+
import { g as v, c as C, a as e } from "./index-CCLkatX6.js";
|
|
3
3
|
var h = (t) => {
|
|
4
4
|
const [r, o] = s({
|
|
5
5
|
prefix: "TanstackQueryDevtools"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-CrFfLRY2.cjs"),t=require("./index-B3cE059x.cjs");var u=o=>{const[r,n]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),c=t.getPreferredColorScheme(),a=t.createMemo(()=>{const l=r.theme_preference||e.THEME_PREFERENCE;return l!=="system"?l:c()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:o,get children(){return t.createComponent(e.PiPProvider,{disabled:!0,localStore:r,setLocalStore:n,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.ParentPanel,{get children(){return t.createComponent(e.ContentView,{localStore:r,setLocalStore:n,get onClose(){return o.onClose},showPanelViewOnly:!0})}})}})}})}})},i=u;exports.default=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),L=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),B=require("lodash-es"),j=require("lucide-react"),X=require("react-dropzone"),A=require("@tanstack/react-query"),b=require("sonner"),a=require("./index-B3cE059x.cjs"),Z=()=>{const n=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async({file:r,folderId:m,name:h})=>d(n,{action:a.ACTIONS.UPLOAD_ASSET,data:{file:r,folderId:m,name:h}}),onSuccess:()=>{c.invalidateQueries({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS]}),b.toast.success("Asset uploaded successfully")},onError:()=>{b.toast.error("Failed to upload asset")}})},ee=()=>{const n=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async r=>d(n,{action:a.ACTIONS.DELETE_ASSET,data:{id:r}}),onSuccess:()=>{c.invalidateQueries({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS]}),b.toast.success("Asset deleted successfully")},onError:()=>{b.toast.error("Failed to delete asset")}})},se=()=>{const n=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async r=>d(n,{action:a.ACTIONS.UPDATE_ASSET,data:r}),onSuccess:()=>{c.invalidateQueries({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS]}),b.toast.success("Asset updated successfully")},onError:()=>{b.toast.error("Failed to update asset")}})},te=(n={})=>{const c=a.useAssetsApiUrl(),d=a.useFetch(),{search:r,page:m=1,limit:h=10}=n;return A.useQuery({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS,r,m,h],queryFn:async()=>(await d(c,{action:a.ACTIONS.GET_ASSETS,data:{search:r,page:m,limit:h}})).data,retry:1})};function ae(){const[c,d]=l.useState([]),[r,m]=l.useState({query:"",page:1,pageSize:10}),h=B.debounce(()=>r.query,300)(),{data:o,isLoading:w}=te({search:(h==null?void 0:h.toLowerCase().trim())||"",page:r.page,limit:r.pageSize}),y=o?Math.ceil(o.total/o.pageSize):0,u=(o==null?void 0:o.page)||1,p=u<y,g=u>1,{mutate:C,isPending:P}=se(),{mutate:N,isPending:f}=Z(),{mutate:E,isPending:T}=ee(),v=l.useCallback(x=>{x>=1&&x<=y&&m(S=>({...S,page:x}))},[y]),q=l.useCallback(()=>{p&&v(u+1)},[u,p,v]),F=l.useCallback(()=>{g&&v(u-1)},[u,g,v]),I=l.useCallback(x=>{m(S=>({...S,query:x,page:1}))},[]),D=l.useCallback(x=>{d(S=>B.find(S,{id:x.id})?[]:[x])},[!1]),k=l.useCallback(()=>{d([])},[]);return{query:(r==null?void 0:r.query)||"",selectedAssets:c,assets:(o==null?void 0:o.assets)||[],currentPage:u,totalPages:y,hasNextPage:p,hasPreviousPage:g,uploadAsset:N,updateAsset:C,deleteAsset:E,goToPage:v,nextPage:q,previousPage:F,updateSearchQuery:I,clearSelectedAssets:k,updateSelectedAssets:D,isLoadingAssets:w,isUploadingAsset:f,isUpdatingAsset:P,isDeletingAsset:T}}const le=l.lazy(()=>Promise.resolve().then(()=>require("./asset-metadata-editor-zw9u1BB9.cjs"))),ne=l.lazy(()=>Promise.resolve().then(()=>require("./image-editor-D8wu5UNM.cjs")));function ie({close:n,onSelect:c,mode:d="image"}){const m=l.useMemo(()=>[d],[d]),[h,o]=l.useState("browse"),[w,y]=l.useState(null),[u,p]=l.useState(null),[g,C]=l.useState({show:!1,file:""}),{query:P,assets:N,selectedAssets:f,uploadAsset:E,updateAsset:T,deleteAsset:v,updateSearchQuery:q,clearSelectedAssets:F,updateSelectedAssets:I,isLoadingAssets:D,isUploadingAsset:k,isUpdatingAsset:x}=ae(),S=l.useRef(null),_=l.useCallback(async s=>new Promise((i,z)=>{const Q=s[0],U=new FileReader;U.readAsDataURL(Q),U.onload=async()=>{const M=await E({file:U.result,folderId:null,name:Q.name});o("browse"),i(M)},U.onerror=M=>z(M)}),[E]),{getRootProps:O,getInputProps:R,isDragActive:K}=X.useDropzone({onDrop:_,accept:{"image/*":m.includes("image")?[]:[],"video/*":m.includes("video")?[]:[]},maxSize:10*1024*1024}),Y=()=>{c([f[0].url]),n()},G=async s=>{p(s)},$=async()=>{u&&(await v(u.id),p(null))},H=s=>{y(s)},V=async(s,i)=>{await T(B.merge(s,i)),n()},J=s=>{q(s.target.value)},W=async(s,i)=>{try{i?await E({file:s,folderId:null,name:g.name||""}):await T({id:g.id||"",file:s}),C({show:!1,file:""}),o("browse")}catch(z){console.error("Error saving edited image:",z)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-[700px] min-h-[600px] w-[900px] max-w-[900px]",children:[e.jsx("h1",{className:"text-lg font-medium pb-4",children:"Digital Asset Manager"}),e.jsxs(t.Tabs,{value:h,onValueChange:s=>o(s),className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs(t.TabsList,{children:[e.jsx(t.TabsTrigger,{value:"browse",children:"Browse Assets"}),e.jsx(t.TabsTrigger,{value:"upload",children:"Upload"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[f.length>0&&e.jsx(e.Fragment,{children:e.jsx(t.Button,{variant:"outline",size:"sm",onClick:()=>F(),title:"Clear selection",children:"Clear"})}),e.jsx(t.Button,{size:"sm",onClick:Y,disabled:f.length===0,children:"Select Asset"})]})]}),e.jsxs(t.TabsContent,{value:"browse",className:"flex-1 flex flex-col",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsxs("div",{className:"relative w-full",children:[e.jsx(j.Search,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(t.Input,{placeholder:"Search assets...",value:P,onChange:J,className:"pl-8"})]})}),D&&N.length===0?e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",children:[e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"})]}):N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-12 h-[380px]",children:[e.jsxs("div",{className:"text-muted-foreground mb-2",children:[e.jsx("h3",{className:"text-gray-800 font-medium",children:"No assets to display"}),e.jsx("p",{className:"text-sm",children:"You haven't uploaded any assets yet. Start by uploading your first asset."})]}),e.jsx("div",{className:"flex gap-2 pt-4",children:e.jsx(t.Button,{size:"lg",onClick:()=>o("upload"),children:"Upload Assets"})})]}):e.jsxs("div",{ref:S,className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",children:[N.map(s=>e.jsx(t.Card,{className:L.mergeClasses("cursor-pointer overflow-hidden transition-all",f.some(i=>i.id===s.id)?"ring-2 ring-primary":"hover:ring-2 hover:ring-primary/20"),onClick:()=>I(s),children:e.jsxs(t.CardContent,{className:"p-0 relative group",children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden bg-muted",children:[s.type==="image"?e.jsx("img",{src:s.thumbnailUrl||"/placeholder.svg",alt:s.name,className:"object-cover w-full h-full"}):e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(j.Film,{className:"h-12 w-12 text-muted-foreground"}),s.thumbnailUrl&&e.jsx("img",{src:s.thumbnailUrl||"/placeholder.svg",alt:s.name,className:"absolute inset-0 object-cover w-full h-full"})]}),e.jsxs("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(t.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:i=>{i.stopPropagation(),H(s)},children:e.jsx(j.ImageIcon,{className:"h-4 w-4"})}),e.jsx(t.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:i=>{i.stopPropagation(),C({id:s.id,show:!0,file:s.url,name:s.name})},children:e.jsx(j.Edit,{className:"h-4 w-4"})}),e.jsx(t.Button,{variant:"destructive",size:"icon",className:"h-8 w-8",onClick:i=>{i.stopPropagation(),G(s)},children:e.jsx(j.Trash2,{className:"h-4 w-4"})})]}),f.some(i=>i.id===s.id)&&e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("input",{type:"checkbox",checked:f.some(i=>i.id===s.id),readOnly:!0,className:"rounded-full"})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-sm font-medium truncate",title:s.name,children:s.name}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center justify-between",children:[e.jsx("span",{children:re((s==null?void 0:s.size)||0)}),e.jsx("span",{children:oe(s.createdAt)})]})]})]})},s.id)),D&&N.length>0&&e.jsx("div",{className:"col-span-full flex justify-center py-4",children:e.jsx(j.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),e.jsx(t.TabsContent,{value:"upload",className:"flex-1 ",children:e.jsxs("div",{...O(),className:L.mergeClasses("border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",K?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...R()}),x||k?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(j.Loader2,{className:"h-12 w-12 text-primary animate-spin mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-1",children:"Uploading files..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please wait while your files are being processed."})]}):e.jsxs(e.Fragment,{children:[e.jsx(j.Upload,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-1",children:"Drag & drop files here"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"or click to browse your files"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Accepted file types: ",m.join(", ")]}),e.jsxs("p",{children:["Maximum file size: ",10,"MB"]})]})]})]})})]})]}),w&&e.jsx(l.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(le,{asset:w,onSave:s=>V(w,s),onCancel:()=>{y(null)}})}),g.show&&e.jsx(l.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(ne,{imageUrl:g.file,onSave:W,onClose:()=>C({show:!1,file:""}),defaultSavedImageName:g.name,isEditing:!!g.id})}),u&&e.jsx(t.Dialog,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Delete Asset"}),e.jsxs(t.DialogDescription,{children:['Are you sure you want to delete "',u.name,'"? This action cannot be undone.']})]}),e.jsxs(t.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(t.Button,{variant:"outline",onClick:()=>p(null),children:"Cancel"}),e.jsx(t.Button,{variant:"destructive",onClick:$,children:"Delete"})]})]})})]})}function re(n){return n<1024?`${n.toFixed(2)} KB`:`${(n/1024).toFixed(2)} MB`}function oe(n){const c=new Date(n);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(c)}exports.default=ie;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as a, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import { mergeClasses as
|
|
4
|
-
import { Tabs as
|
|
5
|
-
import { debounce as
|
|
6
|
-
import { Search as
|
|
7
|
-
import { useDropzone as
|
|
8
|
-
import { useQueryClient as
|
|
1
|
+
import { jsxs as a, Fragment as Q, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import X, { useState as S, useCallback as A, useMemo as oe, useRef as ce, Suspense as Y } from "react";
|
|
3
|
+
import { mergeClasses as $ } from "@chaibuilder/sdk";
|
|
4
|
+
import { Tabs as de, TabsList as ue, TabsTrigger as H, Button as f, TabsContent as V, Input as me, Card as he, CardContent as ge, Dialog as pe, DialogContent as fe, DialogHeader as ye, DialogTitle as ve, DialogDescription as xe, DialogFooter as Ne } from "@chaibuilder/sdk/ui";
|
|
5
|
+
import { debounce as Ae, find as we, merge as Se } from "lodash-es";
|
|
6
|
+
import { Search as be, Film as Ce, ImageIcon as Ee, Edit as Te, Trash2 as De, Loader2 as W, Upload as Pe } from "lucide-react";
|
|
7
|
+
import { useDropzone as Ue } from "react-dropzone";
|
|
8
|
+
import { useQueryClient as R, useMutation as K, useQuery as ze } from "@tanstack/react-query";
|
|
9
9
|
import { toast as b } from "sonner";
|
|
10
|
-
import { W as z, X as F, Y as y, Z as
|
|
10
|
+
import { W as z, X as F, Y as y, Z as M } from "./index-CCLkatX6.js";
|
|
11
11
|
const Fe = () => {
|
|
12
|
-
const t = z(), r =
|
|
13
|
-
return
|
|
12
|
+
const t = z(), r = R(), o = F();
|
|
13
|
+
return K({
|
|
14
14
|
mutationFn: async ({
|
|
15
15
|
file: i,
|
|
16
16
|
folderId: d,
|
|
@@ -21,7 +21,7 @@ const Fe = () => {
|
|
|
21
21
|
}),
|
|
22
22
|
onSuccess: () => {
|
|
23
23
|
r.invalidateQueries({
|
|
24
|
-
queryKey: [y.GET_ASSETS]
|
|
24
|
+
queryKey: [M, y.GET_ASSETS]
|
|
25
25
|
}), b.success("Asset uploaded successfully");
|
|
26
26
|
},
|
|
27
27
|
onError: () => {
|
|
@@ -29,15 +29,15 @@ const Fe = () => {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
}, Me = () => {
|
|
32
|
-
const t = z(), r =
|
|
33
|
-
return
|
|
32
|
+
const t = z(), r = R(), o = F();
|
|
33
|
+
return K({
|
|
34
34
|
mutationFn: async (i) => o(t, {
|
|
35
35
|
action: y.DELETE_ASSET,
|
|
36
36
|
data: { id: i }
|
|
37
37
|
}),
|
|
38
38
|
onSuccess: () => {
|
|
39
39
|
r.invalidateQueries({
|
|
40
|
-
queryKey: [y.GET_ASSETS]
|
|
40
|
+
queryKey: [M, y.GET_ASSETS]
|
|
41
41
|
}), b.success("Asset deleted successfully");
|
|
42
42
|
},
|
|
43
43
|
onError: () => {
|
|
@@ -45,15 +45,15 @@ const Fe = () => {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
}, Ie = () => {
|
|
48
|
-
const t = z(), r =
|
|
49
|
-
return
|
|
48
|
+
const t = z(), r = R(), o = F();
|
|
49
|
+
return K({
|
|
50
50
|
mutationFn: async (i) => o(t, {
|
|
51
51
|
action: y.UPDATE_ASSET,
|
|
52
52
|
data: i
|
|
53
53
|
}),
|
|
54
54
|
onSuccess: () => {
|
|
55
55
|
r.invalidateQueries({
|
|
56
|
-
queryKey: [y.GET_ASSETS]
|
|
56
|
+
queryKey: [M, y.GET_ASSETS]
|
|
57
57
|
}), b.success("Asset updated successfully");
|
|
58
58
|
},
|
|
59
59
|
onError: () => {
|
|
@@ -62,8 +62,8 @@ const Fe = () => {
|
|
|
62
62
|
});
|
|
63
63
|
}, ke = (t = {}) => {
|
|
64
64
|
const r = z(), o = F(), { search: i, page: d = 1, limit: u = 10 } = t;
|
|
65
|
-
return
|
|
66
|
-
queryKey: [
|
|
65
|
+
return ze({
|
|
66
|
+
queryKey: [M, y.GET_ASSETS, i, d, u],
|
|
67
67
|
queryFn: async () => (await o(r, {
|
|
68
68
|
action: y.GET_ASSETS,
|
|
69
69
|
data: {
|
|
@@ -80,11 +80,11 @@ function qe() {
|
|
|
80
80
|
query: "",
|
|
81
81
|
page: 1,
|
|
82
82
|
pageSize: 10
|
|
83
|
-
}), u =
|
|
83
|
+
}), u = Ae(() => i.query, 300)(), { data: n, isLoading: C } = ke({
|
|
84
84
|
search: (u == null ? void 0 : u.toLowerCase().trim()) || "",
|
|
85
85
|
page: i.page,
|
|
86
86
|
limit: i.pageSize
|
|
87
|
-
}), v = n ? Math.ceil(n.total / n.pageSize) : 0, c = (n == null ? void 0 : n.page) || 1, g = c < v, m = c > 1, { mutate: E, isPending:
|
|
87
|
+
}), v = n ? Math.ceil(n.total / n.pageSize) : 0, c = (n == null ? void 0 : n.page) || 1, g = c < v, m = c > 1, { mutate: E, isPending: I } = Ie(), { mutate: w, isPending: p } = Fe(), { mutate: T, isPending: D } = Me(), x = A(
|
|
88
88
|
(h) => {
|
|
89
89
|
h >= 1 && h <= v && d((N) => ({
|
|
90
90
|
...N,
|
|
@@ -92,11 +92,11 @@ function qe() {
|
|
|
92
92
|
}));
|
|
93
93
|
},
|
|
94
94
|
[v]
|
|
95
|
-
),
|
|
95
|
+
), k = A(() => {
|
|
96
96
|
g && x(c + 1);
|
|
97
|
-
}, [c, g, x]),
|
|
97
|
+
}, [c, g, x]), q = A(() => {
|
|
98
98
|
m && x(c - 1);
|
|
99
|
-
}, [c, m, x]),
|
|
99
|
+
}, [c, m, x]), j = A((h) => {
|
|
100
100
|
d((N) => ({
|
|
101
101
|
...N,
|
|
102
102
|
query: h,
|
|
@@ -105,10 +105,10 @@ function qe() {
|
|
|
105
105
|
}));
|
|
106
106
|
}, []), P = A(
|
|
107
107
|
(h) => {
|
|
108
|
-
o((N) =>
|
|
108
|
+
o((N) => we(N, { id: h.id }) ? [] : [h]);
|
|
109
109
|
},
|
|
110
110
|
[!1]
|
|
111
|
-
),
|
|
111
|
+
), _ = A(() => {
|
|
112
112
|
o([]);
|
|
113
113
|
}, []);
|
|
114
114
|
return {
|
|
@@ -125,74 +125,74 @@ function qe() {
|
|
|
125
125
|
updateAsset: E,
|
|
126
126
|
deleteAsset: T,
|
|
127
127
|
goToPage: x,
|
|
128
|
-
nextPage:
|
|
129
|
-
previousPage:
|
|
130
|
-
updateSearchQuery:
|
|
131
|
-
clearSelectedAssets:
|
|
128
|
+
nextPage: k,
|
|
129
|
+
previousPage: q,
|
|
130
|
+
updateSearchQuery: j,
|
|
131
|
+
clearSelectedAssets: _,
|
|
132
132
|
updateSelectedAssets: P,
|
|
133
133
|
// Loading
|
|
134
134
|
isLoadingAssets: C,
|
|
135
135
|
isUploadingAsset: p,
|
|
136
|
-
isUpdatingAsset:
|
|
136
|
+
isUpdatingAsset: I,
|
|
137
137
|
isDeletingAsset: D
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
const je =
|
|
140
|
+
const je = X.lazy(() => import("./asset-metadata-editor-r5vYHUfm.js")), _e = X.lazy(() => import("./image-editor-CwVua57o.js"));
|
|
141
141
|
function Xe({
|
|
142
142
|
close: t,
|
|
143
143
|
onSelect: r,
|
|
144
144
|
mode: o = "image"
|
|
145
145
|
}) {
|
|
146
|
-
const d =
|
|
146
|
+
const d = oe(() => [o], [o]), [u, n] = S("browse"), [C, v] = S(null), [c, g] = S(null), [m, E] = S({ show: !1, file: "" }), {
|
|
147
147
|
// Data
|
|
148
|
-
query:
|
|
148
|
+
query: I,
|
|
149
149
|
assets: w,
|
|
150
150
|
selectedAssets: p,
|
|
151
151
|
// Mutations
|
|
152
152
|
uploadAsset: T,
|
|
153
153
|
updateAsset: D,
|
|
154
154
|
deleteAsset: x,
|
|
155
|
-
updateSearchQuery:
|
|
156
|
-
clearSelectedAssets:
|
|
157
|
-
updateSelectedAssets:
|
|
155
|
+
updateSearchQuery: k,
|
|
156
|
+
clearSelectedAssets: q,
|
|
157
|
+
updateSelectedAssets: j,
|
|
158
158
|
// Loading
|
|
159
159
|
isLoadingAssets: P,
|
|
160
|
-
isUploadingAsset:
|
|
160
|
+
isUploadingAsset: _,
|
|
161
161
|
isUpdatingAsset: h
|
|
162
162
|
// isDeletingAsset,
|
|
163
|
-
} = qe(), N =
|
|
164
|
-
async (s) => new Promise((l,
|
|
165
|
-
const
|
|
166
|
-
U.readAsDataURL(
|
|
167
|
-
const
|
|
163
|
+
} = qe(), N = ce(null), G = A(
|
|
164
|
+
async (s) => new Promise((l, L) => {
|
|
165
|
+
const O = s[0], U = new FileReader();
|
|
166
|
+
U.readAsDataURL(O), U.onload = async () => {
|
|
167
|
+
const B = await T({
|
|
168
168
|
file: U.result,
|
|
169
169
|
folderId: null,
|
|
170
|
-
name:
|
|
170
|
+
name: O.name
|
|
171
171
|
});
|
|
172
|
-
n("browse"), l(
|
|
173
|
-
}, U.onerror = (
|
|
172
|
+
n("browse"), l(B);
|
|
173
|
+
}, U.onerror = (B) => L(B);
|
|
174
174
|
}),
|
|
175
175
|
[T]
|
|
176
|
-
), { getRootProps:
|
|
177
|
-
onDrop:
|
|
176
|
+
), { getRootProps: Z, getInputProps: J, isDragActive: ee } = Ue({
|
|
177
|
+
onDrop: G,
|
|
178
178
|
accept: {
|
|
179
179
|
"image/*": d.includes("image") ? [] : [],
|
|
180
180
|
"video/*": d.includes("video") ? [] : []
|
|
181
181
|
},
|
|
182
182
|
maxSize: 10 * 1024 * 1024
|
|
183
|
-
}),
|
|
183
|
+
}), se = () => {
|
|
184
184
|
r([p[0].url]), t();
|
|
185
|
-
},
|
|
185
|
+
}, ae = async (s) => {
|
|
186
186
|
g(s);
|
|
187
|
-
},
|
|
187
|
+
}, te = async () => {
|
|
188
188
|
c && (await x(c.id), g(null));
|
|
189
|
-
},
|
|
189
|
+
}, le = (s) => {
|
|
190
190
|
v(s);
|
|
191
|
-
},
|
|
192
|
-
await D(
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
},
|
|
191
|
+
}, ie = async (s, l) => {
|
|
192
|
+
await D(Se(s, l)), t();
|
|
193
|
+
}, ne = (s) => {
|
|
194
|
+
k(s.target.value);
|
|
195
|
+
}, re = async (s, l) => {
|
|
196
196
|
try {
|
|
197
197
|
l ? await T({
|
|
198
198
|
file: s,
|
|
@@ -202,32 +202,32 @@ function Xe({
|
|
|
202
202
|
id: m.id || "",
|
|
203
203
|
file: s
|
|
204
204
|
}), E({ show: !1, file: "" }), n("browse");
|
|
205
|
-
} catch (
|
|
206
|
-
console.error("Error saving edited image:",
|
|
205
|
+
} catch (L) {
|
|
206
|
+
console.error("Error saving edited image:", L);
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
|
-
return /* @__PURE__ */ a(
|
|
209
|
+
return /* @__PURE__ */ a(Q, { children: [
|
|
210
210
|
/* @__PURE__ */ a("div", { className: "min-w-[700px] min-h-[600px] w-[900px] max-w-[900px]", children: [
|
|
211
211
|
/* @__PURE__ */ e("h1", { className: "text-lg font-medium pb-4", children: "Digital Asset Manager" }),
|
|
212
212
|
/* @__PURE__ */ a(
|
|
213
|
-
|
|
213
|
+
de,
|
|
214
214
|
{
|
|
215
215
|
value: u,
|
|
216
216
|
onValueChange: (s) => n(s),
|
|
217
217
|
className: "flex-1 flex flex-col h-full",
|
|
218
218
|
children: [
|
|
219
219
|
/* @__PURE__ */ a("div", { className: "flex justify-between items-center mb-2", children: [
|
|
220
|
-
/* @__PURE__ */ a(
|
|
221
|
-
/* @__PURE__ */ e(
|
|
222
|
-
/* @__PURE__ */ e(
|
|
220
|
+
/* @__PURE__ */ a(ue, { children: [
|
|
221
|
+
/* @__PURE__ */ e(H, { value: "browse", children: "Browse Assets" }),
|
|
222
|
+
/* @__PURE__ */ e(H, { value: "upload", children: "Upload" })
|
|
223
223
|
] }),
|
|
224
224
|
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
225
|
-
p.length > 0 && /* @__PURE__ */ e(
|
|
225
|
+
p.length > 0 && /* @__PURE__ */ e(Q, { children: /* @__PURE__ */ e(
|
|
226
226
|
f,
|
|
227
227
|
{
|
|
228
228
|
variant: "outline",
|
|
229
229
|
size: "sm",
|
|
230
|
-
onClick: () =>
|
|
230
|
+
onClick: () => q(),
|
|
231
231
|
title: "Clear selection",
|
|
232
232
|
children: "Clear"
|
|
233
233
|
}
|
|
@@ -236,22 +236,22 @@ function Xe({
|
|
|
236
236
|
f,
|
|
237
237
|
{
|
|
238
238
|
size: "sm",
|
|
239
|
-
onClick:
|
|
239
|
+
onClick: se,
|
|
240
240
|
disabled: p.length === 0,
|
|
241
241
|
children: "Select Asset"
|
|
242
242
|
}
|
|
243
243
|
)
|
|
244
244
|
] })
|
|
245
245
|
] }),
|
|
246
|
-
/* @__PURE__ */ a(
|
|
246
|
+
/* @__PURE__ */ a(V, { value: "browse", className: "flex-1 flex flex-col", children: [
|
|
247
247
|
/* @__PURE__ */ e("div", { className: "flex items-center gap-2 mb-2", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
|
|
248
|
-
/* @__PURE__ */ e(
|
|
248
|
+
/* @__PURE__ */ e(be, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
249
249
|
/* @__PURE__ */ e(
|
|
250
|
-
|
|
250
|
+
me,
|
|
251
251
|
{
|
|
252
252
|
placeholder: "Search assets...",
|
|
253
|
-
value:
|
|
254
|
-
onChange:
|
|
253
|
+
value: I,
|
|
254
|
+
onChange: ne,
|
|
255
255
|
className: "pl-8"
|
|
256
256
|
}
|
|
257
257
|
)
|
|
@@ -280,14 +280,14 @@ function Xe({
|
|
|
280
280
|
className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",
|
|
281
281
|
children: [
|
|
282
282
|
w.map((s) => /* @__PURE__ */ e(
|
|
283
|
-
|
|
283
|
+
he,
|
|
284
284
|
{
|
|
285
|
-
className:
|
|
285
|
+
className: $(
|
|
286
286
|
"cursor-pointer overflow-hidden transition-all",
|
|
287
287
|
p.some((l) => l.id === s.id) ? "ring-2 ring-primary" : "hover:ring-2 hover:ring-primary/20"
|
|
288
288
|
),
|
|
289
|
-
onClick: () =>
|
|
290
|
-
children: /* @__PURE__ */ a(
|
|
289
|
+
onClick: () => j(s),
|
|
290
|
+
children: /* @__PURE__ */ a(ge, { className: "p-0 relative group", children: [
|
|
291
291
|
/* @__PURE__ */ a("div", { className: "aspect-square relative overflow-hidden bg-muted", children: [
|
|
292
292
|
s.type === "image" ? /* @__PURE__ */ e(
|
|
293
293
|
"img",
|
|
@@ -297,7 +297,7 @@ function Xe({
|
|
|
297
297
|
className: "object-cover w-full h-full"
|
|
298
298
|
}
|
|
299
299
|
) : /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full", children: [
|
|
300
|
-
/* @__PURE__ */ e(
|
|
300
|
+
/* @__PURE__ */ e(Ce, { className: "h-12 w-12 text-muted-foreground" }),
|
|
301
301
|
s.thumbnailUrl && /* @__PURE__ */ e(
|
|
302
302
|
"img",
|
|
303
303
|
{
|
|
@@ -315,9 +315,9 @@ function Xe({
|
|
|
315
315
|
size: "icon",
|
|
316
316
|
className: "h-8 w-8",
|
|
317
317
|
onClick: (l) => {
|
|
318
|
-
l.stopPropagation(),
|
|
318
|
+
l.stopPropagation(), le(s);
|
|
319
319
|
},
|
|
320
|
-
children: /* @__PURE__ */ e(
|
|
320
|
+
children: /* @__PURE__ */ e(Ee, { className: "h-4 w-4" })
|
|
321
321
|
}
|
|
322
322
|
),
|
|
323
323
|
/* @__PURE__ */ e(
|
|
@@ -334,7 +334,7 @@ function Xe({
|
|
|
334
334
|
name: s.name
|
|
335
335
|
});
|
|
336
336
|
},
|
|
337
|
-
children: /* @__PURE__ */ e(
|
|
337
|
+
children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
|
|
338
338
|
}
|
|
339
339
|
),
|
|
340
340
|
/* @__PURE__ */ e(
|
|
@@ -344,9 +344,9 @@ function Xe({
|
|
|
344
344
|
size: "icon",
|
|
345
345
|
className: "h-8 w-8",
|
|
346
346
|
onClick: (l) => {
|
|
347
|
-
l.stopPropagation(),
|
|
347
|
+
l.stopPropagation(), ae(s);
|
|
348
348
|
},
|
|
349
|
-
children: /* @__PURE__ */ e(
|
|
349
|
+
children: /* @__PURE__ */ e(De, { className: "h-4 w-4" })
|
|
350
350
|
}
|
|
351
351
|
)
|
|
352
352
|
] }),
|
|
@@ -380,27 +380,27 @@ function Xe({
|
|
|
380
380
|
},
|
|
381
381
|
s.id
|
|
382
382
|
)),
|
|
383
|
-
P && w.length > 0 && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ e(
|
|
383
|
+
P && w.length > 0 && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ e(W, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })
|
|
384
384
|
]
|
|
385
385
|
}
|
|
386
386
|
)
|
|
387
387
|
] }),
|
|
388
|
-
/* @__PURE__ */ e(
|
|
388
|
+
/* @__PURE__ */ e(V, { value: "upload", className: "flex-1 ", children: /* @__PURE__ */ a(
|
|
389
389
|
"div",
|
|
390
390
|
{
|
|
391
|
-
...
|
|
392
|
-
className:
|
|
391
|
+
...Z(),
|
|
392
|
+
className: $(
|
|
393
393
|
"border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",
|
|
394
|
-
|
|
394
|
+
ee ? "border-primary bg-primary/5" : "border-muted-foreground/20"
|
|
395
395
|
),
|
|
396
396
|
children: [
|
|
397
|
-
/* @__PURE__ */ e("input", { ...
|
|
398
|
-
h ||
|
|
399
|
-
/* @__PURE__ */ e(
|
|
397
|
+
/* @__PURE__ */ e("input", { ...J() }),
|
|
398
|
+
h || _ ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center", children: [
|
|
399
|
+
/* @__PURE__ */ e(W, { className: "h-12 w-12 text-primary animate-spin mb-4" }),
|
|
400
400
|
/* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Uploading files..." }),
|
|
401
401
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Please wait while your files are being processed." })
|
|
402
|
-
] }) : /* @__PURE__ */ a(
|
|
403
|
-
/* @__PURE__ */ e(
|
|
402
|
+
] }) : /* @__PURE__ */ a(Q, { children: [
|
|
403
|
+
/* @__PURE__ */ e(Pe, { className: "h-12 w-12 text-muted-foreground mb-4" }),
|
|
404
404
|
/* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Drag & drop files here" }),
|
|
405
405
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: "or click to browse your files" }),
|
|
406
406
|
/* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground", children: [
|
|
@@ -422,43 +422,43 @@ function Xe({
|
|
|
422
422
|
}
|
|
423
423
|
)
|
|
424
424
|
] }),
|
|
425
|
-
C && /* @__PURE__ */ e(
|
|
425
|
+
C && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
|
|
426
426
|
je,
|
|
427
427
|
{
|
|
428
428
|
asset: C,
|
|
429
|
-
onSave: (s) =>
|
|
429
|
+
onSave: (s) => ie(C, s),
|
|
430
430
|
onCancel: () => {
|
|
431
431
|
v(null);
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
) }),
|
|
435
|
-
m.show && /* @__PURE__ */ e(
|
|
435
|
+
m.show && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
|
|
436
436
|
_e,
|
|
437
437
|
{
|
|
438
438
|
imageUrl: m.file,
|
|
439
|
-
onSave:
|
|
439
|
+
onSave: re,
|
|
440
440
|
onClose: () => E({ show: !1, file: "" }),
|
|
441
441
|
defaultSavedImageName: m.name,
|
|
442
442
|
isEditing: !!m.id
|
|
443
443
|
}
|
|
444
444
|
) }),
|
|
445
445
|
c && /* @__PURE__ */ e(
|
|
446
|
-
|
|
446
|
+
pe,
|
|
447
447
|
{
|
|
448
448
|
open: !!c,
|
|
449
449
|
onOpenChange: () => g(null),
|
|
450
|
-
children: /* @__PURE__ */ a(
|
|
451
|
-
/* @__PURE__ */ a(
|
|
452
|
-
/* @__PURE__ */ e(
|
|
453
|
-
/* @__PURE__ */ a(
|
|
450
|
+
children: /* @__PURE__ */ a(fe, { children: [
|
|
451
|
+
/* @__PURE__ */ a(ye, { children: [
|
|
452
|
+
/* @__PURE__ */ e(ve, { children: "Delete Asset" }),
|
|
453
|
+
/* @__PURE__ */ a(xe, { children: [
|
|
454
454
|
'Are you sure you want to delete "',
|
|
455
455
|
c.name,
|
|
456
456
|
'"? This action cannot be undone.'
|
|
457
457
|
] })
|
|
458
458
|
] }),
|
|
459
|
-
/* @__PURE__ */ a(
|
|
459
|
+
/* @__PURE__ */ a(Ne, { className: "gap-2 sm:gap-0", children: [
|
|
460
460
|
/* @__PURE__ */ e(f, { variant: "outline", onClick: () => g(null), children: "Cancel" }),
|
|
461
|
-
/* @__PURE__ */ e(f, { variant: "destructive", onClick:
|
|
461
|
+
/* @__PURE__ */ e(f, { variant: "destructive", onClick: te, children: "Delete" })
|
|
462
462
|
] })
|
|
463
463
|
] })
|
|
464
464
|
}
|