quirk-ui 0.1.208 → 0.1.210

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"});require('../../../index38.css');const e=require("react/jsx-runtime"),i=require("react"),Y=require("react-dom"),L=require("../../../x-Dft9NVe_.cjs"),R="_overlay_6t5hy_2",P="_fadeIn_6t5hy_1",A="_container_6t5hy_19",F="_modal_6t5hy_49",K="_slideUp_6t5hy_1",X="_closeButton_6t5hy_60",G="_title_6t5hy_87",H="_content_6t5hy_97",J="_intro_6t5hy_116",Q="_trigger_6t5hy_123",V="_fadeOut_6t5hy_1",W="_closing_6t5hy_170",Z="_slideUpSheet_6t5hy_1",O="_slideDownSheet_6t5hy_1",t={overlay:R,fadeIn:P,container:A,"size-sm":"_size-sm_6t5hy_26","size-md":"_size-md_6t5hy_30","size-lg":"_size-lg_6t5hy_34","size-xl":"_size-xl_6t5hy_38","size-full":"_size-full_6t5hy_42",modal:F,slideUp:K,closeButton:X,title:G,content:H,intro:J,trigger:Q,fadeOut:V,closing:W,slideUpSheet:Z,slideDownSheet:O},ee=()=>{if(typeof document>"u")return;const s=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${s}px`,document.body.style.width="100%",document.body.style.overflowY="scroll"},k=()=>{if(typeof document>"u")return;const s=Math.abs(parseInt(document.body.style.top||"0",10));document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflowY="",s&&window.scrollTo(0,s)};function te({content:s,trigger:z,isOpen:m,onOpen:c,onClose:y,size:S="md",closeOnEscape:g=!0,closeOnOverlayClick:$=!0,showCloseButton:E=!0,className:j,overlayClassName:C,style:I,formData:v,renderForm:b}){const[q,p]=i.useState(!1),[_,w]=i.useState(!1),f=i.useRef(null),h=m!==void 0,o=h?m:q,N=()=>{h||p(!0),c==null||c()},r=()=>{w(!0),setTimeout(()=>{w(!1),h?y==null||y():p(!1)},300)},T=()=>o?r():N(),U=()=>{$&&r()};i.useEffect(()=>{if(!g||!o)return;const n=d=>{d.key==="Escape"&&r()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[o,g]),i.useEffect(()=>(o?ee():k(),()=>k()),[o]),i.useEffect(()=>{if(!o||!f.current)return;const n=f.current,d=n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),l=d[0],a=d[d.length-1],x=u=>{u.key==="Tab"&&(u.shiftKey?document.activeElement===l&&(u.preventDefault(),a==null||a.focus()):document.activeElement===a&&(u.preventDefault(),l==null||l.focus()))};return n.addEventListener("keydown",x),l==null||l.focus(),()=>n.removeEventListener("keydown",x)},[o]);const B=t[`size-${S}`]??"",D=s!==void 0?s:e.jsx(e.Fragment,{children:v&&b?b(v):null}),M=o||_?e.jsx("div",{className:`${t.overlay} ${_?t.closing:""} ${C??""}`.trim(),onClick:U,role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:`${B} ${t.container} ${_?t.closing:""}`,children:[E&&e.jsx("button",{"aria-label":"Close",className:t.closeButton,onClick:r,type:"button",children:e.jsx(L.X,{size:20})}),e.jsx("div",{ref:f,className:`${t.modal} ${j??""}`.trim(),style:I,onClick:n=>n.stopPropagation(),children:e.jsx("div",{className:t.content,children:D})})]})}):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:t.trigger,onClick:T,children:z}),typeof window<"u"&&Y.createPortal(M,document.body)]})}exports.Modal=te;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../../index38.css');const e=require("react/jsx-runtime"),i=require("react"),L=require("react-dom"),R=require("../../../x-Dft9NVe_.cjs"),P="_overlay_6t5hy_2",A="_fadeIn_6t5hy_1",F="_container_6t5hy_19",K="_modal_6t5hy_49",X="_slideUp_6t5hy_1",G="_closeButton_6t5hy_60",H="_title_6t5hy_87",J="_content_6t5hy_97",Q="_intro_6t5hy_116",V="_trigger_6t5hy_123",W="_fadeOut_6t5hy_1",Z="_closing_6t5hy_170",O="_slideUpSheet_6t5hy_1",ee="_slideDownSheet_6t5hy_1",o={overlay:P,fadeIn:A,container:F,"size-sm":"_size-sm_6t5hy_26","size-md":"_size-md_6t5hy_30","size-lg":"_size-lg_6t5hy_34","size-xl":"_size-xl_6t5hy_38","size-full":"_size-full_6t5hy_42",modal:K,slideUp:X,closeButton:G,title:H,content:J,intro:Q,trigger:V,fadeOut:W,closing:Z,slideUpSheet:O,slideDownSheet:ee},te=()=>{if(typeof document>"u")return;const s=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${s}px`,document.body.style.width="100%",document.body.style.overflowY="scroll"},k=()=>{if(typeof document>"u")return;const s=Math.abs(parseInt(document.body.style.top||"0",10));document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflowY="",s&&window.scrollTo(0,s)};function oe({content:s,trigger:z,isOpen:h,onOpen:c,onClose:y,size:S="md",closeOnEscape:g=!0,closeOnOverlayClick:$=!0,showCloseButton:E=!0,className:j,overlayClassName:T,style:C,formData:v,renderForm:b}){const[I,p]=i.useState(!1),[_,w]=i.useState(!1),f=i.useRef(null),m=h!==void 0,n=m?h:I,q=()=>{m||p(!0),c==null||c()},d=()=>{w(!0),setTimeout(()=>{w(!1),m?y==null||y():p(!1)},300)},N=()=>n?d():q(),U=()=>{$&&d()};i.useEffect(()=>{if(!g||!n)return;const t=r=>{r.key==="Escape"&&d()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[n,g]),i.useEffect(()=>(n?te():k(),()=>k()),[n]),i.useEffect(()=>{if(!n||!f.current)return;const t=f.current;t.scrollTop=0;const r=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),l=r[0],a=r[r.length-1],x=u=>{u.key==="Tab"&&(u.shiftKey?document.activeElement===l&&(u.preventDefault(),a==null||a.focus()):document.activeElement===a&&(u.preventDefault(),l==null||l.focus()))};t.addEventListener("keydown",x);const Y=setTimeout(()=>l==null?void 0:l.focus(),50);return()=>{t.removeEventListener("keydown",x),clearTimeout(Y)}},[n]);const B=o[`size-${S}`]??"",D=s!==void 0?s:e.jsx(e.Fragment,{children:v&&b?b(v):null}),M=n||_?e.jsx("div",{className:`${o.overlay} ${_?o.closing:""} ${T??""}`.trim(),onClick:U,role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:`${B} ${o.container} ${_?o.closing:""}`,children:[E&&e.jsx("button",{"aria-label":"Close",className:o.closeButton,onClick:d,type:"button",children:e.jsx(R.X,{size:20})}),e.jsx("div",{ref:f,className:`${o.modal} ${j??""}`.trim(),style:C,onClick:t=>t.stopPropagation(),children:e.jsx("div",{className:o.content,children:D})})]})}):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:o.trigger,onClick:N,children:z}),typeof window<"u"&&L.createPortal(M,document.body)]})}exports.Modal=oe;
@@ -1,28 +1,28 @@
1
1
  import { jsx as l, Fragment as z, jsxs as x } from "react/jsx-runtime";
2
- import { useState as S, useRef as q, useEffect as f } from "react";
3
- import { createPortal as A } from "react-dom";
4
- import { X as K } from "../../../x-CnsEH4Ox.js";
5
- import '../../../index38.css';const X = "_overlay_6t5hy_2", F = "_fadeIn_6t5hy_1", G = "_container_6t5hy_19", H = "_modal_6t5hy_49", J = "_slideUp_6t5hy_1", Q = "_closeButton_6t5hy_60", V = "_title_6t5hy_87", W = "_content_6t5hy_97", Z = "_intro_6t5hy_116", O = "_trigger_6t5hy_123", ee = "_fadeOut_6t5hy_1", te = "_closing_6t5hy_170", oe = "_slideUpSheet_6t5hy_1", ne = "_slideDownSheet_6t5hy_1", e = {
6
- overlay: X,
7
- fadeIn: F,
8
- container: G,
2
+ import { useState as S, useRef as A, useEffect as f } from "react";
3
+ import { createPortal as K } from "react-dom";
4
+ import { X } from "../../../x-CnsEH4Ox.js";
5
+ import '../../../index38.css';const F = "_overlay_6t5hy_2", G = "_fadeIn_6t5hy_1", H = "_container_6t5hy_19", J = "_modal_6t5hy_49", Q = "_slideUp_6t5hy_1", V = "_closeButton_6t5hy_60", W = "_title_6t5hy_87", Z = "_content_6t5hy_97", O = "_intro_6t5hy_116", ee = "_trigger_6t5hy_123", te = "_fadeOut_6t5hy_1", oe = "_closing_6t5hy_170", ne = "_slideUpSheet_6t5hy_1", se = "_slideDownSheet_6t5hy_1", t = {
6
+ overlay: F,
7
+ fadeIn: G,
8
+ container: H,
9
9
  "size-sm": "_size-sm_6t5hy_26",
10
10
  "size-md": "_size-md_6t5hy_30",
11
11
  "size-lg": "_size-lg_6t5hy_34",
12
12
  "size-xl": "_size-xl_6t5hy_38",
13
13
  "size-full": "_size-full_6t5hy_42",
14
- modal: H,
15
- slideUp: J,
16
- closeButton: Q,
17
- title: V,
18
- content: W,
19
- intro: Z,
20
- trigger: O,
21
- fadeOut: ee,
22
- closing: te,
23
- slideUpSheet: oe,
24
- slideDownSheet: ne
25
- }, se = () => {
14
+ modal: J,
15
+ slideUp: Q,
16
+ closeButton: V,
17
+ title: W,
18
+ content: Z,
19
+ intro: O,
20
+ trigger: ee,
21
+ fadeOut: te,
22
+ closing: oe,
23
+ slideUpSheet: ne,
24
+ slideDownSheet: se
25
+ }, le = () => {
26
26
  if (typeof document > "u") return;
27
27
  const n = window.scrollY;
28
28
  document.body.style.position = "fixed", document.body.style.top = `-${n}px`, document.body.style.width = "100%", document.body.style.overflowY = "scroll";
@@ -31,79 +31,85 @@ import '../../../index38.css';const X = "_overlay_6t5hy_2", F = "_fadeIn_6t5hy_1
31
31
  const n = Math.abs(parseInt(document.body.style.top || "0", 10));
32
32
  document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflowY = "", n && window.scrollTo(0, n);
33
33
  };
34
- function re({
34
+ function ae({
35
35
  content: n,
36
36
  trigger: E,
37
37
  isOpen: h,
38
38
  onOpen: i,
39
39
  onClose: u,
40
- size: C = "md",
40
+ size: T = "md",
41
41
  closeOnEscape: v = !0,
42
- closeOnOverlayClick: I = !0,
43
- showCloseButton: N = !0,
44
- className: U,
45
- overlayClassName: B,
46
- style: T,
42
+ closeOnOverlayClick: C = !0,
43
+ showCloseButton: I = !0,
44
+ className: N,
45
+ overlayClassName: U,
46
+ style: B,
47
47
  // title,
48
48
  // richTextBlocks,
49
49
  // renderRichText,
50
- formData: g,
51
- renderForm: p
50
+ formData: p,
51
+ renderForm: g
52
52
  }) {
53
- const [Y, b] = S(!1), [y, w] = S(!1), _ = q(null), m = h !== void 0, t = m ? h : Y, D = () => {
53
+ const [Y, b] = S(!1), [y, w] = S(!1), _ = A(null), m = h !== void 0, o = m ? h : Y, D = () => {
54
54
  m || b(!0), i == null || i();
55
55
  }, d = () => {
56
56
  w(!0), setTimeout(() => {
57
57
  w(!1), m ? u == null || u() : b(!1);
58
58
  }, 300);
59
- }, L = () => t ? d() : D(), j = () => {
60
- I && d();
59
+ }, L = () => o ? d() : D(), j = () => {
60
+ C && d();
61
61
  };
62
62
  f(() => {
63
- if (!v || !t) return;
64
- const o = (c) => {
63
+ if (!v || !o) return;
64
+ const e = (c) => {
65
65
  c.key === "Escape" && d();
66
66
  };
67
- return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
68
- }, [t, v]), f(() => (t ? se() : $(), () => $()), [t]), f(() => {
69
- if (!t || !_.current) return;
70
- const o = _.current, c = o.querySelectorAll(
67
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
68
+ }, [o, v]), f(() => (o ? le() : $(), () => $()), [o]), f(() => {
69
+ if (!o || !_.current) return;
70
+ const e = _.current;
71
+ e.scrollTop = 0;
72
+ const c = e.querySelectorAll(
71
73
  'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
72
74
  ), s = c[0], r = c[c.length - 1], k = (a) => {
73
75
  a.key === "Tab" && (a.shiftKey ? document.activeElement === s && (a.preventDefault(), r == null || r.focus()) : document.activeElement === r && (a.preventDefault(), s == null || s.focus()));
74
76
  };
75
- return o.addEventListener("keydown", k), s == null || s.focus(), () => o.removeEventListener("keydown", k);
76
- }, [t]);
77
- const M = e[`size-${C}`] ?? "", P = n !== void 0 ? n : /* @__PURE__ */ l(z, { children: g && p ? p(g) : null }), R = t || y ? /* @__PURE__ */ l(
77
+ e.addEventListener("keydown", k);
78
+ const q = setTimeout(() => s == null ? void 0 : s.focus(), 50);
79
+ return () => {
80
+ e.removeEventListener("keydown", k), clearTimeout(q);
81
+ };
82
+ }, [o]);
83
+ const M = t[`size-${T}`] ?? "", P = n !== void 0 ? n : /* @__PURE__ */ l(z, { children: p && g ? g(p) : null }), R = o || y ? /* @__PURE__ */ l(
78
84
  "div",
79
85
  {
80
- className: `${e.overlay} ${y ? e.closing : ""} ${B ?? ""}`.trim(),
86
+ className: `${t.overlay} ${y ? t.closing : ""} ${U ?? ""}`.trim(),
81
87
  onClick: j,
82
88
  role: "dialog",
83
89
  "aria-modal": "true",
84
90
  children: /* @__PURE__ */ x(
85
91
  "div",
86
92
  {
87
- className: `${M} ${e.container} ${y ? e.closing : ""}`,
93
+ className: `${M} ${t.container} ${y ? t.closing : ""}`,
88
94
  children: [
89
- N && /* @__PURE__ */ l(
95
+ I && /* @__PURE__ */ l(
90
96
  "button",
91
97
  {
92
98
  "aria-label": "Close",
93
- className: e.closeButton,
99
+ className: t.closeButton,
94
100
  onClick: d,
95
101
  type: "button",
96
- children: /* @__PURE__ */ l(K, { size: 20 })
102
+ children: /* @__PURE__ */ l(X, { size: 20 })
97
103
  }
98
104
  ),
99
105
  /* @__PURE__ */ l(
100
106
  "div",
101
107
  {
102
108
  ref: _,
103
- className: `${e.modal} ${U ?? ""}`.trim(),
104
- style: T,
105
- onClick: (o) => o.stopPropagation(),
106
- children: /* @__PURE__ */ l("div", { className: e.content, children: P })
109
+ className: `${t.modal} ${N ?? ""}`.trim(),
110
+ style: B,
111
+ onClick: (e) => e.stopPropagation(),
112
+ children: /* @__PURE__ */ l("div", { className: t.content, children: P })
107
113
  }
108
114
  )
109
115
  ]
@@ -112,10 +118,10 @@ function re({
112
118
  }
113
119
  ) : null;
114
120
  return /* @__PURE__ */ x(z, { children: [
115
- /* @__PURE__ */ l("div", { className: e.trigger, onClick: L, children: E }),
116
- typeof window < "u" && A(R, document.body)
121
+ /* @__PURE__ */ l("div", { className: t.trigger, onClick: L, children: E }),
122
+ typeof window < "u" && K(R, document.body)
117
123
  ] });
118
124
  }
119
125
  export {
120
- re as Modal
126
+ ae as Modal
121
127
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.1.208",
4
+ "version": "0.1.210",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {