@chaibuilder/pages 0.4.8-beta.1 → 0.4.8-beta.3
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-DyR5KduJ.cjs → B4MFY5CR-CHMJEiI7.cjs} +1 -1
- package/dist/{B4MFY5CR-B6Ovh3Gq.js → B4MFY5CR-DmzYJmsY.js} +1 -1
- package/dist/{HO4MOOFI-HjzuoPRe.cjs → HO4MOOFI-BVo9KBFO.cjs} +1 -1
- package/dist/{HO4MOOFI-Dv82-fP1.js → HO4MOOFI-PgDfNOYI.js} +2 -2
- package/dist/{HUY7CZI3-Cx1xpXqQ.js → HUY7CZI3-BByK5e-X.js} +2 -2
- package/dist/{HUY7CZI3-bzxTWlyM.cjs → HUY7CZI3-CSBRfbLq.cjs} +1 -1
- package/dist/{asset-metadata-editor-r5vYHUfm.js → asset-metadata-editor-CyTBhS-V.js} +9 -9
- package/dist/{asset-metadata-editor-zw9u1BB9.cjs → asset-metadata-editor-IRTgc3or.cjs} +1 -1
- package/dist/digital-asset-manager-DI7DD87K.cjs +1 -0
- package/dist/{digital-asset-manager-Dfg9MZry.js → digital-asset-manager-DeLcDhkr.js} +68 -62
- package/dist/{image-editor-CwVua57o.js → image-editor-By8RDHso.js} +20 -20
- package/dist/{image-editor-D8wu5UNM.cjs → image-editor-DHmv5L8S.cjs} +1 -1
- package/dist/{index-CqQe5PpG.js → index-CpcOqKZB.js} +3 -3
- package/dist/{index-C6iwM3hl.cjs → index-CqIGt4M7.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/digital-asset-manager-IFfwC5Xe.cjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var ps = Object.defineProperty;
|
|
2
2
|
var xs = (e, t, n) => t in e ? ps(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var qe = (e, t, n) => xs(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { s as Vn, m as Gn, b as R, d as rr, e as U, a as m, f as W, h as oe, S as B, c as D, i as we, u as $e, j as V, k as A, l as Ne, o as ut, P as zo, n as j, D as ws, t as q, p as Ft, q as ln, r as k, v as F, w as $s, x as Rt, y as Cs, z as Ss, A as wn, F as ks, B as Es, C as Ds, E as Kt, G as Ms, H as As, I as Fs, J as or, K as Kr, L as Ts, M as qt, $ as Ro, N as Br, O as Is, Q as Ps, R as zn, T as Ls, U as Os, V as qs } from "./index-
|
|
4
|
+
import { s as Vn, m as Gn, b as R, d as rr, e as U, a as m, f as W, h as oe, S as B, c as D, i as we, u as $e, j as V, k as A, l as Ne, o as ut, P as zo, n as j, D as ws, t as q, p as Ft, q as ln, r as k, v as F, w as $s, x as Rt, y as Cs, z as Ss, A as wn, F as ks, B as Es, C as Ds, E as Kt, G as Ms, H as As, I as Fs, J as or, K as Kr, L as Ts, M as qt, $ as Ro, N as Br, O as Is, Q as Ps, R as zn, T as Ls, U as Os, V as qs } from "./index-CpcOqKZB.js";
|
|
5
5
|
var _s = (e) => e != null, zs = (e) => e.filter(_s);
|
|
6
6
|
function Rs(e) {
|
|
7
7
|
return (...t) => {
|
|
@@ -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-CHMJEiI7.cjs"),t=require("./index-CqIGt4M7.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-DmzYJmsY.js";
|
|
2
|
+
import { g as d, c as f, a as e } from "./index-CpcOqKZB.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-DmzYJmsY.js";
|
|
2
|
+
import { g as v, c as C, a as e } from "./index-CpcOqKZB.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-CHMJEiI7.cjs"),t=require("./index-CqIGt4M7.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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as i, Fragment as w, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { Dialog as u, DialogContent as h, DialogHeader as
|
|
3
|
-
import { Eye as
|
|
2
|
+
import { Dialog as u, DialogContent as h, DialogHeader as N, DialogTitle as b, Label as r, Textarea as D, DialogFooter as F, Button as p } from "@chaibuilder/sdk/ui";
|
|
3
|
+
import { Eye as y } from "lucide-react";
|
|
4
4
|
import { useState as n } from "react";
|
|
5
|
-
function
|
|
5
|
+
function k({
|
|
6
6
|
asset: e,
|
|
7
7
|
onSave: l,
|
|
8
8
|
onCancel: o
|
|
@@ -19,7 +19,7 @@ function E({
|
|
|
19
19
|
};
|
|
20
20
|
return /* @__PURE__ */ i(w, { children: [
|
|
21
21
|
/* @__PURE__ */ a(u, { open: !0, onOpenChange: () => o(), children: /* @__PURE__ */ i(h, { className: "sm:max-w-[700px]", children: [
|
|
22
|
-
/* @__PURE__ */ a(
|
|
22
|
+
/* @__PURE__ */ a(N, { children: /* @__PURE__ */ a(b, { children: "Edit Asset Details" }) }),
|
|
23
23
|
/* @__PURE__ */ i("div", { className: "flex gap-4", children: [
|
|
24
24
|
/* @__PURE__ */ i("div", { className: "relative group", children: [
|
|
25
25
|
/* @__PURE__ */ a(
|
|
@@ -34,7 +34,7 @@ function E({
|
|
|
34
34
|
{
|
|
35
35
|
onClick: () => s(!0),
|
|
36
36
|
className: "absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-md",
|
|
37
|
-
children: /* @__PURE__ */ a(
|
|
37
|
+
children: /* @__PURE__ */ a(y, { className: "h-8 w-8 text-white" })
|
|
38
38
|
}
|
|
39
39
|
)
|
|
40
40
|
] }),
|
|
@@ -62,7 +62,7 @@ function E({
|
|
|
62
62
|
/* @__PURE__ */ i("div", { className: "grid gap-2", children: [
|
|
63
63
|
/* @__PURE__ */ a(r, { htmlFor: "description", children: "Description" }),
|
|
64
64
|
/* @__PURE__ */ a(
|
|
65
|
-
|
|
65
|
+
D,
|
|
66
66
|
{
|
|
67
67
|
id: "description",
|
|
68
68
|
value: c,
|
|
@@ -74,7 +74,7 @@ function E({
|
|
|
74
74
|
] })
|
|
75
75
|
] })
|
|
76
76
|
] }),
|
|
77
|
-
/* @__PURE__ */ i(
|
|
77
|
+
/* @__PURE__ */ i(F, { children: [
|
|
78
78
|
/* @__PURE__ */ a(p, { variant: "outline", onClick: o, children: "Cancel" }),
|
|
79
79
|
/* @__PURE__ */ a(p, { onClick: x, disabled: d, children: d ? "Saving..." : "Save Changes" })
|
|
80
80
|
] })
|
|
@@ -90,7 +90,7 @@ function E({
|
|
|
90
90
|
] });
|
|
91
91
|
}
|
|
92
92
|
function S(e) {
|
|
93
|
-
return e < 1024 ? `${e.toFixed(2)} KB` : `${(e / 1024).toFixed(2)} MB`;
|
|
93
|
+
return e < 1024 ? `${e.toFixed(2)} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(2)} KB` : `${(e / (1024 * 1024)).toFixed(2)} MB`;
|
|
94
94
|
}
|
|
95
95
|
function g(e) {
|
|
96
96
|
if (!e) return "N/A";
|
|
@@ -104,5 +104,5 @@ function g(e) {
|
|
|
104
104
|
}).format(l);
|
|
105
105
|
}
|
|
106
106
|
export {
|
|
107
|
-
|
|
107
|
+
k as default
|
|
108
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk/ui"),g=require("lucide-react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk/ui"),g=require("lucide-react"),r=require("react");function p({asset:t,onSave:l,onCancel:n}){const[s,m]=r.useState(t.description||""),[o,c]=r.useState(!1),[x,d]=r.useState(!1),h=async()=>{c(!0);try{await l({description:s||void 0})}finally{c(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(a.Dialog,{open:!0,onOpenChange:()=>n(),children:e.jsxs(a.DialogContent,{className:"sm:max-w-[700px]",children:[e.jsx(a.DialogHeader,{children:e.jsx(a.DialogTitle,{children:"Edit Asset Details"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.url,className:"max-h-96 w-96 border rounded-md p-2"}),e.jsx("button",{onClick:()=>d(!0),className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-md",children:e.jsx(g.Eye,{className:"h-8 w-8 text-white"})})]}),e.jsxs("div",{className:"grid gap-3 w-full",children:[e.jsx(a.Label,{htmlFor:"description",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:[{label:"File Name",value:t.name},{label:"Type",value:t.type},{label:"Format",value:t.format},{label:"Size",value:f(t.size)},{label:"Dimensions",value:`${t.width} × ${t.height}`},{label:"Created",value:u(t.createdAt)},{label:"Updated",value:u((t==null?void 0:t.updatedAt)||"")}].map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:i.label}),":",e.jsx("div",{className:"w-max text-left font-medium text-gray-900 capitalize",children:i.value})]}))}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(a.Label,{htmlFor:"description",children:"Description"}),e.jsx(a.Textarea,{id:"description",value:s,placeholder:"Enter a description for the asset",onChange:i=>m(i.target.value),rows:3})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:o,children:o?"Saving...":"Save Changes"})]})]})}),e.jsx(a.Dialog,{open:x,onOpenChange:d,children:e.jsx(a.DialogContent,{className:"w-[60vw] h-[60vh] p-0 flex items-center justify-center bg-gray-100",children:e.jsx("img",{src:t.url,className:"w-full h-full object-contain",alt:t.name})})})]})}function f(t){return t<1024?`${t.toFixed(2)} B`:t<1024*1024?`${(t/1024).toFixed(2)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function u(t){if(!t)return"N/A";const l=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(l)}exports.default=p;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),L=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),P=require("lodash-es"),j=require("lucide-react"),X=require("react-dropzone"),A=require("@tanstack/react-query"),b=require("sonner"),a=require("./index-CqIGt4M7.cjs"),Z=()=>{const l=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async({file:r,folderId:m,name:h})=>d(l,{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 l=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async r=>d(l,{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 l=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async r=>d(l,{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=(l={})=>{const c=a.useAssetsApiUrl(),d=a.useFetch(),{search:r,page:m=1,limit:h=10}=l;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}}),retry:1})};function ae(){const[c,d]=n.useState([]),[r,m]=n.useState({query:"",page:1,pageSize:10}),h=P.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:q}=se(),{mutate:N,isPending:f}=Z(),{mutate:E,isPending:T}=ee(),v=n.useCallback(x=>{x>=1&&x<=y&&m(S=>({...S,page:x}))},[y]),F=n.useCallback(()=>{p&&v(u+1)},[u,p,v]),k=n.useCallback(()=>{g&&v(u-1)},[u,g,v]),I=n.useCallback(x=>{m(S=>({...S,query:x,page:1}))},[]),U=n.useCallback(x=>{d(S=>P.find(S,{id:x.id})?[]:[x])},[!1]),z=n.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:F,previousPage:k,updateSearchQuery:I,clearSelectedAssets:z,updateSelectedAssets:U,isLoadingAssets:w,isUploadingAsset:f,isUpdatingAsset:q,isDeletingAsset:T}}const le=n.lazy(()=>Promise.resolve().then(()=>require("./asset-metadata-editor-IRTgc3or.cjs"))),ne=n.lazy(()=>Promise.resolve().then(()=>require("./image-editor-DHmv5L8S.cjs")));function ie({close:l,onSelect:c,mode:d="image"}){const m=n.useMemo(()=>[d],[d]),[h,o]=n.useState("browse"),[w,y]=n.useState(null),[u,p]=n.useState(null),[g,C]=n.useState({show:!1,file:""}),{query:q,assets:N,selectedAssets:f,uploadAsset:E,updateAsset:T,deleteAsset:v,updateSearchQuery:F,clearSelectedAssets:k,updateSelectedAssets:I,isLoadingAssets:U,isUploadingAsset:z,isUpdatingAsset:x}=ae(),S=n.useRef(null),_=n.useCallback(async s=>new Promise((i,M)=>{const Q=s[0],D=new FileReader;D.readAsDataURL(Q),D.onload=async()=>{const B=await E({file:D.result,folderId:null,name:Q.name},{onSuccess:()=>{o("browse")}});i(B)},D.onerror=B=>M(B)}),[E]),{getRootProps:O,getInputProps:R,isDragActive:K}=X.useDropzone({onDrop:_,accept:{"image/*":m.includes("image")?[]:[]},maxSize:10*1024*1024}),Y=()=>{c([f[0].url]),l()},G=async s=>{p(s)},$=async()=>{u&&(await v(u.id),p(null))},H=s=>{y(s)},V=async(s,i)=>{await T(P.merge(s,P.pick(i,["id","description"]))),l()},J=s=>{F(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(M){console.error("Error saving edited image:",M)}};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:()=>k(),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:q,onChange:J,className:"pl-8"})]})}),U&&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 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 min-h-[100px]"}):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)),U&&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||z?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(n.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(n.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(l){return l<1024?`${l.toFixed(2)} B`:l<1024*1024?`${(l/1024).toFixed(2)} KB`:`${(l/(1024*1024)).toFixed(2)} MB`}function oe(l){const c=new Date(l);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(c)}exports.default=ie;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsxs as a, Fragment as Q, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import X, { useState as
|
|
2
|
+
import X, { useState as w, useCallback as A, useMemo as oe, useRef as ce, Suspense as Y } from "react";
|
|
3
3
|
import { mergeClasses as $ } from "@chaibuilder/sdk";
|
|
4
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
|
|
6
|
-
import { Search as
|
|
7
|
-
import { useDropzone as
|
|
5
|
+
import { debounce as Ae, find as Se, merge as we, pick as be } from "lodash-es";
|
|
6
|
+
import { Search as Ce, Film as Ee, ImageIcon as Te, Edit as De, Trash2 as Pe, Loader2 as W, Upload as Ue } from "lucide-react";
|
|
7
|
+
import { useDropzone as Fe } from "react-dropzone";
|
|
8
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
|
|
11
|
-
const
|
|
12
|
-
const t =
|
|
10
|
+
import { W as F, X as z, Y as y, Z as k } from "./index-CpcOqKZB.js";
|
|
11
|
+
const ke = () => {
|
|
12
|
+
const t = F(), r = R(), o = z();
|
|
13
13
|
return K({
|
|
14
14
|
mutationFn: async ({
|
|
15
15
|
file: i,
|
|
@@ -21,7 +21,7 @@ const Fe = () => {
|
|
|
21
21
|
}),
|
|
22
22
|
onSuccess: () => {
|
|
23
23
|
r.invalidateQueries({
|
|
24
|
-
queryKey: [
|
|
24
|
+
queryKey: [k, y.GET_ASSETS]
|
|
25
25
|
}), b.success("Asset uploaded successfully");
|
|
26
26
|
},
|
|
27
27
|
onError: () => {
|
|
@@ -29,7 +29,7 @@ const Fe = () => {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
}, Me = () => {
|
|
32
|
-
const t =
|
|
32
|
+
const t = F(), r = R(), o = z();
|
|
33
33
|
return K({
|
|
34
34
|
mutationFn: async (i) => o(t, {
|
|
35
35
|
action: y.DELETE_ASSET,
|
|
@@ -37,7 +37,7 @@ const Fe = () => {
|
|
|
37
37
|
}),
|
|
38
38
|
onSuccess: () => {
|
|
39
39
|
r.invalidateQueries({
|
|
40
|
-
queryKey: [
|
|
40
|
+
queryKey: [k, y.GET_ASSETS]
|
|
41
41
|
}), b.success("Asset deleted successfully");
|
|
42
42
|
},
|
|
43
43
|
onError: () => {
|
|
@@ -45,7 +45,7 @@ const Fe = () => {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
}, Ie = () => {
|
|
48
|
-
const t =
|
|
48
|
+
const t = F(), r = R(), o = z();
|
|
49
49
|
return K({
|
|
50
50
|
mutationFn: async (i) => o(t, {
|
|
51
51
|
action: y.UPDATE_ASSET,
|
|
@@ -53,17 +53,17 @@ const Fe = () => {
|
|
|
53
53
|
}),
|
|
54
54
|
onSuccess: () => {
|
|
55
55
|
r.invalidateQueries({
|
|
56
|
-
queryKey: [
|
|
56
|
+
queryKey: [k, y.GET_ASSETS]
|
|
57
57
|
}), b.success("Asset updated successfully");
|
|
58
58
|
},
|
|
59
59
|
onError: () => {
|
|
60
60
|
b.error("Failed to update asset");
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
},
|
|
64
|
-
const r =
|
|
63
|
+
}, qe = (t = {}) => {
|
|
64
|
+
const r = F(), o = z(), { search: i, page: d = 1, limit: u = 10 } = t;
|
|
65
65
|
return ze({
|
|
66
|
-
queryKey: [
|
|
66
|
+
queryKey: [k, y.GET_ASSETS, i, d, u],
|
|
67
67
|
queryFn: async () => await o(r, {
|
|
68
68
|
action: y.GET_ASSETS,
|
|
69
69
|
data: {
|
|
@@ -75,16 +75,16 @@ const Fe = () => {
|
|
|
75
75
|
retry: 1
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
|
-
function
|
|
79
|
-
const [r, o] =
|
|
78
|
+
function je() {
|
|
79
|
+
const [r, o] = w([]), [i, d] = w({
|
|
80
80
|
query: "",
|
|
81
81
|
page: 1,
|
|
82
82
|
pageSize: 10
|
|
83
|
-
}), u = Ae(() => i.query, 300)(), { data: n, isLoading: C } =
|
|
83
|
+
}), u = Ae(() => i.query, 300)(), { data: n, isLoading: C } = qe({
|
|
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: M } = Ie(), { mutate: S, isPending: p } = ke(), { mutate: T, isPending: D } = Me(), x = A(
|
|
88
88
|
(h) => {
|
|
89
89
|
h >= 1 && h <= v && d((N) => ({
|
|
90
90
|
...N,
|
|
@@ -92,7 +92,7 @@ function qe() {
|
|
|
92
92
|
}));
|
|
93
93
|
},
|
|
94
94
|
[v]
|
|
95
|
-
),
|
|
95
|
+
), I = A(() => {
|
|
96
96
|
g && x(c + 1);
|
|
97
97
|
}, [c, g, x]), q = A(() => {
|
|
98
98
|
m && x(c - 1);
|
|
@@ -105,7 +105,7 @@ function qe() {
|
|
|
105
105
|
}));
|
|
106
106
|
}, []), P = A(
|
|
107
107
|
(h) => {
|
|
108
|
-
o((N) =>
|
|
108
|
+
o((N) => Se(N, { id: h.id }) ? [] : [h]);
|
|
109
109
|
},
|
|
110
110
|
[!1]
|
|
111
111
|
), _ = A(() => {
|
|
@@ -121,11 +121,11 @@ function qe() {
|
|
|
121
121
|
hasNextPage: g,
|
|
122
122
|
hasPreviousPage: m,
|
|
123
123
|
// Mutations
|
|
124
|
-
uploadAsset:
|
|
124
|
+
uploadAsset: S,
|
|
125
125
|
updateAsset: E,
|
|
126
126
|
deleteAsset: T,
|
|
127
127
|
goToPage: x,
|
|
128
|
-
nextPage:
|
|
128
|
+
nextPage: I,
|
|
129
129
|
previousPage: q,
|
|
130
130
|
updateSearchQuery: j,
|
|
131
131
|
clearSelectedAssets: _,
|
|
@@ -133,26 +133,26 @@ function qe() {
|
|
|
133
133
|
// Loading
|
|
134
134
|
isLoadingAssets: C,
|
|
135
135
|
isUploadingAsset: p,
|
|
136
|
-
isUpdatingAsset:
|
|
136
|
+
isUpdatingAsset: M,
|
|
137
137
|
isDeletingAsset: D
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
const
|
|
141
|
-
function
|
|
140
|
+
const _e = X.lazy(() => import("./asset-metadata-editor-CyTBhS-V.js")), Le = X.lazy(() => import("./image-editor-By8RDHso.js"));
|
|
141
|
+
function Ze({
|
|
142
142
|
close: t,
|
|
143
143
|
onSelect: r,
|
|
144
144
|
mode: o = "image"
|
|
145
145
|
}) {
|
|
146
|
-
const d = oe(() => [o], [o]), [u, n] =
|
|
146
|
+
const d = oe(() => [o], [o]), [u, n] = w("browse"), [C, v] = w(null), [c, g] = w(null), [m, E] = w({ show: !1, file: "" }), {
|
|
147
147
|
// Data
|
|
148
|
-
query:
|
|
149
|
-
assets:
|
|
148
|
+
query: M,
|
|
149
|
+
assets: S,
|
|
150
150
|
selectedAssets: p,
|
|
151
151
|
// Mutations
|
|
152
152
|
uploadAsset: T,
|
|
153
153
|
updateAsset: D,
|
|
154
154
|
deleteAsset: x,
|
|
155
|
-
updateSearchQuery:
|
|
155
|
+
updateSearchQuery: I,
|
|
156
156
|
clearSelectedAssets: q,
|
|
157
157
|
updateSelectedAssets: j,
|
|
158
158
|
// Loading
|
|
@@ -160,24 +160,30 @@ function Xe({
|
|
|
160
160
|
isUploadingAsset: _,
|
|
161
161
|
isUpdatingAsset: h
|
|
162
162
|
// isDeletingAsset,
|
|
163
|
-
} =
|
|
163
|
+
} = je(), N = ce(null), G = A(
|
|
164
164
|
async (s) => new Promise((l, L) => {
|
|
165
165
|
const O = s[0], U = new FileReader();
|
|
166
166
|
U.readAsDataURL(O), U.onload = async () => {
|
|
167
|
-
const B = await T(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
const B = await T(
|
|
168
|
+
{
|
|
169
|
+
file: U.result,
|
|
170
|
+
folderId: null,
|
|
171
|
+
name: O.name
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
onSuccess: () => {
|
|
175
|
+
n("browse");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
l(B);
|
|
173
180
|
}, U.onerror = (B) => L(B);
|
|
174
181
|
}),
|
|
175
182
|
[T]
|
|
176
|
-
), { getRootProps: Z, getInputProps: J, isDragActive: ee } =
|
|
183
|
+
), { getRootProps: Z, getInputProps: J, isDragActive: ee } = Fe({
|
|
177
184
|
onDrop: G,
|
|
178
185
|
accept: {
|
|
179
|
-
"image/*": d.includes("image") ? [] : []
|
|
180
|
-
"video/*": d.includes("video") ? [] : []
|
|
186
|
+
"image/*": d.includes("image") ? [] : []
|
|
181
187
|
},
|
|
182
188
|
maxSize: 10 * 1024 * 1024
|
|
183
189
|
}), se = () => {
|
|
@@ -189,9 +195,9 @@ function Xe({
|
|
|
189
195
|
}, le = (s) => {
|
|
190
196
|
v(s);
|
|
191
197
|
}, ie = async (s, l) => {
|
|
192
|
-
await D(
|
|
198
|
+
await D(we(s, be(l, ["id", "description"]))), t();
|
|
193
199
|
}, ne = (s) => {
|
|
194
|
-
|
|
200
|
+
I(s.target.value);
|
|
195
201
|
}, re = async (s, l) => {
|
|
196
202
|
try {
|
|
197
203
|
l ? await T({
|
|
@@ -245,18 +251,18 @@ function Xe({
|
|
|
245
251
|
] }),
|
|
246
252
|
/* @__PURE__ */ a(V, { value: "browse", className: "flex-1 flex flex-col", children: [
|
|
247
253
|
/* @__PURE__ */ e("div", { className: "flex items-center gap-2 mb-2", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
|
|
248
|
-
/* @__PURE__ */ e(
|
|
254
|
+
/* @__PURE__ */ e(Ce, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
249
255
|
/* @__PURE__ */ e(
|
|
250
256
|
me,
|
|
251
257
|
{
|
|
252
258
|
placeholder: "Search assets...",
|
|
253
|
-
value:
|
|
259
|
+
value: M,
|
|
254
260
|
onChange: ne,
|
|
255
261
|
className: "pl-8"
|
|
256
262
|
}
|
|
257
263
|
)
|
|
258
264
|
] }) }),
|
|
259
|
-
P &&
|
|
265
|
+
P && S.length === 0 ? /* @__PURE__ */ a("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: [
|
|
260
266
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
261
267
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
262
268
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
@@ -267,7 +273,7 @@ function Xe({
|
|
|
267
273
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
268
274
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
269
275
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" })
|
|
270
|
-
] }) :
|
|
276
|
+
] }) : S.length === 0 ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center justify-center text-center p-12 h-[380px]", children: [
|
|
271
277
|
/* @__PURE__ */ a("div", { className: "text-muted-foreground mb-2", children: [
|
|
272
278
|
/* @__PURE__ */ e("h3", { className: "text-gray-800 font-medium", children: "No assets to display" }),
|
|
273
279
|
/* @__PURE__ */ e("p", { className: "text-sm", children: "You haven't uploaded any assets yet. Start by uploading your first asset." })
|
|
@@ -279,7 +285,7 @@ function Xe({
|
|
|
279
285
|
ref: N,
|
|
280
286
|
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
287
|
children: [
|
|
282
|
-
|
|
288
|
+
S.map((s) => /* @__PURE__ */ e(
|
|
283
289
|
he,
|
|
284
290
|
{
|
|
285
291
|
className: $(
|
|
@@ -294,10 +300,10 @@ function Xe({
|
|
|
294
300
|
{
|
|
295
301
|
src: s.thumbnailUrl || "/placeholder.svg",
|
|
296
302
|
alt: s.name,
|
|
297
|
-
className: "object-cover w-full h-full"
|
|
303
|
+
className: "object-cover w-full h-full min-h-[100px]"
|
|
298
304
|
}
|
|
299
305
|
) : /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full", children: [
|
|
300
|
-
/* @__PURE__ */ e(
|
|
306
|
+
/* @__PURE__ */ e(Ee, { className: "h-12 w-12 text-muted-foreground" }),
|
|
301
307
|
s.thumbnailUrl && /* @__PURE__ */ e(
|
|
302
308
|
"img",
|
|
303
309
|
{
|
|
@@ -317,7 +323,7 @@ function Xe({
|
|
|
317
323
|
onClick: (l) => {
|
|
318
324
|
l.stopPropagation(), le(s);
|
|
319
325
|
},
|
|
320
|
-
children: /* @__PURE__ */ e(
|
|
326
|
+
children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
|
|
321
327
|
}
|
|
322
328
|
),
|
|
323
329
|
/* @__PURE__ */ e(
|
|
@@ -334,7 +340,7 @@ function Xe({
|
|
|
334
340
|
name: s.name
|
|
335
341
|
});
|
|
336
342
|
},
|
|
337
|
-
children: /* @__PURE__ */ e(
|
|
343
|
+
children: /* @__PURE__ */ e(De, { className: "h-4 w-4" })
|
|
338
344
|
}
|
|
339
345
|
),
|
|
340
346
|
/* @__PURE__ */ e(
|
|
@@ -346,7 +352,7 @@ function Xe({
|
|
|
346
352
|
onClick: (l) => {
|
|
347
353
|
l.stopPropagation(), ae(s);
|
|
348
354
|
},
|
|
349
|
-
children: /* @__PURE__ */ e(
|
|
355
|
+
children: /* @__PURE__ */ e(Pe, { className: "h-4 w-4" })
|
|
350
356
|
}
|
|
351
357
|
)
|
|
352
358
|
] }),
|
|
@@ -372,15 +378,15 @@ function Xe({
|
|
|
372
378
|
}
|
|
373
379
|
),
|
|
374
380
|
/* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground flex items-center justify-between", children: [
|
|
375
|
-
/* @__PURE__ */ e("span", { children:
|
|
376
|
-
/* @__PURE__ */ e("span", { children:
|
|
381
|
+
/* @__PURE__ */ e("span", { children: Be((s == null ? void 0 : s.size) || 0) }),
|
|
382
|
+
/* @__PURE__ */ e("span", { children: Qe(s.createdAt) })
|
|
377
383
|
] })
|
|
378
384
|
] })
|
|
379
385
|
] })
|
|
380
386
|
},
|
|
381
387
|
s.id
|
|
382
388
|
)),
|
|
383
|
-
P &&
|
|
389
|
+
P && S.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
390
|
]
|
|
385
391
|
}
|
|
386
392
|
)
|
|
@@ -400,7 +406,7 @@ function Xe({
|
|
|
400
406
|
/* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Uploading files..." }),
|
|
401
407
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Please wait while your files are being processed." })
|
|
402
408
|
] }) : /* @__PURE__ */ a(Q, { children: [
|
|
403
|
-
/* @__PURE__ */ e(
|
|
409
|
+
/* @__PURE__ */ e(Ue, { className: "h-12 w-12 text-muted-foreground mb-4" }),
|
|
404
410
|
/* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Drag & drop files here" }),
|
|
405
411
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: "or click to browse your files" }),
|
|
406
412
|
/* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground", children: [
|
|
@@ -423,7 +429,7 @@ function Xe({
|
|
|
423
429
|
)
|
|
424
430
|
] }),
|
|
425
431
|
C && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
|
|
426
|
-
|
|
432
|
+
_e,
|
|
427
433
|
{
|
|
428
434
|
asset: C,
|
|
429
435
|
onSave: (s) => ie(C, s),
|
|
@@ -433,7 +439,7 @@ function Xe({
|
|
|
433
439
|
}
|
|
434
440
|
) }),
|
|
435
441
|
m.show && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
|
|
436
|
-
|
|
442
|
+
Le,
|
|
437
443
|
{
|
|
438
444
|
imageUrl: m.file,
|
|
439
445
|
onSave: re,
|
|
@@ -465,10 +471,10 @@ function Xe({
|
|
|
465
471
|
)
|
|
466
472
|
] });
|
|
467
473
|
}
|
|
468
|
-
function Le(t) {
|
|
469
|
-
return t < 1024 ? `${t.toFixed(2)} KB` : `${(t / 1024).toFixed(2)} MB`;
|
|
470
|
-
}
|
|
471
474
|
function Be(t) {
|
|
475
|
+
return t < 1024 ? `${t.toFixed(2)} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(2)} KB` : `${(t / (1024 * 1024)).toFixed(2)} MB`;
|
|
476
|
+
}
|
|
477
|
+
function Qe(t) {
|
|
472
478
|
const r = new Date(t);
|
|
473
479
|
return new Intl.DateTimeFormat("en-US", {
|
|
474
480
|
month: "short",
|
|
@@ -477,5 +483,5 @@ function Be(t) {
|
|
|
477
483
|
}).format(r);
|
|
478
484
|
}
|
|
479
485
|
export {
|
|
480
|
-
|
|
486
|
+
Ze as default
|
|
481
487
|
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import S from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
const R =
|
|
8
|
-
({ imageUrl: n, onSave:
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog as T, DialogContent as y } from "@chaibuilder/sdk/ui";
|
|
3
|
+
import { debounce as S } from "lodash-es";
|
|
4
|
+
import { Save as w, Copy as E } from "lucide-react";
|
|
5
|
+
import { memo as O, useState as p, useEffect as k, useMemo as s, useCallback as I } from "react";
|
|
6
|
+
import A from "react-filerobot-image-editor";
|
|
7
|
+
const R = O(
|
|
8
|
+
({ imageUrl: n, onSave: i, onClose: l, defaultSavedImageName: g, isEditing: m = !1 }) => {
|
|
9
9
|
const [b, c] = p(!0), [h, C] = p(!1);
|
|
10
|
-
|
|
10
|
+
k(() => {
|
|
11
11
|
const e = new Image();
|
|
12
12
|
return e.src = n, e.onload = () => C(!0), () => {
|
|
13
13
|
e.onload = null;
|
|
14
14
|
};
|
|
15
15
|
}, [n]);
|
|
16
16
|
const f = s(
|
|
17
|
-
() =>
|
|
17
|
+
() => S((e, o = !1) => {
|
|
18
18
|
const t = e.imageBase64;
|
|
19
|
-
|
|
19
|
+
i(t, o), c(!1);
|
|
20
20
|
}, 300),
|
|
21
|
-
[
|
|
21
|
+
[i]
|
|
22
22
|
), a = I(
|
|
23
23
|
(e, o = !1) => {
|
|
24
24
|
f(e, o);
|
|
25
25
|
},
|
|
26
26
|
[f]
|
|
27
27
|
), u = I(() => {
|
|
28
|
-
c(!1),
|
|
29
|
-
}, [
|
|
28
|
+
c(!1), l();
|
|
29
|
+
}, [l]), r = s(
|
|
30
30
|
() => ({
|
|
31
31
|
tabsIds: [
|
|
32
32
|
"Adjust",
|
|
@@ -56,25 +56,25 @@ const R = T(
|
|
|
56
56
|
onClick: (e, o) => o((...t) => {
|
|
57
57
|
a(t[0], !1);
|
|
58
58
|
}),
|
|
59
|
-
icon:
|
|
59
|
+
icon: w
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
label: "Save as new file",
|
|
63
63
|
onClick: (e, o) => o((...t) => {
|
|
64
64
|
a(t[0], !0);
|
|
65
65
|
}),
|
|
66
|
-
icon:
|
|
66
|
+
icon: E
|
|
67
67
|
}
|
|
68
68
|
] : [],
|
|
69
69
|
[m, a]
|
|
70
70
|
);
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
|
|
71
|
+
return /* @__PURE__ */ d(T, { open: !0, onOpenChange: (e) => !e && u(), children: /* @__PURE__ */ d(
|
|
72
|
+
y,
|
|
73
73
|
{
|
|
74
74
|
id: "chai-image-editor-container",
|
|
75
75
|
className: "flex-1 overflow-hidden p-4 min-w-[1280px]",
|
|
76
|
-
children: b && h && /* @__PURE__ */
|
|
77
|
-
|
|
76
|
+
children: b && h && /* @__PURE__ */ d(
|
|
77
|
+
A,
|
|
78
78
|
{
|
|
79
79
|
theme: v,
|
|
80
80
|
source: n,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),I=require("@chaibuilder/sdk/ui"),T=require("lodash-es"),p=require("lucide-react"),t=require("react"),y=require("react-filerobot-image-editor"),b=t.memo(({imageUrl:n,onSave:d,onClose:r,defaultSavedImageName:g,isEditing:u=!1})=>{const[h,c]=t.useState(!0),[x,C]=t.useState(!1);t.useEffect(()=>{const e=new Image;return e.src=n,e.onload=()=>C(!0),()=>{e.onload=null}},[n]);const m=t.useMemo(()=>T.debounce((e,o=!1)=>{const a=e.imageBase64;d(a,o),c(!1)},300),[d]),s=t.useCallback((e,o=!1)=>{m(e,o)},[m]),f=t.useCallback(()=>{c(!1),r()},[r]),l=t.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],defaultTabId:"Adjust",defaultToolId:"Crop"}),[]),v=t.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),S=t.useMemo(()=>u?[{label:"Update this file",onClick:(e,o)=>o((...a)=>{s(a[0],!1)}),icon:p.Save},{label:"Save as new file",onClick:(e,o)=>o((...a)=>{s(a[0],!0)}),icon:p.Copy}]:[],[u,s]);return i.jsx(I.Dialog,{open:!0,onOpenChange:e=>!e&&f(),children:i.jsx(I.DialogContent,{id:"chai-image-editor-container",className:"flex-1 overflow-hidden p-4 min-w-[1280px]",children:h&&x&&i.jsx(y,{theme:v,source:n,onSave:s,onClose:f,Text:{text:"Add text here"},Rotate:{angle:90,componentType:"slider"},tabsIds:l.tabsIds,defaultTabId:l.defaultTabId,defaultToolId:l.defaultToolId,savingPixelRatio:2,previewPixelRatio:1,defaultSavedImageName:g,moreSaveOptions:S,useZoomPresetsMenu:!0})})})});b.displayName="ImageEditor";exports.default=b;
|
|
@@ -7422,7 +7422,7 @@ var Ed = (e, t = !1) => {
|
|
|
7422
7422
|
const t = oa(() => {
|
|
7423
7423
|
const n = this, [s] = R(this, yt), [a] = R(this, vt), [i] = R(this, Et), [l] = R(this, bt), [o] = R(this, gt);
|
|
7424
7424
|
let c;
|
|
7425
|
-
return R(this, wt) ? c = R(this, wt) : (c = ia(() => import("./HO4MOOFI-
|
|
7425
|
+
return R(this, wt) ? c = R(this, wt) : (c = ia(() => import("./HO4MOOFI-PgDfNOYI.js")), te(this, wt, c)), Ca(R(this, Yt), R(this, pt)), ra(c, aa({
|
|
7426
7426
|
get queryFlavor() {
|
|
7427
7427
|
return R(n, zt);
|
|
7428
7428
|
},
|
|
@@ -7516,7 +7516,7 @@ var Ed = (e, t = !1) => {
|
|
|
7516
7516
|
const t = oa(() => {
|
|
7517
7517
|
const n = this, [s] = R(this, At), [a] = R(this, xt), [i] = R(this, Tt), [l] = R(this, Ct), [o] = R(this, St), [c] = R(this, Pt);
|
|
7518
7518
|
let h;
|
|
7519
|
-
return R(this, _t) ? h = R(this, _t) : (h = ia(() => import("./HUY7CZI3-
|
|
7519
|
+
return R(this, _t) ? h = R(this, _t) : (h = ia(() => import("./HUY7CZI3-BByK5e-X.js")), te(this, _t, h)), Ca(R(this, en), R(this, Nt)), ra(h, aa({
|
|
7520
7520
|
get queryFlavor() {
|
|
7521
7521
|
return R(n, Zt);
|
|
7522
7522
|
},
|
|
@@ -7634,7 +7634,7 @@ var Iu = process.env.NODE_ENV !== "development" ? function() {
|
|
|
7634
7634
|
} : Pu;
|
|
7635
7635
|
process.env.NODE_ENV;
|
|
7636
7636
|
const ku = Qa(
|
|
7637
|
-
() => import("./digital-asset-manager-
|
|
7637
|
+
() => import("./digital-asset-manager-DeLcDhkr.js")
|
|
7638
7638
|
);
|
|
7639
7639
|
ul();
|
|
7640
7640
|
ec();
|