quirk-ui 0.1.208 → 0.1.209
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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../../index38.css');const e=require("react/jsx-runtime"),c=require("react"),F=require("react-dom"),L=require("../../../x-Dft9NVe_.cjs"),R="_overlay_1dim9_2",P="_fadeIn_1dim9_1",A="_container_1dim9_19",K="_modal_1dim9_49",X="_slideUp_1dim9_1",G="_closeButton_1dim9_60",H="_title_1dim9_87",J="_content_1dim9_97",Q="_intro_1dim9_116",V="_trigger_1dim9_123",W="_overlayFadeIn_1dim9_1",Z="_fadeOut_1dim9_1",O="_closing_1dim9_175",ee="_slideUpSheet_1dim9_1",te="_slideDownSheet_1dim9_1",o={overlay:R,fadeIn:P,container:A,"size-sm":"_size-sm_1dim9_26","size-md":"_size-md_1dim9_30","size-lg":"_size-lg_1dim9_34","size-xl":"_size-xl_1dim9_38","size-full":"_size-full_1dim9_42",modal:K,slideUp:X,closeButton:G,title:H,content:J,intro:Q,trigger:V,overlayFadeIn:W,fadeOut:Z,closing:O,slideUpSheet:ee,slideDownSheet:te},oe=()=>{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 ne({content:s,trigger:z,isOpen:v,onOpen:l,onClose:m,size:S="md",closeOnEscape:g=!0,closeOnOverlayClick:$=!0,showCloseButton:E=!0,className:j,overlayClassName:I,style:T,formData:h,renderForm:b}){const[C,p]=c.useState(!1),[_,w]=c.useState(!1),f=c.useRef(null),y=v!==void 0,n=y?v:C,q=()=>{y||p(!0),l==null||l()},r=()=>{w(!0),setTimeout(()=>{w(!1),y?m==null||m():p(!1)},300)},N=()=>n?r():q(),U=()=>{$&&r()};c.useEffect(()=>{if(!g||!n)return;const t=d=>{d.key==="Escape"&&r()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[n,g]),c.useEffect(()=>(n?oe():k(),()=>k()),[n]),c.useEffect(()=>{if(!n||!f.current)return;const t=f.current;t.scrollTop=0;const d=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),i=d[0],a=d[d.length-1],x=u=>{u.key==="Tab"&&(u.shiftKey?document.activeElement===i&&(u.preventDefault(),a==null||a.focus()):document.activeElement===a&&(u.preventDefault(),i==null||i.focus()))};t.addEventListener("keydown",x);const Y=setTimeout(()=>i==null?void 0:i.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:h&&b?b(h):null}),M=n||_?e.jsx("div",{className:`${o.overlay} ${_?o.closing:""} ${I??""}`.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:r,type:"button",children:e.jsx(L.X,{size:20})}),e.jsx("div",{ref:f,className:`${o.modal} ${j??""}`.trim(),style:T,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"&&F.createPortal(M,document.body)]})}exports.Modal=ne;
|
|
@@ -1,109 +1,116 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as i, Fragment as z, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import { useState as I, useRef as q, useEffect as y } from "react";
|
|
3
3
|
import { createPortal as A } from "react-dom";
|
|
4
4
|
import { X as K } from "../../../x-CnsEH4Ox.js";
|
|
5
|
-
import '../../../index38.css';const X = "
|
|
5
|
+
import '../../../index38.css';const X = "_overlay_1dim9_2", G = "_fadeIn_1dim9_1", H = "_container_1dim9_19", J = "_modal_1dim9_49", Q = "_slideUp_1dim9_1", V = "_closeButton_1dim9_60", W = "_title_1dim9_87", Z = "_content_1dim9_97", O = "_intro_1dim9_116", ee = "_trigger_1dim9_123", te = "_overlayFadeIn_1dim9_1", oe = "_fadeOut_1dim9_1", ne = "_closing_1dim9_175", se = "_slideUpSheet_1dim9_1", ie = "_slideDownSheet_1dim9_1", t = {
|
|
6
6
|
overlay: X,
|
|
7
|
-
fadeIn:
|
|
8
|
-
container:
|
|
9
|
-
"size-sm": "_size-
|
|
10
|
-
"size-md": "_size-
|
|
11
|
-
"size-lg": "_size-
|
|
12
|
-
"size-xl": "_size-
|
|
13
|
-
"size-full": "_size-
|
|
14
|
-
modal:
|
|
15
|
-
slideUp:
|
|
16
|
-
closeButton:
|
|
17
|
-
title:
|
|
18
|
-
content:
|
|
19
|
-
intro:
|
|
20
|
-
trigger:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
fadeIn: G,
|
|
8
|
+
container: H,
|
|
9
|
+
"size-sm": "_size-sm_1dim9_26",
|
|
10
|
+
"size-md": "_size-md_1dim9_30",
|
|
11
|
+
"size-lg": "_size-lg_1dim9_34",
|
|
12
|
+
"size-xl": "_size-xl_1dim9_38",
|
|
13
|
+
"size-full": "_size-full_1dim9_42",
|
|
14
|
+
modal: J,
|
|
15
|
+
slideUp: Q,
|
|
16
|
+
closeButton: V,
|
|
17
|
+
title: W,
|
|
18
|
+
content: Z,
|
|
19
|
+
intro: O,
|
|
20
|
+
trigger: ee,
|
|
21
|
+
overlayFadeIn: te,
|
|
22
|
+
fadeOut: oe,
|
|
23
|
+
closing: ne,
|
|
24
|
+
slideUpSheet: se,
|
|
25
|
+
slideDownSheet: ie
|
|
26
|
+
}, le = () => {
|
|
26
27
|
if (typeof document > "u") return;
|
|
27
28
|
const n = window.scrollY;
|
|
28
29
|
document.body.style.position = "fixed", document.body.style.top = `-${n}px`, document.body.style.width = "100%", document.body.style.overflowY = "scroll";
|
|
29
|
-
},
|
|
30
|
+
}, S = () => {
|
|
30
31
|
if (typeof document > "u") return;
|
|
31
32
|
const n = Math.abs(parseInt(document.body.style.top || "0", 10));
|
|
32
33
|
document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflowY = "", n && window.scrollTo(0, n);
|
|
33
34
|
};
|
|
34
|
-
function
|
|
35
|
+
function me({
|
|
35
36
|
content: n,
|
|
36
|
-
trigger:
|
|
37
|
-
isOpen:
|
|
38
|
-
onOpen:
|
|
39
|
-
onClose:
|
|
40
|
-
size:
|
|
41
|
-
closeOnEscape:
|
|
42
|
-
closeOnOverlayClick:
|
|
43
|
-
showCloseButton:
|
|
44
|
-
className:
|
|
45
|
-
overlayClassName:
|
|
46
|
-
style:
|
|
37
|
+
trigger: $,
|
|
38
|
+
isOpen: v,
|
|
39
|
+
onOpen: l,
|
|
40
|
+
onClose: m,
|
|
41
|
+
size: E = "md",
|
|
42
|
+
closeOnEscape: h = !0,
|
|
43
|
+
closeOnOverlayClick: T = !0,
|
|
44
|
+
showCloseButton: C = !0,
|
|
45
|
+
className: N,
|
|
46
|
+
overlayClassName: U,
|
|
47
|
+
style: B,
|
|
47
48
|
// title,
|
|
48
49
|
// richTextBlocks,
|
|
49
50
|
// renderRichText,
|
|
50
|
-
formData:
|
|
51
|
-
renderForm:
|
|
51
|
+
formData: p,
|
|
52
|
+
renderForm: g
|
|
52
53
|
}) {
|
|
53
|
-
const [Y, b] =
|
|
54
|
-
|
|
55
|
-
},
|
|
54
|
+
const [Y, b] = I(!1), [u, w] = I(!1), _ = q(null), f = v !== void 0, o = f ? v : Y, D = () => {
|
|
55
|
+
f || b(!0), l == null || l();
|
|
56
|
+
}, c = () => {
|
|
56
57
|
w(!0), setTimeout(() => {
|
|
57
|
-
w(!1),
|
|
58
|
+
w(!1), f ? m == null || m() : b(!1);
|
|
58
59
|
}, 300);
|
|
59
|
-
}, L = () =>
|
|
60
|
-
|
|
60
|
+
}, L = () => o ? c() : D(), F = () => {
|
|
61
|
+
T && c();
|
|
61
62
|
};
|
|
62
|
-
|
|
63
|
-
if (!
|
|
64
|
-
const
|
|
65
|
-
|
|
63
|
+
y(() => {
|
|
64
|
+
if (!h || !o) return;
|
|
65
|
+
const e = (d) => {
|
|
66
|
+
d.key === "Escape" && c();
|
|
66
67
|
};
|
|
67
|
-
return document.addEventListener("keydown",
|
|
68
|
-
}, [
|
|
69
|
-
if (!
|
|
70
|
-
const
|
|
68
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
69
|
+
}, [o, h]), y(() => (o ? le() : S(), () => S()), [o]), y(() => {
|
|
70
|
+
if (!o || !_.current) return;
|
|
71
|
+
const e = _.current;
|
|
72
|
+
e.scrollTop = 0;
|
|
73
|
+
const d = e.querySelectorAll(
|
|
71
74
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
72
|
-
), s =
|
|
75
|
+
), s = d[0], r = d[d.length - 1], k = (a) => {
|
|
73
76
|
a.key === "Tab" && (a.shiftKey ? document.activeElement === s && (a.preventDefault(), r == null || r.focus()) : document.activeElement === r && (a.preventDefault(), s == null || s.focus()));
|
|
74
77
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
e.addEventListener("keydown", k);
|
|
79
|
+
const R = setTimeout(() => s == null ? void 0 : s.focus(), 50);
|
|
80
|
+
return () => {
|
|
81
|
+
e.removeEventListener("keydown", k), clearTimeout(R);
|
|
82
|
+
};
|
|
83
|
+
}, [o]);
|
|
84
|
+
const j = t[`size-${E}`] ?? "", M = n !== void 0 ? n : /* @__PURE__ */ i(z, { children: p && g ? g(p) : null }), P = o || u ? /* @__PURE__ */ i(
|
|
78
85
|
"div",
|
|
79
86
|
{
|
|
80
|
-
className: `${
|
|
81
|
-
onClick:
|
|
87
|
+
className: `${t.overlay} ${u ? t.closing : ""} ${U ?? ""}`.trim(),
|
|
88
|
+
onClick: F,
|
|
82
89
|
role: "dialog",
|
|
83
90
|
"aria-modal": "true",
|
|
84
91
|
children: /* @__PURE__ */ x(
|
|
85
92
|
"div",
|
|
86
93
|
{
|
|
87
|
-
className: `${
|
|
94
|
+
className: `${j} ${t.container} ${u ? t.closing : ""}`,
|
|
88
95
|
children: [
|
|
89
|
-
|
|
96
|
+
C && /* @__PURE__ */ i(
|
|
90
97
|
"button",
|
|
91
98
|
{
|
|
92
99
|
"aria-label": "Close",
|
|
93
|
-
className:
|
|
94
|
-
onClick:
|
|
100
|
+
className: t.closeButton,
|
|
101
|
+
onClick: c,
|
|
95
102
|
type: "button",
|
|
96
|
-
children: /* @__PURE__ */
|
|
103
|
+
children: /* @__PURE__ */ i(K, { size: 20 })
|
|
97
104
|
}
|
|
98
105
|
),
|
|
99
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ i(
|
|
100
107
|
"div",
|
|
101
108
|
{
|
|
102
109
|
ref: _,
|
|
103
|
-
className: `${
|
|
104
|
-
style:
|
|
105
|
-
onClick: (
|
|
106
|
-
children: /* @__PURE__ */
|
|
110
|
+
className: `${t.modal} ${N ?? ""}`.trim(),
|
|
111
|
+
style: B,
|
|
112
|
+
onClick: (e) => e.stopPropagation(),
|
|
113
|
+
children: /* @__PURE__ */ i("div", { className: t.content, children: M })
|
|
107
114
|
}
|
|
108
115
|
)
|
|
109
116
|
]
|
|
@@ -112,10 +119,10 @@ function re({
|
|
|
112
119
|
}
|
|
113
120
|
) : null;
|
|
114
121
|
return /* @__PURE__ */ x(z, { children: [
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
typeof window < "u" && A(
|
|
122
|
+
/* @__PURE__ */ i("div", { className: t.trigger, onClick: L, children: $ }),
|
|
123
|
+
typeof window < "u" && A(P, document.body)
|
|
117
124
|
] });
|
|
118
125
|
}
|
|
119
126
|
export {
|
|
120
|
-
|
|
127
|
+
me as Modal
|
|
121
128
|
};
|
package/dist/index38.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._overlay_1dim9_2{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000;animation:_fadeIn_1dim9_1 .2s ease;padding:var(--spacing-md, 1rem);overflow-y:auto}._container_1dim9_19{position:relative;display:flex;flex-direction:column}._size-sm_1dim9_26{width:90%;max-width:400px}._size-md_1dim9_30{width:90%;max-width:600px}._size-lg_1dim9_34{width:90%;max-width:800px}._size-xl_1dim9_38{width:90%;max-width:1200px}._size-full_1dim9_42{width:95%;height:95dvh;max-height:95dvh}._modal_1dim9_49{position:relative;background-color:var(--color-background, #fff);border-radius:var(--radius-lg, .5rem);padding:var(--spacing-xl, 2rem);max-height:90dvh;overflow-y:auto;animation:_slideUp_1dim9_1 .3s ease}._closeButton_1dim9_60{background:none;border:none;cursor:pointer;padding:var(--spacing-xs, .25rem);margin-bottom:var(--spacing-xs);border-radius:var(--radius-sm, .25rem);color:#fff;transition:all .2s ease;display:flex;align-items:center;justify-content:center;align-self:flex-end;z-index:1}._closeButton_1dim9_60:hover{background-color:var(--color-secondary-10, #f5f5f5);color:var(--color-text-primary, #333)}._closeButton_1dim9_60:focus-visible{outline:2px solid var(--color-primary-100, #007bff);outline-offset:2px}._title_1dim9_87{font-size:var(--font-size-xl, 1.5rem);font-weight:var(--font-weight-bold, 700);color:var(--color-heading, #111);margin-bottom:var(--spacing-lg, 1.5rem);padding-right:var(--spacing-xl, 2rem);line-height:var(--line-height-heading, 1.2)}._content_1dim9_97{color:var(--color-text-primary, #333);line-height:var(--line-height-normal, 1.5);display:flex;flex-direction:column;gap:var(--spacing-xl)}._content_1dim9_97 video,._content_1dim9_97 img{max-width:100%;height:auto;border-radius:var(--radius-md, .5rem)}._content_1dim9_97 video{width:100%}._intro_1dim9_116{margin-bottom:var(--spacing-lg, 1.5rem);padding-bottom:var(--spacing-lg, 1.5rem);border-bottom:1px solid var(--color-border, #e5e7eb)}._trigger_1dim9_123{width:auto;display:inline-block;cursor:pointer}@keyframes _fadeIn_1dim9_1{0%{opacity:0}to{opacity:1}}@keyframes _fadeOut_1dim9_1{0%{opacity:1}to{opacity:0}}@keyframes _slideUp_1dim9_1{0%{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@media (max-width: 767px){._overlay_1dim9_2{align-items:flex-end;justify-content:stretch;padding:0;overflow:hidden;height:100dvh;animation:_overlayFadeIn_1dim9_1 .2s ease forwards}._overlay_1dim9_2._closing_1dim9_175{animation:_fadeOut_1dim9_1 .28s ease forwards}._container_1dim9_19{width:100%;max-width:100%;max-height:92dvh;display:flex;flex-direction:column;border-radius:var(--radius-lg, .5rem) var(--radius-lg, .5rem) 0 0;background-color:var(--color-background, #fff);animation:_slideUpSheet_1dim9_1 .32s cubic-bezier(.32,.72,0,1) forwards;padding-bottom:env(safe-area-inset-bottom)}._container_1dim9_19._closing_1dim9_175{animation:_slideDownSheet_1dim9_1 .28s cubic-bezier(.32,.72,0,1) forwards}._size-sm_1dim9_26,._size-md_1dim9_30,._size-lg_1dim9_34,._size-xl_1dim9_38,._size-full_1dim9_42{width:100%;max-width:100%;max-height:92dvh;height:auto}._closeButton_1dim9_60{color:var(--color-text-primary, #333);align-self:flex-end;flex-shrink:0;margin:var(--spacing-sm) var(--spacing-sm) 0}._modal_1dim9_49{border-radius:0;padding:var(--spacing-md) var(--spacing-lg) var(--spacing-lg);flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;animation:none;max-height:none}._content_1dim9_97{width:100%}._title_1dim9_87{font-size:var(--font-size-lg, 1.25rem);padding-right:0}}@keyframes _overlayFadeIn_1dim9_1{0%{opacity:0}to{opacity:1}}@keyframes _slideUpSheet_1dim9_1{0%{transform:translateY(150%);opacity:.75}to{transform:translateY(0);opacity:1}}@keyframes _slideDownSheet_1dim9_1{0%{transform:translateY(0);opacity:1}to{transform:translateY(100%);opacity:0}}
|