@x-plat/design-system 0.5.11 → 0.5.13
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/Chart/index.cjs +67 -48
- package/dist/components/Chart/index.js +68 -49
- package/dist/components/DatePicker/index.cjs +398 -380
- package/dist/components/DatePicker/index.js +384 -366
- package/dist/components/Dropdown/index.cjs +34 -17
- package/dist/components/Dropdown/index.css +9 -9
- package/dist/components/Dropdown/index.js +33 -16
- package/dist/components/Modal/index.cjs +25 -9
- package/dist/components/Modal/index.d.cts +0 -3
- package/dist/components/Modal/index.d.ts +0 -3
- package/dist/components/Modal/index.js +24 -8
- package/dist/components/PopOver/index.cjs +29 -12
- package/dist/components/PopOver/index.css +6 -9
- package/dist/components/PopOver/index.js +28 -11
- package/dist/components/Select/index.cjs +348 -331
- package/dist/components/Select/index.css +12 -19
- package/dist/components/Select/index.js +346 -329
- package/dist/components/index.cjs +480 -439
- package/dist/components/index.css +27 -37
- package/dist/components/index.js +436 -395
- package/dist/index.cjs +504 -463
- package/dist/index.css +27 -37
- package/dist/index.js +458 -417
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ __export(Dropdown_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(Dropdown_exports);
|
|
36
36
|
|
|
37
37
|
// src/components/Dropdown/Dropdown.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
39
39
|
|
|
40
40
|
// src/tokens/hooks/useAutoPosition.ts
|
|
41
41
|
var import_react = __toESM(require("react"), 1);
|
|
@@ -68,9 +68,12 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
68
68
|
direction
|
|
69
69
|
});
|
|
70
70
|
}, [triggerRef, popRef]);
|
|
71
|
-
import_react.default.
|
|
71
|
+
import_react.default.useLayoutEffect(() => {
|
|
72
72
|
if (!enabled) return;
|
|
73
73
|
calculatePosition();
|
|
74
|
+
}, [calculatePosition, enabled]);
|
|
75
|
+
import_react.default.useEffect(() => {
|
|
76
|
+
if (!enabled) return;
|
|
74
77
|
window.addEventListener("resize", calculatePosition);
|
|
75
78
|
window.addEventListener("scroll", calculatePosition, true);
|
|
76
79
|
return () => {
|
|
@@ -107,6 +110,20 @@ var useClickOutside = (refs, handler, enabled = true) => {
|
|
|
107
110
|
};
|
|
108
111
|
var useClickOutside_default = useClickOutside;
|
|
109
112
|
|
|
113
|
+
// src/tokens/hooks/Portal.tsx
|
|
114
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
115
|
+
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
116
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
117
|
+
var PortalContainerContext = import_react3.default.createContext(null);
|
|
118
|
+
var Portal = ({ children }) => {
|
|
119
|
+
const contextContainer = import_react3.default.useContext(PortalContainerContext);
|
|
120
|
+
if (typeof document === "undefined") return null;
|
|
121
|
+
const container = contextContainer ?? document.body;
|
|
122
|
+
return import_react_dom.default.createPortal(children, container);
|
|
123
|
+
};
|
|
124
|
+
Portal.displayName = "Portal";
|
|
125
|
+
var Portal_default = Portal;
|
|
126
|
+
|
|
110
127
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
111
128
|
function r(e) {
|
|
112
129
|
var t, f, n = "";
|
|
@@ -124,17 +141,17 @@ function clsx() {
|
|
|
124
141
|
var clsx_default = clsx;
|
|
125
142
|
|
|
126
143
|
// src/components/Dropdown/Dropdown.tsx
|
|
127
|
-
var
|
|
144
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
128
145
|
var Dropdown = (props) => {
|
|
129
146
|
const { items, children } = props;
|
|
130
|
-
const [isOpen, setIsOpen] =
|
|
131
|
-
const [mounted, setMounted] =
|
|
132
|
-
const [visible, setVisible] =
|
|
133
|
-
const triggerRef =
|
|
134
|
-
const menuRef =
|
|
135
|
-
const { position, direction } = useAutoPosition_default(triggerRef, menuRef,
|
|
136
|
-
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false));
|
|
137
|
-
|
|
147
|
+
const [isOpen, setIsOpen] = import_react4.default.useState(false);
|
|
148
|
+
const [mounted, setMounted] = import_react4.default.useState(false);
|
|
149
|
+
const [visible, setVisible] = import_react4.default.useState(false);
|
|
150
|
+
const triggerRef = import_react4.default.useRef(null);
|
|
151
|
+
const menuRef = import_react4.default.useRef(null);
|
|
152
|
+
const { position, direction } = useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
153
|
+
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
154
|
+
import_react4.default.useEffect(() => {
|
|
138
155
|
if (isOpen) {
|
|
139
156
|
setMounted(true);
|
|
140
157
|
const t2 = setTimeout(() => setVisible(true), 1);
|
|
@@ -149,8 +166,8 @@ var Dropdown = (props) => {
|
|
|
149
166
|
item.onClick?.();
|
|
150
167
|
setIsOpen(false);
|
|
151
168
|
};
|
|
152
|
-
return /* @__PURE__ */ (0,
|
|
153
|
-
/* @__PURE__ */ (0,
|
|
169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "lib-xplat-dropdown", children: [
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
154
171
|
"div",
|
|
155
172
|
{
|
|
156
173
|
ref: triggerRef,
|
|
@@ -159,14 +176,14 @@ var Dropdown = (props) => {
|
|
|
159
176
|
children
|
|
160
177
|
}
|
|
161
178
|
),
|
|
162
|
-
mounted && /* @__PURE__ */ (0,
|
|
179
|
+
mounted && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
163
180
|
"div",
|
|
164
181
|
{
|
|
165
182
|
ref: menuRef,
|
|
166
|
-
className: clsx_default("dropdown-menu", direction, { visible }),
|
|
183
|
+
className: clsx_default("lib-xplat-dropdown-menu", direction, { visible }),
|
|
167
184
|
style: { top: position.top, left: position.left },
|
|
168
185
|
role: "menu",
|
|
169
|
-
children: items.map((item) => /* @__PURE__ */ (0,
|
|
186
|
+
children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
170
187
|
"button",
|
|
171
188
|
{
|
|
172
189
|
className: clsx_default("dropdown-item", {
|
|
@@ -181,7 +198,7 @@ var Dropdown = (props) => {
|
|
|
181
198
|
item.key
|
|
182
199
|
))
|
|
183
200
|
}
|
|
184
|
-
)
|
|
201
|
+
) })
|
|
185
202
|
] });
|
|
186
203
|
};
|
|
187
204
|
Dropdown.displayName = "Dropdown";
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
.lib-xplat-dropdown .dropdown-trigger {
|
|
8
8
|
cursor: pointer;
|
|
9
9
|
}
|
|
10
|
-
.lib-xplat-dropdown
|
|
10
|
+
.lib-xplat-dropdown-menu {
|
|
11
11
|
position: fixed;
|
|
12
|
-
z-index:
|
|
12
|
+
z-index: 1000;
|
|
13
13
|
min-width: 160px;
|
|
14
14
|
background: var(--semantic-surface-neutral-default);
|
|
15
15
|
border: 1px solid var(--semantic-border-default);
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
transform: translateY(-4px);
|
|
21
21
|
transition: opacity 0.15s ease, transform 0.15s ease;
|
|
22
22
|
}
|
|
23
|
-
.lib-xplat-dropdown
|
|
23
|
+
.lib-xplat-dropdown-menu.bottom {
|
|
24
24
|
transform: translateY(4px);
|
|
25
25
|
}
|
|
26
|
-
.lib-xplat-dropdown
|
|
26
|
+
.lib-xplat-dropdown-menu.visible {
|
|
27
27
|
opacity: 1;
|
|
28
28
|
transform: translateY(0);
|
|
29
29
|
}
|
|
30
|
-
.lib-xplat-dropdown .dropdown-item {
|
|
30
|
+
.lib-xplat-dropdown-menu .dropdown-item {
|
|
31
31
|
display: flex;
|
|
32
32
|
align-items: center;
|
|
33
33
|
width: 100%;
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
text-align: left;
|
|
41
41
|
transition: background-color 0.15s;
|
|
42
42
|
}
|
|
43
|
-
.lib-xplat-dropdown .dropdown-item:hover:not(:disabled) {
|
|
43
|
+
.lib-xplat-dropdown-menu .dropdown-item:hover:not(:disabled) {
|
|
44
44
|
background-color: var(--semantic-surface-neutral-subtle);
|
|
45
45
|
}
|
|
46
|
-
.lib-xplat-dropdown .dropdown-item.danger {
|
|
46
|
+
.lib-xplat-dropdown-menu .dropdown-item.danger {
|
|
47
47
|
color: var(--semantic-text-error);
|
|
48
48
|
}
|
|
49
|
-
.lib-xplat-dropdown .dropdown-item.danger:hover:not(:disabled) {
|
|
49
|
+
.lib-xplat-dropdown-menu .dropdown-item.danger:hover:not(:disabled) {
|
|
50
50
|
background-color: var(--semantic-surface-error-subtle);
|
|
51
51
|
}
|
|
52
|
-
.lib-xplat-dropdown .dropdown-item:disabled {
|
|
52
|
+
.lib-xplat-dropdown-menu .dropdown-item:disabled {
|
|
53
53
|
color: var(--semantic-text-disabled);
|
|
54
54
|
cursor: not-allowed;
|
|
55
55
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/Dropdown/Dropdown.tsx
|
|
2
|
-
import
|
|
2
|
+
import React4 from "react";
|
|
3
3
|
|
|
4
4
|
// src/tokens/hooks/useAutoPosition.ts
|
|
5
5
|
import React from "react";
|
|
@@ -32,9 +32,12 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
32
32
|
direction
|
|
33
33
|
});
|
|
34
34
|
}, [triggerRef, popRef]);
|
|
35
|
-
React.
|
|
35
|
+
React.useLayoutEffect(() => {
|
|
36
36
|
if (!enabled) return;
|
|
37
37
|
calculatePosition();
|
|
38
|
+
}, [calculatePosition, enabled]);
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
if (!enabled) return;
|
|
38
41
|
window.addEventListener("resize", calculatePosition);
|
|
39
42
|
window.addEventListener("scroll", calculatePosition, true);
|
|
40
43
|
return () => {
|
|
@@ -71,6 +74,20 @@ var useClickOutside = (refs, handler, enabled = true) => {
|
|
|
71
74
|
};
|
|
72
75
|
var useClickOutside_default = useClickOutside;
|
|
73
76
|
|
|
77
|
+
// src/tokens/hooks/Portal.tsx
|
|
78
|
+
import React3 from "react";
|
|
79
|
+
import ReactDOM from "react-dom";
|
|
80
|
+
import { jsx } from "react/jsx-runtime";
|
|
81
|
+
var PortalContainerContext = React3.createContext(null);
|
|
82
|
+
var Portal = ({ children }) => {
|
|
83
|
+
const contextContainer = React3.useContext(PortalContainerContext);
|
|
84
|
+
if (typeof document === "undefined") return null;
|
|
85
|
+
const container = contextContainer ?? document.body;
|
|
86
|
+
return ReactDOM.createPortal(children, container);
|
|
87
|
+
};
|
|
88
|
+
Portal.displayName = "Portal";
|
|
89
|
+
var Portal_default = Portal;
|
|
90
|
+
|
|
74
91
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
75
92
|
function r(e) {
|
|
76
93
|
var t, f, n = "";
|
|
@@ -88,17 +105,17 @@ function clsx() {
|
|
|
88
105
|
var clsx_default = clsx;
|
|
89
106
|
|
|
90
107
|
// src/components/Dropdown/Dropdown.tsx
|
|
91
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
108
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
92
109
|
var Dropdown = (props) => {
|
|
93
110
|
const { items, children } = props;
|
|
94
|
-
const [isOpen, setIsOpen] =
|
|
95
|
-
const [mounted, setMounted] =
|
|
96
|
-
const [visible, setVisible] =
|
|
97
|
-
const triggerRef =
|
|
98
|
-
const menuRef =
|
|
99
|
-
const { position, direction } = useAutoPosition_default(triggerRef, menuRef,
|
|
100
|
-
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false));
|
|
101
|
-
|
|
111
|
+
const [isOpen, setIsOpen] = React4.useState(false);
|
|
112
|
+
const [mounted, setMounted] = React4.useState(false);
|
|
113
|
+
const [visible, setVisible] = React4.useState(false);
|
|
114
|
+
const triggerRef = React4.useRef(null);
|
|
115
|
+
const menuRef = React4.useRef(null);
|
|
116
|
+
const { position, direction } = useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
117
|
+
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
118
|
+
React4.useEffect(() => {
|
|
102
119
|
if (isOpen) {
|
|
103
120
|
setMounted(true);
|
|
104
121
|
const t2 = setTimeout(() => setVisible(true), 1);
|
|
@@ -114,7 +131,7 @@ var Dropdown = (props) => {
|
|
|
114
131
|
setIsOpen(false);
|
|
115
132
|
};
|
|
116
133
|
return /* @__PURE__ */ jsxs("div", { className: "lib-xplat-dropdown", children: [
|
|
117
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ jsx2(
|
|
118
135
|
"div",
|
|
119
136
|
{
|
|
120
137
|
ref: triggerRef,
|
|
@@ -123,14 +140,14 @@ var Dropdown = (props) => {
|
|
|
123
140
|
children
|
|
124
141
|
}
|
|
125
142
|
),
|
|
126
|
-
mounted && /* @__PURE__ */
|
|
143
|
+
mounted && /* @__PURE__ */ jsx2(Portal_default, { children: /* @__PURE__ */ jsx2(
|
|
127
144
|
"div",
|
|
128
145
|
{
|
|
129
146
|
ref: menuRef,
|
|
130
|
-
className: clsx_default("dropdown-menu", direction, { visible }),
|
|
147
|
+
className: clsx_default("lib-xplat-dropdown-menu", direction, { visible }),
|
|
131
148
|
style: { top: position.top, left: position.left },
|
|
132
149
|
role: "menu",
|
|
133
|
-
children: items.map((item) => /* @__PURE__ */
|
|
150
|
+
children: items.map((item) => /* @__PURE__ */ jsx2(
|
|
134
151
|
"button",
|
|
135
152
|
{
|
|
136
153
|
className: clsx_default("dropdown-item", {
|
|
@@ -145,7 +162,7 @@ var Dropdown = (props) => {
|
|
|
145
162
|
item.key
|
|
146
163
|
))
|
|
147
164
|
}
|
|
148
|
-
)
|
|
165
|
+
) })
|
|
149
166
|
] });
|
|
150
167
|
};
|
|
151
168
|
Dropdown.displayName = "Dropdown";
|
|
@@ -35,8 +35,22 @@ __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
|
|
38
42
|
var import_react = __toESM(require("react"), 1);
|
|
39
|
-
var import_react_dom = require("react-dom");
|
|
43
|
+
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
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";
|
|
40
54
|
|
|
41
55
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
42
56
|
function r(e) {
|
|
@@ -55,13 +69,14 @@ function clsx() {
|
|
|
55
69
|
var clsx_default = clsx;
|
|
56
70
|
|
|
57
71
|
// src/components/Modal/Modal.tsx
|
|
58
|
-
var
|
|
72
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
59
73
|
var ANIMATION_DURATION_MS = 200;
|
|
60
74
|
var Modal = (props) => {
|
|
61
75
|
const { isOpen, onClose, children } = props;
|
|
62
|
-
const [mounted, setMounted] =
|
|
63
|
-
const [visible, setVisible] =
|
|
64
|
-
|
|
76
|
+
const [mounted, setMounted] = import_react2.default.useState(false);
|
|
77
|
+
const [visible, setVisible] = import_react2.default.useState(false);
|
|
78
|
+
const boxRef = import_react2.default.useRef(null);
|
|
79
|
+
import_react2.default.useEffect(() => {
|
|
65
80
|
if (isOpen) {
|
|
66
81
|
setMounted(true);
|
|
67
82
|
const t2 = setTimeout(() => setVisible(true), 1);
|
|
@@ -74,20 +89,21 @@ var Modal = (props) => {
|
|
|
74
89
|
if (typeof document === "undefined") return null;
|
|
75
90
|
if (!mounted) return null;
|
|
76
91
|
const stateClass = visible ? "enter" : "exit";
|
|
77
|
-
return (0,
|
|
78
|
-
/* @__PURE__ */ (0,
|
|
92
|
+
return (0, import_react_dom2.createPortal)(
|
|
93
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
79
94
|
"div",
|
|
80
95
|
{
|
|
81
96
|
className: clsx_default("lib-xplat-modal", "dim", stateClass),
|
|
82
97
|
onClick: onClose,
|
|
83
|
-
children: /* @__PURE__ */ (0,
|
|
98
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
84
99
|
"div",
|
|
85
100
|
{
|
|
101
|
+
ref: boxRef,
|
|
86
102
|
className: clsx_default("lib-xplat-modal", "modal-box", stateClass),
|
|
87
103
|
role: "dialog",
|
|
88
104
|
"aria-modal": "true",
|
|
89
105
|
onClick: (e) => e.stopPropagation(),
|
|
90
|
-
children
|
|
106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PortalProvider, { container: boxRef.current, children })
|
|
91
107
|
}
|
|
92
108
|
)
|
|
93
109
|
}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
// src/components/Modal/Modal.tsx
|
|
2
|
-
import
|
|
2
|
+
import React2 from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
|
|
5
|
+
// src/tokens/hooks/Portal.tsx
|
|
6
|
+
import React from "react";
|
|
7
|
+
import ReactDOM from "react-dom";
|
|
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";
|
|
18
|
+
|
|
5
19
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
6
20
|
function r(e) {
|
|
7
21
|
var t, f, n = "";
|
|
@@ -19,13 +33,14 @@ function clsx() {
|
|
|
19
33
|
var clsx_default = clsx;
|
|
20
34
|
|
|
21
35
|
// src/components/Modal/Modal.tsx
|
|
22
|
-
import { jsx } from "react/jsx-runtime";
|
|
36
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
23
37
|
var ANIMATION_DURATION_MS = 200;
|
|
24
38
|
var Modal = (props) => {
|
|
25
39
|
const { isOpen, onClose, children } = props;
|
|
26
|
-
const [mounted, setMounted] =
|
|
27
|
-
const [visible, setVisible] =
|
|
28
|
-
|
|
40
|
+
const [mounted, setMounted] = React2.useState(false);
|
|
41
|
+
const [visible, setVisible] = React2.useState(false);
|
|
42
|
+
const boxRef = React2.useRef(null);
|
|
43
|
+
React2.useEffect(() => {
|
|
29
44
|
if (isOpen) {
|
|
30
45
|
setMounted(true);
|
|
31
46
|
const t2 = setTimeout(() => setVisible(true), 1);
|
|
@@ -39,19 +54,20 @@ var Modal = (props) => {
|
|
|
39
54
|
if (!mounted) return null;
|
|
40
55
|
const stateClass = visible ? "enter" : "exit";
|
|
41
56
|
return createPortal(
|
|
42
|
-
/* @__PURE__ */
|
|
57
|
+
/* @__PURE__ */ jsx2(
|
|
43
58
|
"div",
|
|
44
59
|
{
|
|
45
60
|
className: clsx_default("lib-xplat-modal", "dim", stateClass),
|
|
46
61
|
onClick: onClose,
|
|
47
|
-
children: /* @__PURE__ */
|
|
62
|
+
children: /* @__PURE__ */ jsx2(
|
|
48
63
|
"div",
|
|
49
64
|
{
|
|
65
|
+
ref: boxRef,
|
|
50
66
|
className: clsx_default("lib-xplat-modal", "modal-box", stateClass),
|
|
51
67
|
role: "dialog",
|
|
52
68
|
"aria-modal": "true",
|
|
53
69
|
onClick: (e) => e.stopPropagation(),
|
|
54
|
-
children
|
|
70
|
+
children: /* @__PURE__ */ jsx2(PortalProvider, { container: boxRef.current, children })
|
|
55
71
|
}
|
|
56
72
|
)
|
|
57
73
|
}
|
|
@@ -35,7 +35,7 @@ __export(PopOver_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(PopOver_exports);
|
|
36
36
|
|
|
37
37
|
// src/components/PopOver/PopOver.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
39
39
|
|
|
40
40
|
// src/tokens/hooks/useAutoPosition.ts
|
|
41
41
|
var import_react = __toESM(require("react"), 1);
|
|
@@ -68,9 +68,12 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
68
68
|
direction
|
|
69
69
|
});
|
|
70
70
|
}, [triggerRef, popRef]);
|
|
71
|
-
import_react.default.
|
|
71
|
+
import_react.default.useLayoutEffect(() => {
|
|
72
72
|
if (!enabled) return;
|
|
73
73
|
calculatePosition();
|
|
74
|
+
}, [calculatePosition, enabled]);
|
|
75
|
+
import_react.default.useEffect(() => {
|
|
76
|
+
if (!enabled) return;
|
|
74
77
|
window.addEventListener("resize", calculatePosition);
|
|
75
78
|
window.addEventListener("scroll", calculatePosition, true);
|
|
76
79
|
return () => {
|
|
@@ -107,6 +110,20 @@ var useClickOutside = (refs, handler, enabled = true) => {
|
|
|
107
110
|
};
|
|
108
111
|
var useClickOutside_default = useClickOutside;
|
|
109
112
|
|
|
113
|
+
// src/tokens/hooks/Portal.tsx
|
|
114
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
115
|
+
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
116
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
117
|
+
var PortalContainerContext = import_react3.default.createContext(null);
|
|
118
|
+
var Portal = ({ children }) => {
|
|
119
|
+
const contextContainer = import_react3.default.useContext(PortalContainerContext);
|
|
120
|
+
if (typeof document === "undefined") return null;
|
|
121
|
+
const container = contextContainer ?? document.body;
|
|
122
|
+
return import_react_dom.default.createPortal(children, container);
|
|
123
|
+
};
|
|
124
|
+
Portal.displayName = "Portal";
|
|
125
|
+
var Portal_default = Portal;
|
|
126
|
+
|
|
110
127
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
111
128
|
function r(e) {
|
|
112
129
|
var t, f, n = "";
|
|
@@ -124,16 +141,16 @@ function clsx() {
|
|
|
124
141
|
var clsx_default = clsx;
|
|
125
142
|
|
|
126
143
|
// src/components/PopOver/PopOver.tsx
|
|
127
|
-
var
|
|
144
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
128
145
|
var PopOver = (props) => {
|
|
129
146
|
const { children, isOpen, onClose, PopOverEl } = props;
|
|
130
|
-
const popRef =
|
|
131
|
-
const triggerRef =
|
|
132
|
-
const [localOpen, setLocalOpen] =
|
|
133
|
-
const [eventTrigger, setEventTrigger] =
|
|
147
|
+
const popRef = import_react4.default.useRef(null);
|
|
148
|
+
const triggerRef = import_react4.default.useRef(null);
|
|
149
|
+
const [localOpen, setLocalOpen] = import_react4.default.useState(false);
|
|
150
|
+
const [eventTrigger, setEventTrigger] = import_react4.default.useState(false);
|
|
134
151
|
useClickOutside_default([popRef, triggerRef], onClose, isOpen);
|
|
135
152
|
const position = useAutoPosition_default(triggerRef, popRef, localOpen);
|
|
136
|
-
|
|
153
|
+
import_react4.default.useEffect(() => {
|
|
137
154
|
if (isOpen) {
|
|
138
155
|
setLocalOpen(isOpen);
|
|
139
156
|
setTimeout(() => {
|
|
@@ -146,7 +163,7 @@ var PopOver = (props) => {
|
|
|
146
163
|
}, 200);
|
|
147
164
|
}
|
|
148
165
|
}, [isOpen]);
|
|
149
|
-
return /* @__PURE__ */ (0,
|
|
166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
150
167
|
"div",
|
|
151
168
|
{
|
|
152
169
|
className: "lib-xplat-pop-over",
|
|
@@ -156,11 +173,11 @@ var PopOver = (props) => {
|
|
|
156
173
|
},
|
|
157
174
|
children: [
|
|
158
175
|
children,
|
|
159
|
-
localOpen && /* @__PURE__ */ (0,
|
|
176
|
+
localOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
160
177
|
"div",
|
|
161
178
|
{
|
|
162
179
|
className: clsx_default(
|
|
163
|
-
"content
|
|
180
|
+
"lib-xplat-pop-over-content",
|
|
164
181
|
position.direction,
|
|
165
182
|
eventTrigger && "visible"
|
|
166
183
|
),
|
|
@@ -170,7 +187,7 @@ var PopOver = (props) => {
|
|
|
170
187
|
},
|
|
171
188
|
children: PopOverEl
|
|
172
189
|
}
|
|
173
|
-
)
|
|
190
|
+
) })
|
|
174
191
|
]
|
|
175
192
|
}
|
|
176
193
|
);
|
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
/* src/components/PopOver/popOver.scss */
|
|
2
2
|
.lib-xplat-pop-over {
|
|
3
3
|
position: relative;
|
|
4
|
-
z-index: 10;
|
|
5
4
|
width: fit-content;
|
|
6
5
|
cursor: pointer;
|
|
7
6
|
user-select: none;
|
|
8
7
|
}
|
|
9
|
-
.lib-xplat-pop-over
|
|
8
|
+
.lib-xplat-pop-over-content {
|
|
10
9
|
position: fixed;
|
|
10
|
+
z-index: 1000;
|
|
11
11
|
cursor: default;
|
|
12
12
|
transition: transform 0.2s ease, opacity 0.2s ease;
|
|
13
|
-
background:
|
|
13
|
+
background: var(--semantic-surface-neutral-default);
|
|
14
14
|
border-radius: var(--spacing-radius-md);
|
|
15
15
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
16
|
-
z-index: 10;
|
|
17
16
|
opacity: 0;
|
|
18
17
|
transform: scale(0.8);
|
|
19
18
|
}
|
|
20
|
-
.lib-xplat-pop-over
|
|
19
|
+
.lib-xplat-pop-over-content.top {
|
|
21
20
|
transform-origin: bottom;
|
|
22
|
-
margin-bottom: var(--spacing-space-2);
|
|
23
21
|
}
|
|
24
|
-
.lib-xplat-pop-over
|
|
22
|
+
.lib-xplat-pop-over-content.bottom {
|
|
25
23
|
transform-origin: top;
|
|
26
|
-
margin-top: var(--spacing-space-2);
|
|
27
24
|
}
|
|
28
|
-
.lib-xplat-pop-over
|
|
25
|
+
.lib-xplat-pop-over-content.visible {
|
|
29
26
|
opacity: 1;
|
|
30
27
|
transform: scale(1);
|
|
31
28
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/PopOver/PopOver.tsx
|
|
2
|
-
import
|
|
2
|
+
import React4 from "react";
|
|
3
3
|
|
|
4
4
|
// src/tokens/hooks/useAutoPosition.ts
|
|
5
5
|
import React from "react";
|
|
@@ -32,9 +32,12 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
32
32
|
direction
|
|
33
33
|
});
|
|
34
34
|
}, [triggerRef, popRef]);
|
|
35
|
-
React.
|
|
35
|
+
React.useLayoutEffect(() => {
|
|
36
36
|
if (!enabled) return;
|
|
37
37
|
calculatePosition();
|
|
38
|
+
}, [calculatePosition, enabled]);
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
if (!enabled) return;
|
|
38
41
|
window.addEventListener("resize", calculatePosition);
|
|
39
42
|
window.addEventListener("scroll", calculatePosition, true);
|
|
40
43
|
return () => {
|
|
@@ -71,6 +74,20 @@ var useClickOutside = (refs, handler, enabled = true) => {
|
|
|
71
74
|
};
|
|
72
75
|
var useClickOutside_default = useClickOutside;
|
|
73
76
|
|
|
77
|
+
// src/tokens/hooks/Portal.tsx
|
|
78
|
+
import React3 from "react";
|
|
79
|
+
import ReactDOM from "react-dom";
|
|
80
|
+
import { jsx } from "react/jsx-runtime";
|
|
81
|
+
var PortalContainerContext = React3.createContext(null);
|
|
82
|
+
var Portal = ({ children }) => {
|
|
83
|
+
const contextContainer = React3.useContext(PortalContainerContext);
|
|
84
|
+
if (typeof document === "undefined") return null;
|
|
85
|
+
const container = contextContainer ?? document.body;
|
|
86
|
+
return ReactDOM.createPortal(children, container);
|
|
87
|
+
};
|
|
88
|
+
Portal.displayName = "Portal";
|
|
89
|
+
var Portal_default = Portal;
|
|
90
|
+
|
|
74
91
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
75
92
|
function r(e) {
|
|
76
93
|
var t, f, n = "";
|
|
@@ -88,16 +105,16 @@ function clsx() {
|
|
|
88
105
|
var clsx_default = clsx;
|
|
89
106
|
|
|
90
107
|
// src/components/PopOver/PopOver.tsx
|
|
91
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
108
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
92
109
|
var PopOver = (props) => {
|
|
93
110
|
const { children, isOpen, onClose, PopOverEl } = props;
|
|
94
|
-
const popRef =
|
|
95
|
-
const triggerRef =
|
|
96
|
-
const [localOpen, setLocalOpen] =
|
|
97
|
-
const [eventTrigger, setEventTrigger] =
|
|
111
|
+
const popRef = React4.useRef(null);
|
|
112
|
+
const triggerRef = React4.useRef(null);
|
|
113
|
+
const [localOpen, setLocalOpen] = React4.useState(false);
|
|
114
|
+
const [eventTrigger, setEventTrigger] = React4.useState(false);
|
|
98
115
|
useClickOutside_default([popRef, triggerRef], onClose, isOpen);
|
|
99
116
|
const position = useAutoPosition_default(triggerRef, popRef, localOpen);
|
|
100
|
-
|
|
117
|
+
React4.useEffect(() => {
|
|
101
118
|
if (isOpen) {
|
|
102
119
|
setLocalOpen(isOpen);
|
|
103
120
|
setTimeout(() => {
|
|
@@ -120,11 +137,11 @@ var PopOver = (props) => {
|
|
|
120
137
|
},
|
|
121
138
|
children: [
|
|
122
139
|
children,
|
|
123
|
-
localOpen && /* @__PURE__ */
|
|
140
|
+
localOpen && /* @__PURE__ */ jsx2(Portal_default, { children: /* @__PURE__ */ jsx2(
|
|
124
141
|
"div",
|
|
125
142
|
{
|
|
126
143
|
className: clsx_default(
|
|
127
|
-
"content
|
|
144
|
+
"lib-xplat-pop-over-content",
|
|
128
145
|
position.direction,
|
|
129
146
|
eventTrigger && "visible"
|
|
130
147
|
),
|
|
@@ -134,7 +151,7 @@ var PopOver = (props) => {
|
|
|
134
151
|
},
|
|
135
152
|
children: PopOverEl
|
|
136
153
|
}
|
|
137
|
-
)
|
|
154
|
+
) })
|
|
138
155
|
]
|
|
139
156
|
}
|
|
140
157
|
);
|