quirk-ui 0.0.523 → 0.0.524

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"),t=require("react"),P=require("../../ui/PortableTextRenderer/index.cjs"),Q=require("../../hooks/useStyleClasses.cjs"),V=require("../../contexts/LocaleBridge.cjs"),N=require("../../../index-BN6814Bi.cjs"),Y=require("../../../core/components/Input/index.cjs"),F=require("../../../core/components/Select/index.cjs"),ee=require("../../cards/BlogArticleCard/index.cjs"),s=require("../../../CategoryFilters-tDVNMlQO.cjs"),se=require("../../../x-Dft9NVe_.cjs"),te=[{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 le({heading:o,layout:z="grid",includeFilters:p,excludeFilters:v,limit:b=3,categoryFilters:d,documentType:g,styleOptions:D,initialArticles:j=[],initialTotalCount:L=0,initialIncludeCategories:I=[]}){const[k,c]=t.useState(j),[H,O]=t.useState(L),[C,W]=t.useState("date-desc"),[u,q]=t.useState(I),[T,i]=t.useState(j.length),[a,A]=t.useState(!1),[x,y]=t.useState(!1),[E,r]=t.useState(j.length<L),[f,_]=t.useState(""),[S,Z]=t.useState(""),{locale:G}=V.useLocaleBridge(),U=Q.useStyleClasses(D),R=t.useRef(!1),X={list:s.styles.list}[z??"grid"],J=l=>{W(l.target.value),c([]),i(0),r(!0)},B=()=>{y(!x)},K=()=>{c([]),i(0),r(!0),q([]),_(""),y(!1)},$=async(l=!1)=>{if(a||!E)return;A(!0);const h=new URLSearchParams({start:l?"0":String(T),limit:String(b),sort:C,documentType:g,locale:G});S&&h.append("search",S),u.forEach(n=>h.append("categories",n)),p==null||p.forEach(n=>h.append("include",n._id)),v==null||v.forEach(n=>h.append("exclude",n._id));try{const m=await(await fetch(`/api/articles?${h.toString()}`,{method:"GET"})).json();c(w=>l?m.articles:[...w,...m.articles]),i(w=>l?b:w+b),O(m.totalCount),r(T+m.articles.length<m.totalCount)}catch(n){console.error("Failed to load articles:",n),r(!1)}finally{A(!1)}},M=t.useCallback(()=>{typeof window<"u"&&window.innerWidth>768&&(y(!1),typeof document<"u"&&(document.body.style.overflow=""))},[]);return t.useEffect(()=>{const l=typeof window<"u";return l&&window.addEventListener("resize",M),()=>{l&&window.removeEventListener("resize",M)}},[]),t.useEffect(()=>{if(typeof document<"u")return document.body.style.overflow=x?"hidden":"",()=>{document.body.style.overflow=""}},[x]),t.useEffect(()=>{const l=setTimeout(()=>{Z(f)},500);return()=>clearTimeout(l)},[f]),t.useEffect(()=>{if(!R.current){R.current=!0;return}(S||C!=="date-desc"||u.length>0)&&$(!0)},[S,C,u.join(",")]),e.jsx("section",{className:`${s.styles.documentList} ${U}`,children:e.jsxs("article",{className:s.styles.container,children:[e.jsxs("div",{className:s.styles.heading,children:[(o==null?void 0:o.title)&&e.jsx(P.RichText,{blocks:o==null?void 0:o.title}),(o==null?void 0:o.description)&&e.jsx(P.RichText,{blocks:o==null?void 0:o.description})]}),e.jsxs("div",{className:s.styles.listContainer,children:[(d==null?void 0:d.length)&&e.jsxs("div",{className:s.styles.filterToggle,children:[e.jsx(N.CallToAction,{as:"button",variant:"secondary",onClick:B,disabled:a,icon:"settings",iconAlignment:"left",children:"Filters"}),e.jsx(N.CallToAction,{as:"button",variant:"link",onClick:K,disabled:a||u.length===0&&f.length===0,children:"Reset"})]}),d&&e.jsx(s.CategoryFilters,{categoryFilters:d,selectedCategories:u,setSelectedCategories:q,setArticles:c,setStart:i,setHasMore:r,showFilters:x,toggleFilters:B,isLoading:a}),e.jsxs("div",{className:s.styles.listWrapper,children:[e.jsxs("div",{className:s.styles.listHeader,children:[e.jsxs("div",{className:s.styles.listResults,children:["Results: ",e.jsx("span",{children:H})]}),e.jsxs("div",{className:s.styles.listHeaderFilters,children:[e.jsxs("div",{className:s.styles.listSearch,children:[e.jsx(Y.Input,{type:"text",name:"list-search",placeholder:"Search articles",value:f,onChange:l=>{_(l.target.value),c([]),i(0),r(!0)}}),f&&e.jsx("button",{className:s.styles.clearSearch,onClick:()=>{_(""),c([]),i(0),r(!0)},children:e.jsx(se.X,{size:21})})]}),e.jsx("div",{className:s.styles.listSort,children:e.jsx(F.Select,{id:"list-sort",name:"list-sort",label:"Sort by",options:te,onChange:J})})]})]}),e.jsx("div",{className:`${s.styles.list} ${X}`,children:k&&k.map(l=>g=="blog"&&e.jsx(ee.BlogArticleCard,{article:l},l._id))}),E&&e.jsx("div",{className:s.styles.loadMore,children:e.jsx(N.CallToAction,{as:"button",variant:"primary",onClick:()=>$(!1),disabled:a,icon:"refresh",iconAlignment:"left",className:a?s.styles.buttonIsLoading:"",children:a?"Loading...":"Load more"})})]})]})]})})}exports.DocumentListBlock=le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),P=require("../../ui/PortableTextRenderer/index.cjs"),Q=require("../../hooks/useStyleClasses.cjs"),V=require("../../contexts/LocaleBridge.cjs"),N=require("../../../index-BN6814Bi.cjs"),Y=require("../../../core/components/Input/index.cjs"),F=require("../../../core/components/Select/index.cjs"),ee=require("../../cards/BlogArticleCard/index.cjs"),s=require("../../../CategoryFilters-tDVNMlQO.cjs"),se=require("../../../x-Dft9NVe_.cjs"),te=[{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 le({heading:o,layout:z="grid",includeFilters:p,excludeFilters:v,limit:b=3,categoryFilters:d,documentType:g,styleOptions:D,initialArticles:j=[],initialTotalCount:L=0,initialIncludeCategories:I=[]}){const[k,c]=t.useState(j),[H,O]=t.useState(L),[C,W]=t.useState("date-desc"),[u,q]=t.useState(I),[T,i]=t.useState(j.length),[a,A]=t.useState(!1),[x,y]=t.useState(!1),[E,r]=t.useState(j.length<L),[f,_]=t.useState(""),[S,Z]=t.useState(""),{locale:G}=V.useLocaleBridge(),U=Q.useStyleClasses(D),R=t.useRef(!1),X={list:s.styles.list}[z??"grid"],J=l=>{W(l.target.value),c([]),i(0),r(!0)},B=()=>{y(!x)},K=()=>{c([]),i(0),r(!0),q([]),_(""),y(!1)},$=async(l=!1)=>{if(a||!E)return;A(!0);const h=new URLSearchParams({start:l?"0":String(T),limit:String(b),sort:C,documentType:g,locale:G});S&&h.append("search",S),u.forEach(n=>h.append("categories",n)),p==null||p.forEach(n=>h.append("include",n._id)),v==null||v.forEach(n=>h.append("exclude",n._id));try{const m=await(await fetch(`/api/articles?${h.toString()}`,{method:"GET"})).json();c(w=>l?m.articles:[...w,...m.articles]),i(w=>l?b:w+b),O(m.totalCount),r(T+m.articles.length<m.totalCount)}catch(n){console.error("Failed to load articles:",n),r(!1)}finally{A(!1)}},M=t.useCallback(()=>{typeof window<"u"&&window.innerWidth>768&&(y(!1),typeof document<"u"&&(document.body.style.overflow=""))},[]);return t.useEffect(()=>{const l=typeof window<"u";return l&&window.addEventListener("resize",M),()=>{l&&window.removeEventListener("resize",M)}},[]),t.useEffect(()=>{if(typeof document<"u")return document.body.style.overflow=x?"hidden":"",()=>{document.body.style.overflow=""}},[x]),t.useEffect(()=>{const l=setTimeout(()=>{Z(f)},500);return()=>clearTimeout(l)},[f]),t.useEffect(()=>{if(!R.current){R.current=!0;return}(S||C!=="date-desc"||u.length>0)&&$(!0)},[S,C,u.join(",")]),e.jsx("section",{className:`${s.styles.documentList} ${U}`,children:e.jsxs("article",{className:s.styles.container,children:[e.jsxs("div",{className:s.styles.heading,children:[(o==null?void 0:o.title)&&e.jsx(P.RichText,{blocks:o==null?void 0:o.title}),(o==null?void 0:o.description)&&e.jsx(P.RichText,{blocks:o==null?void 0:o.description})]}),e.jsxs("div",{className:s.styles.listContainer,children:[(d==null?void 0:d.length)&&e.jsxs("div",{className:s.styles.filterToggle,children:[e.jsx(N.CallToAction,{as:"button",variant:"secondary",onClick:B,disabled:a,icon:"settings",iconAlignment:"left",children:"Filters"}),e.jsx(N.CallToAction,{as:"button",variant:"link",onClick:K,disabled:a||u.length===0&&f.length===0,children:"Reset"})]}),d&&e.jsx(s.CategoryFilters,{categoryFilters:d,selectedCategories:u,setSelectedCategories:q,setArticles:c,setStart:i,setHasMore:r,showFilters:x,toggleFilters:B,isLoading:a}),e.jsxs("div",{className:s.styles.listWrapper,children:[e.jsxs("div",{className:s.styles.listHeader,children:[e.jsxs("div",{className:s.styles.listResults,children:["Results: ",e.jsx("span",{children:H})]}),e.jsxs("div",{className:s.styles.listHeaderFilters,children:[e.jsxs("div",{className:s.styles.listSearch,children:[e.jsx(Y.Input,{type:"text",name:"list-search",placeholder:"Search articles",value:f,onChange:l=>{_(l.target.value),c([]),i(0),r(!0)}}),f&&e.jsx("button",{className:s.styles.clearSearch,onClick:()=>{_(""),c([]),i(0),r(!0)},children:e.jsx(se.X,{size:21})})]}),e.jsx("div",{className:s.styles.listSort,children:e.jsx(F.Select,{id:"list-sort",name:"list-sort","aria-label":"Sort by",options:te,onChange:J})})]})]}),e.jsx("div",{className:`${s.styles.list} ${X}`,children:k&&k.map(l=>g=="blog"&&e.jsx(ee.BlogArticleCard,{article:l},l._id))}),E&&e.jsx("div",{className:s.styles.loadMore,children:e.jsx(N.CallToAction,{as:"button",variant:"primary",onClick:()=>$(!1),disabled:a,icon:"refresh",iconAlignment:"left",className:a?s.styles.buttonIsLoading:"",children:a?"Loading...":"Load more"})})]})]})]})})}exports.DocumentListBlock=le;
@@ -1,4 +1,4 @@
1
- import { jsx as e, jsxs as l } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
2
  import { useState as a, useRef as Y, useCallback as F, useEffect as w } from "react";
3
3
  import { RichText as _ } from "../../ui/PortableTextRenderer/index.mjs";
4
4
  import { useStyleClasses as ee } from "../../hooks/useStyleClasses.mjs";
@@ -7,8 +7,8 @@ import { C as R } from "../../../index-C-E0ib2G.js";
7
7
  import { Input as se } from "../../../core/components/Input/index.mjs";
8
8
  import { Select as oe } from "../../../core/components/Select/index.mjs";
9
9
  import { BlogArticleCard as ae } from "../../cards/BlogArticleCard/index.mjs";
10
- import { s as t, C as le } from "../../../CategoryFilters-DJyQJ-ww.js";
11
- import { X as re } from "../../../x-CnsEH4Ox.js";
10
+ import { s as t, C as re } from "../../../CategoryFilters-DJyQJ-ww.js";
11
+ import { X as le } from "../../../x-CnsEH4Ox.js";
12
12
  const ne = [
13
13
  { label: "Newest", value: "date-desc" },
14
14
  { label: "Oldest", value: "date-asc" },
@@ -56,11 +56,11 @@ function we({
56
56
  locale: X
57
57
  });
58
58
  C && h.append("search", C), m.forEach(
59
- (r) => h.append("categories", r)
59
+ (l) => h.append("categories", l)
60
60
  ), S == null || S.forEach(
61
- (r) => h.append("include", r._id)
61
+ (l) => h.append("include", l._id)
62
62
  ), N == null || N.forEach(
63
- (r) => h.append("exclude", r._id)
63
+ (l) => h.append("exclude", l._id)
64
64
  );
65
65
  try {
66
66
  const p = await (await fetch(`/api/articles?${h.toString()}`, {
@@ -69,8 +69,8 @@ function we({
69
69
  i(
70
70
  (E) => s ? p.articles : [...E, ...p.articles]
71
71
  ), d((E) => s ? y : E + y), q(p.totalCount), c(j + p.articles.length < p.totalCount);
72
- } catch (r) {
73
- console.error("Failed to load articles:", r), c(!1);
72
+ } catch (l) {
73
+ console.error("Failed to load articles:", l), c(!1);
74
74
  } finally {
75
75
  z(!1);
76
76
  }
@@ -98,13 +98,13 @@ function we({
98
98
  return;
99
99
  }
100
100
  (C || L !== "date-desc" || m.length > 0) && P(!0);
101
- }, [C, L, m.join(",")]), /* @__PURE__ */ e("section", { className: `${t.documentList} ${J}`, children: /* @__PURE__ */ l("article", { className: t.container, children: [
102
- /* @__PURE__ */ l("div", { className: t.heading, children: [
101
+ }, [C, L, m.join(",")]), /* @__PURE__ */ e("section", { className: `${t.documentList} ${J}`, children: /* @__PURE__ */ r("article", { className: t.container, children: [
102
+ /* @__PURE__ */ r("div", { className: t.heading, children: [
103
103
  (o == null ? void 0 : o.title) && /* @__PURE__ */ e(_, { blocks: o == null ? void 0 : o.title }),
104
104
  (o == null ? void 0 : o.description) && /* @__PURE__ */ e(_, { blocks: o == null ? void 0 : o.description })
105
105
  ] }),
106
- /* @__PURE__ */ l("div", { className: t.listContainer, children: [
107
- (f == null ? void 0 : f.length) && /* @__PURE__ */ l("div", { className: t.filterToggle, children: [
106
+ /* @__PURE__ */ r("div", { className: t.listContainer, children: [
107
+ (f == null ? void 0 : f.length) && /* @__PURE__ */ r("div", { className: t.filterToggle, children: [
108
108
  /* @__PURE__ */ e(
109
109
  R,
110
110
  {
@@ -129,7 +129,7 @@ function we({
129
129
  )
130
130
  ] }),
131
131
  f && /* @__PURE__ */ e(
132
- le,
132
+ re,
133
133
  {
134
134
  categoryFilters: f,
135
135
  selectedCategories: m,
@@ -142,14 +142,14 @@ function we({
142
142
  isLoading: n
143
143
  }
144
144
  ),
145
- /* @__PURE__ */ l("div", { className: t.listWrapper, children: [
146
- /* @__PURE__ */ l("div", { className: t.listHeader, children: [
147
- /* @__PURE__ */ l("div", { className: t.listResults, children: [
145
+ /* @__PURE__ */ r("div", { className: t.listWrapper, children: [
146
+ /* @__PURE__ */ r("div", { className: t.listHeader, children: [
147
+ /* @__PURE__ */ r("div", { className: t.listResults, children: [
148
148
  "Results: ",
149
149
  /* @__PURE__ */ e("span", { children: Z })
150
150
  ] }),
151
- /* @__PURE__ */ l("div", { className: t.listHeaderFilters, children: [
152
- /* @__PURE__ */ l("div", { className: t.listSearch, children: [
151
+ /* @__PURE__ */ r("div", { className: t.listHeaderFilters, children: [
152
+ /* @__PURE__ */ r("div", { className: t.listSearch, children: [
153
153
  /* @__PURE__ */ e(
154
154
  se,
155
155
  {
@@ -169,7 +169,7 @@ function we({
169
169
  onClick: () => {
170
170
  k(""), i([]), d(0), c(!0);
171
171
  },
172
- children: /* @__PURE__ */ e(re, { size: 21 })
172
+ children: /* @__PURE__ */ e(le, { size: 21 })
173
173
  }
174
174
  )
175
175
  ] }),
@@ -178,7 +178,7 @@ function we({
178
178
  {
179
179
  id: "list-sort",
180
180
  name: "list-sort",
181
- label: "Sort by",
181
+ "aria-label": "Sort by",
182
182
  options: ne,
183
183
  onChange: Q
184
184
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.523",
4
+ "version": "0.0.524",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {