@dotss/ui 1.0.8 → 1.0.10
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
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
|
};
|
|
@@ -1 +1 @@
|
|
|
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 a=require("react"),i=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"," ","Home","End","PageUp","PageDown"];function c(){const[u,t]=a.useState(!1);return a.useEffect(()=>{const o=r=>{var s;if(i.includes(r.key)){const e=r.target,d=(s=e==null?void 0:e.tagName)==null?void 0:s.toLowerCase();if(d==="input"||d==="textarea"||e.isContentEditable||(e==null?void 0:e.getAttribute("role"))==="textbox"){t(!1);return}t(!0)}},n=()=>{t(!1)};return document.addEventListener("keydown",o),document.addEventListener("mousedown",n),()=>{document.removeEventListener("keydown",o),document.removeEventListener("mousedown",n)}},[]),{isKeyboardMode:u}}exports.default=c;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
const
|
|
1
|
+
import { useState as i, useEffect as u } from "react";
|
|
2
|
+
const c = [
|
|
3
3
|
"Tab",
|
|
4
4
|
"ArrowUp",
|
|
5
5
|
"ArrowDown",
|
|
@@ -12,19 +12,27 @@ const u = [
|
|
|
12
12
|
"PageUp",
|
|
13
13
|
"PageDown"
|
|
14
14
|
];
|
|
15
|
-
function
|
|
16
|
-
const [
|
|
17
|
-
return
|
|
15
|
+
function E() {
|
|
16
|
+
const [a, t] = i(!1);
|
|
17
|
+
return u(() => {
|
|
18
18
|
const o = (r) => {
|
|
19
|
-
|
|
19
|
+
var s;
|
|
20
|
+
if (c.includes(r.key)) {
|
|
21
|
+
const e = r.target, d = (s = e == null ? void 0 : e.tagName) == null ? void 0 : s.toLowerCase();
|
|
22
|
+
if (d === "input" || d === "textarea" || e.isContentEditable || (e == null ? void 0 : e.getAttribute("role")) === "textbox") {
|
|
23
|
+
t(!1);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
t(!0);
|
|
27
|
+
}
|
|
20
28
|
}, n = () => {
|
|
21
|
-
|
|
29
|
+
t(!1);
|
|
22
30
|
};
|
|
23
31
|
return document.addEventListener("keydown", o), document.addEventListener("mousedown", n), () => {
|
|
24
32
|
document.removeEventListener("keydown", o), document.removeEventListener("mousedown", n);
|
|
25
33
|
};
|
|
26
|
-
}, []), { isKeyboardMode:
|
|
34
|
+
}, []), { isKeyboardMode: a };
|
|
27
35
|
}
|
|
28
36
|
export {
|
|
29
|
-
|
|
37
|
+
E as default
|
|
30
38
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotss/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "React UI components for Dotss",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.cjs",
|
|
@@ -60,22 +60,15 @@
|
|
|
60
60
|
"ui"
|
|
61
61
|
],
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@chromatic-com/storybook": "^1",
|
|
63
|
+
"@chromatic-com/storybook": "^4.1.1",
|
|
64
64
|
"@emotion/react": "^11.11.4",
|
|
65
65
|
"@emotion/serialize": "^1.1.4",
|
|
66
66
|
"@emotion/styled": "^11.11.5",
|
|
67
|
-
"@storybook/addon-a11y": "^
|
|
68
|
-
"@storybook/addon-
|
|
69
|
-
"@storybook/
|
|
70
|
-
"@storybook/
|
|
71
|
-
"@storybook/addon-
|
|
72
|
-
"@storybook/addon-viewport": "^8.6.14",
|
|
73
|
-
"@storybook/blocks": "^8.6.14",
|
|
74
|
-
"@storybook/manager-api": "^8.6.14",
|
|
75
|
-
"@storybook/react": "^8.6.14",
|
|
76
|
-
"@storybook/react-vite": "^8.6.14",
|
|
77
|
-
"@storybook/test": "^8.6.14",
|
|
78
|
-
"@storybook/theming": "^8.6.14",
|
|
67
|
+
"@storybook/addon-a11y": "^9.1.15",
|
|
68
|
+
"@storybook/addon-links": "^9.1.15",
|
|
69
|
+
"@storybook/react": "^9.1.15",
|
|
70
|
+
"@storybook/react-vite": "^9.1.15",
|
|
71
|
+
"@storybook/addon-docs": "^9.1.15",
|
|
79
72
|
"@testing-library/jest-dom": "^6.4.2",
|
|
80
73
|
"@testing-library/react": "^15.0.0",
|
|
81
74
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -91,7 +84,7 @@
|
|
|
91
84
|
"react": "^18.3.1",
|
|
92
85
|
"react-dom": "^18.3.1",
|
|
93
86
|
"rollup-plugin-visualizer": "^5.12.0",
|
|
94
|
-
"storybook": "^
|
|
87
|
+
"storybook": "^9.1.15",
|
|
95
88
|
"vite": "^6.3.3",
|
|
96
89
|
"vite-plugin-dts": "^3.9.1",
|
|
97
90
|
"vite-plugin-svgr": "^4.2.0",
|