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"),
|
|
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
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { X
|
|
5
|
-
import '../../../index38.css';const
|
|
6
|
-
overlay:
|
|
7
|
-
fadeIn:
|
|
8
|
-
container:
|
|
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:
|
|
15
|
-
slideUp:
|
|
16
|
-
closeButton:
|
|
17
|
-
title:
|
|
18
|
-
content:
|
|
19
|
-
intro:
|
|
20
|
-
trigger:
|
|
21
|
-
fadeOut:
|
|
22
|
-
closing:
|
|
23
|
-
slideUpSheet:
|
|
24
|
-
slideDownSheet:
|
|
25
|
-
},
|
|
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
|
|
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:
|
|
40
|
+
size: T = "md",
|
|
41
41
|
closeOnEscape: v = !0,
|
|
42
|
-
closeOnOverlayClick:
|
|
43
|
-
showCloseButton:
|
|
44
|
-
className:
|
|
45
|
-
overlayClassName:
|
|
46
|
-
style:
|
|
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:
|
|
51
|
-
renderForm:
|
|
50
|
+
formData: p,
|
|
51
|
+
renderForm: g
|
|
52
52
|
}) {
|
|
53
|
-
const [Y, b] = S(!1), [y, w] = S(!1), _ =
|
|
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 = () =>
|
|
60
|
-
|
|
59
|
+
}, L = () => o ? d() : D(), j = () => {
|
|
60
|
+
C && d();
|
|
61
61
|
};
|
|
62
62
|
f(() => {
|
|
63
|
-
if (!v || !
|
|
64
|
-
const
|
|
63
|
+
if (!v || !o) return;
|
|
64
|
+
const e = (c) => {
|
|
65
65
|
c.key === "Escape" && d();
|
|
66
66
|
};
|
|
67
|
-
return document.addEventListener("keydown",
|
|
68
|
-
}, [
|
|
69
|
-
if (!
|
|
70
|
-
const
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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: `${
|
|
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} ${
|
|
93
|
+
className: `${M} ${t.container} ${y ? t.closing : ""}`,
|
|
88
94
|
children: [
|
|
89
|
-
|
|
95
|
+
I && /* @__PURE__ */ l(
|
|
90
96
|
"button",
|
|
91
97
|
{
|
|
92
98
|
"aria-label": "Close",
|
|
93
|
-
className:
|
|
99
|
+
className: t.closeButton,
|
|
94
100
|
onClick: d,
|
|
95
101
|
type: "button",
|
|
96
|
-
children: /* @__PURE__ */ l(
|
|
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: `${
|
|
104
|
-
style:
|
|
105
|
-
onClick: (
|
|
106
|
-
children: /* @__PURE__ */ l("div", { className:
|
|
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:
|
|
116
|
-
typeof window < "u" &&
|
|
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
|
-
|
|
126
|
+
ae as Modal
|
|
121
127
|
};
|