@dotss/ui 1.0.8 → 1.0.9
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.
- package/Backdrop/Backdrop.cjs +5 -5
- package/Backdrop/Backdrop.d.ts +1 -0
- package/Backdrop/Backdrop.es.js +70 -53
- package/package.json +1 -1
package/Backdrop/Backdrop.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@emotion/react/jsx-runtime"),s=require("react"),M=require("react-dom"),O=require("@emotion/styled"),W=e=>e&&e.__esModule?e:{default:e},S=W(O),_=S.default.div`
|
|
2
2
|
position: fixed;
|
|
3
3
|
|
|
4
|
-
${({hasContainer:e,containerTop:
|
|
4
|
+
${({hasContainer:e,containerTop:o,containerLeft:u,containerWidth:d,containerHeight:i})=>e?{top:o,left:u,width:d,height:i}:{top:0,left:0,width:"100%",height:"100%"}};
|
|
5
5
|
|
|
6
6
|
z-index: 100000;
|
|
7
7
|
|
|
8
8
|
background-color: ${({theme:{palette:{etc:e}}})=>e.dimmed01};
|
|
9
9
|
transition: opacity ${({transitionDuration:e})=>e}ms;
|
|
10
10
|
opacity: ${({open:e})=>e?1:0};
|
|
11
|
-
`,
|
|
11
|
+
`,k=S.default.div`
|
|
12
12
|
position: relative;
|
|
13
13
|
|
|
14
|
-
${({theme:{spacing:e},fullScreen:
|
|
14
|
+
${({theme:{spacing:e},fullScreen:o})=>o?{width:"100%",height:"100%"}:{width:`calc(100% - ${e.content(10)}px)`,height:`calc(100% - ${e.content(10)}px)`,margin:e.content(5)}};
|
|
15
15
|
|
|
16
16
|
${({centered:e})=>e?{display:"flex",alignItems:"center",justifyContent:"center"}:null}}
|
|
17
|
-
`,
|
|
17
|
+
`,A=s.forwardRef(function({children:o,open:u,onClose:d,transitionDuration:i=200,fullScreen:a,centered:h,containerRef:r,inlineCSS:m,disablePortal:q=!1,...p},y){const[g,T]=s.useState(!1),[z,v]=s.useState(!0),[w,I]=s.useState(0),[x,L]=s.useState(0),[b,B]=s.useState(0),[C,H]=s.useState(0),c=s.useRef(),n=s.useRef(),$=!!(r!=null&&r.current);return s.useEffect(()=>{u&&(n.current&&clearTimeout(n.current),document.body.style.overflow="hidden",v(!1),c.current=setTimeout(()=>{T(!0)},100))},[u]),s.useEffect(()=>{u||(c.current&&clearTimeout(c.current),document.body.removeAttribute("style"),T(!1),n.current=setTimeout(()=>{v(!0)},i))},[u,i]),s.useEffect(()=>{const t=r==null?void 0:r.current,l=()=>{var j;t&&(I((t==null?void 0:t.offsetTop)||0),L(((j=t.getBoundingClientRect())==null?void 0:j.left)||0),B((t==null?void 0:t.offsetWidth)||0),H((t==null?void 0:t.offsetHeight)||0))};return t&&(l(),window.addEventListener("resize",l)),()=>{t&&window.removeEventListener("resize",l)}},[r]),s.useEffect(()=>()=>{document.body.removeAttribute("style"),c.current&&clearTimeout(c.current),n.current&&clearTimeout(n.current)},[]),z?null:q?f.jsx(_,{ref:y,open:g,transitionDuration:i,onClick:d,hasContainer:$,containerTop:w,containerLeft:x,containerWidth:b,containerHeight:C,...p,css:m,children:f.jsx(k,{fullScreen:a,centered:h,children:o})}):M.createPortal(f.jsx(_,{ref:y,open:g,transitionDuration:i,onClick:d,hasContainer:$,containerTop:w,containerLeft:x,containerWidth:b,containerHeight:C,...p,css:m,children:f.jsx(k,{fullScreen:a,centered:h,children:o})}),document.body)});exports.default=A;
|
package/Backdrop/Backdrop.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface BackdropProps extends GeneralComponentProps<HTMLAttributes<HTML
|
|
|
8
8
|
fullScreen?: boolean;
|
|
9
9
|
centered?: boolean;
|
|
10
10
|
containerRef?: RefObject<HTMLElement>;
|
|
11
|
+
disablePortal?: boolean;
|
|
11
12
|
}
|
|
12
13
|
declare const Backdrop: import('react').ForwardRefExoticComponent<BackdropProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
13
14
|
export default Backdrop;
|
package/Backdrop/Backdrop.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { jsx as f } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef as F, useState as n, useRef as I, useEffect as l } from "react";
|
|
3
|
+
import { createPortal as G } from "react-dom";
|
|
4
|
+
import H from "@emotion/styled";
|
|
5
|
+
const L = H.div`
|
|
6
6
|
position: fixed;
|
|
7
7
|
|
|
8
|
-
${({ hasContainer: t, containerTop:
|
|
9
|
-
top:
|
|
10
|
-
left:
|
|
11
|
-
width:
|
|
12
|
-
height:
|
|
8
|
+
${({ hasContainer: t, containerTop: o, containerLeft: i, containerWidth: d, containerHeight: s }) => t ? {
|
|
9
|
+
top: o,
|
|
10
|
+
left: i,
|
|
11
|
+
width: d,
|
|
12
|
+
height: s
|
|
13
13
|
} : {
|
|
14
14
|
top: 0,
|
|
15
15
|
left: 0,
|
|
@@ -26,10 +26,10 @@ const S = T.div`
|
|
|
26
26
|
}) => t.dimmed01};
|
|
27
27
|
transition: opacity ${({ transitionDuration: t }) => t}ms;
|
|
28
28
|
opacity: ${({ open: t }) => t ? 1 : 0};
|
|
29
|
-
`,
|
|
29
|
+
`, B = H.div`
|
|
30
30
|
position: relative;
|
|
31
31
|
|
|
32
|
-
${({ theme: { spacing: t }, fullScreen:
|
|
32
|
+
${({ theme: { spacing: t }, fullScreen: o }) => o ? {
|
|
33
33
|
width: "100%",
|
|
34
34
|
height: "100%"
|
|
35
35
|
} : {
|
|
@@ -43,57 +43,74 @@ const S = T.div`
|
|
|
43
43
|
alignItems: "center",
|
|
44
44
|
justifyContent: "center"
|
|
45
45
|
} : null}}
|
|
46
|
-
`,
|
|
47
|
-
children:
|
|
48
|
-
open:
|
|
49
|
-
onClose:
|
|
50
|
-
transitionDuration:
|
|
51
|
-
fullScreen:
|
|
52
|
-
centered:
|
|
46
|
+
`, Q = F(function({
|
|
47
|
+
children: o,
|
|
48
|
+
open: i,
|
|
49
|
+
onClose: d,
|
|
50
|
+
transitionDuration: s = 200,
|
|
51
|
+
fullScreen: h,
|
|
52
|
+
centered: p,
|
|
53
53
|
containerRef: r,
|
|
54
|
-
inlineCSS:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
inlineCSS: a,
|
|
55
|
+
disablePortal: W = !1,
|
|
56
|
+
...y
|
|
57
|
+
}, T) {
|
|
58
|
+
const [g, w] = n(!1), [j, v] = n(!0), [C, A] = n(0), [$, O] = n(0), [b, P] = n(0), [x, q] = n(0), c = I(), u = I(), k = !!(r != null && r.current);
|
|
59
|
+
return l(() => {
|
|
60
|
+
i && (u.current && clearTimeout(u.current), document.body.style.overflow = "hidden", v(!1), c.current = setTimeout(() => {
|
|
61
|
+
w(!0);
|
|
61
62
|
}, 100));
|
|
62
|
-
}, [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
}, [
|
|
67
|
-
const e = r == null ? void 0 : r.current,
|
|
68
|
-
var
|
|
69
|
-
e && (
|
|
63
|
+
}, [i]), l(() => {
|
|
64
|
+
i || (c.current && clearTimeout(c.current), document.body.removeAttribute("style"), w(!1), u.current = setTimeout(() => {
|
|
65
|
+
v(!0);
|
|
66
|
+
}, s));
|
|
67
|
+
}, [i, s]), l(() => {
|
|
68
|
+
const e = r == null ? void 0 : r.current, m = () => {
|
|
69
|
+
var z;
|
|
70
|
+
e && (A((e == null ? void 0 : e.offsetTop) || 0), O(((z = e.getBoundingClientRect()) == null ? void 0 : z.left) || 0), P((e == null ? void 0 : e.offsetWidth) || 0), q((e == null ? void 0 : e.offsetHeight) || 0));
|
|
70
71
|
};
|
|
71
|
-
return e && (
|
|
72
|
-
e && window.removeEventListener("resize",
|
|
72
|
+
return e && (m(), window.addEventListener("resize", m)), () => {
|
|
73
|
+
e && window.removeEventListener("resize", m);
|
|
73
74
|
};
|
|
74
|
-
}, [r]),
|
|
75
|
+
}, [r]), l(() => () => {
|
|
75
76
|
document.body.removeAttribute("style"), c.current && clearTimeout(c.current), u.current && clearTimeout(u.current);
|
|
76
|
-
}, []),
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
}, []), j ? null : W ? /* @__PURE__ */ f(
|
|
78
|
+
L,
|
|
79
|
+
{
|
|
80
|
+
ref: T,
|
|
81
|
+
open: g,
|
|
82
|
+
transitionDuration: s,
|
|
83
|
+
onClick: d,
|
|
84
|
+
hasContainer: k,
|
|
85
|
+
containerTop: C,
|
|
86
|
+
containerLeft: $,
|
|
87
|
+
containerWidth: b,
|
|
88
|
+
containerHeight: x,
|
|
89
|
+
...y,
|
|
90
|
+
css: a,
|
|
91
|
+
children: /* @__PURE__ */ f(B, { fullScreen: h, centered: p, children: o })
|
|
92
|
+
}
|
|
93
|
+
) : G(
|
|
94
|
+
/* @__PURE__ */ f(
|
|
95
|
+
L,
|
|
79
96
|
{
|
|
80
|
-
ref:
|
|
81
|
-
open:
|
|
82
|
-
transitionDuration:
|
|
83
|
-
onClick:
|
|
84
|
-
hasContainer:
|
|
85
|
-
containerTop:
|
|
86
|
-
containerLeft:
|
|
87
|
-
containerWidth:
|
|
88
|
-
containerHeight:
|
|
89
|
-
...
|
|
90
|
-
css:
|
|
91
|
-
children: /* @__PURE__ */
|
|
97
|
+
ref: T,
|
|
98
|
+
open: g,
|
|
99
|
+
transitionDuration: s,
|
|
100
|
+
onClick: d,
|
|
101
|
+
hasContainer: k,
|
|
102
|
+
containerTop: C,
|
|
103
|
+
containerLeft: $,
|
|
104
|
+
containerWidth: b,
|
|
105
|
+
containerHeight: x,
|
|
106
|
+
...y,
|
|
107
|
+
css: a,
|
|
108
|
+
children: /* @__PURE__ */ f(B, { fullScreen: h, centered: p, children: o })
|
|
92
109
|
}
|
|
93
110
|
),
|
|
94
111
|
document.body
|
|
95
112
|
);
|
|
96
113
|
});
|
|
97
114
|
export {
|
|
98
|
-
|
|
115
|
+
Q as default
|
|
99
116
|
};
|