quirk-ui 0.1.151 → 0.1.152
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"),d=require("react"),C=require("react-dom"),F=require("../../../x-Dft9NVe_.cjs"),K="_overlay_1u4kf_2",X="_fadeIn_1u4kf_1",B="_container_1u4kf_19",G="_modal_1u4kf_49",H="_slideUp_1u4kf_1",J="_closeButton_1u4kf_60",Q="_title_1u4kf_87",V="_content_1u4kf_97",W="_trigger_1u4kf_117",t={overlay:K,fadeIn:X,container:B,"size-sm":"_size-sm_1u4kf_26","size-md":"_size-md_1u4kf_30","size-lg":"_size-lg_1u4kf_34","size-xl":"_size-xl_1u4kf_38","size-full":"_size-full_1u4kf_42",modal:G,slideUp:H,closeButton:J,title:Q,content:V,trigger:W},Y=()=>{typeof document<"u"&&(document.body.style.overflow="hidden")},E=()=>{typeof document<"u"&&(document.body.style.overflow="")};function Z({content:y,trigger:p,isOpen:k,onOpen:o,onClose:i,size:$="md",closeOnEscape:g=!0,closeOnOverlayClick:w=!0,showCloseButton:N=!0,className:q,overlayClassName:S,style:I,title:_,richTextBlocks:a,renderRichText:b,formData:h,renderForm:z}){const[L,j]=d.useState(!1),m=d.useRef(null),v=k!==void 0,n=v?k:L,M=()=>{v||j(!0),o==null||o()},r=()=>{v||j(!1),i==null||i()},P=()=>n?r():M(),R=()=>{w&&r()};d.useEffect(()=>{if(!g||!n)return;const s=c=>{c.key==="Escape"&&r()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[n,g]),d.useEffect(()=>(n?Y():E(),()=>E()),[n]),d.useEffect(()=>{if(!n||!m.current)return;const s=m.current,c=s.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),l=c[0],u=c[c.length-1],x=f=>{f.key==="Tab"&&(f.shiftKey?document.activeElement===l&&(f.preventDefault(),u==null||u.focus()):document.activeElement===u&&(f.preventDefault(),l==null||l.focus()))};return s.addEventListener("keydown",x),l==null||l.focus(),()=>s.removeEventListener("keydown",x)},[n]);const U=t[`size-${$}`]??"",D=y!==void 0?y:e.jsxs(e.Fragment,{children:[a!=null&&a.length&&b?e.jsx("div",{className:t.intro,children:b({blocks:a})}):null,h&&z?z(h):null]}),A=n?e.jsx("div",{className:`${t.overlay} ${S??""}`.trim(),onClick:R,role:"dialog","aria-modal":"true","aria-labelledby":_?"modal-title":void 0,children:e.jsxs("div",{className:`${U} ${t.container}`,children:[N&&e.jsx("button",{"aria-label":"Close",className:t.closeButton,onClick:r,type:"button",children:e.jsx(F.X,{size:20})}),e.jsxs("div",{ref:m,className:`${t.modal} ${q??""}`.trim(),style:I,onClick:s=>s.stopPropagation(),children:[_&&e.jsx("div",{className:t.title,id:"modal-title",children:_}),e.jsx("div",{className:t.content,children:D})]})]})}):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:t.trigger,onClick:P,children:p}),typeof window<"u"&&C.createPortal(A,document.body)]})}exports.Modal=Z;
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as X, useRef as B, useEffect as
|
|
1
|
+
import { jsxs as f, Fragment as N, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useState as X, useRef as B, useEffect as y } from "react";
|
|
3
3
|
import { createPortal as F } from "react-dom";
|
|
4
4
|
import { X as G } from "../../../x-CnsEH4Ox.js";
|
|
5
|
-
import '../../../index38.css';const H = "
|
|
5
|
+
import '../../../index38.css';const H = "_overlay_1u4kf_2", J = "_fadeIn_1u4kf_1", Q = "_container_1u4kf_19", V = "_modal_1u4kf_49", W = "_slideUp_1u4kf_1", Y = "_closeButton_1u4kf_60", Z = "_title_1u4kf_87", T = "_content_1u4kf_97", O = "_trigger_1u4kf_117", e = {
|
|
6
6
|
overlay: H,
|
|
7
7
|
fadeIn: J,
|
|
8
8
|
container: Q,
|
|
9
|
-
"size-sm": "_size-
|
|
10
|
-
"size-md": "_size-
|
|
11
|
-
"size-lg": "_size-
|
|
12
|
-
"size-xl": "_size-
|
|
13
|
-
"size-full": "_size-
|
|
9
|
+
"size-sm": "_size-sm_1u4kf_26",
|
|
10
|
+
"size-md": "_size-md_1u4kf_30",
|
|
11
|
+
"size-lg": "_size-lg_1u4kf_34",
|
|
12
|
+
"size-xl": "_size-xl_1u4kf_38",
|
|
13
|
+
"size-full": "_size-full_1u4kf_42",
|
|
14
14
|
modal: V,
|
|
15
15
|
slideUp: W,
|
|
16
16
|
closeButton: Y,
|
|
17
17
|
title: Z,
|
|
18
18
|
content: T,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, te = () => {
|
|
19
|
+
trigger: O
|
|
20
|
+
}, ee = () => {
|
|
22
21
|
typeof document < "u" && (document.body.style.overflow = "hidden");
|
|
23
22
|
}, $ = () => {
|
|
24
23
|
typeof document < "u" && (document.body.style.overflow = "");
|
|
25
24
|
};
|
|
26
|
-
function
|
|
27
|
-
content:
|
|
25
|
+
function ie({
|
|
26
|
+
content: k,
|
|
28
27
|
trigger: I,
|
|
29
28
|
isOpen: g,
|
|
30
|
-
onOpen:
|
|
31
|
-
onClose:
|
|
29
|
+
onOpen: i,
|
|
30
|
+
onClose: s,
|
|
32
31
|
size: L = "md",
|
|
33
32
|
closeOnEscape: b = !0,
|
|
34
33
|
closeOnOverlayClick: S = !0,
|
|
@@ -36,37 +35,37 @@ function ce({
|
|
|
36
35
|
className: j,
|
|
37
36
|
overlayClassName: x,
|
|
38
37
|
style: P,
|
|
39
|
-
title:
|
|
40
|
-
richTextBlocks:
|
|
38
|
+
title: m,
|
|
39
|
+
richTextBlocks: c,
|
|
41
40
|
renderRichText: h,
|
|
42
|
-
formData:
|
|
43
|
-
renderForm:
|
|
41
|
+
formData: p,
|
|
42
|
+
renderForm: z
|
|
44
43
|
}) {
|
|
45
|
-
const [q, E] = X(!1),
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
}, C = () => t ?
|
|
50
|
-
S &&
|
|
44
|
+
const [q, E] = X(!1), _ = B(null), v = g !== void 0, t = v ? g : q, A = () => {
|
|
45
|
+
v || E(!0), i == null || i();
|
|
46
|
+
}, a = () => {
|
|
47
|
+
v || E(!1), s == null || s();
|
|
48
|
+
}, C = () => t ? a() : A(), D = () => {
|
|
49
|
+
S && a();
|
|
51
50
|
};
|
|
52
|
-
|
|
51
|
+
y(() => {
|
|
53
52
|
if (!b || !t) return;
|
|
54
|
-
const n = (
|
|
55
|
-
|
|
53
|
+
const n = (d) => {
|
|
54
|
+
d.key === "Escape" && a();
|
|
56
55
|
};
|
|
57
56
|
return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
|
|
58
|
-
}, [t, b]),
|
|
59
|
-
if (!t || !
|
|
60
|
-
const n =
|
|
57
|
+
}, [t, b]), y(() => (t ? ee() : $(), () => $()), [t]), y(() => {
|
|
58
|
+
if (!t || !_.current) return;
|
|
59
|
+
const n = _.current, d = n.querySelectorAll(
|
|
61
60
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
62
|
-
), l =
|
|
61
|
+
), l = d[0], r = d[d.length - 1], w = (u) => {
|
|
63
62
|
u.key === "Tab" && (u.shiftKey ? document.activeElement === l && (u.preventDefault(), r == null || r.focus()) : document.activeElement === r && (u.preventDefault(), l == null || l.focus()));
|
|
64
63
|
};
|
|
65
64
|
return n.addEventListener("keydown", w), l == null || l.focus(), () => n.removeEventListener("keydown", w);
|
|
66
65
|
}, [t]);
|
|
67
|
-
const K = e[`size-${L}`] ?? "", M =
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
const K = e[`size-${L}`] ?? "", M = k !== void 0 ? k : /* @__PURE__ */ f(N, { children: [
|
|
67
|
+
c != null && c.length && h ? /* @__PURE__ */ o("div", { className: e.intro, children: h({ blocks: c }) }) : null,
|
|
68
|
+
p && z ? z(p) : null
|
|
70
69
|
] }), R = t ? /* @__PURE__ */ o(
|
|
71
70
|
"div",
|
|
72
71
|
{
|
|
@@ -74,27 +73,27 @@ function ce({
|
|
|
74
73
|
onClick: D,
|
|
75
74
|
role: "dialog",
|
|
76
75
|
"aria-modal": "true",
|
|
77
|
-
"aria-labelledby":
|
|
78
|
-
children: /* @__PURE__ */
|
|
76
|
+
"aria-labelledby": m ? "modal-title" : void 0,
|
|
77
|
+
children: /* @__PURE__ */ f("div", { className: `${K} ${e.container}`, children: [
|
|
79
78
|
U && /* @__PURE__ */ o(
|
|
80
79
|
"button",
|
|
81
80
|
{
|
|
82
81
|
"aria-label": "Close",
|
|
83
82
|
className: e.closeButton,
|
|
84
|
-
onClick:
|
|
83
|
+
onClick: a,
|
|
85
84
|
type: "button",
|
|
86
85
|
children: /* @__PURE__ */ o(G, { size: 20 })
|
|
87
86
|
}
|
|
88
87
|
),
|
|
89
|
-
/* @__PURE__ */
|
|
88
|
+
/* @__PURE__ */ f(
|
|
90
89
|
"div",
|
|
91
90
|
{
|
|
92
|
-
ref:
|
|
91
|
+
ref: _,
|
|
93
92
|
className: `${e.modal} ${j ?? ""}`.trim(),
|
|
94
93
|
style: P,
|
|
95
94
|
onClick: (n) => n.stopPropagation(),
|
|
96
95
|
children: [
|
|
97
|
-
|
|
96
|
+
m && /* @__PURE__ */ o("div", { className: e.title, id: "modal-title", children: m }),
|
|
98
97
|
/* @__PURE__ */ o("div", { className: e.content, children: M })
|
|
99
98
|
]
|
|
100
99
|
}
|
|
@@ -102,11 +101,11 @@ function ce({
|
|
|
102
101
|
] })
|
|
103
102
|
}
|
|
104
103
|
) : null;
|
|
105
|
-
return /* @__PURE__ */
|
|
104
|
+
return /* @__PURE__ */ f(N, { children: [
|
|
106
105
|
/* @__PURE__ */ o("div", { className: e.trigger, onClick: C, children: I }),
|
|
107
106
|
typeof window < "u" && F(R, document.body)
|
|
108
107
|
] });
|
|
109
108
|
}
|
|
110
109
|
export {
|
|
111
|
-
|
|
110
|
+
ie as Modal
|
|
112
111
|
};
|
package/dist/index38.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._overlay_1u4kf_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_1u4kf_1 .2s ease;padding:var(--spacing-md, 1rem);overflow-y:auto}._container_1u4kf_19{position:relative;display:flex;flex-direction:column}._size-sm_1u4kf_26{width:90%;max-width:400px}._size-md_1u4kf_30{width:90%;max-width:600px}._size-lg_1u4kf_34{width:90%;max-width:800px}._size-xl_1u4kf_38{width:90%;max-width:1200px}._size-full_1u4kf_42{width:95%;height:95dvh;max-height:95dvh}._modal_1u4kf_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_1u4kf_1 .3s ease}._closeButton_1u4kf_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_1u4kf_60:hover{background-color:var(--color-secondary-10, #f5f5f5);color:var(--color-text-primary, #333)}._closeButton_1u4kf_60:focus-visible{outline:2px solid var(--color-primary-100, #007bff);outline-offset:2px}._title_1u4kf_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_1u4kf_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_1u4kf_97 video,._content_1u4kf_97 img{max-width:100%;height:auto;border-radius:var(--radius-md, .5rem)}._content_1u4kf_97 video{width:100%}._trigger_1u4kf_117{width:auto;display:inline-block;cursor:pointer}@keyframes _fadeIn_1u4kf_1{0%{opacity:0}to{opacity:1}}@keyframes _slideUp_1u4kf_1{0%{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@media (max-width: 768px){._modal_1u4kf_49{padding:var(--spacing-lg, 1.5rem);max-height:85dvh}._size-sm_1u4kf_26,._size-md_1u4kf_30,._size-lg_1u4kf_34,._size-xl_1u4kf_38{width:95%}._title_1u4kf_87{font-size:var(--font-size-lg, 1.25rem);padding-right:var(--spacing-lg, 1.5rem)}}@media (max-width: 480px){._overlay_1u4kf_2{padding:var(--spacing-sm, .5rem)}._modal_1u4kf_49{padding:var(--spacing-md, 1rem);max-height:90dvh}._title_1u4kf_87{font-size:var(--font-size-md, 1rem);margin-bottom:var(--spacing-md, 1rem)}}
|