quirk-ui 0.0.475 → 0.0.476
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),B=require("../../ui/PortableTextRenderer/index.cjs"),X=require("../../hooks/useStyleClasses.cjs"),J=require("../../contexts/LocaleBridge.cjs"),w=require("../../../index-DpYgzTme.cjs"),K=require("../../../core/components/Input/index.cjs"),Q=require("../../../core/components/Select/index.cjs"),V=require("../../cards/BlogArticleCard/index.cjs"),l=require("../../../CategoryFilters-CJsgwMGz.cjs"),Y=require("../../../x-Dft9NVe_.cjs"),F=[{label:"Newest",value:"date-desc"},{label:"Oldest",value:"date-asc"},{label:"Title A-Z",value:"title-asc"},{label:"Title Z-A",value:"title-desc"},{label:"Most Popular",value:"popular-desc"}];function ee({heading:o,layout:$="grid",includeFilters:y,excludeFilters:x,limit:_=3,categoryFilters:u,documentType:g,styleOptions:P}){const[N,c]=s.useState([]),[M,z]=s.useState(null),[T,D]=s.useState("date-desc"),[m,S]=s.useState([]),[L,I]=s.useState(null),[k,i]=s.useState(0),[d,q]=s.useState(!1),[h,p]=s.useState(!1),[A,a]=s.useState(!0),[f,v]=s.useState(""),[j,U]=s.useState(""),{locale:H}=J.useLocaleBridge(),O=X.useStyleClasses(P),W={list:l.styles.list}[$??"grid"];s.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.getAll("categories");n.length>0&&S(n);const r=t.get("type");r&&I(r),c([]),i(0),a(!0),(n||r)&&b()},[]);const Z=t=>{D(t.target.value),c([]),i(0),a(!0)},E=()=>{p(!h)},G=()=>{c([]),i(0),a(!0),S([]),v(""),p(!1)},b=async()=>{if(d||!A)return;q(!0);const t=new URLSearchParams({start:String(k),limit:String(_),sort:T,documentType:g,locale:H});L&&t.append("type",L),j&&t.append("search",j),m.forEach(n=>t.append("categories",n)),y==null||y.forEach(n=>t.append("include",n._id)),x==null||x.forEach(n=>t.append("exclude",n._id));try{const r=await(await fetch(`/api/articles?${t.toString()}`,{method:"GET"})).json();c(C=>[...C,...r.articles]),i(C=>C+_),z(r.totalCount),k+r.articles.length>=r.totalCount&&a(!1)}catch(n){console.error("Failed to load articles:",n),a(!1)}finally{q(!1)}},R=s.useCallback(()=>{typeof window<"u"&&window.innerWidth>768&&(p(!1),typeof document<"u"&&(document.body.style.overflow=""))},[]);return s.useEffect(()=>{const t=typeof window<"u";return t&&window.addEventListener("resize",R),()=>{t&&window.removeEventListener("resize",R)}},[]),s.useEffect(()=>{if(typeof document<"u")return document.body.style.overflow=h?"hidden":"",()=>{document.body.style.overflow=""}},[h]),s.useEffect(()=>{const t=setTimeout(()=>{U(f)},1e3);return()=>clearTimeout(t)},[f]),s.useEffect(()=>{b()},[j,T,m.join(",")]),e.jsx("section",{className:`${l.styles.documentList} ${O}`,children:e.jsxs("article",{className:l.styles.container,children:[e.jsxs("div",{className:l.styles.heading,children:[(o==null?void 0:o.title)&&e.jsx(B.RichText,{blocks:o==null?void 0:o.title}),(o==null?void 0:o.description)&&e.jsx(B.RichText,{blocks:o==null?void 0:o.description})]}),e.jsxs("div",{className:l.styles.listContainer,children:[(u==null?void 0:u.length)&&e.jsxs("div",{className:l.styles.filterToggle,children:[e.jsx(w.CallToAction,{as:"button",variant:"secondary",onClick:E,disabled:d,icon:"settings",iconAlignment:"left",children:"Filters"}),e.jsx(w.CallToAction,{as:"button",variant:"link",onClick:G,disabled:d||m.length===0&&f.length===0,children:"Reset"})]}),u&&e.jsx(l.CategoryFilters,{categoryFilters:u,selectedCategories:m,setSelectedCategories:S,setArticles:c,setStart:i,setHasMore:a,showFilters:h,toggleFilters:E,isLoading:d}),e.jsxs("div",{className:l.styles.listWrapper,children:[e.jsxs("div",{className:l.styles.listHeader,children:[e.jsxs("div",{className:l.styles.listResults,children:["Results: ",e.jsx("span",{children:M})]}),e.jsxs("div",{className:l.styles.listHeaderFilters,children:[e.jsxs("div",{className:l.styles.listSearch,children:[e.jsx(K.Input,{type:"text",name:"list-search",placeholder:"Search articles",value:f,onChange:t=>{v(t.target.value),c([]),i(0),a(!0)}}),f&&e.jsx("button",{className:l.styles.clearSearch,onClick:()=>{v(""),c([]),i(0),a(!0)},children:e.jsx(Y.X,{size:21})})]}),e.jsx("div",{className:l.styles.listSort,children:e.jsx(Q.Select,{id:"list-sort",name:"list-sort",options:F,onChange:Z})})]})]}),e.jsx("div",{className:`${l.styles.list} ${W}`,children:N&&N.map(t=>g=="blog"&&e.jsx(V.BlogArticleCard,{article:t},t._id))}),A&&e.jsx("div",{className:l.styles.loadMore,children:e.jsx(w.CallToAction,{as:"button",variant:"primary",onClick:b,disabled:d,icon:"refresh",iconAlignment:"left",className:d?l.styles.buttonIsLoading:"",children:d?"Loading...":"Load more"})})]})]})]})})}exports.DocumentListBlock=ee;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),B=require("../../ui/PortableTextRenderer/index.cjs"),X=require("../../hooks/useStyleClasses.cjs"),J=require("../../contexts/LocaleBridge.cjs"),w=require("../../../index-DpYgzTme.cjs"),K=require("../../../core/components/Input/index.cjs"),Q=require("../../../core/components/Select/index.cjs"),V=require("../../cards/BlogArticleCard/index.cjs"),l=require("../../../CategoryFilters-CJsgwMGz.cjs"),Y=require("../../../x-Dft9NVe_.cjs"),F=[{label:"Newest",value:"date-desc"},{label:"Oldest",value:"date-asc"},{label:"Title A-Z",value:"title-asc"},{label:"Title Z-A",value:"title-desc"},{label:"Most Popular",value:"popular-desc"}];function ee({heading:o,layout:$="grid",includeFilters:y,excludeFilters:x,limit:_=3,categoryFilters:u,documentType:g,styleOptions:P}){const[N,c]=s.useState([]),[M,z]=s.useState(null),[T,D]=s.useState("date-desc"),[m,S]=s.useState([]),[L,I]=s.useState(null),[k,i]=s.useState(0),[d,q]=s.useState(!1),[h,p]=s.useState(!1),[A,a]=s.useState(!0),[f,v]=s.useState(""),[j,U]=s.useState(""),{locale:H}=J.useLocaleBridge(),O=X.useStyleClasses(P),W={list:l.styles.list}[$??"grid"];s.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.getAll("categories");n.length>0&&S(n);const r=t.get("type");r&&I(r),c([]),i(0),a(!0),(n.length>0||r)&&b()},[]);const Z=t=>{D(t.target.value),c([]),i(0),a(!0)},E=()=>{p(!h)},G=()=>{c([]),i(0),a(!0),S([]),v(""),p(!1)},b=async()=>{if(d||!A)return;q(!0);const t=new URLSearchParams({start:String(k),limit:String(_),sort:T,documentType:g,locale:H});L&&t.append("type",L),j&&t.append("search",j),m.forEach(n=>t.append("categories",n)),y==null||y.forEach(n=>t.append("include",n._id)),x==null||x.forEach(n=>t.append("exclude",n._id));try{const r=await(await fetch(`/api/articles?${t.toString()}`,{method:"GET"})).json();c(C=>[...C,...r.articles]),i(C=>C+_),z(r.totalCount),k+r.articles.length>=r.totalCount&&a(!1)}catch(n){console.error("Failed to load articles:",n),a(!1)}finally{q(!1)}},R=s.useCallback(()=>{typeof window<"u"&&window.innerWidth>768&&(p(!1),typeof document<"u"&&(document.body.style.overflow=""))},[]);return s.useEffect(()=>{const t=typeof window<"u";return t&&window.addEventListener("resize",R),()=>{t&&window.removeEventListener("resize",R)}},[]),s.useEffect(()=>{if(typeof document<"u")return document.body.style.overflow=h?"hidden":"",()=>{document.body.style.overflow=""}},[h]),s.useEffect(()=>{const t=setTimeout(()=>{U(f)},1e3);return()=>clearTimeout(t)},[f]),s.useEffect(()=>{b()},[j,T,m.join(",")]),e.jsx("section",{className:`${l.styles.documentList} ${O}`,children:e.jsxs("article",{className:l.styles.container,children:[e.jsxs("div",{className:l.styles.heading,children:[(o==null?void 0:o.title)&&e.jsx(B.RichText,{blocks:o==null?void 0:o.title}),(o==null?void 0:o.description)&&e.jsx(B.RichText,{blocks:o==null?void 0:o.description})]}),e.jsxs("div",{className:l.styles.listContainer,children:[(u==null?void 0:u.length)&&e.jsxs("div",{className:l.styles.filterToggle,children:[e.jsx(w.CallToAction,{as:"button",variant:"secondary",onClick:E,disabled:d,icon:"settings",iconAlignment:"left",children:"Filters"}),e.jsx(w.CallToAction,{as:"button",variant:"link",onClick:G,disabled:d||m.length===0&&f.length===0,children:"Reset"})]}),u&&e.jsx(l.CategoryFilters,{categoryFilters:u,selectedCategories:m,setSelectedCategories:S,setArticles:c,setStart:i,setHasMore:a,showFilters:h,toggleFilters:E,isLoading:d}),e.jsxs("div",{className:l.styles.listWrapper,children:[e.jsxs("div",{className:l.styles.listHeader,children:[e.jsxs("div",{className:l.styles.listResults,children:["Results: ",e.jsx("span",{children:M})]}),e.jsxs("div",{className:l.styles.listHeaderFilters,children:[e.jsxs("div",{className:l.styles.listSearch,children:[e.jsx(K.Input,{type:"text",name:"list-search",placeholder:"Search articles",value:f,onChange:t=>{v(t.target.value),c([]),i(0),a(!0)}}),f&&e.jsx("button",{className:l.styles.clearSearch,onClick:()=>{v(""),c([]),i(0),a(!0)},children:e.jsx(Y.X,{size:21})})]}),e.jsx("div",{className:l.styles.listSort,children:e.jsx(Q.Select,{id:"list-sort",name:"list-sort",options:F,onChange:Z})})]})]}),e.jsx("div",{className:`${l.styles.list} ${W}`,children:N&&N.map(t=>g=="blog"&&e.jsx(V.BlogArticleCard,{article:t},t._id))}),A&&e.jsx("div",{className:l.styles.loadMore,children:e.jsx(w.CallToAction,{as:"button",variant:"primary",onClick:b,disabled:d,icon:"refresh",iconAlignment:"left",className:d?l.styles.buttonIsLoading:"",children:d?"Loading...":"Load more"})})]})]})]})})}exports.DocumentListBlock=ee;
|
|
@@ -36,7 +36,7 @@ function he({
|
|
|
36
36
|
const e = new URLSearchParams(window.location.search), l = e.getAll("categories");
|
|
37
37
|
l.length > 0 && S(l);
|
|
38
38
|
const i = e.get("type");
|
|
39
|
-
i && D(i), c([]), d(0), n(!0), (l || i) && g();
|
|
39
|
+
i && D(i), c([]), d(0), n(!0), (l.length > 0 || i) && g();
|
|
40
40
|
}, []);
|
|
41
41
|
const X = (e) => {
|
|
42
42
|
x(e.target.value), c([]), d(0), n(!0);
|