@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.
@@ -1,17 +1,17 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@emotion/react/jsx-runtime"),r=require("react"),L=require("react-dom"),B=require("@emotion/styled"),H=e=>e&&e.__esModule?e:{default:e},p=H(B),M=p.default.div`
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:u,containerLeft:o,containerWidth:d,containerHeight:i})=>e?{top:u,left:o,width:d,height:i}:{top:0,left:0,width:"100%",height:"100%"}};
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
- `,O=p.default.div`
11
+ `,k=S.default.div`
12
12
  position: relative;
13
13
 
14
- ${({theme:{spacing:e},fullScreen:u})=>u?{width:"100%",height:"100%"}:{width:`calc(100% - ${e.content(10)}px)`,height:`calc(100% - ${e.content(10)}px)`,margin:e.content(5)}};
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
- `,W=r.forwardRef(function({children:u,open:o,onClose:d,transitionDuration:i=200,fullScreen:y,centered:g,containerRef:s,inlineCSS:T,...v},w){const[C,f]=r.useState(!1),[b,a]=r.useState(!0),[x,S]=r.useState(0),[$,_]=r.useState(0),[j,k]=r.useState(0),[q,z]=r.useState(0),n=r.useRef(),c=r.useRef(),I=!!(s!=null&&s.current);return r.useEffect(()=>{o&&(c.current&&clearTimeout(c.current),document.body.style.overflow="hidden",a(!1),n.current=setTimeout(()=>{f(!0)},100))},[o]),r.useEffect(()=>{o||(n.current&&clearTimeout(n.current),document.body.removeAttribute("style"),f(!1),c.current=setTimeout(()=>{a(!0)},i))},[o,i]),r.useEffect(()=>{const t=s==null?void 0:s.current,l=()=>{var h;t&&(S((t==null?void 0:t.offsetTop)||0),_(((h=t.getBoundingClientRect())==null?void 0:h.left)||0),k((t==null?void 0:t.offsetWidth)||0),z((t==null?void 0:t.offsetHeight)||0))};return t&&(l(),window.addEventListener("resize",l)),()=>{t&&window.removeEventListener("resize",l)}},[s]),r.useEffect(()=>()=>{document.body.removeAttribute("style"),n.current&&clearTimeout(n.current),c.current&&clearTimeout(c.current)},[]),b?null:L.createPortal(m.jsx(M,{ref:w,open:C,transitionDuration:i,onClick:d,hasContainer:I,containerTop:x,containerLeft:$,containerWidth:j,containerHeight:q,...v,css:T,children:m.jsx(O,{fullScreen:y,centered:g,children:u})}),document.body)});exports.default=W;
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;
@@ -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;
@@ -1,15 +1,15 @@
1
- import { jsx as a } from "@emotion/react/jsx-runtime";
2
- import { forwardRef as O, useState as i, useRef as y, useEffect as d } from "react";
3
- import { createPortal as P } from "react-dom";
4
- import T from "@emotion/styled";
5
- const S = T.div`
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: s, containerLeft: o, containerWidth: f, containerHeight: n }) => t ? {
9
- top: s,
10
- left: o,
11
- width: f,
12
- height: n
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
- `, q = T.div`
29
+ `, B = H.div`
30
30
  position: relative;
31
31
 
32
- ${({ theme: { spacing: t }, fullScreen: s }) => s ? {
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
- `, K = O(function({
47
- children: s,
48
- open: o,
49
- onClose: f,
50
- transitionDuration: n = 200,
51
- fullScreen: g,
52
- centered: w,
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: C,
55
- ...v
56
- }, $) {
57
- const [b, m] = i(!1), [x, h] = i(!0), [k, z] = i(0), [I, L] = i(0), [B, H] = i(0), [W, j] = i(0), c = y(), u = y(), A = !!(r != null && r.current);
58
- return d(() => {
59
- o && (u.current && clearTimeout(u.current), document.body.style.overflow = "hidden", h(!1), c.current = setTimeout(() => {
60
- m(!0);
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
- }, [o]), d(() => {
63
- o || (c.current && clearTimeout(c.current), document.body.removeAttribute("style"), m(!1), u.current = setTimeout(() => {
64
- h(!0);
65
- }, n));
66
- }, [o, n]), d(() => {
67
- const e = r == null ? void 0 : r.current, l = () => {
68
- var p;
69
- e && (z((e == null ? void 0 : e.offsetTop) || 0), L(((p = e.getBoundingClientRect()) == null ? void 0 : p.left) || 0), H((e == null ? void 0 : e.offsetWidth) || 0), j((e == null ? void 0 : e.offsetHeight) || 0));
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 && (l(), window.addEventListener("resize", l)), () => {
72
- e && window.removeEventListener("resize", l);
72
+ return e && (m(), window.addEventListener("resize", m)), () => {
73
+ e && window.removeEventListener("resize", m);
73
74
  };
74
- }, [r]), d(() => () => {
75
+ }, [r]), l(() => () => {
75
76
  document.body.removeAttribute("style"), c.current && clearTimeout(c.current), u.current && clearTimeout(u.current);
76
- }, []), x ? null : P(
77
- /* @__PURE__ */ a(
78
- S,
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: b,
82
- transitionDuration: n,
83
- onClick: f,
84
- hasContainer: A,
85
- containerTop: k,
86
- containerLeft: I,
87
- containerWidth: B,
88
- containerHeight: W,
89
- ...v,
90
- css: C,
91
- children: /* @__PURE__ */ a(q, { fullScreen: g, centered: w, children: s })
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
- K as default
115
+ Q as default
99
116
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react"),s=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"," ","Home","End","PageUp","PageDown"];function u(){const[r,e]=n.useState(!1);return n.useEffect(()=>{const o=d=>{s.includes(d.key)&&e(!0)},t=()=>{e(!1)};return document.addEventListener("keydown",o),document.addEventListener("mousedown",t),()=>{document.removeEventListener("keydown",o),document.removeEventListener("mousedown",t)}},[]),{isKeyboardMode:r}}exports.default=u;
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 d, useEffect as s } from "react";
2
- const u = [
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 c() {
16
- const [t, e] = d(!1);
17
- return s(() => {
15
+ function E() {
16
+ const [a, t] = i(!1);
17
+ return u(() => {
18
18
  const o = (r) => {
19
- u.includes(r.key) && e(!0);
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
- e(!1);
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: t };
34
+ }, []), { isKeyboardMode: a };
27
35
  }
28
36
  export {
29
- c as default
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.8",
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": "^8.6.14",
68
- "@storybook/addon-docs": "^8.6.14",
69
- "@storybook/addon-essentials": "^8.6.14",
70
- "@storybook/addon-interactions": "^8.6.14",
71
- "@storybook/addon-links": "^8.6.14",
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": "^8.6.14",
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",