@flexkit/studio 0.2.3 → 0.2.4
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/activity-nav-button-AESIPODJ.js +2 -0
- package/dist/{activity-nav-button-Z6M3FURW.js.map → activity-nav-button-AESIPODJ.js.map} +1 -1
- package/dist/{chat-page-J7I5V6G4.js → chat-page-S2YGOKO5.js} +3 -3
- package/dist/{chat-page-J7I5V6G4.js.map → chat-page-S2YGOKO5.js.map} +1 -1
- package/dist/{chunk-BP27UNNR.js → chunk-2AHDTE5T.js} +2 -2
- package/dist/{chunk-BP27UNNR.js.map → chunk-2AHDTE5T.js.map} +1 -1
- package/dist/chunk-3TGCCDOR.js +2 -0
- package/dist/chunk-3TGCCDOR.js.map +1 -0
- package/dist/{chunk-QJDD73JR.js → chunk-6RDPFMLK.js} +2 -2
- package/dist/{chunk-QJDD73JR.js.map → chunk-6RDPFMLK.js.map} +1 -1
- package/dist/{chunk-MM356YIK.js → chunk-CKNFYN3O.js} +3 -3
- package/dist/chunk-CKNFYN3O.js.map +1 -0
- package/dist/chunk-J2G4C6I5.js +2 -0
- package/dist/chunk-J2G4C6I5.js.map +1 -0
- package/dist/{chunk-G74PT7Z7.js → chunk-KWS3NAYS.js} +3 -3
- package/dist/{chunk-G74PT7Z7.js.map → chunk-KWS3NAYS.js.map} +1 -1
- package/dist/{chunk-76CL7HSO.js → chunk-LN55VJ35.js} +3 -3
- package/dist/{chunk-76CL7HSO.js.map → chunk-LN55VJ35.js.map} +1 -1
- package/dist/{chunk-IAA4CEBW.js → chunk-NOFQHWES.js} +2 -2
- package/dist/{chunk-IAA4CEBW.js.map → chunk-NOFQHWES.js.map} +1 -1
- package/dist/{chunk-MPLNRUP3.js → chunk-NYKATVPZ.js} +3 -3
- package/dist/{chunk-MPLNRUP3.js.map → chunk-NYKATVPZ.js.map} +1 -1
- package/dist/{chunk-QDXGSL5B.js → chunk-PWQPA2QL.js} +2 -2
- package/dist/{chunk-QDXGSL5B.js.map → chunk-PWQPA2QL.js.map} +1 -1
- package/dist/chunk-SVZY7ZZD.js +8 -0
- package/dist/chunk-SVZY7ZZD.js.map +1 -0
- package/dist/index.css +19 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +1 -1
- package/dist/{list-IBUZ2LXU.js → list-PNKQAYUK.js} +2 -2
- package/dist/{list-IBUZ2LXU.js.map → list-PNKQAYUK.js.map} +1 -1
- package/dist/pages-KHFSZ3PH.js +3 -0
- package/dist/pages-KHFSZ3PH.js.map +1 -0
- package/dist/{plugin-pages-HQPZQSZT.js → plugin-pages-SE52XFFW.js} +2 -2
- package/dist/{plugin-pages-HQPZQSZT.js.map → plugin-pages-SE52XFFW.js.map} +1 -1
- package/dist/{root-XGNAKO5P.js → root-44ZJLA4E.js} +2 -2
- package/dist/{root-XGNAKO5P.js.map → root-44ZJLA4E.js.map} +1 -1
- package/dist/{root-ZY2HGDBT.js → root-BH3PQS2H.js} +3 -3
- package/dist/{root-ZY2HGDBT.js.map → root-BH3PQS2H.js.map} +1 -1
- package/dist/{root-4UVGZZRU.js → root-LFQA2VSE.js} +2 -2
- package/dist/{root-4UVGZZRU.js.map → root-LFQA2VSE.js.map} +1 -1
- package/dist/{root-HUJPHUHL.js → root-X5NDURAN.js} +3 -3
- package/dist/{root-HUJPHUHL.js.map → root-X5NDURAN.js.map} +1 -1
- package/dist/{search-N7G6BVN6.js → search-Q65IC67C.js} +2 -2
- package/dist/{search-N7G6BVN6.js.map → search-Q65IC67C.js.map} +1 -1
- package/dist/{skills-pages-VP32HFUN.js → skills-pages-TWOIIU5J.js} +2 -2
- package/dist/{skills-pages-VP32HFUN.js.map → skills-pages-TWOIIU5J.js.map} +1 -1
- package/package.json +3 -3
- package/dist/activity-nav-button-Z6M3FURW.js +0 -2
- package/dist/chunk-72TZUR4Q.js +0 -2
- package/dist/chunk-72TZUR4Q.js.map +0 -1
- package/dist/chunk-AN4APNXO.js +0 -2
- package/dist/chunk-AN4APNXO.js.map +0 -1
- package/dist/chunk-K7FD54PW.js +0 -6
- package/dist/chunk-K7FD54PW.js.map +0 -1
- package/dist/chunk-MM356YIK.js.map +0 -1
- package/dist/pages-ZKDDV5T3.js +0 -3
- package/dist/pages-ZKDDV5T3.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import'./index.css';import {c as c$3,a as a$3}from'./chunk-
|
|
1
|
+
import'./index.css';import {c as c$3,a as a$3}from'./chunk-NOFQHWES.js';import {a as a$1}from'./chunk-6RDPFMLK.js';import {a as a$2}from'./chunk-3C2EG3SI.js';import {s,J,u,v,w,x as x$1,C,j,e,h,g,A,B,E,G,F,H}from'./chunk-KWS3NAYS.js';import {c}from'./chunk-P6BZ4QP7.js';import {b as b$1}from'./chunk-7SK5YPHT.js';import'./chunk-2DXR5NJV.js';import {f,b}from'./chunk-LN55VJ35.js';import'./chunk-NNA4MLFC.js';import {x,y,z,s as s$1,ma,c as c$4,d as d$1,o as o$2}from'./chunk-YCCFUGWJ.js';import {c as c$2,d,h as h$1,i,k,l,j as j$1,w as w$1,n,o as o$1,p,q,r,t as t$1,s as s$2}from'./chunk-32ZU4MLE.js';import'./chunk-HDOIOXMP.js';import {e as e$2,g as g$1,h as h$2,j as j$2,o,t}from'./chunk-SZEGGBOC.js';import'./chunk-U45E5X3H.js';import {a,b as b$2,c as c$1,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$3}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useMemo,useCallback,useRef,useEffect}from'react';import {TagIcon,PlusIcon,Loader2,Ellipsis,Check,Copy,Link,MinusIcon,Trash2,LoaderCircle,Search,X,ImagePlayIcon,ImageIcon,FilePlayIcon,LayersIcon,SplinePointerIcon,ListChecks,Trash2Icon,LayoutGrid,List}from'lucide-react';import {gql}from'@apollo/client';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useLocation,Outlet,useParams}from'react-router-dom';import {useReactTable,getSortedRowModel,getPaginationRowModel,getFilteredRowModel,getCoreRowModel}from'@tanstack/react-table';import {defaultStyles,FileIcon}from'react-file-icon';var we={where:{},limit:500,offset:0,sort:[{name:"ASC"}]},Y={selection:"display",includeCount:false};function Et(){let{scope:e$3}=c(),{currentProjectSchema:n}=f(),[t,a$1,i$1]=C(),[f$1,c$3]=useState(""),[d$1,b]=useState(false),[v,u$1]=useState(false),[l$1,s]=useState(null),[M,p]=useState(false),[E,I]=useState(null),[J,x]=useState(""),[_,U]=useState(false),[F,B]=useState(false),h$3=b$1(),D="_tag",m="_tags",{data:C$1,isLoading:S}=u({entityNamePlural:m,schema:n,scope:e$3,variables:we,...Y}),z=(Array.isArray(C$1)?C$1:[]).map(r=>{let V=r;return {_id:V._id,name:V.name}}),O=useCallback(async()=>{let r=f$1.trim();if(!r)return;U(true);let V=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}`,L=j(m,n,{name:{value:r,disabled:false,scope:"default"}},V),j$1=e(m,e$3,n,Y),K=gql`
|
|
2
2
|
${j$1.query}
|
|
3
3
|
`;await new Promise(y=>{a$1(gql`
|
|
4
4
|
${L}
|
|
@@ -19,5 +19,5 @@ import'./index.css';import {c as c$3,a as a$3}from'./chunk-IAA4CEBW.js';import {
|
|
|
19
19
|
${D}
|
|
20
20
|
`),b({variables:{where:{_id:{in:e}}},onCompleted:S=>{x(S),m();},onError:S=>C(S)}),c$1(!0);}),a?.(),I(),t(null);}catch{}finally{M(false);}}},[x,e,s,a,t,I,c$1,v,i,u$1,d,b]),U=useCallback(async()=>{if(!(e.length===0||u$1.length===0||s)){M(true);try{let h={tags:{relationships:{disconnect:u$1},disabled:!1,scope:i}},D=g("_assets",e[0]??"",i,v,{},h,{responseFields:Ft});await new Promise((m,C)=>{d(gql`
|
|
21
21
|
${D}
|
|
22
|
-
`),b({variables:{where:{_id:{in:e}}},onCompleted:S=>{x(S),m();},onError:S=>C(S)}),c$1(!0);}),a?.(),I(),t(null);}catch{}finally{M(false);}}},[x,e,s,a,t,I,c$1,v,i,u$1,d,b]),F=n$1==="remove",B=F?"Remove tag(s)":"Add tag(s)";return e.length>1&&(B=F?"Remove tag(s) from selected assets":"Add tag(s) to selected assets"),jsxs(n,{open:n$1!==null,onOpenChange:J,children:[jsx(o$1,{placeholder:"Search tags..."}),jsxs(p,{className:"fk:h-75",children:[jsx(q,{children:"No tags found."}),jsx(r,{heading:"Tags",children:E.map(h=>{let D=u$1.includes(h._id);return jsxs(t$1,{disabled:s,onSelect:()=>{s||l(m=>D?m.filter(C=>C!==h._id):[...m,h._id]);},children:[jsx("input",{className:"fk:mr-2",checked:D,onChange:()=>{},type:"checkbox"}),h.name]},h._id)})})]}),jsx(s$2,{}),jsx("div",{className:"fk:p-2",children:jsxs(b$3,{className:"fk:w-full",disabled:u$1.length===0||s,onClick:F?U:_,children:[s?jsx(LoaderCircle,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):null,B]})})]})}function qe({overlay:e=false,row:n}){let[t,a]=useState(null),[i,f]=useState(null),c=A(),d=b$1(),b$2=n.original,v=b$2._id??"",u=b$2.url??"";function l(){c({type:"DeleteEntity",payload:{entityId:v,entityName:b.name}});}function s(p,E){navigator.clipboard.writeText(E),a(p),window.setTimeout(()=>a(null),1500);}return jsxs(Fragment,{children:[jsxs(e$2,{children:[jsx(g$1,{asChild:true,children:jsxs(b$3,{className:e?"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:text-white fk:group-hover:bg-background/10 fk:group-hover:text-white! fk:data-[state=open]:bg-background/15":"fk:flex fk:h-8 fk:w-8 fk:p-0 fk:data-[state=open]:bg-muted",onClick:p=>p.stopPropagation(),variant:"ghost",children:[jsx(Ellipsis,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Open menu"})]})}),jsxs(h$2,{align:"start",className:"fk:w-45",children:[jsxs(j$2,{disabled:!v,onClick:p=>{p.stopPropagation(),s("id",v);},children:[t==="id"?jsx(Check,{className:"fk:mr-2 fk:h-4 fk:w-4"}):jsx(Copy,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Copy ID"]}),jsxs(j$2,{disabled:!u,onClick:p=>{p.stopPropagation(),s("url",u);},children:[t==="url"?jsx(Check,{className:"fk:mr-2 fk:h-4 fk:w-4"}):jsx(Link,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Copy URL"]}),jsx(o,{}),jsxs(j$2,{disabled:!v||!d,onClick:p=>{p.stopPropagation(),f("add");},children:[jsx(TagIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Add tag"]}),jsxs(j$2,{disabled:!v||!d,onClick:p=>{p.stopPropagation(),f("remove");},children:[jsx(MinusIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Remove tag"]}),jsx(o,{}),jsxs(j$2,{className:"fk:text-destructive",disabled:!v||!d,onClick:p=>{p.stopPropagation(),l();},children:[jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete"]})]})]}),i!==null?jsx(Ve,{assetIds:v?[v]:[],mode:i,onModeChange:f}):null]})}var bo=FileIcon,wo="fk:bg-[#fafafa] [--asset-checker:#f0f0f0] [background-image:linear-gradient(45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(-45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--asset-checker)_75%),linear-gradient(-45deg,transparent_75%,var(--asset-checker)_75%)] [background-position:0_0,0_4px,4px_-4px,-4px_0px] [background-size:8px_8px] fk:dark:bg-[#222] dark:[--asset-checker:#2a2a2a]";function Do(e){return Math.max(600,e)}function Co(e){return e==null||Number.isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ot({columns:e,data:n,entityName:t$1,hasMore:a=false,isLoading:i=false,isLoadingMore:f=false,onLoadMore:c,onSortingChange:d,pageSize:b,sorting:v,toolbarComponent:u}){let l=useRef(null),{schemaErrorMessage:s$1}=s(),[M,p]=useState({}),[E,I]=useState({}),[J,x]=useState([]),[_,U]=useState([]),F=v??_;useEffect(()=>{l.current?.scrollTo({top:0});},[t$1]);function B(w){if(d){d(w);return}U(w);}let h=useReactTable({data:n,columns:e,state:{sorting:F,columnVisibility:E,rowSelection:M,columnFilters:J},initialState:{pagination:{pageSize:b??50}},enableRowSelection:true,onRowSelectionChange:p,onSortingChange:B,onColumnFiltersChange:x,onColumnVisibilityChange:I,getCoreRowModel:getCoreRowModel(),getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),getSortedRowModel:getSortedRowModel(),getRowId:w=>w._id,manualFiltering:true,manualPagination:true,manualSorting:true}),{rows:D}=h.getRowModel(),m=useRef(c),C=useRef(a),S=useRef(f);m.current=c,C.current=a,S.current=f;let z=useCallback(w=>{if(!m.current||!C.current||S.current)return;let P=w??l.current;if(!P)return;let{scrollHeight:r,scrollTop:V,clientHeight:X}=P;r-V-X>=Do(X)||m.current();},[]);useEffect(()=>{z();},[z,D.length,a,f]);function O(w){z(w.currentTarget);}return s$1?jsx(Fragment,{}):jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:w-full fk:min-w-0 fk:flex-col fk:gap-4",children:[u?u(h):null,jsxs("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1",children:[f?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:top-0 fk:right-px fk:left-px fk:z-20 fk:h-0.5 fk:overflow-hidden fk:opacity-40",children:jsx("div",{className:"fk:animate-progress fk:h-full fk:w-full fk:bg-foreground"})}):null,jsxs("div",{className:"fk:h-full fk:overflow-auto fk:pt-px fk:pb-20 fk:-ml-0.5 fk:pr-3",onScroll:O,ref:l,children:[i?jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] fk:gap-3",children:Array.from({length:b??50},(w,P)=>jsxs("div",{className:"fk:rounded-md fk:border fk:border-border fk:p-2 fk:corner-squircle",children:[jsx(t,{className:"fk:aspect-square fk:w-full fk:rounded-sm fk:corner-squircle"}),jsx(t,{className:"fk:mt-2 fk:h-3 fk:w-[75%]"}),jsx(t,{className:"fk:mt-1.5 fk:h-3 fk:w-[50%]"})]},`skeleton-${P}`))}):null,!i&&D.length===0?jsx("div",{className:"fk:flex fk:h-24 fk:items-center fk:justify-center fk:text-sm fk:text-muted-foreground",children:"No results."}):null,!i&&D.length>0?jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] fk:pl-0.5 fk:gap-3",children:D.map(w=>jsx(To,{row:w},w.id))}):null]})]})]})}function To({row:e}){let n=e.original,t=E(n)||"Untitled",a=n.mimeType??"",i=Co(n.size),f=e.getIsSelected(),c=[a,i].filter(Boolean).join(" \xB7 ");return jsxs("div",{className:`fk:relative fk:rounded-md fk:border fk:p-2 fk:transition-colors ${f?"fk:border-primary fk:ring-1 fk:ring-primary/40 fk:bg-muted/40":"fk:border-border fk:bg-background fk:hover:border-muted-foreground/30"} fk:corner-squircle`,"data-state":f?"selected":void 0,children:[jsx("div",{className:"fk:absolute fk:left-3 fk:top-3 fk:z-10 fk:mix-blend-difference",children:jsx(o$2,{className:"fk:border-white!","aria-label":`Select ${t}`,checked:f,onCheckedChange:d=>{e.toggleSelected(!!d);},onClick:d=>d.stopPropagation()})}),jsx("div",{className:"fk:group fk:absolute fk:right-2 fk:top-2 fk:z-10 fk:mix-blend-difference",children:jsx(qe,{overlay:true,row:e})}),jsx(So,{asset:n,filename:t}),jsx("div",{className:"fk:mt-2 fk:truncate fk:text-xs fk:font-medium",title:t,children:t}),c?jsx("div",{className:"fk:mt-0.5 fk:truncate fk:text-[11px] fk:text-muted-foreground",title:c,children:c}):null]})}function So({asset:e,filename:n}){let[t,a]=useState(false),[i$1,f]=useState(false),c=e.url??"";if(!c&&!e.path)return jsx("div",{className:"fk:flex fk:aspect-square fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:corner-squircle",children:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"No preview"})});if(!G(e)||!c){let s=F(e),M=defaultStyles[s];return jsx("div",{className:"fk:flex fk:aspect-square fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:[&>svg]:h-12 fk:[&>svg]:w-auto fk:corner-squircle",children:jsx(bo,{extension:s,...M||{}})})}let b=H(c,{width:320,height:320}),v=c;function u(s){s.stopPropagation(),f(false),a(true);}function l$1(s){a(s),s||f(false);}return jsxs(Fragment,{children:[jsx("button",{className:`fk:aspect-square fk:w-full fk:cursor-zoom-in fk:overflow-hidden fk:rounded-sm fk:border-0 fk:p-0 ${wo} fk:corner-squircle`,onClick:u,type:"button",children:jsx("img",{alt:n,className:"fk:h-full fk:w-full fk:object-contain",src:b})}),jsx(c$2,{open:t,onOpenChange:l$1,children:jsxs(h$1,{className:"fk:sm:max-w-4xl fk:p-3",children:[jsxs(i,{children:[jsx(k,{className:"fk:sr-only",children:"Asset preview"}),jsx(l,{className:"fk:sr-only",children:"Enlarged asset preview"})]}),jsxs("div",{className:"fk:relative fk:flex fk:h-[min(85vh,56rem)] fk:w-full fk:items-center fk:justify-center fk:overflow-hidden fk:rounded-md fk:corner-squircle",children:[i$1?null:jsx(LoaderCircle,{"aria-label":"Loading image",className:"fk:absolute fk:h-8 fk:w-8 fk:animate-spin fk:text-muted-foreground"}),jsx("img",{alt:n,className:`fk:max-h-full fk:max-w-full fk:object-contain fk:transition-opacity ${i$1?"fk:opacity-100":"fk:opacity-0"}`,onError:()=>f(true),onLoad:()=>f(true),src:v})]})]})})]})}var Oo=[{value:"image/gif",label:"GIF",icon:ImagePlayIcon},{value:"image/jpeg",label:"JPEG",icon:ImageIcon},{value:"video/mp4",label:"MP4",icon:FilePlayIcon},{value:"image/png",label:"PNG",icon:LayersIcon},{value:"image/svg+xml",label:"SVG",icon:SplinePointerIcon},{value:"image/webp",label:"WebP",icon:ImageIcon}];function Ze({entityName:e,isUploading:n=false,table:t,viewMode:a,onUploadClick:i,onViewModeChange:f$1,onSearchLoadingChange:c$1,onSearchWhereChange:d}){let b=t.getState().columnFilters.length>0,{projectId:v}=useParams(),u$1=A(),{scope:l}=c(),[s,M]=useState(null),{currentProjectSchema:p}=f(),E=b$1(),[I,J]=useState(""),x=useRef({}),_=useRef({});function U(){return {searchRequests:{searches:[{collection:"_assets"},{collection:"_tags"}]},commonParams:{q:""}}}let F=useMemo(()=>U(),[]),[B$1,h]=useState(F),{results:D,isLoading:m}=a$1(v??"",B$1),C=useRef(""),S=I.trim(),z=B$1.commonParams.q??"",O=S.length>0&&(m||z!==S),w=useMemo(()=>Uo(g=>{h({...F,commonParams:{q:g}});},300),[F]);useEffect(()=>()=>{w.cancel();},[w]);let P=t.getSelectedRowModel().rows.map(g=>g.original._id),{data:r}=u({entityNamePlural:"_tags",schema:p,scope:l,variables:we,...Y}),V=useMemo(()=>(Array.isArray(r)?r:[]).map(N=>({_id:N._id,name:N.name})),[r]),X$1=useMemo(()=>V.map(g=>({value:g._id,label:g.name})),[V]),L=useCallback(()=>{if(!d)return;let g=[];Object.keys(x.current).length>0&&g.push(x.current),Object.keys(_.current).length>0&&g.push(_.current);let N=g.length===0?{}:g.length===1?g[0]:{AND:g},Z=JSON.stringify(N);C.current!==Z&&(C.current=Z,d(N));},[d]);function j(){w.cancel(),J(""),h({...F,commonParams:{q:""}}),x.current={},L();}async function K(){u$1({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${P.length} asset${P.length>1?"s":""}`,dialogMessage:P.length>1?"Are you sure you want to delete the selected assets? They will be deleted permanently.":"Are you sure you want to delete the selected asset? The item will be deleted permanently.",dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionCancel:()=>{},dialogActionSubmit:()=>{u$1({type:"DeleteEntity",_id:`delete-batch-${Date.now()}`,payload:{entityId:P,entityName:e,silent:true}}),t.resetRowSelection();}}}});}useEffect(()=>{c$1?.(O);},[O,c$1]),useEffect(()=>{if(!d)return;if(S.length===0){x.current={},L();return}if(O)return;let g=D??[],N={};if(g.length===0)N={_id:{in:[]}};else {let Z=g.filter(q=>q._entityNamePlural==="_assets").map(q=>q._id),xe=g.filter(q=>q._entityNamePlural==="_tags").map(q=>({tags:{some:{_id:{eq:q._id}}}})),Q=[];Z.length>0&&Q.push({_id:{in:Z}}),Q.push(...xe),Q.length===0?N={_id:{in:[]}}:Q.length===1?N=Q[0]:N={OR:Q};}x.current=N,L();},[L,O,d,D,S]);let y=JSON.stringify(t.getState().columnFilters);return useEffect(()=>{if(!d)return;let g=t.getState().columnFilters.find(q=>q.id==="mimeType"),N=Array.isArray(g?.value)?g?.value:[],Z=t.getState().columnFilters.find(q=>q.id==="tags"),xe=Array.isArray(Z?.value)?Z?.value:[],Q=[];if(N.length>0&&Q.push({mimeType:{in:N}}),xe.length>0){let q=xe.map(Ht=>({tags:{some:{_id:{eq:Ht}}}}));Q.push(q.length===1?q[0]:{OR:q});}Q.length===0?_.current={}:Q.length===1?_.current=Q[0]:_.current={AND:Q},L();},[y,L,d,t]),jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:pr-3",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[jsxs("div",{className:"fk:relative",children:[m?jsx(LoaderCircle,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50 fk:animate-spin"}):jsx(Search,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50"}),jsx(s$1,{placeholder:"Search assets...",name:"search-assets",value:I,onChange:g=>{let{value:N}=g.target;if(J(N),N.trim().length===0){j();return}w(N.trim());},className:"fk:h-8 fk:w-37.5 fk:lg:w-70 fk:px-7"}),I?jsx(b$3,{"aria-label":"Clear search",className:"fk:absolute fk:right-1 fk:top-1 fk:h-6 fk:w-6 fk:text-muted-foreground fk:hover:text-foreground fk:hover:bg-foreground/10 fk:cursor-pointer fk:rounded-full fk:bg-transparent fk:corner-squircle",onClick:j,type:"button",children:jsx(X,{className:"fk:h-4 fk:w-4"})}):null]}),t.getColumn("mimeType")&&jsx(a$2,{column:t.getColumn("mimeType"),options:Oo,title:"File type"}),t.getColumn("tags")&&jsx(a$2,{column:t.getColumn("tags"),options:X$1,title:"Tags"}),b&&jsxs(b$3,{variant:"ghost",onClick:()=>{t.resetColumnFilters(),_.current={},L();},className:"fk:h-8 fk:px-2 fk:lg:px-3",children:["Reset",jsx(X,{className:"fk:ml-2 fk:h-4 fk:w-4"})]}),jsx(B,{table:t})]}),P.length>0?jsx("div",{className:"fk:flex fk:items-center fk:gap-2",children:jsxs(e$2,{children:[jsx(ma,{disabled:!E,children:jsx(g$1,{asChild:true,children:jsxs(b$3,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:!E,size:"sm",variant:"secondary",children:["Actions ",jsx(ListChecks,{className:"fk:ml-2 fk:h-4 fk:w-4"})]})})}),jsxs(h$2,{align:"end",className:"fk:w-[240px]",children:[jsxs(j$2,{onClick:()=>M("add"),children:[jsx(TagIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Add tag"]}),jsxs(j$2,{onClick:()=>M("remove"),children:[jsx(MinusIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Remove tag"]}),jsx(o,{}),jsxs(j$2,{onClick:K,className:"fk:text-destructive",children:[jsx(Trash2Icon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Delete asset",P.length>1?"s":""," (",P.length,")"]})]})]})}):null,jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(c$4,{size:"sm",type:"single",value:a,onValueChange:g=>{(g==="list"||g==="grid")&&f$1(g);},children:[jsx(d$1,{"aria-label":"Grid view",value:"grid",children:jsx(LayoutGrid,{className:"fk:h-4 fk:w-4"})}),jsx(d$1,{"aria-label":"List view",value:"list",children:jsx(List,{className:"fk:h-4 fk:w-4"})})]}),jsx(ma,{disabled:!E,children:jsxs(b$3,{"aria-busy":n,className:"fk:h-8 fk:lg:flex",disabled:!E||n,onClick:i,size:"sm",variant:"default",children:[n?jsx(LoaderCircle,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):null,"Upload assets"]})})]}),s!==null?jsx(Ve,{assetIds:P,mode:s,onCompleted:()=>t.resetRowSelection(),onModeChange:M}):null]})}function Uo(e,n=300){let t,a=function(...i){t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e.apply(this,i);},n);};return a.cancel=()=>{t!==void 0&&(clearTimeout(t),t=void 0);},a}var Qo=4*1024*1024;function Gt(){let{projectId:e}=useParams(),n=c$3(),t=b$1(),[a,i]=useState(false);async function f(c){if(!(!t||a)&&!(c&&c.length===0))try{await n({files:c,maxBytes:Qo,multiple:!0,onUploadStart:()=>{i(!0);},projectId:e});}finally{i(false);}}return {canMutate:t,isUploading:a,uploadFiles:c=>f(c),uploadFromDialog:()=>f()}}var Wt="flexkit-asset-manager:viewMode";function $t(){if(typeof localStorage>"u")return "grid";try{let e=localStorage.getItem(Wt);if(e==="list"||e==="grid")return e}catch{}return "grid"}function Jt(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(Wt,e);}catch{}}var Me=36,Jo=[{_updatedAt:"DESC"},{_id:"DESC"}];function Xt(){let e="_assets",{search:n}=useLocation(),a=new URLSearchParams(n).get("id"),{scope:i}=c(),{schemaErrorMessage:f$1}=s(),{currentProject:c$1}=f(),d=c$1?.schema??[],[b$1,v$1]=useState([]),[u$1,l]=useState(()=>$t()),s$1=J({attributesSchema:b.attributes,actionsComponent:y=>jsx(qe,{row:y}),checkboxSelect:"multiple",enableColumnSorting:true}),[M,p]=useState({}),[E,I]=useState(false),{canMutate:J$1,isUploading:x,uploadFiles:_,uploadFromDialog:U}=Gt(),F=useMemo(()=>{let y=a?{_id:{eq:a}}:{NOT:{path:{eq:null}}};return !M||Object.keys(M).length===0||a?y:{AND:[y,M]}},[a,M]),B=useMemo(()=>{if(b$1.length===0)return Jo;let y=b$1.map(({id:N,desc:Z})=>({[N]:Z?"DESC":"ASC"}));return y.some(N=>"_id"in N)?y:[...y,{_id:"DESC"}]},[b$1]),h=useMemo(()=>({where:F,offset:0,limit:Me,sort:B}),[F,B]);function D(y){v$1(y);}function m(y){l(y),Jt(y);}let{isLoading:C,isLoadingMore:S,fetchMore:z,count:O,data:w$1,isProjectDisabled:P}=u({entityNamePlural:e,schema:d,scope:i,variables:h,selection:"list"}),r=E||C&&(w$1==null||w$1.length===0),V=w$1?.length??0,X=!E&&O>0&&V>0&&V<O,L=useCallback(()=>{z({variables:{offset:0,limit:Me}});},[z]),j=useMemo(()=>Array.from({length:Me},(y,g)=>({_id:`loading-${g}`})),[]),K=useMemo(()=>Xo(s$1),[s$1]);return P?jsx("div",{className:"fk:flex fk:flex-col fk:h-full fk:pl-3",children:jsx(v,{})}):jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:pl-3",children:[jsx(w,{}),jsxs("div",{className:"fk:mb-4 fk:flex fk:items-center fk:gap-2 fk:pr-3",children:[jsx("h2",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"Asset Manager"}),r?null:jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[O.toLocaleString()," ",O===1?"record":"records"]})]}),f$1?null:jsx(_t,{disabled:!J$1||x,onDropFiles:_,children:u$1==="list"?jsx(x$1,{classNames:{row:"fk:h-20"},columns:r?K:s$1,data:r?j:w$1??[],entityName:b.name,hasMore:X,isLoadingMore:S,pageSize:Me,sorting:b$1,onLoadMore:L,onSortingChange:D,toolbarComponent:y=>jsx(Ze,{entityName:b.name,isUploading:x,table:y,viewMode:u$1,onSearchLoadingChange:I,onSearchWhereChange:p,onUploadClick:U,onViewModeChange:m})}):jsx(Ot,{columns:s$1,data:r?[]:w$1??[],entityName:b.name,hasMore:X,isLoading:r,isLoadingMore:S,pageSize:Me,sorting:b$1,onLoadMore:L,onSortingChange:D,toolbarComponent:y=>jsx(Ze,{entityName:b.name,isUploading:x,table:y,viewMode:u$1,onSearchLoadingChange:I,onSearchWhereChange:p,onUploadClick:U,onViewModeChange:m})})}),jsx(Outlet,{})]})}function Xo(e){return e.map(n=>({...n,cell:()=>jsx(t,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}function On(){return jsxs(x,{orientation:"horizontal",className:"fk:h-full",children:[jsx(y,{className:"fk:p-3",defaultSize:"82%",children:jsx("div",{className:"fk:flex fk:flex-col fk:h-full",children:jsx(Xt,{})})}),jsx(z,{className:"fk:hover:bg-blue-500 fk:transition-colors",withHandle:true}),jsx(y,{defaultSize:"18%",minSize:"10%",children:jsx("div",{className:"fk:sm:hidden fk:md:block",children:jsx(Et,{})})})]})}export{On as Root};//# sourceMappingURL=root-HUJPHUHL.js.map
|
|
23
|
-
//# sourceMappingURL=root-
|
|
22
|
+
`),b({variables:{where:{_id:{in:e}}},onCompleted:S=>{x(S),m();},onError:S=>C(S)}),c$1(!0);}),a?.(),I(),t(null);}catch{}finally{M(false);}}},[x,e,s,a,t,I,c$1,v,i,u$1,d,b]),F=n$1==="remove",B=F?"Remove tag(s)":"Add tag(s)";return e.length>1&&(B=F?"Remove tag(s) from selected assets":"Add tag(s) to selected assets"),jsxs(n,{open:n$1!==null,onOpenChange:J,children:[jsx(o$1,{placeholder:"Search tags..."}),jsxs(p,{className:"fk:h-75",children:[jsx(q,{children:"No tags found."}),jsx(r,{heading:"Tags",children:E.map(h=>{let D=u$1.includes(h._id);return jsxs(t$1,{disabled:s,onSelect:()=>{s||l(m=>D?m.filter(C=>C!==h._id):[...m,h._id]);},children:[jsx("input",{className:"fk:mr-2",checked:D,onChange:()=>{},type:"checkbox"}),h.name]},h._id)})})]}),jsx(s$2,{}),jsx("div",{className:"fk:p-2",children:jsxs(b$3,{className:"fk:w-full",disabled:u$1.length===0||s,onClick:F?U:_,children:[s?jsx(LoaderCircle,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):null,B]})})]})}function qe({overlay:e=false,row:n}){let[t,a]=useState(null),[i,f]=useState(null),c=A(),d=b$1(),b$2=n.original,v=b$2._id??"",u=b$2.url??"";function l(){c({type:"DeleteEntity",payload:{entityId:v,entityName:b.name}});}function s(p,E){navigator.clipboard.writeText(E),a(p),window.setTimeout(()=>a(null),1500);}return jsxs(Fragment,{children:[jsxs(e$2,{children:[jsx(g$1,{asChild:true,children:jsxs(b$3,{className:e?"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:text-white fk:group-hover:bg-background/10 fk:group-hover:text-white! fk:data-[state=open]:bg-background/15":"fk:flex fk:h-8 fk:w-8 fk:p-0 fk:data-[state=open]:bg-muted",onClick:p=>p.stopPropagation(),variant:"ghost",children:[jsx(Ellipsis,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Open menu"})]})}),jsxs(h$2,{align:"start",className:"fk:w-45",children:[jsxs(j$2,{disabled:!v,onClick:p=>{p.stopPropagation(),s("id",v);},children:[t==="id"?jsx(Check,{className:"fk:mr-2 fk:h-4 fk:w-4"}):jsx(Copy,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Copy ID"]}),jsxs(j$2,{disabled:!u,onClick:p=>{p.stopPropagation(),s("url",u);},children:[t==="url"?jsx(Check,{className:"fk:mr-2 fk:h-4 fk:w-4"}):jsx(Link,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Copy URL"]}),jsx(o,{}),jsxs(j$2,{disabled:!v||!d,onClick:p=>{p.stopPropagation(),f("add");},children:[jsx(TagIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Add tag"]}),jsxs(j$2,{disabled:!v||!d,onClick:p=>{p.stopPropagation(),f("remove");},children:[jsx(MinusIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Remove tag"]}),jsx(o,{}),jsxs(j$2,{className:"fk:text-destructive",disabled:!v||!d,onClick:p=>{p.stopPropagation(),l();},children:[jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete"]})]})]}),i!==null?jsx(Ve,{assetIds:v?[v]:[],mode:i,onModeChange:f}):null]})}var bo=FileIcon,wo="fk:bg-[#fafafa] [--asset-checker:#f0f0f0] [background-image:linear-gradient(45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(-45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--asset-checker)_75%),linear-gradient(-45deg,transparent_75%,var(--asset-checker)_75%)] [background-position:0_0,0_4px,4px_-4px,-4px_0px] [background-size:8px_8px] fk:dark:bg-[#222] dark:[--asset-checker:#2a2a2a]";function Do(e){return Math.max(600,e)}function Co(e){return e==null||Number.isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ot({columns:e,data:n,entityName:t$1,hasMore:a=false,isLoading:i=false,isLoadingMore:f=false,onLoadMore:c,onSortingChange:d,pageSize:b,sorting:v,toolbarComponent:u}){let l=useRef(null),{schemaErrorMessage:s$1}=s(),[M,p]=useState({}),[E,I]=useState({}),[J,x]=useState([]),[_,U]=useState([]),F=v??_;useEffect(()=>{l.current?.scrollTo({top:0});},[t$1]);function B(w){if(d){d(w);return}U(w);}let h=useReactTable({data:n,columns:e,state:{sorting:F,columnVisibility:E,rowSelection:M,columnFilters:J},initialState:{pagination:{pageSize:b??50}},enableRowSelection:true,onRowSelectionChange:p,onSortingChange:B,onColumnFiltersChange:x,onColumnVisibilityChange:I,getCoreRowModel:getCoreRowModel(),getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),getSortedRowModel:getSortedRowModel(),getRowId:w=>w._id,manualFiltering:true,manualPagination:true,manualSorting:true}),{rows:D}=h.getRowModel(),m=useRef(c),C=useRef(a),S=useRef(f);m.current=c,C.current=a,S.current=f;let z=useCallback(w=>{if(!m.current||!C.current||S.current)return;let P=w??l.current;if(!P)return;let{scrollHeight:r,scrollTop:V,clientHeight:X}=P;r-V-X>=Do(X)||m.current();},[]);useEffect(()=>{z();},[z,D.length,a,f]);function O(w){z(w.currentTarget);}return s$1?jsx(Fragment,{}):jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:w-full fk:min-w-0 fk:flex-col fk:gap-4",children:[u?u(h):null,jsxs("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1",children:[f?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:top-0 fk:right-px fk:left-px fk:z-20 fk:h-0.5 fk:overflow-hidden fk:opacity-40",children:jsx("div",{className:"fk:animate-progress fk:h-full fk:w-full fk:bg-foreground"})}):null,jsxs("div",{className:"fk:h-full fk:overflow-auto fk:pt-px fk:pb-20 fk:-ml-0.5 fk:pr-3",onScroll:O,ref:l,children:[i?jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] fk:gap-3",children:Array.from({length:b??50},(w,P)=>jsxs("div",{className:"fk:rounded-md fk:border fk:border-border fk:p-2 fk:corner-squircle",children:[jsx(t,{className:"fk:aspect-square fk:w-full fk:rounded-sm fk:corner-squircle"}),jsx(t,{className:"fk:mt-2 fk:h-3 fk:w-[75%]"}),jsx(t,{className:"fk:mt-1.5 fk:h-3 fk:w-[50%]"})]},`skeleton-${P}`))}):null,!i&&D.length===0?jsx("div",{className:"fk:flex fk:h-24 fk:items-center fk:justify-center fk:text-sm fk:text-muted-foreground",children:"No results."}):null,!i&&D.length>0?jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] fk:pl-0.5 fk:gap-3",children:D.map(w=>jsx(To,{row:w},w.id))}):null]})]})]})}function To({row:e}){let n=e.original,t=E(n)||"Untitled",a=n.mimeType??"",i=Co(n.size),f=e.getIsSelected(),c=[a,i].filter(Boolean).join(" \xB7 ");return jsxs("div",{className:`fk:relative fk:rounded-md fk:border fk:p-2 fk:transition-colors ${f?"fk:border-primary fk:ring-1 fk:ring-primary/40 fk:bg-muted/40":"fk:border-border fk:bg-background fk:hover:border-muted-foreground/30"} fk:corner-squircle`,"data-state":f?"selected":void 0,children:[jsx("div",{className:"fk:absolute fk:left-3 fk:top-3 fk:z-10 fk:mix-blend-difference",children:jsx(o$2,{className:"fk:border-white!","aria-label":`Select ${t}`,checked:f,onCheckedChange:d=>{e.toggleSelected(!!d);},onClick:d=>d.stopPropagation()})}),jsx("div",{className:"fk:group fk:absolute fk:right-2 fk:top-2 fk:z-10 fk:mix-blend-difference",children:jsx(qe,{overlay:true,row:e})}),jsx(So,{asset:n,filename:t}),jsx("div",{className:"fk:mt-2 fk:truncate fk:text-xs fk:font-medium",title:t,children:t}),c?jsx("div",{className:"fk:mt-0.5 fk:truncate fk:text-[11px] fk:text-muted-foreground",title:c,children:c}):null]})}function So({asset:e,filename:n}){let[t,a]=useState(false),[i$1,f]=useState(false),c=e.url??"";if(!c&&!e.path)return jsx("div",{className:"fk:flex fk:aspect-square fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:corner-squircle",children:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"No preview"})});if(!G(e)||!c){let s=F(e),M=defaultStyles[s];return jsx("div",{className:"fk:flex fk:aspect-square fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:[&>svg]:h-12 fk:[&>svg]:w-auto fk:corner-squircle",children:jsx(bo,{extension:s,...M||{}})})}let b=H(c,{width:320,height:320}),v=c;function u(s){s.stopPropagation(),f(false),a(true);}function l$1(s){a(s),s||f(false);}return jsxs(Fragment,{children:[jsx("button",{className:`fk:aspect-square fk:w-full fk:cursor-zoom-in fk:overflow-hidden fk:rounded-sm fk:border-0 fk:p-0 ${wo} fk:corner-squircle`,onClick:u,type:"button",children:jsx("img",{alt:n,className:"fk:h-full fk:w-full fk:object-contain",src:b})}),jsx(c$2,{open:t,onOpenChange:l$1,children:jsxs(h$1,{className:"fk:sm:max-w-4xl fk:p-3",children:[jsxs(i,{children:[jsx(k,{className:"fk:sr-only",children:"Asset preview"}),jsx(l,{className:"fk:sr-only",children:"Enlarged asset preview"})]}),jsxs("div",{className:"fk:relative fk:flex fk:h-[min(85vh,56rem)] fk:w-full fk:items-center fk:justify-center fk:overflow-hidden fk:rounded-md fk:corner-squircle",children:[i$1?null:jsx(LoaderCircle,{"aria-label":"Loading image",className:"fk:absolute fk:h-8 fk:w-8 fk:animate-spin fk:text-muted-foreground"}),jsx("img",{alt:n,className:`fk:max-h-full fk:max-w-full fk:object-contain fk:transition-opacity ${i$1?"fk:opacity-100":"fk:opacity-0"}`,onError:()=>f(true),onLoad:()=>f(true),src:v})]})]})})]})}var Oo=[{value:"image/gif",label:"GIF",icon:ImagePlayIcon},{value:"image/jpeg",label:"JPEG",icon:ImageIcon},{value:"video/mp4",label:"MP4",icon:FilePlayIcon},{value:"image/png",label:"PNG",icon:LayersIcon},{value:"image/svg+xml",label:"SVG",icon:SplinePointerIcon},{value:"image/webp",label:"WebP",icon:ImageIcon}];function Ze({entityName:e,isUploading:n=false,table:t,viewMode:a,onUploadClick:i,onViewModeChange:f$1,onSearchLoadingChange:c$1,onSearchWhereChange:d}){let b=t.getState().columnFilters.length>0,{projectId:v}=useParams(),u$1=A(),{scope:l}=c(),[s,M]=useState(null),{currentProjectSchema:p}=f(),E=b$1(),[I,J]=useState(""),x=useRef({}),_=useRef({});function U(){return {searchRequests:{searches:[{collection:"_assets"},{collection:"_tags"}]},commonParams:{q:""}}}let F=useMemo(()=>U(),[]),[B$1,h]=useState(F),{results:D,isLoading:m}=a$1(v??"",B$1),C=useRef(""),S=I.trim(),z=B$1.commonParams.q??"",O=S.length>0&&(m||z!==S),w=useMemo(()=>Uo(g=>{h({...F,commonParams:{q:g}});},300),[F]);useEffect(()=>()=>{w.cancel();},[w]);let P=t.getSelectedRowModel().rows.map(g=>g.original._id),{data:r}=u({entityNamePlural:"_tags",schema:p,scope:l,variables:we,...Y}),V=useMemo(()=>(Array.isArray(r)?r:[]).map(N=>({_id:N._id,name:N.name})),[r]),X$1=useMemo(()=>V.map(g=>({value:g._id,label:g.name})),[V]),L=useCallback(()=>{if(!d)return;let g=[];Object.keys(x.current).length>0&&g.push(x.current),Object.keys(_.current).length>0&&g.push(_.current);let N=g.length===0?{}:g.length===1?g[0]:{AND:g},Z=JSON.stringify(N);C.current!==Z&&(C.current=Z,d(N));},[d]);function j(){w.cancel(),J(""),h({...F,commonParams:{q:""}}),x.current={},L();}async function K(){u$1({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${P.length} asset${P.length>1?"s":""}`,dialogMessage:P.length>1?"Are you sure you want to delete the selected assets? They will be deleted permanently.":"Are you sure you want to delete the selected asset? The item will be deleted permanently.",dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionCancel:()=>{},dialogActionSubmit:()=>{u$1({type:"DeleteEntity",_id:`delete-batch-${Date.now()}`,payload:{entityId:P,entityName:e,silent:true}}),t.resetRowSelection();}}}});}useEffect(()=>{c$1?.(O);},[O,c$1]),useEffect(()=>{if(!d)return;if(S.length===0){x.current={},L();return}if(O)return;let g=D??[],N={};if(g.length===0)N={_id:{in:[]}};else {let Z=g.filter(q=>q._entityNamePlural==="_assets").map(q=>q._id),xe=g.filter(q=>q._entityNamePlural==="_tags").map(q=>({tags:{some:{_id:{eq:q._id}}}})),Q=[];Z.length>0&&Q.push({_id:{in:Z}}),Q.push(...xe),Q.length===0?N={_id:{in:[]}}:Q.length===1?N=Q[0]:N={OR:Q};}x.current=N,L();},[L,O,d,D,S]);let y=JSON.stringify(t.getState().columnFilters);return useEffect(()=>{if(!d)return;let g=t.getState().columnFilters.find(q=>q.id==="mimeType"),N=Array.isArray(g?.value)?g?.value:[],Z=t.getState().columnFilters.find(q=>q.id==="tags"),xe=Array.isArray(Z?.value)?Z?.value:[],Q=[];if(N.length>0&&Q.push({mimeType:{in:N}}),xe.length>0){let q=xe.map(Ht=>({tags:{some:{_id:{eq:Ht}}}}));Q.push(q.length===1?q[0]:{OR:q});}Q.length===0?_.current={}:Q.length===1?_.current=Q[0]:_.current={AND:Q},L();},[y,L,d,t]),jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:pr-3",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[jsxs("div",{className:"fk:relative",children:[m?jsx(LoaderCircle,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50 fk:animate-spin"}):jsx(Search,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50"}),jsx(s$1,{placeholder:"Search assets...",name:"search-assets",value:I,onChange:g=>{let{value:N}=g.target;if(J(N),N.trim().length===0){j();return}w(N.trim());},className:"fk:h-8 fk:w-37.5 fk:lg:w-70 fk:px-7"}),I?jsx(b$3,{"aria-label":"Clear search",className:"fk:absolute fk:right-1 fk:top-1 fk:h-6 fk:w-6 fk:text-muted-foreground fk:hover:text-foreground fk:hover:bg-foreground/10 fk:cursor-pointer fk:rounded-full fk:bg-transparent fk:corner-squircle",onClick:j,type:"button",children:jsx(X,{className:"fk:h-4 fk:w-4"})}):null]}),t.getColumn("mimeType")&&jsx(a$2,{column:t.getColumn("mimeType"),options:Oo,title:"File type"}),t.getColumn("tags")&&jsx(a$2,{column:t.getColumn("tags"),options:X$1,title:"Tags"}),b&&jsxs(b$3,{variant:"ghost",onClick:()=>{t.resetColumnFilters(),_.current={},L();},className:"fk:h-8 fk:px-2 fk:lg:px-3",children:["Reset",jsx(X,{className:"fk:ml-2 fk:h-4 fk:w-4"})]}),jsx(B,{table:t})]}),P.length>0?jsx("div",{className:"fk:flex fk:items-center fk:gap-2",children:jsxs(e$2,{children:[jsx(ma,{disabled:!E,children:jsx(g$1,{asChild:true,children:jsxs(b$3,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:!E,size:"sm",variant:"secondary",children:["Actions ",jsx(ListChecks,{className:"fk:ml-2 fk:h-4 fk:w-4"})]})})}),jsxs(h$2,{align:"end",className:"fk:w-[240px]",children:[jsxs(j$2,{onClick:()=>M("add"),children:[jsx(TagIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Add tag"]}),jsxs(j$2,{onClick:()=>M("remove"),children:[jsx(MinusIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Remove tag"]}),jsx(o,{}),jsxs(j$2,{onClick:K,className:"fk:text-destructive",children:[jsx(Trash2Icon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Delete asset",P.length>1?"s":""," (",P.length,")"]})]})]})}):null,jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(c$4,{size:"sm",type:"single",value:a,onValueChange:g=>{(g==="list"||g==="grid")&&f$1(g);},children:[jsx(d$1,{"aria-label":"Grid view",value:"grid",children:jsx(LayoutGrid,{className:"fk:h-4 fk:w-4"})}),jsx(d$1,{"aria-label":"List view",value:"list",children:jsx(List,{className:"fk:h-4 fk:w-4"})})]}),jsx(ma,{disabled:!E,children:jsxs(b$3,{"aria-busy":n,className:"fk:h-8 fk:lg:flex",disabled:!E||n,onClick:i,size:"sm",variant:"default",children:[n?jsx(LoaderCircle,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):null,"Upload assets"]})})]}),s!==null?jsx(Ve,{assetIds:P,mode:s,onCompleted:()=>t.resetRowSelection(),onModeChange:M}):null]})}function Uo(e,n=300){let t,a=function(...i){t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e.apply(this,i);},n);};return a.cancel=()=>{t!==void 0&&(clearTimeout(t),t=void 0);},a}var Qo=4*1024*1024;function Gt(){let{projectId:e}=useParams(),n=c$3(),t=b$1(),[a,i]=useState(false);async function f(c){if(!(!t||a)&&!(c&&c.length===0))try{await n({files:c,maxBytes:Qo,multiple:!0,onUploadStart:()=>{i(!0);},projectId:e});}finally{i(false);}}return {canMutate:t,isUploading:a,uploadFiles:c=>f(c),uploadFromDialog:()=>f()}}var Wt="flexkit-asset-manager:viewMode";function $t(){if(typeof localStorage>"u")return "grid";try{let e=localStorage.getItem(Wt);if(e==="list"||e==="grid")return e}catch{}return "grid"}function Jt(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(Wt,e);}catch{}}var Me=36,Jo=[{_updatedAt:"DESC"},{_id:"DESC"}];function Xt(){let e="_assets",{search:n}=useLocation(),a=new URLSearchParams(n).get("id"),{scope:i}=c(),{schemaErrorMessage:f$1}=s(),{currentProject:c$1}=f(),d=c$1?.schema??[],[b$1,v$1]=useState([]),[u$1,l]=useState(()=>$t()),s$1=J({attributesSchema:b.attributes,actionsComponent:y=>jsx(qe,{row:y}),checkboxSelect:"multiple",enableColumnSorting:true}),[M,p]=useState({}),[E,I]=useState(false),{canMutate:J$1,isUploading:x,uploadFiles:_,uploadFromDialog:U}=Gt(),F=useMemo(()=>{let y=a?{_id:{eq:a}}:{NOT:{path:{eq:null}}};return !M||Object.keys(M).length===0||a?y:{AND:[y,M]}},[a,M]),B=useMemo(()=>{if(b$1.length===0)return Jo;let y=b$1.map(({id:N,desc:Z})=>({[N]:Z?"DESC":"ASC"}));return y.some(N=>"_id"in N)?y:[...y,{_id:"DESC"}]},[b$1]),h=useMemo(()=>({where:F,offset:0,limit:Me,sort:B}),[F,B]);function D(y){v$1(y);}function m(y){l(y),Jt(y);}let{isLoading:C,isLoadingMore:S,fetchMore:z,count:O,data:w$1,isProjectDisabled:P}=u({entityNamePlural:e,schema:d,scope:i,variables:h,selection:"list"}),r=E||C&&(w$1==null||w$1.length===0),V=w$1?.length??0,X=!E&&O>0&&V>0&&V<O,L=useCallback(()=>{z({variables:{offset:0,limit:Me}});},[z]),j=useMemo(()=>Array.from({length:Me},(y,g)=>({_id:`loading-${g}`})),[]),K=useMemo(()=>Xo(s$1),[s$1]);return P?jsx("div",{className:"fk:flex fk:flex-col fk:h-full fk:pl-3",children:jsx(v,{})}):jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:pl-3",children:[jsx(w,{}),jsxs("div",{className:"fk:mb-4 fk:flex fk:items-center fk:gap-2 fk:pr-3",children:[jsx("h2",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"Asset Manager"}),r?null:jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[O.toLocaleString()," ",O===1?"record":"records"]})]}),f$1?null:jsx(_t,{disabled:!J$1||x,onDropFiles:_,children:u$1==="list"?jsx(x$1,{classNames:{row:"fk:h-20"},columns:r?K:s$1,data:r?j:w$1??[],entityName:b.name,hasMore:X,isLoadingMore:S,pageSize:Me,sorting:b$1,onLoadMore:L,onSortingChange:D,toolbarComponent:y=>jsx(Ze,{entityName:b.name,isUploading:x,table:y,viewMode:u$1,onSearchLoadingChange:I,onSearchWhereChange:p,onUploadClick:U,onViewModeChange:m})}):jsx(Ot,{columns:s$1,data:r?[]:w$1??[],entityName:b.name,hasMore:X,isLoading:r,isLoadingMore:S,pageSize:Me,sorting:b$1,onLoadMore:L,onSortingChange:D,toolbarComponent:y=>jsx(Ze,{entityName:b.name,isUploading:x,table:y,viewMode:u$1,onSearchLoadingChange:I,onSearchWhereChange:p,onUploadClick:U,onViewModeChange:m})})}),jsx(Outlet,{})]})}function Xo(e){return e.map(n=>({...n,cell:()=>jsx(t,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}function On(){return jsxs(x,{orientation:"horizontal",className:"fk:h-full",children:[jsx(y,{className:"fk:p-3",defaultSize:"82%",children:jsx("div",{className:"fk:flex fk:flex-col fk:h-full",children:jsx(Xt,{})})}),jsx(z,{className:"fk:hover:bg-blue-500 fk:transition-colors",withHandle:true}),jsx(y,{defaultSize:"18%",minSize:"10%",children:jsx("div",{className:"fk:sm:hidden fk:md:block",children:jsx(Et,{})})})]})}export{On as Root};//# sourceMappingURL=root-X5NDURAN.js.map
|
|
23
|
+
//# sourceMappingURL=root-X5NDURAN.js.map
|