@x-plat/design-system 0.8.0 → 0.8.1
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/dist/components/DatePicker/index.cjs +388 -400
- package/dist/components/DatePicker/index.css +3 -0
- package/dist/components/DatePicker/index.js +375 -387
- package/dist/components/Dropdown/index.cjs +21 -26
- package/dist/components/Dropdown/index.js +20 -25
- package/dist/components/Modal/index.cjs +18 -28
- package/dist/components/Modal/index.css +3 -0
- package/dist/components/Modal/index.js +17 -27
- package/dist/components/PopOver/index.cjs +18 -23
- package/dist/components/PopOver/index.js +17 -22
- package/dist/components/Select/index.cjs +337 -342
- package/dist/components/Select/index.js +336 -341
- package/dist/components/Tooltip/index.cjs +27 -32
- package/dist/components/Tooltip/index.js +26 -31
- package/dist/components/index.cjs +467 -471
- package/dist/components/index.css +3 -0
- package/dist/components/index.js +418 -422
- package/dist/index.cjs +491 -495
- package/dist/index.css +3 -0
- package/dist/index.js +440 -444
- package/package.json +1 -1
|
@@ -35,30 +35,25 @@ __export(Dropdown_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(Dropdown_exports);
|
|
36
36
|
|
|
37
37
|
// src/components/Dropdown/Dropdown.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
39
39
|
|
|
40
40
|
// src/tokens/hooks/Portal.tsx
|
|
41
|
-
var import_react = __toESM(require("react"), 1);
|
|
42
41
|
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
43
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
-
var PortalContainerContext = import_react.default.createContext(null);
|
|
45
42
|
var Portal = ({ children }) => {
|
|
46
|
-
const contextContainer = import_react.default.useContext(PortalContainerContext);
|
|
47
43
|
if (typeof document === "undefined") return null;
|
|
48
|
-
|
|
49
|
-
return import_react_dom.default.createPortal(children, container);
|
|
44
|
+
return import_react_dom.default.createPortal(children, document.body);
|
|
50
45
|
};
|
|
51
46
|
Portal.displayName = "Portal";
|
|
52
47
|
var Portal_default = Portal;
|
|
53
48
|
|
|
54
49
|
// src/tokens/hooks/useAutoPosition.ts
|
|
55
|
-
var
|
|
50
|
+
var import_react = __toESM(require("react"), 1);
|
|
56
51
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
57
|
-
const [position, setPosition] =
|
|
52
|
+
const [position, setPosition] = import_react.default.useState({
|
|
58
53
|
position: {},
|
|
59
54
|
direction: "bottom"
|
|
60
55
|
});
|
|
61
|
-
const calculatePosition =
|
|
56
|
+
const calculatePosition = import_react.default.useCallback(() => {
|
|
62
57
|
if (!triggerRef.current || !popRef.current) return;
|
|
63
58
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
64
59
|
const popW = popRef.current.offsetWidth;
|
|
@@ -85,13 +80,13 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
85
80
|
direction
|
|
86
81
|
});
|
|
87
82
|
}, [triggerRef, popRef]);
|
|
88
|
-
|
|
83
|
+
import_react.default.useLayoutEffect(() => {
|
|
89
84
|
if (!enabled) return;
|
|
90
85
|
calculatePosition();
|
|
91
86
|
const raf = requestAnimationFrame(calculatePosition);
|
|
92
87
|
return () => cancelAnimationFrame(raf);
|
|
93
88
|
}, [calculatePosition, enabled]);
|
|
94
|
-
|
|
89
|
+
import_react.default.useEffect(() => {
|
|
95
90
|
if (!enabled || !popRef.current) return;
|
|
96
91
|
const observer = new ResizeObserver(() => {
|
|
97
92
|
calculatePosition();
|
|
@@ -99,7 +94,7 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
99
94
|
observer.observe(popRef.current);
|
|
100
95
|
return () => observer.disconnect();
|
|
101
96
|
}, [calculatePosition, enabled, popRef]);
|
|
102
|
-
|
|
97
|
+
import_react.default.useEffect(() => {
|
|
103
98
|
if (!enabled) return;
|
|
104
99
|
window.addEventListener("resize", calculatePosition);
|
|
105
100
|
window.addEventListener("scroll", calculatePosition, true);
|
|
@@ -113,9 +108,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
113
108
|
var useAutoPosition_default = useAutoPosition;
|
|
114
109
|
|
|
115
110
|
// src/tokens/hooks/useClickOutside.ts
|
|
116
|
-
var
|
|
111
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
117
112
|
var useClickOutside = (refs, handler, enabled = true) => {
|
|
118
|
-
|
|
113
|
+
import_react2.default.useEffect(() => {
|
|
119
114
|
if (!enabled) return;
|
|
120
115
|
const refArray = Array.isArray(refs) ? refs : [refs];
|
|
121
116
|
const listener = (event) => {
|
|
@@ -154,17 +149,17 @@ function clsx() {
|
|
|
154
149
|
var clsx_default = clsx;
|
|
155
150
|
|
|
156
151
|
// src/components/Dropdown/Dropdown.tsx
|
|
157
|
-
var
|
|
152
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
158
153
|
var Dropdown = (props) => {
|
|
159
154
|
const { items, children } = props;
|
|
160
|
-
const [isOpen, setIsOpen] =
|
|
161
|
-
const [mounted, setMounted] =
|
|
162
|
-
const [visible, setVisible] =
|
|
163
|
-
const triggerRef =
|
|
164
|
-
const menuRef =
|
|
155
|
+
const [isOpen, setIsOpen] = import_react3.default.useState(false);
|
|
156
|
+
const [mounted, setMounted] = import_react3.default.useState(false);
|
|
157
|
+
const [visible, setVisible] = import_react3.default.useState(false);
|
|
158
|
+
const triggerRef = import_react3.default.useRef(null);
|
|
159
|
+
const menuRef = import_react3.default.useRef(null);
|
|
165
160
|
const { position, direction } = useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
166
161
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
167
|
-
|
|
162
|
+
import_react3.default.useEffect(() => {
|
|
168
163
|
if (isOpen) {
|
|
169
164
|
setMounted(true);
|
|
170
165
|
const t2 = setTimeout(() => setVisible(true), 1);
|
|
@@ -179,8 +174,8 @@ var Dropdown = (props) => {
|
|
|
179
174
|
item.onClick?.();
|
|
180
175
|
setIsOpen(false);
|
|
181
176
|
};
|
|
182
|
-
return /* @__PURE__ */ (0,
|
|
183
|
-
/* @__PURE__ */ (0,
|
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "lib-xplat-dropdown", children: [
|
|
178
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
184
179
|
"div",
|
|
185
180
|
{
|
|
186
181
|
ref: triggerRef,
|
|
@@ -189,14 +184,14 @@ var Dropdown = (props) => {
|
|
|
189
184
|
children
|
|
190
185
|
}
|
|
191
186
|
),
|
|
192
|
-
mounted && /* @__PURE__ */ (0,
|
|
187
|
+
mounted && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
193
188
|
"div",
|
|
194
189
|
{
|
|
195
190
|
ref: menuRef,
|
|
196
191
|
className: clsx_default("lib-xplat-dropdown-menu", direction, { visible }),
|
|
197
192
|
style: { top: position.top, left: position.left },
|
|
198
193
|
role: "menu",
|
|
199
|
-
children: items.map((item) => /* @__PURE__ */ (0,
|
|
194
|
+
children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
200
195
|
"button",
|
|
201
196
|
{
|
|
202
197
|
className: clsx_default("dropdown-item", {
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
// src/components/Dropdown/Dropdown.tsx
|
|
2
|
-
import
|
|
2
|
+
import React3 from "react";
|
|
3
3
|
|
|
4
4
|
// src/tokens/hooks/Portal.tsx
|
|
5
|
-
import React from "react";
|
|
6
5
|
import ReactDOM from "react-dom";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
var PortalContainerContext = React.createContext(null);
|
|
9
6
|
var Portal = ({ children }) => {
|
|
10
|
-
const contextContainer = React.useContext(PortalContainerContext);
|
|
11
7
|
if (typeof document === "undefined") return null;
|
|
12
|
-
|
|
13
|
-
return ReactDOM.createPortal(children, container);
|
|
8
|
+
return ReactDOM.createPortal(children, document.body);
|
|
14
9
|
};
|
|
15
10
|
Portal.displayName = "Portal";
|
|
16
11
|
var Portal_default = Portal;
|
|
17
12
|
|
|
18
13
|
// src/tokens/hooks/useAutoPosition.ts
|
|
19
|
-
import
|
|
14
|
+
import React from "react";
|
|
20
15
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
21
|
-
const [position, setPosition] =
|
|
16
|
+
const [position, setPosition] = React.useState({
|
|
22
17
|
position: {},
|
|
23
18
|
direction: "bottom"
|
|
24
19
|
});
|
|
25
|
-
const calculatePosition =
|
|
20
|
+
const calculatePosition = React.useCallback(() => {
|
|
26
21
|
if (!triggerRef.current || !popRef.current) return;
|
|
27
22
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
28
23
|
const popW = popRef.current.offsetWidth;
|
|
@@ -49,13 +44,13 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
49
44
|
direction
|
|
50
45
|
});
|
|
51
46
|
}, [triggerRef, popRef]);
|
|
52
|
-
|
|
47
|
+
React.useLayoutEffect(() => {
|
|
53
48
|
if (!enabled) return;
|
|
54
49
|
calculatePosition();
|
|
55
50
|
const raf = requestAnimationFrame(calculatePosition);
|
|
56
51
|
return () => cancelAnimationFrame(raf);
|
|
57
52
|
}, [calculatePosition, enabled]);
|
|
58
|
-
|
|
53
|
+
React.useEffect(() => {
|
|
59
54
|
if (!enabled || !popRef.current) return;
|
|
60
55
|
const observer = new ResizeObserver(() => {
|
|
61
56
|
calculatePosition();
|
|
@@ -63,7 +58,7 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
63
58
|
observer.observe(popRef.current);
|
|
64
59
|
return () => observer.disconnect();
|
|
65
60
|
}, [calculatePosition, enabled, popRef]);
|
|
66
|
-
|
|
61
|
+
React.useEffect(() => {
|
|
67
62
|
if (!enabled) return;
|
|
68
63
|
window.addEventListener("resize", calculatePosition);
|
|
69
64
|
window.addEventListener("scroll", calculatePosition, true);
|
|
@@ -77,9 +72,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
77
72
|
var useAutoPosition_default = useAutoPosition;
|
|
78
73
|
|
|
79
74
|
// src/tokens/hooks/useClickOutside.ts
|
|
80
|
-
import
|
|
75
|
+
import React2 from "react";
|
|
81
76
|
var useClickOutside = (refs, handler, enabled = true) => {
|
|
82
|
-
|
|
77
|
+
React2.useEffect(() => {
|
|
83
78
|
if (!enabled) return;
|
|
84
79
|
const refArray = Array.isArray(refs) ? refs : [refs];
|
|
85
80
|
const listener = (event) => {
|
|
@@ -118,17 +113,17 @@ function clsx() {
|
|
|
118
113
|
var clsx_default = clsx;
|
|
119
114
|
|
|
120
115
|
// src/components/Dropdown/Dropdown.tsx
|
|
121
|
-
import { jsx
|
|
116
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
122
117
|
var Dropdown = (props) => {
|
|
123
118
|
const { items, children } = props;
|
|
124
|
-
const [isOpen, setIsOpen] =
|
|
125
|
-
const [mounted, setMounted] =
|
|
126
|
-
const [visible, setVisible] =
|
|
127
|
-
const triggerRef =
|
|
128
|
-
const menuRef =
|
|
119
|
+
const [isOpen, setIsOpen] = React3.useState(false);
|
|
120
|
+
const [mounted, setMounted] = React3.useState(false);
|
|
121
|
+
const [visible, setVisible] = React3.useState(false);
|
|
122
|
+
const triggerRef = React3.useRef(null);
|
|
123
|
+
const menuRef = React3.useRef(null);
|
|
129
124
|
const { position, direction } = useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
130
125
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
131
|
-
|
|
126
|
+
React3.useEffect(() => {
|
|
132
127
|
if (isOpen) {
|
|
133
128
|
setMounted(true);
|
|
134
129
|
const t2 = setTimeout(() => setVisible(true), 1);
|
|
@@ -144,7 +139,7 @@ var Dropdown = (props) => {
|
|
|
144
139
|
setIsOpen(false);
|
|
145
140
|
};
|
|
146
141
|
return /* @__PURE__ */ jsxs("div", { className: "lib-xplat-dropdown", children: [
|
|
147
|
-
/* @__PURE__ */
|
|
142
|
+
/* @__PURE__ */ jsx(
|
|
148
143
|
"div",
|
|
149
144
|
{
|
|
150
145
|
ref: triggerRef,
|
|
@@ -153,14 +148,14 @@ var Dropdown = (props) => {
|
|
|
153
148
|
children
|
|
154
149
|
}
|
|
155
150
|
),
|
|
156
|
-
mounted && /* @__PURE__ */
|
|
151
|
+
mounted && /* @__PURE__ */ jsx(Portal_default, { children: /* @__PURE__ */ jsx(
|
|
157
152
|
"div",
|
|
158
153
|
{
|
|
159
154
|
ref: menuRef,
|
|
160
155
|
className: clsx_default("lib-xplat-dropdown-menu", direction, { visible }),
|
|
161
156
|
style: { top: position.top, left: position.left },
|
|
162
157
|
role: "menu",
|
|
163
|
-
children: items.map((item) => /* @__PURE__ */
|
|
158
|
+
children: items.map((item) => /* @__PURE__ */ jsx(
|
|
164
159
|
"button",
|
|
165
160
|
{
|
|
166
161
|
className: clsx_default("dropdown-item", {
|
|
@@ -35,22 +35,8 @@ __export(Modal_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(Modal_exports);
|
|
36
36
|
|
|
37
37
|
// src/components/Modal/Modal.tsx
|
|
38
|
-
var import_react2 = __toESM(require("react"), 1);
|
|
39
|
-
var import_react_dom2 = require("react-dom");
|
|
40
|
-
|
|
41
|
-
// src/tokens/hooks/Portal.tsx
|
|
42
38
|
var import_react = __toESM(require("react"), 1);
|
|
43
|
-
var import_react_dom =
|
|
44
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
-
var PortalContainerContext = import_react.default.createContext(null);
|
|
46
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalContainerContext.Provider, { value: container, children });
|
|
47
|
-
var Portal = ({ children }) => {
|
|
48
|
-
const contextContainer = import_react.default.useContext(PortalContainerContext);
|
|
49
|
-
if (typeof document === "undefined") return null;
|
|
50
|
-
const container = contextContainer ?? document.body;
|
|
51
|
-
return import_react_dom.default.createPortal(children, container);
|
|
52
|
-
};
|
|
53
|
-
Portal.displayName = "Portal";
|
|
39
|
+
var import_react_dom = require("react-dom");
|
|
54
40
|
|
|
55
41
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
56
42
|
function r(e) {
|
|
@@ -69,19 +55,24 @@ function clsx() {
|
|
|
69
55
|
var clsx_default = clsx;
|
|
70
56
|
|
|
71
57
|
// src/components/Modal/Modal.tsx
|
|
72
|
-
var
|
|
58
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
73
59
|
var ANIMATION_DURATION_MS = 200;
|
|
74
60
|
var Modal = (props) => {
|
|
75
61
|
const { isOpen, onClose, children } = props;
|
|
76
|
-
const [mounted, setMounted] =
|
|
77
|
-
const [visible, setVisible] =
|
|
78
|
-
const
|
|
79
|
-
|
|
62
|
+
const [mounted, setMounted] = import_react.default.useState(false);
|
|
63
|
+
const [visible, setVisible] = import_react.default.useState(false);
|
|
64
|
+
const [settled, setSettled] = import_react.default.useState(false);
|
|
65
|
+
import_react.default.useEffect(() => {
|
|
80
66
|
if (isOpen) {
|
|
81
67
|
setMounted(true);
|
|
82
|
-
const
|
|
83
|
-
|
|
68
|
+
const show = setTimeout(() => setVisible(true), 1);
|
|
69
|
+
const settle = setTimeout(() => setSettled(true), ANIMATION_DURATION_MS + 50);
|
|
70
|
+
return () => {
|
|
71
|
+
clearTimeout(show);
|
|
72
|
+
clearTimeout(settle);
|
|
73
|
+
};
|
|
84
74
|
}
|
|
75
|
+
setSettled(false);
|
|
85
76
|
setVisible(false);
|
|
86
77
|
const t = setTimeout(() => setMounted(false), ANIMATION_DURATION_MS);
|
|
87
78
|
return () => clearTimeout(t);
|
|
@@ -89,21 +80,20 @@ var Modal = (props) => {
|
|
|
89
80
|
if (typeof document === "undefined") return null;
|
|
90
81
|
if (!mounted) return null;
|
|
91
82
|
const stateClass = visible ? "enter" : "exit";
|
|
92
|
-
return (0,
|
|
93
|
-
/* @__PURE__ */ (0,
|
|
83
|
+
return (0, import_react_dom.createPortal)(
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
85
|
"div",
|
|
95
86
|
{
|
|
96
87
|
className: clsx_default("lib-xplat-modal", "dim", stateClass),
|
|
97
88
|
onClick: onClose,
|
|
98
|
-
children: /* @__PURE__ */ (0,
|
|
89
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
90
|
"div",
|
|
100
91
|
{
|
|
101
|
-
|
|
102
|
-
className: clsx_default("lib-xplat-modal", "modal-box", stateClass),
|
|
92
|
+
className: clsx_default("lib-xplat-modal", "modal-box", stateClass, settled && "settled"),
|
|
103
93
|
role: "dialog",
|
|
104
94
|
"aria-modal": "true",
|
|
105
95
|
onClick: (e) => e.stopPropagation(),
|
|
106
|
-
children
|
|
96
|
+
children
|
|
107
97
|
}
|
|
108
98
|
)
|
|
109
99
|
}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
// src/components/Modal/Modal.tsx
|
|
2
|
-
import React2 from "react";
|
|
3
|
-
import { createPortal } from "react-dom";
|
|
4
|
-
|
|
5
|
-
// src/tokens/hooks/Portal.tsx
|
|
6
2
|
import React from "react";
|
|
7
|
-
import
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
var PortalContainerContext = React.createContext(null);
|
|
10
|
-
var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx(PortalContainerContext.Provider, { value: container, children });
|
|
11
|
-
var Portal = ({ children }) => {
|
|
12
|
-
const contextContainer = React.useContext(PortalContainerContext);
|
|
13
|
-
if (typeof document === "undefined") return null;
|
|
14
|
-
const container = contextContainer ?? document.body;
|
|
15
|
-
return ReactDOM.createPortal(children, container);
|
|
16
|
-
};
|
|
17
|
-
Portal.displayName = "Portal";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
18
4
|
|
|
19
5
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
20
6
|
function r(e) {
|
|
@@ -33,19 +19,24 @@ function clsx() {
|
|
|
33
19
|
var clsx_default = clsx;
|
|
34
20
|
|
|
35
21
|
// src/components/Modal/Modal.tsx
|
|
36
|
-
import { jsx
|
|
22
|
+
import { jsx } from "react/jsx-runtime";
|
|
37
23
|
var ANIMATION_DURATION_MS = 200;
|
|
38
24
|
var Modal = (props) => {
|
|
39
25
|
const { isOpen, onClose, children } = props;
|
|
40
|
-
const [mounted, setMounted] =
|
|
41
|
-
const [visible, setVisible] =
|
|
42
|
-
const
|
|
43
|
-
|
|
26
|
+
const [mounted, setMounted] = React.useState(false);
|
|
27
|
+
const [visible, setVisible] = React.useState(false);
|
|
28
|
+
const [settled, setSettled] = React.useState(false);
|
|
29
|
+
React.useEffect(() => {
|
|
44
30
|
if (isOpen) {
|
|
45
31
|
setMounted(true);
|
|
46
|
-
const
|
|
47
|
-
|
|
32
|
+
const show = setTimeout(() => setVisible(true), 1);
|
|
33
|
+
const settle = setTimeout(() => setSettled(true), ANIMATION_DURATION_MS + 50);
|
|
34
|
+
return () => {
|
|
35
|
+
clearTimeout(show);
|
|
36
|
+
clearTimeout(settle);
|
|
37
|
+
};
|
|
48
38
|
}
|
|
39
|
+
setSettled(false);
|
|
49
40
|
setVisible(false);
|
|
50
41
|
const t = setTimeout(() => setMounted(false), ANIMATION_DURATION_MS);
|
|
51
42
|
return () => clearTimeout(t);
|
|
@@ -54,20 +45,19 @@ var Modal = (props) => {
|
|
|
54
45
|
if (!mounted) return null;
|
|
55
46
|
const stateClass = visible ? "enter" : "exit";
|
|
56
47
|
return createPortal(
|
|
57
|
-
/* @__PURE__ */
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
58
49
|
"div",
|
|
59
50
|
{
|
|
60
51
|
className: clsx_default("lib-xplat-modal", "dim", stateClass),
|
|
61
52
|
onClick: onClose,
|
|
62
|
-
children: /* @__PURE__ */
|
|
53
|
+
children: /* @__PURE__ */ jsx(
|
|
63
54
|
"div",
|
|
64
55
|
{
|
|
65
|
-
|
|
66
|
-
className: clsx_default("lib-xplat-modal", "modal-box", stateClass),
|
|
56
|
+
className: clsx_default("lib-xplat-modal", "modal-box", stateClass, settled && "settled"),
|
|
67
57
|
role: "dialog",
|
|
68
58
|
"aria-modal": "true",
|
|
69
59
|
onClick: (e) => e.stopPropagation(),
|
|
70
|
-
children
|
|
60
|
+
children
|
|
71
61
|
}
|
|
72
62
|
)
|
|
73
63
|
}
|
|
@@ -35,30 +35,25 @@ __export(PopOver_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(PopOver_exports);
|
|
36
36
|
|
|
37
37
|
// src/components/PopOver/PopOver.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
39
39
|
|
|
40
40
|
// src/tokens/hooks/Portal.tsx
|
|
41
|
-
var import_react = __toESM(require("react"), 1);
|
|
42
41
|
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
43
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
-
var PortalContainerContext = import_react.default.createContext(null);
|
|
45
42
|
var Portal = ({ children }) => {
|
|
46
|
-
const contextContainer = import_react.default.useContext(PortalContainerContext);
|
|
47
43
|
if (typeof document === "undefined") return null;
|
|
48
|
-
|
|
49
|
-
return import_react_dom.default.createPortal(children, container);
|
|
44
|
+
return import_react_dom.default.createPortal(children, document.body);
|
|
50
45
|
};
|
|
51
46
|
Portal.displayName = "Portal";
|
|
52
47
|
var Portal_default = Portal;
|
|
53
48
|
|
|
54
49
|
// src/tokens/hooks/useAutoPosition.ts
|
|
55
|
-
var
|
|
50
|
+
var import_react = __toESM(require("react"), 1);
|
|
56
51
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
57
|
-
const [position, setPosition] =
|
|
52
|
+
const [position, setPosition] = import_react.default.useState({
|
|
58
53
|
position: {},
|
|
59
54
|
direction: "bottom"
|
|
60
55
|
});
|
|
61
|
-
const calculatePosition =
|
|
56
|
+
const calculatePosition = import_react.default.useCallback(() => {
|
|
62
57
|
if (!triggerRef.current || !popRef.current) return;
|
|
63
58
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
64
59
|
const popW = popRef.current.offsetWidth;
|
|
@@ -85,13 +80,13 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
85
80
|
direction
|
|
86
81
|
});
|
|
87
82
|
}, [triggerRef, popRef]);
|
|
88
|
-
|
|
83
|
+
import_react.default.useLayoutEffect(() => {
|
|
89
84
|
if (!enabled) return;
|
|
90
85
|
calculatePosition();
|
|
91
86
|
const raf = requestAnimationFrame(calculatePosition);
|
|
92
87
|
return () => cancelAnimationFrame(raf);
|
|
93
88
|
}, [calculatePosition, enabled]);
|
|
94
|
-
|
|
89
|
+
import_react.default.useEffect(() => {
|
|
95
90
|
if (!enabled || !popRef.current) return;
|
|
96
91
|
const observer = new ResizeObserver(() => {
|
|
97
92
|
calculatePosition();
|
|
@@ -99,7 +94,7 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
99
94
|
observer.observe(popRef.current);
|
|
100
95
|
return () => observer.disconnect();
|
|
101
96
|
}, [calculatePosition, enabled, popRef]);
|
|
102
|
-
|
|
97
|
+
import_react.default.useEffect(() => {
|
|
103
98
|
if (!enabled) return;
|
|
104
99
|
window.addEventListener("resize", calculatePosition);
|
|
105
100
|
window.addEventListener("scroll", calculatePosition, true);
|
|
@@ -113,9 +108,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
113
108
|
var useAutoPosition_default = useAutoPosition;
|
|
114
109
|
|
|
115
110
|
// src/tokens/hooks/useClickOutside.ts
|
|
116
|
-
var
|
|
111
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
117
112
|
var useClickOutside = (refs, handler, enabled = true) => {
|
|
118
|
-
|
|
113
|
+
import_react2.default.useEffect(() => {
|
|
119
114
|
if (!enabled) return;
|
|
120
115
|
const refArray = Array.isArray(refs) ? refs : [refs];
|
|
121
116
|
const listener = (event) => {
|
|
@@ -154,16 +149,16 @@ function clsx() {
|
|
|
154
149
|
var clsx_default = clsx;
|
|
155
150
|
|
|
156
151
|
// src/components/PopOver/PopOver.tsx
|
|
157
|
-
var
|
|
152
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
158
153
|
var PopOver = (props) => {
|
|
159
154
|
const { children, isOpen, onClose, PopOverEl } = props;
|
|
160
|
-
const popRef =
|
|
161
|
-
const triggerRef =
|
|
162
|
-
const [localOpen, setLocalOpen] =
|
|
163
|
-
const [eventTrigger, setEventTrigger] =
|
|
155
|
+
const popRef = import_react3.default.useRef(null);
|
|
156
|
+
const triggerRef = import_react3.default.useRef(null);
|
|
157
|
+
const [localOpen, setLocalOpen] = import_react3.default.useState(false);
|
|
158
|
+
const [eventTrigger, setEventTrigger] = import_react3.default.useState(false);
|
|
164
159
|
useClickOutside_default([popRef, triggerRef], onClose, isOpen);
|
|
165
160
|
const position = useAutoPosition_default(triggerRef, popRef, localOpen);
|
|
166
|
-
|
|
161
|
+
import_react3.default.useEffect(() => {
|
|
167
162
|
if (isOpen) {
|
|
168
163
|
setLocalOpen(isOpen);
|
|
169
164
|
setTimeout(() => {
|
|
@@ -176,7 +171,7 @@ var PopOver = (props) => {
|
|
|
176
171
|
}, 200);
|
|
177
172
|
}
|
|
178
173
|
}, [isOpen]);
|
|
179
|
-
return /* @__PURE__ */ (0,
|
|
174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
180
175
|
"div",
|
|
181
176
|
{
|
|
182
177
|
className: "lib-xplat-pop-over",
|
|
@@ -186,7 +181,7 @@ var PopOver = (props) => {
|
|
|
186
181
|
},
|
|
187
182
|
children: [
|
|
188
183
|
children,
|
|
189
|
-
localOpen && /* @__PURE__ */ (0,
|
|
184
|
+
localOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
190
185
|
"div",
|
|
191
186
|
{
|
|
192
187
|
className: clsx_default(
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
// src/components/PopOver/PopOver.tsx
|
|
2
|
-
import
|
|
2
|
+
import React3 from "react";
|
|
3
3
|
|
|
4
4
|
// src/tokens/hooks/Portal.tsx
|
|
5
|
-
import React from "react";
|
|
6
5
|
import ReactDOM from "react-dom";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
var PortalContainerContext = React.createContext(null);
|
|
9
6
|
var Portal = ({ children }) => {
|
|
10
|
-
const contextContainer = React.useContext(PortalContainerContext);
|
|
11
7
|
if (typeof document === "undefined") return null;
|
|
12
|
-
|
|
13
|
-
return ReactDOM.createPortal(children, container);
|
|
8
|
+
return ReactDOM.createPortal(children, document.body);
|
|
14
9
|
};
|
|
15
10
|
Portal.displayName = "Portal";
|
|
16
11
|
var Portal_default = Portal;
|
|
17
12
|
|
|
18
13
|
// src/tokens/hooks/useAutoPosition.ts
|
|
19
|
-
import
|
|
14
|
+
import React from "react";
|
|
20
15
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
21
|
-
const [position, setPosition] =
|
|
16
|
+
const [position, setPosition] = React.useState({
|
|
22
17
|
position: {},
|
|
23
18
|
direction: "bottom"
|
|
24
19
|
});
|
|
25
|
-
const calculatePosition =
|
|
20
|
+
const calculatePosition = React.useCallback(() => {
|
|
26
21
|
if (!triggerRef.current || !popRef.current) return;
|
|
27
22
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
28
23
|
const popW = popRef.current.offsetWidth;
|
|
@@ -49,13 +44,13 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
49
44
|
direction
|
|
50
45
|
});
|
|
51
46
|
}, [triggerRef, popRef]);
|
|
52
|
-
|
|
47
|
+
React.useLayoutEffect(() => {
|
|
53
48
|
if (!enabled) return;
|
|
54
49
|
calculatePosition();
|
|
55
50
|
const raf = requestAnimationFrame(calculatePosition);
|
|
56
51
|
return () => cancelAnimationFrame(raf);
|
|
57
52
|
}, [calculatePosition, enabled]);
|
|
58
|
-
|
|
53
|
+
React.useEffect(() => {
|
|
59
54
|
if (!enabled || !popRef.current) return;
|
|
60
55
|
const observer = new ResizeObserver(() => {
|
|
61
56
|
calculatePosition();
|
|
@@ -63,7 +58,7 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
63
58
|
observer.observe(popRef.current);
|
|
64
59
|
return () => observer.disconnect();
|
|
65
60
|
}, [calculatePosition, enabled, popRef]);
|
|
66
|
-
|
|
61
|
+
React.useEffect(() => {
|
|
67
62
|
if (!enabled) return;
|
|
68
63
|
window.addEventListener("resize", calculatePosition);
|
|
69
64
|
window.addEventListener("scroll", calculatePosition, true);
|
|
@@ -77,9 +72,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
77
72
|
var useAutoPosition_default = useAutoPosition;
|
|
78
73
|
|
|
79
74
|
// src/tokens/hooks/useClickOutside.ts
|
|
80
|
-
import
|
|
75
|
+
import React2 from "react";
|
|
81
76
|
var useClickOutside = (refs, handler, enabled = true) => {
|
|
82
|
-
|
|
77
|
+
React2.useEffect(() => {
|
|
83
78
|
if (!enabled) return;
|
|
84
79
|
const refArray = Array.isArray(refs) ? refs : [refs];
|
|
85
80
|
const listener = (event) => {
|
|
@@ -118,16 +113,16 @@ function clsx() {
|
|
|
118
113
|
var clsx_default = clsx;
|
|
119
114
|
|
|
120
115
|
// src/components/PopOver/PopOver.tsx
|
|
121
|
-
import { jsx
|
|
116
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
122
117
|
var PopOver = (props) => {
|
|
123
118
|
const { children, isOpen, onClose, PopOverEl } = props;
|
|
124
|
-
const popRef =
|
|
125
|
-
const triggerRef =
|
|
126
|
-
const [localOpen, setLocalOpen] =
|
|
127
|
-
const [eventTrigger, setEventTrigger] =
|
|
119
|
+
const popRef = React3.useRef(null);
|
|
120
|
+
const triggerRef = React3.useRef(null);
|
|
121
|
+
const [localOpen, setLocalOpen] = React3.useState(false);
|
|
122
|
+
const [eventTrigger, setEventTrigger] = React3.useState(false);
|
|
128
123
|
useClickOutside_default([popRef, triggerRef], onClose, isOpen);
|
|
129
124
|
const position = useAutoPosition_default(triggerRef, popRef, localOpen);
|
|
130
|
-
|
|
125
|
+
React3.useEffect(() => {
|
|
131
126
|
if (isOpen) {
|
|
132
127
|
setLocalOpen(isOpen);
|
|
133
128
|
setTimeout(() => {
|
|
@@ -150,7 +145,7 @@ var PopOver = (props) => {
|
|
|
150
145
|
},
|
|
151
146
|
children: [
|
|
152
147
|
children,
|
|
153
|
-
localOpen && /* @__PURE__ */
|
|
148
|
+
localOpen && /* @__PURE__ */ jsx(Portal_default, { children: /* @__PURE__ */ jsx(
|
|
154
149
|
"div",
|
|
155
150
|
{
|
|
156
151
|
className: clsx_default(
|