PageSourceSearch

https://www.artgalleryofballarat.com.au/_build/assets/advanced-search-BehZp_b4.js

js artgalleryofballarat.com.au collected 2026-10-02 02:34:01 UTC 12,846 bytes, 1 lines download raw bytes

1import{k as je,r as s,ac as ne,W as oe,e as ve,j as t,ad as Le,t as Se}from"./client-CW2TRXQx.js";import{u as we}from"./useSearchParams-CLP8caqV.js";import{L as ae,l as re}from"./loader-animation-CuknHXCH.js";import{u as Ae,a as ke,M as Ee}from"./use-colum-count-Bw9m59-N.js";import{u as Ie}from"./use-infinite-loader-vozw6pY1.js";function De(){const e=je("vernon.artists.names",{});return{names:e.data??[],loading:e.isLoading}}const B=12,Te={title:"",artist:[],artistConnector:"AND",dateFrom:"",dateTo:"",dateConnector:"AND",medium:[],mediumConnector:"AND",accessionNo:"",accessionNoConnector:"AND",creditLine:"",creditLineConnector:"AND",sort:"",direction:""},Re=/^\d{4}$/,ce=e=>e===""||Re.test(e);function _e(){const[e,n]=we(Te),[d,g]=s.useState(e.title),[m,i]=s.useState(e.artist),[p,C]=s.useState(e.artistConnector),[u,f]=s.useState(e.dateFrom),[h,b]=s.useState(e.dateTo),[v,o]=s.useState(e.dateConnector),[c,y]=s.useState(e.medium),[Y,w]=s.useState(e.mediumConnector),[z,A]=s.useState(e.accessionNo),[G,k]=s.useState(e.accessionNoConnector),[H,E]=s.useState(e.creditLine),[K,I]=s.useState(e.creditLineConnector),[Q,D]=s.useState("");s.useEffect(()=>g(e.title),[e.title]),s.useEffect(()=>i(e.artist),[e.artist]),s.useEffect(()=>C(e.artistConnector),[e.artistConnector]),s.useEffect(()=>f(e.dateFrom),[e.dateFrom]),s.useEffect(()=>b(e.dateTo),[e.dateTo]),s.useEffect(()=>o(e.dateConnector),[e.dateConnector]),s.useEffect(()=>y(e.medium),[e.medium]),s.useEffect(()=>w(e.mediumConnector),[e.mediumConnector]),s.useEffect(()=>A(e.accessionNo),[e.accessionNo]),s.useEffect(()=>k(e.accessionNoConnector),[e.accessionNoConnector]),s.useEffect(()=>E(e.creditLine),[e.creditLine]),s.useEffect(()=>I(e.creditLineConnector),[e.creditLineConnector]);const{names:le}=De(),[de,ue]=s.useState([]),me=ne("vernon.objects.departments");s.useEffect(()=>{me.mutateAsync(void 0).then(a=>{a?.length&&ue(a)})},[]);const T=s.useRef(0),L=s.useRef(null),R=s.useRef(!1),_=s.useRef(!1),W=s.useRef(null),[x,M]=s.useState(null),[pe,X]=s.useState(!1),[N,F]=s.useState(0),[$,O]=s.useState(!1),[S,P]=s.useState(!1),[J,U]=s.useState(null),Z=ne("vernon.objects.advancedSearch"),fe=Ae(),he=ke(),xe=`${e.title}|${e.artist.join(",")}|${e.artistConnector}|${e.dateFrom}|${e.dateTo}|${e.dateConnector}|${e.medium.join(",")}|${e.mediumConnector}|${e.accessionNo}|${e.accessionNoConnector}|${e.creditLine}|${e.creditLineConnector}`,Ne=Ie(async(a,r,l)=>{S||!$||F(l.filter(Boolean).length)},{isItemLoaded:(a,r)=>a<r.length,minimumBatchSize:B,threshold:3,totalItems:J??void 0});s.useEffect(()=>{if(!!!(e.title.trim()||e.artist.length>0||e.dateFrom.trim()||e.dateTo.trim()||e.medium.length>0||e.accessionNo.trim()||e.creditLine.trim())){M(null),O(!1),F(0),P(!1),U(null),L.current=null;return}R.current=!0,_.current=!0,X(!0),Z.mutateAsync({title:e.title.trim(),artist:e.artist,artistConnector:e.artistConnector,dateFrom:e.dateFrom.trim(),dateTo:e.dateTo.trim(),dateConnector:e.dateConnector,medium:e.medium,mediumConnector:e.mediumConnector,accessionNo:e.accessionNo.trim(),accessionNoConnector:e.accessionNoConnector,creditLine:e.creditLine.trim(),creditLineConnector:e.creditLineConnector,limit:B,offset:0,sort:e.sort||"",direction:e.direction||""}).then(r=>{if(!r)return;M(r.results),U(r.total);const l=r.total>r.results.length&&r.results.length>0;O(l),F(l?r.results.length:0),L.current=null,oe("collection_search",{source:"advanced",title:e.title.trim(),artist:e.artist,artist_connector:e.artistConnector,date_from:e.dateFrom.trim(),date_to:e.dateTo.trim(),date_connector:e.dateConnector,medium:e.medium,medium_connector:e.mediumConnector,accession_no:e.accessionNo.trim(),credit_line:e.creditLine.trim(),sort:e.sort,direction:e.direction,total_results:r.total})}).finally(()=>{X(!1),R.current=!1})},[e.title,e.artist,e.artistConnector,e.dateFrom,e.dateTo,e.dateConnector,e.medium,e.mediumConnector,e.accessionNo,e.accessionNoConnector,e.creditLine,e.creditLineConnector,e.sort,e.direction]),s.useEffect(()=>{_.current&&(_.current=!1,W.current?.scrollIntoView({behavior:"smooth",block:"start"}))},[x]),s.useEffect(()=>{if(!!!(e.title.trim()||e.artist.length>0||e.dateFrom.trim()||e.dateTo.trim()||e.medium.length>0||e.accessionNo.trim()||e.creditLine.trim())||!$||N===0||S||R.current||L.current===N)return;L.current=N;const r=++T.current;P(!0),Z.mutateAsync({title:e.title.trim(),artist:e.artist,artistConnector:e.artistConnector,dateFrom:e.dateFrom.trim(),dateTo:e.dateTo.trim(),dateConnector:e.dateConnector,medium:e.medium,mediumConnector:e.mediumConnector,accessionNo:e.accessionNo.trim(),accessionNoConnector:e.accessionNoConnector,creditLine:e.creditLine.trim(),creditLineConnector:e.creditLineConnector,limit:B,offset:N,sort:e.sort||"",direction:e.direction||""}).then(l=>{if(r!==T.current)return;const te=l.results;M(be=>{const se=new Set,q=[...be??[],...te].filter(ye=>{const V=ye?.objectId??"";return V?se.has(V)?!1:(se.add(V),!0):!0});return O(l.total>q.length&&te.length>0),oe("collection_search_load_more",{source:"advanced",offset:N,total_results:l.total,loaded_count:q.length}),q})}).finally(()=>{r===T.current&&P(!1)})},[N,$,S]);function ge(a){if(a.preventDefault(),!ce(u)||!ce(h)){D("Enter a 4-digit year, e.g. 1990");return}D(""),n.set("title",d),n.set("artist",m),n.set("artistConnector",p),n.set("dateFrom",u),n.set("dateTo",h),n.set("dateConnector",v),n.set("medium",c),n.set("mediumConnector",Y),n.set("accessionNo",z),n.set("accessionNoConnector",G),n.set("creditLine",H),n.set("creditLineConnector",K)}function Ce(){g(""),i([]),C("AND"),f(""),b(""),o("AND"),y([]),w("AND"),A(""),k("AND"),E(""),I("AND"),D(""),n.set("title",""),n.set("artist",[]),n.set("artistConnector","AND"),n.set("dateFrom",""),n.set("dateTo",""),n.set("dateConnector","AND"),n.set("medium",[]),n.set("mediumConnector","AND"),n.set("accessionNo",""),n.set("accessionNoConnector","AND"),n.set("creditLine",""),n.set("creditLineConnector","AND")}function ee(a){return r=>{a(r.target.value.replace(/\D/g,"").slice(0,4))}}return ve()?null:t.jsxs("div",{className:"grid-auto gap-y-10 mb-6",children:[t.jsx("div",{className:"flex col-span-12 justify-start",children:t.jsx("div",{className:"flex flex-col gap-y-5 order-2 md:order-1",children:t.jsx("h1",{className:"type-title-xl-comp mt-[100px] md:mt-[150px]",children:"Advanced Search"})})}),t.jsxs("form",{className:"col-span-12 md:col-span-10 lg:col-span-8 flex flex-col",onSubmit:ge,children:[t.jsxs("div",{className:"w-full border-t border-black py-3 grid grid-cols-8",children:[t.jsx("span",{className:"col-span-3 type-body-m font-bold",children:"Title"}),t.jsx("div",{className:"col-span-5",children:t.jsx("input",{type:"text",className:"w-full bg-black/5 p-2 type-body-m",value:d,onChange:a=>g(a.target.value)})})]}),t.jsxs("div",{className:"w-full border-t border-black py-3 grid grid-cols-8",children:[t.jsx("span",{className:"col-span-2 type-body-m font-bold",children:"Artist"}),t.jsx("div",{className:"col-span-1",children:t.jsx(j,{value:p,onChange:C})}),t.jsx("div",{className:"col-span-5",children:t.jsx(ie,{options:le,selected:m,onChange:i,placeholder:"Search artists…"})})]}),t.jsxs("div",{className:"w-full border-t border-black py-3 grid grid-cols-8",children:[t.jsx("span",{className:"col-span-2 type-body-m font-bold",children:"Production Date"}),t.jsx("div",{className:"col-span-1",children:t.jsx(j,{value:v,onCh
1ange:o})}),t.jsxs("div",{className:"col-span-5 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex justify-between gap-4 items-center",children:[t.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:4,placeholder:"From",className:"w-auto bg-black/5 p-2 flex-grow type-body-m",value:u,onChange:ee(f)}),t.jsx("span",{className:"type-body-m font-bold",children:"to"}),t.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:4,placeholder:"To",className:"w-auto bg-black/5 p-2 flex-grow type-body-m",value:h,onChange:ee(b)})]}),Q&&t.jsx("span",{className:"type-body-s text-red-600",children:Q})]})]}),t.jsxs("div",{className:"w-full border-t border-black py-3 grid grid-cols-8",children:[t.jsx("span",{className:"col-span-2 type-body-m font-bold",children:"Medium"}),t.jsx("div",{className:"col-span-1",children:t.jsx(j,{value:Y,onChange:w})}),t.jsx("div",{className:"col-span-5",children:t.jsx(ie,{options:de.map(a=>a.value),selected:c,onChange:y,placeholder:"Search mediums…"})})]}),t.jsxs("div",{className:"w-full border-t border-black py-3 grid grid-cols-8",children:[t.jsx("span",{className:"col-span-2 type-body-m font-bold",children:"Accession Number"}),t.jsx("div",{className:"col-span-1",children:t.jsx(j,{value:G,onChange:k})}),t.jsx("div",{className:"col-span-5",children:t.jsx("input",{type:"text",className:"w-full bg-black/5 p-2 type-body-m",value:z,onChange:a=>A(a.target.value)})})]}),t.jsxs("div",{className:"w-full border-t border-black py-3 grid grid-cols-8",children:[t.jsx("span",{className:"col-span-2 type-body-m font-bold",children:"Credit Line"}),t.jsx("div",{className:"col-span-1",children:t.jsx(j,{value:K,onChange:I})}),t.jsx("div",{className:"col-span-5",children:t.jsx("input",{type:"text",className:"w-full bg-black/5 p-2 type-body-m",value:H,onChange:a=>E(a.target.value)})})]}),t.jsxs("div",{ref:W,className:"w-full flex justify-end gap-4 pt-4",children:[t.jsx("button",{type:"button",onClick:Ce,className:"type-title-s uppercase px-3 py-1 underline hover:no-underline",children:"Reset"}),t.jsx("button",{type:"submit",className:"bg-black text-white type-title-s uppercase px-3 py-1 hover:bg-black/50",children:"Search"})]})]}),t.jsx("div",{className:"col-span-12 md:col-span-10 lg:col-span-8 flex items-center justify-between",children:x&&t.jsxs("span",{className:"flex items-center type-body-s gap-1",children:[t.jsx("strong",{children:J})," works found"]})}),t.jsxs("div",{className:"col-span-12 w-full overflow-hidden",children:[t.jsx("div",{className:"w-full flex flex-col gap-10",children:pe?t.jsx("div",{className:"block [&_path]:fill-black w-1/2 m-auto",children:t.jsx(ae,{animationData:re,loop:!0})}):t.jsx(t.Fragment,{children:x&&x.length===0?t.jsx("div",{className:"grid-auto gap-6",children:t.jsx("div",{className:"col-span-12",children:t.jsx("span",{className:"type-title-m",children:"No results"})})}):x?t.jsxs("div",{className:"grid-auto gap-6",children:[t.jsx("div",{className:"col-span-12",children:t.jsx(Ee,{items:x,columnGutter:he,columnCount:fe,overscanBy:2,onRender:Ne,itemKey:a=>a?.objectId??"",render:Le},xe)}),S&&t.jsx("div",{className:"col-span-2 col-start-6 flex flex-col gap-6 items-center py-6",children:t.jsx(ae,{animationData:re,loop:!0})})]}):t.jsx("div",{className:"grid-auto",children:t.jsx("p",{className:"col-span-12 type-title-s text-black/40 text-center",children:"Enter search terms above to find artworks."})})})}),t.jsx("div",{className:"h-10"})]})]})}_e.displayName="View(templates/advanced-search)";function j({value:e,onChange:n}){return t.jsxs("select",{className:"type-body-m font-bold",value:e,onChange:d=>n(d.target.value),children:[t.jsx("option",{value:"AND",children:"And"}),t.jsx("option",{value:"NOT",children:"Not"}),t.jsx("option",{value:"OR",children:"Or"})]})}const Me=50;function ie({options:e,selected:n,onChange:d,placeholder:g}){const[m,i]=s.useState(!1),[p,C]=s.useState(""),u=s.useRef(null),f=s.useRef(null);s.useEffect(()=>{if(!m)return;const o=c=>{u.current&&!u.current.contains(c.target)&&i(!1)};return document.addEventListener("click",o),()=>document.removeEventListener("click",o)},[m]);const h=s.useMemo(()=>{const o=p.trim().toLowerCase();return(o?e.filter(y=>y.toLowerCase().includes(o)):e).slice(0,Me)},[e,p]);function b(o){d(n.includes(o)?n.filter(c=>c!==o):[...n,o])}function v(o){d(n.filter(c=>c!==o))}return t.jsxs("div",{ref:u,className:"relative w-full",children:[t.jsxs("div",{className:"w-full bg-black/5 p-2 flex flex-wrap gap-1 items-center cursor-text min-h-[42px]",onClick:()=>{i(!0),f.current?.focus()},children:[n.map(o=>t.jsxs("span",{className:"flex items-center gap-1 bg-black text-white type-body-s px-2 py-0.5",onClick:c=>c.stopPropagation(),children:[o,t.jsx("button",{type:"button",onClick:()=>v(o),className:"hover:text-pink","aria-label":`Remove ${o}`,children:"×"})]},o)),t.jsx("input",{ref:f,type:"text",className:"flex-grow min-w-[80px] bg-transparent !outline-none type-body-m",value:p,placeholder:n.length===0?g:"",onFocus:()=>i(!0),onChange:o=>{C(o.target.value),i(!0)}})]}),m&&t.jsx("div",{className:"absolute left-0 top-full mt-1 bg-white border border-black/10 w-full max-h-[280px] overflow-y-auto z-20 py-1",children:h.length===0?t.jsx("div",{className:"px-4 py-2 type-body-s text-black/40",children:"No matches"}):h.map(o=>t.jsx("button",{type:"button",className:Se("w-full text-left px-4 py-2 type-body-s hover:bg-black/5",n.includes(o)&&"font-medium text-pink"),onClick:()=>b(o),children:o},o))})]})}export{_e as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.