@kvdbil/components 17.2.1 → 17.2.3
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,5 +1,4 @@
|
|
|
1
1
|
"use strict";var e,t=require("react/jsx-runtime"),r=require("react"),n=require("styled-components");const u=((e=n)&&e.__esModule?e:{default:e}).default.div`
|
|
2
|
-
display: flex;
|
|
3
2
|
width: 100%;
|
|
4
3
|
height: 100%;
|
|
5
4
|
`;exports.FocusTrap=({children:e,pause:n=!1,autoFocusOnOpen:s="firstElem",restoreFocusOnClose:c=!0})=>{const o=r.useRef(null),i=r.useRef([]),l=r.useRef(null),d=r.useRef(null),f=r.useRef(!1);return r.useEffect((()=>{if(n)return void(c&&f.current&&d.current&&d.current.focus());const e=o.current;if(!e)return;c&&(d.current=document.activeElement);const t=["a[href]","button:not([disabled])","textarea:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])",'[tabindex]:not([tabindex="-1"])'],r=()=>{i.current=Array.from(e.querySelectorAll(t.join(",")))},u=e=>{if("Tab"!==e.key)return;const t=i.current;if(0===t.length)return void e.preventDefault();const r=t[0],n=t[t.length-1],u=t.findIndex((e=>e===document.activeElement));e.preventDefault(),e.shiftKey?u<=0?n.focus():t[u-1].focus():-1===u||u===t.length-1?r.focus():t[u+1].focus()};return r(),"firstElem"===s&&i.current.length>0&&i.current[0].focus(),"firstInput"===s&&i.current.find((e=>"INPUT"===e.tagName))?.focus(),e.addEventListener("keydown",u),l.current=new MutationObserver(r),l.current.observe(e,{childList:!0,subtree:!0}),f.current=!0,()=>{e.removeEventListener("keydown",u),l.current?.disconnect(),l.current=null}}),[n,s,c]),t.jsx(u,{ref:o,children:e})};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("react-dom"),o=require("react-transition-group"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("react-dom"),o=require("react-transition-group"),n=require("styled-components"),r=require("../../icons/components/CloseIcon.js"),a=require("../../utils/utils.js"),s=require("../FocusTrap.js");var d,l=(d=n)&&d.__esModule?d:{default:d};const c=n.css`
|
|
2
2
|
.backgroundTransition-enter {
|
|
3
3
|
opacity: 0;
|
|
4
4
|
}
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
opacity: 0;
|
|
17
17
|
transition: opacity 0.25s ease-in-out;
|
|
18
18
|
}
|
|
19
|
-
`,
|
|
20
|
-
${
|
|
19
|
+
`,u=l.default.div`
|
|
20
|
+
${c}
|
|
21
21
|
position: fixed;
|
|
22
22
|
width: 100%;
|
|
23
23
|
height: 100%;
|
|
@@ -25,14 +25,21 @@
|
|
|
25
25
|
left: 0;
|
|
26
26
|
z-index: 200;
|
|
27
27
|
`,p=l.default.div`
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
`,x=l.default.div`
|
|
28
34
|
z-index: -1;
|
|
29
35
|
position: absolute;
|
|
30
36
|
width: 100%;
|
|
31
37
|
height: 100%;
|
|
32
38
|
background-color: rgba(34, 34, 34, 0.3);
|
|
33
|
-
`,
|
|
39
|
+
`,b=l.default.div`
|
|
34
40
|
position: relative;
|
|
35
|
-
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
|
|
36
43
|
padding: 1rem;
|
|
37
44
|
background-color: white;
|
|
38
45
|
border-radius: 3px;
|
|
@@ -41,19 +48,10 @@
|
|
|
41
48
|
0px 9px 46px rgba(0, 0, 0, 0.09),
|
|
42
49
|
0px 11px 15px rgba(0, 0, 0, 0.15);
|
|
43
50
|
|
|
44
|
-
overflow-y: hidden;
|
|
45
51
|
margin: 1rem;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
margin-right: 1rem;
|
|
50
|
-
|
|
51
|
-
@media (min-width: 500px) {
|
|
52
|
-
margin-left: auto;
|
|
53
|
-
margin-right: auto;
|
|
54
|
-
min-width: 355px;
|
|
55
|
-
}
|
|
56
|
-
`,m=l.default.button`
|
|
52
|
+
width: 80vw;
|
|
53
|
+
max-width: 512px;
|
|
54
|
+
`,w=l.default.button`
|
|
57
55
|
${a.resetButtonStyle}
|
|
58
56
|
display: flex;
|
|
59
57
|
justify-self: flex-end;
|
|
@@ -69,12 +67,12 @@
|
|
|
69
67
|
svg {
|
|
70
68
|
font-size: 1.5rem;
|
|
71
69
|
}
|
|
72
|
-
`,g=
|
|
70
|
+
`,g=n.createGlobalStyle`
|
|
73
71
|
body {
|
|
74
72
|
overflow: hidden;
|
|
75
73
|
|
|
76
74
|
${typeof window<"u"&&window.innerWidth>1024&&"\n padding-right: 15px !important;\n "}
|
|
77
75
|
}
|
|
78
|
-
`,
|
|
79
|
-
${
|
|
80
|
-
`,
|
|
76
|
+
`,h=n.createGlobalStyle`
|
|
77
|
+
${c}
|
|
78
|
+
`,y=({children:n,isOpen:a,contentStyles:d,withPortal:l=!1,withCloseIcon:c=!0,onClose:y,focusTrapProps:f={},...m})=>{t.useEffect((()=>{const e=e=>{"Escape"===e.key&&a&&y()};return a&&window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}}),[y,a]);const v=!!(typeof window<"u"&&window.document&&window.document.createElement),j=e.jsx(o.CSSTransition,{in:a,mountOnEnter:!0,unmountOnExit:!0,timeout:400,classNames:"backgroundTransition",children:e.jsxs(e.Fragment,{children:[e.jsx(h,{}),e.jsxs(u,{...m,children:[e.jsx(x,{"data-testid":"background",onClick:y}),e.jsx(s.FocusTrap,{pause:!a,...f,children:e.jsx(p,{children:e.jsxs(b,{style:d,role:"dialog","aria-modal":"true","aria-labelledby":"modal-title",children:[c&&e.jsx(w,{onClick:y,"data-testid":"close",type:"button","aria-label":"Close dialog",children:e.jsx(r.default,{})}),n]})})}),e.jsx(g,{})]})]})});return l&&v?i.createPortal(j,document.body):j};exports.Modal=y,exports.default=y;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import{jsx as
|
|
2
|
-
display: flex;
|
|
1
|
+
import{jsx as g}from"react/jsx-runtime";import{useRef as o,useEffect as x}from"react";import w from"styled-components";const L=w.div`
|
|
3
2
|
width: 100%;
|
|
4
3
|
height: 100%;
|
|
5
|
-
`,O=({children:p,pause:f=!1,autoFocusOnOpen:s="firstElem",restoreFocusOnClose:i=!0})=>{const d=o(null),r=o([]),c=o(null),l=o(null),a=o(!1);return
|
|
4
|
+
`,O=({children:p,pause:f=!1,autoFocusOnOpen:s="firstElem",restoreFocusOnClose:i=!0})=>{const d=o(null),r=o([]),c=o(null),l=o(null),a=o(!1);return x(()=>{if(f){i&&a.current&&l.current&&l.current.focus();return}const n=d.current;if(!n)return;i&&(l.current=document.activeElement);const b=["a[href]","button:not([disabled])","textarea:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])",'[tabindex]:not([tabindex="-1"])'],m=()=>{r.current=Array.from(n.querySelectorAll(b.join(",")))},h=t=>{if(t.key!=="Tab")return;const e=r.current;if(e.length===0){t.preventDefault();return}const v=e[0],E=e[e.length-1],u=e.findIndex(y=>y===document.activeElement);t.preventDefault(),t.shiftKey?u<=0?E.focus():e[u-1].focus():u===-1||u===e.length-1?v.focus():e[u+1].focus()};return m(),s==="firstElem"&&r.current.length>0&&r.current[0].focus(),s==="firstInput"&&r.current.find(t=>t.tagName==="INPUT")?.focus(),n.addEventListener("keydown",h),c.current=new MutationObserver(m),c.current.observe(n,{childList:!0,subtree:!0}),a.current=!0,()=>{n.removeEventListener("keydown",h),c.current?.disconnect(),c.current=null}},[f,s,i]),g(L,{ref:d,children:p})};export{O as FocusTrap};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as n,Fragment as b}from"react/jsx-runtime";import{useEffect as g}from"react";import{createPortal as y}from"react-dom";import{CSSTransition as v}from"react-transition-group";import e,{css as k,createGlobalStyle as d}from"styled-components";import T from"../../icons/components/CloseIcon.js";import{resetButtonStyle as E}from"../../utils/utils.js";import{FocusTrap as C}from"../FocusTrap.js";const s=k`
|
|
2
2
|
.backgroundTransition-enter {
|
|
3
3
|
opacity: 0;
|
|
4
4
|
}
|
|
@@ -24,15 +24,22 @@ import{jsx as t,jsxs as r,Fragment as w}from"react/jsx-runtime";import{useEffect
|
|
|
24
24
|
top: 0;
|
|
25
25
|
left: 0;
|
|
26
26
|
z-index: 200;
|
|
27
|
+
`,j=e.div`
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
27
33
|
`,P=e.div`
|
|
28
34
|
z-index: -1;
|
|
29
35
|
position: absolute;
|
|
30
36
|
width: 100%;
|
|
31
37
|
height: 100%;
|
|
32
38
|
background-color: rgba(34, 34, 34, 0.3);
|
|
33
|
-
|
|
39
|
+
`,z=e.div`
|
|
34
40
|
position: relative;
|
|
35
|
-
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
|
|
36
43
|
padding: 1rem;
|
|
37
44
|
background-color: white;
|
|
38
45
|
border-radius: 3px;
|
|
@@ -41,19 +48,10 @@ import{jsx as t,jsxs as r,Fragment as w}from"react/jsx-runtime";import{useEffect
|
|
|
41
48
|
0px 9px 46px rgba(0, 0, 0, 0.09),
|
|
42
49
|
0px 11px 15px rgba(0, 0, 0, 0.15);
|
|
43
50
|
|
|
44
|
-
overflow-y: hidden;
|
|
45
51
|
margin: 1rem;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
margin-right: 1rem;
|
|
50
|
-
|
|
51
|
-
@media (min-width: 500px) {
|
|
52
|
-
margin-left: auto;
|
|
53
|
-
margin-right: auto;
|
|
54
|
-
min-width: 355px;
|
|
55
|
-
}
|
|
56
|
-
`,j=e.button`
|
|
52
|
+
width: 80vw;
|
|
53
|
+
max-width: 512px;
|
|
54
|
+
`,F=e.button`
|
|
57
55
|
${E}
|
|
58
56
|
display: flex;
|
|
59
57
|
justify-self: flex-end;
|
|
@@ -69,7 +67,7 @@ import{jsx as t,jsxs as r,Fragment as w}from"react/jsx-runtime";import{useEffect
|
|
|
69
67
|
svg {
|
|
70
68
|
font-size: 1.5rem;
|
|
71
69
|
}
|
|
72
|
-
`,
|
|
70
|
+
`,O=d`
|
|
73
71
|
body {
|
|
74
72
|
overflow: hidden;
|
|
75
73
|
|
|
@@ -77,6 +75,6 @@ import{jsx as t,jsxs as r,Fragment as w}from"react/jsx-runtime";import{useEffect
|
|
|
77
75
|
padding-right: 15px !important;
|
|
78
76
|
`}
|
|
79
77
|
}
|
|
80
|
-
`,
|
|
78
|
+
`,L=d`
|
|
81
79
|
${s}
|
|
82
|
-
`,
|
|
80
|
+
`,c=({children:l,isOpen:o,contentStyles:p,withPortal:u=!1,withCloseIcon:m=!0,onClose:i,focusTrapProps:f={},...w})=>{g(()=>{const a=x=>{x.key==="Escape"&&o&&i()};return o&&window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[i,o]);const h=!!(typeof window<"u"&&window.document&&window.document.createElement),r=t(v,{in:o,mountOnEnter:!0,unmountOnExit:!0,timeout:400,classNames:"backgroundTransition",children:n(b,{children:[t(L,{}),n(S,{...w,children:[t(P,{"data-testid":"background",onClick:i}),t(C,{pause:!o,...f,children:t(j,{children:n(z,{style:p,role:"dialog","aria-modal":"true","aria-labelledby":"modal-title",children:[m&&t(F,{onClick:i,"data-testid":"close",type:"button","aria-label":"Close dialog",children:t(T,{})}),l]})})}),t(O,{})]})]})});return u&&h?y(r,document.body):r};export{c as Modal,c as default};
|
package/package.json
CHANGED