quirk-ui 0.0.474 → 0.0.475

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"),C=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:w=3,categoryFilters:u,documentType:_,styleOptions:P}){const[g,r]=s.useState([]),[M,z]=s.useState(null),[N,D]=s.useState("date-desc"),[m,S]=s.useState([]),[T,I]=s.useState(null),[L,c]=s.useState(0),[i,k]=s.useState(!1),[h,p]=s.useState(!1),[q,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 d=t.get("type");d&&I(d),r([]),c(0),a(!0)},[]);const Z=t=>{D(t.target.value),r([]),c(0),a(!0)},A=()=>{p(!h)},G=()=>{r([]),c(0),a(!0),S([]),v(""),p(!1)},E=async()=>{if(i||!q)return;k(!0);const t=new URLSearchParams({start:String(L),limit:String(w),sort:N,documentType:_,locale:H});T&&t.append("type",T),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 d=await(await fetch(`/api/articles?${t.toString()}`,{method:"GET"})).json();r(b=>[...b,...d.articles]),c(b=>b+w),z(d.totalCount),L+d.articles.length>=d.totalCount&&a(!1)}catch(n){console.error("Failed to load articles:",n),a(!1)}finally{k(!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(()=>{E()},[j,N,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(C.CallToAction,{as:"button",variant:"secondary",onClick:A,disabled:i,icon:"settings",iconAlignment:"left",children:"Filters"}),e.jsx(C.CallToAction,{as:"button",variant:"link",onClick:G,disabled:i||m.length===0&&f.length===0,children:"Reset"})]}),u&&e.jsx(l.CategoryFilters,{categoryFilters:u,selectedCategories:m,setSelectedCategories:S,setArticles:r,setStart:c,setHasMore:a,showFilters:h,toggleFilters:A,isLoading:i}),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),r([]),c(0),a(!0)}}),f&&e.jsx("button",{className:l.styles.clearSearch,onClick:()=>{v(""),r([]),c(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:g&&g.map(t=>_=="blog"&&e.jsx(V.BlogArticleCard,{article:t},t._id))}),q&&e.jsx("div",{className:l.styles.loadMore,children:e.jsx(C.CallToAction,{as:"button",variant:"primary",onClick:E,disabled:i,icon:"refresh",iconAlignment:"left",className:i?l.styles.buttonIsLoading:"",children:i?"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||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;
@@ -3,7 +3,7 @@ import { useState as a, useEffect as p, useCallback as K } from "react";
3
3
  import { RichText as B } from "../../ui/PortableTextRenderer/index.mjs";
4
4
  import { useStyleClasses as Q } from "../../hooks/useStyleClasses.mjs";
5
5
  import { useLocaleBridge as V } from "../../contexts/LocaleBridge.mjs";
6
- import { C as L } from "../../../index-CIb65n0z.js";
6
+ import { C as T } from "../../../index-CIb65n0z.js";
7
7
  import { Input as Y } from "../../../core/components/Input/index.mjs";
8
8
  import { Select as F } from "../../../core/components/Select/index.mjs";
9
9
  import { BlogArticleCard as ee } from "../../cards/BlogArticleCard/index.mjs";
@@ -21,13 +21,13 @@ function he({
21
21
  layout: H = "grid",
22
22
  includeFilters: b,
23
23
  excludeFilters: C,
24
- limit: T = 3,
24
+ limit: k = 3,
25
25
  categoryFilters: f,
26
- documentType: k,
26
+ documentType: A,
27
27
  // filterMode,
28
28
  styleOptions: I
29
29
  }) {
30
- const [A, i] = a([]), [W, _] = a(null), [E, x] = a("date-desc"), [h, S] = a([]), [R, D] = a(null), [$, c] = a(0), [d, j] = a(!1), [v, w] = a(!1), [z, n] = a(!0), [u, y] = a(""), [N, O] = a(""), { locale: Z } = V(), q = Q(I), G = {
30
+ const [E, c] = a([]), [W, _] = a(null), [R, x] = a("date-desc"), [h, S] = a([]), [$, D] = a(null), [j, d] = a(0), [m, z] = a(!1), [v, w] = a(!1), [M, n] = a(!0), [u, y] = a(""), [N, O] = a(""), { locale: Z } = V(), q = Q(I), G = {
31
31
  //grid: styles.grid,
32
32
  list: s.list
33
33
  }[H ?? "grid"];
@@ -35,26 +35,26 @@ function he({
35
35
  if (typeof window > "u") return;
36
36
  const e = new URLSearchParams(window.location.search), l = e.getAll("categories");
37
37
  l.length > 0 && S(l);
38
- const m = e.get("type");
39
- m && D(m), i([]), c(0), n(!0);
38
+ const i = e.get("type");
39
+ i && D(i), c([]), d(0), n(!0), (l || i) && g();
40
40
  }, []);
41
41
  const X = (e) => {
42
- x(e.target.value), i([]), c(0), n(!0);
43
- }, M = () => {
42
+ x(e.target.value), c([]), d(0), n(!0);
43
+ }, P = () => {
44
44
  w(!v);
45
45
  }, J = () => {
46
- i([]), c(0), n(!0), S([]), y(""), w(!1);
47
- }, P = async () => {
48
- if (d || !z) return;
49
- j(!0);
46
+ c([]), d(0), n(!0), S([]), y(""), w(!1);
47
+ }, g = async () => {
48
+ if (m || !M) return;
49
+ z(!0);
50
50
  const e = new URLSearchParams({
51
- start: String($),
52
- limit: String(T),
53
- sort: E,
54
- documentType: k,
51
+ start: String(j),
52
+ limit: String(k),
53
+ sort: R,
54
+ documentType: A,
55
55
  locale: Z
56
56
  });
57
- R && e.append("type", R), N && e.append("search", N), h.forEach(
57
+ $ && e.append("type", $), N && e.append("search", N), h.forEach(
58
58
  (l) => e.append("categories", l)
59
59
  ), b == null || b.forEach(
60
60
  (l) => e.append("include", l._id)
@@ -62,14 +62,14 @@ function he({
62
62
  (l) => e.append("exclude", l._id)
63
63
  );
64
64
  try {
65
- const m = await (await fetch(`/api/articles?${e.toString()}`, {
65
+ const i = await (await fetch(`/api/articles?${e.toString()}`, {
66
66
  method: "GET"
67
67
  })).json();
68
- i((g) => [...g, ...m.articles]), c((g) => g + T), _(m.totalCount), $ + m.articles.length >= m.totalCount && n(!1);
68
+ c((L) => [...L, ...i.articles]), d((L) => L + k), _(i.totalCount), j + i.articles.length >= i.totalCount && n(!1);
69
69
  } catch (l) {
70
70
  console.error("Failed to load articles:", l), n(!1);
71
71
  } finally {
72
- j(!1);
72
+ z(!1);
73
73
  }
74
74
  }, U = K(() => {
75
75
  typeof window < "u" && window.innerWidth > 768 && (w(!1), typeof document < "u" && (document.body.style.overflow = ""));
@@ -90,8 +90,8 @@ function he({
90
90
  }, 1e3);
91
91
  return () => clearTimeout(e);
92
92
  }, [u]), p(() => {
93
- P();
94
- }, [N, E, h.join(",")]), /* @__PURE__ */ t("section", { className: `${s.documentList} ${q}`, children: /* @__PURE__ */ r("article", { className: s.container, children: [
93
+ g();
94
+ }, [N, R, h.join(",")]), /* @__PURE__ */ t("section", { className: `${s.documentList} ${q}`, children: /* @__PURE__ */ r("article", { className: s.container, children: [
95
95
  /* @__PURE__ */ r("div", { className: s.heading, children: [
96
96
  (o == null ? void 0 : o.title) && /* @__PURE__ */ t(B, { blocks: o == null ? void 0 : o.title }),
97
97
  (o == null ? void 0 : o.description) && /* @__PURE__ */ t(B, { blocks: o == null ? void 0 : o.description })
@@ -99,24 +99,24 @@ function he({
99
99
  /* @__PURE__ */ r("div", { className: s.listContainer, children: [
100
100
  (f == null ? void 0 : f.length) && /* @__PURE__ */ r("div", { className: s.filterToggle, children: [
101
101
  /* @__PURE__ */ t(
102
- L,
102
+ T,
103
103
  {
104
104
  as: "button",
105
105
  variant: "secondary",
106
- onClick: M,
107
- disabled: d,
106
+ onClick: P,
107
+ disabled: m,
108
108
  icon: "settings",
109
109
  iconAlignment: "left",
110
110
  children: "Filters"
111
111
  }
112
112
  ),
113
113
  /* @__PURE__ */ t(
114
- L,
114
+ T,
115
115
  {
116
116
  as: "button",
117
117
  variant: "link",
118
118
  onClick: J,
119
- disabled: d || h.length === 0 && u.length === 0,
119
+ disabled: m || h.length === 0 && u.length === 0,
120
120
  children: "Reset"
121
121
  }
122
122
  )
@@ -127,12 +127,12 @@ function he({
127
127
  categoryFilters: f,
128
128
  selectedCategories: h,
129
129
  setSelectedCategories: S,
130
- setArticles: i,
131
- setStart: c,
130
+ setArticles: c,
131
+ setStart: d,
132
132
  setHasMore: n,
133
133
  showFilters: v,
134
- toggleFilters: M,
135
- isLoading: d
134
+ toggleFilters: P,
135
+ isLoading: m
136
136
  }
137
137
  ),
138
138
  /* @__PURE__ */ r("div", { className: s.listWrapper, children: [
@@ -151,7 +151,7 @@ function he({
151
151
  placeholder: "Search articles",
152
152
  value: u,
153
153
  onChange: (e) => {
154
- y(e.target.value), i([]), c(0), n(!0);
154
+ y(e.target.value), c([]), d(0), n(!0);
155
155
  }
156
156
  }
157
157
  ),
@@ -160,7 +160,7 @@ function he({
160
160
  {
161
161
  className: s.clearSearch,
162
162
  onClick: () => {
163
- y(""), i([]), c(0), n(!0);
163
+ y(""), c([]), d(0), n(!0);
164
164
  },
165
165
  children: /* @__PURE__ */ t(se, { size: 21 })
166
166
  }
@@ -177,20 +177,20 @@ function he({
177
177
  ) })
178
178
  ] })
179
179
  ] }),
180
- /* @__PURE__ */ t("div", { className: `${s.list} ${G}`, children: A && A.map(
181
- (e) => k == "blog" && /* @__PURE__ */ t(ee, { article: e }, e._id)
180
+ /* @__PURE__ */ t("div", { className: `${s.list} ${G}`, children: E && E.map(
181
+ (e) => A == "blog" && /* @__PURE__ */ t(ee, { article: e }, e._id)
182
182
  ) }),
183
- z && /* @__PURE__ */ t("div", { className: s.loadMore, children: /* @__PURE__ */ t(
184
- L,
183
+ M && /* @__PURE__ */ t("div", { className: s.loadMore, children: /* @__PURE__ */ t(
184
+ T,
185
185
  {
186
186
  as: "button",
187
187
  variant: "primary",
188
- onClick: P,
189
- disabled: d,
188
+ onClick: g,
189
+ disabled: m,
190
190
  icon: "refresh",
191
191
  iconAlignment: "left",
192
- className: d ? s.buttonIsLoading : "",
193
- children: d ? "Loading..." : "Load more"
192
+ className: m ? s.buttonIsLoading : "",
193
+ children: m ? "Loading..." : "Load more"
194
194
  }
195
195
  ) })
196
196
  ] })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.474",
4
+ "version": "0.0.475",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {