@nexus-cross/design-system 1.0.3-beta.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.
Files changed (256) hide show
  1. package/cursor-rules/nexus-project-setup.mdc +188 -0
  2. package/cursor-rules/nexus-ui-api.mdc +698 -0
  3. package/cursor-rules/nexus-ui-components.mdc +104 -0
  4. package/dist/accordion.d.mts +28 -0
  5. package/dist/accordion.d.ts +28 -0
  6. package/dist/accordion.js +28 -0
  7. package/dist/accordion.mjs +3 -0
  8. package/dist/avatar.d.mts +17 -0
  9. package/dist/avatar.d.ts +17 -0
  10. package/dist/avatar.js +16 -0
  11. package/dist/avatar.mjs +3 -0
  12. package/dist/button.d.mts +15 -0
  13. package/dist/button.d.ts +15 -0
  14. package/dist/button.js +16 -0
  15. package/dist/button.mjs +3 -0
  16. package/dist/carousel.d.mts +36 -0
  17. package/dist/carousel.d.ts +36 -0
  18. package/dist/carousel.js +32 -0
  19. package/dist/carousel.mjs +3 -0
  20. package/dist/checkbox.d.mts +21 -0
  21. package/dist/checkbox.d.ts +21 -0
  22. package/dist/checkbox.js +20 -0
  23. package/dist/checkbox.mjs +3 -0
  24. package/dist/chip.d.mts +16 -0
  25. package/dist/chip.d.ts +16 -0
  26. package/dist/chip.js +16 -0
  27. package/dist/chip.mjs +3 -0
  28. package/dist/chunks/chunk-22ULI3BF.js +21 -0
  29. package/dist/chunks/chunk-2JTPRBHZ.mjs +36 -0
  30. package/dist/chunks/chunk-377KBJQG.js +74 -0
  31. package/dist/chunks/chunk-3CHRUKSJ.mjs +120 -0
  32. package/dist/chunks/chunk-4ITJA3IS.mjs +83 -0
  33. package/dist/chunks/chunk-4J3GCZ7W.mjs +102 -0
  34. package/dist/chunks/chunk-53A2SL62.js +218 -0
  35. package/dist/chunks/chunk-54IA2P2Z.mjs +40 -0
  36. package/dist/chunks/chunk-5I2VRWWU.js +172 -0
  37. package/dist/chunks/chunk-5TBXVD56.js +88 -0
  38. package/dist/chunks/chunk-6DZVNFVY.js +82 -0
  39. package/dist/chunks/chunk-6FHK6CBR.js +117 -0
  40. package/dist/chunks/chunk-6H7V2I3X.mjs +270 -0
  41. package/dist/chunks/chunk-6MRM5K2N.js +106 -0
  42. package/dist/chunks/chunk-6NTASYZO.js +132 -0
  43. package/dist/chunks/chunk-76CY4STF.js +165 -0
  44. package/dist/chunks/chunk-76K6KXCT.js +100 -0
  45. package/dist/chunks/chunk-7MT3QYE6.js +92 -0
  46. package/dist/chunks/chunk-7OEK2KX3.mjs +81 -0
  47. package/dist/chunks/chunk-AKIBUO5A.mjs +83 -0
  48. package/dist/chunks/chunk-AOVU67NI.mjs +139 -0
  49. package/dist/chunks/chunk-AOXXE5UQ.mjs +14 -0
  50. package/dist/chunks/chunk-AWBGWBFS.js +135 -0
  51. package/dist/chunks/chunk-AZ2URLDD.js +39 -0
  52. package/dist/chunks/chunk-BEA727LO.mjs +108 -0
  53. package/dist/chunks/chunk-C3E7CSKG.mjs +115 -0
  54. package/dist/chunks/chunk-C6H2UNOX.js +83 -0
  55. package/dist/chunks/chunk-CVYXRSXT.mjs +8 -0
  56. package/dist/chunks/chunk-EIOP4DOE.mjs +292 -0
  57. package/dist/chunks/chunk-FA2OPP3U.mjs +140 -0
  58. package/dist/chunks/chunk-FHPHDK3O.mjs +89 -0
  59. package/dist/chunks/chunk-FKHW7QYG.js +725 -0
  60. package/dist/chunks/chunk-FKZI2HTI.js +104 -0
  61. package/dist/chunks/chunk-G4XJG7XI.js +66 -0
  62. package/dist/chunks/chunk-GMIGQ5VP.mjs +86 -0
  63. package/dist/chunks/chunk-GSLIY6WW.js +109 -0
  64. package/dist/chunks/chunk-HHXDOKXY.js +108 -0
  65. package/dist/chunks/chunk-HUPAHDJ7.js +273 -0
  66. package/dist/chunks/chunk-I252NERB.mjs +21 -0
  67. package/dist/chunks/chunk-I7YJB2F5.js +143 -0
  68. package/dist/chunks/chunk-IB5UCYQY.mjs +66 -0
  69. package/dist/chunks/chunk-IJG7J2VU.mjs +148 -0
  70. package/dist/chunks/chunk-INP2AH3B.js +27 -0
  71. package/dist/chunks/chunk-IUNNTSD2.mjs +195 -0
  72. package/dist/chunks/chunk-JNMCYWGY.js +10 -0
  73. package/dist/chunks/chunk-JZ3PWHKS.mjs +51 -0
  74. package/dist/chunks/chunk-KWPIEHD2.mjs +78 -0
  75. package/dist/chunks/chunk-LBKBCI2K.mjs +44 -0
  76. package/dist/chunks/chunk-LVTD2UQN.mjs +48 -0
  77. package/dist/chunks/chunk-MPKRXMCJ.js +93 -0
  78. package/dist/chunks/chunk-NCQDOPBR.mjs +86 -0
  79. package/dist/chunks/chunk-NHDGKOAM.js +104 -0
  80. package/dist/chunks/chunk-OTGS6BDQ.mjs +25 -0
  81. package/dist/chunks/chunk-Q2TMXHPK.js +178 -0
  82. package/dist/chunks/chunk-Q7GQVAYY.js +88 -0
  83. package/dist/chunks/chunk-Q7H6LCNN.js +169 -0
  84. package/dist/chunks/chunk-QJNQCLMV.js +25 -0
  85. package/dist/chunks/chunk-QK6NCII4.js +36 -0
  86. package/dist/chunks/chunk-RLP3U52D.mjs +153 -0
  87. package/dist/chunks/chunk-T2IY2TSR.js +43 -0
  88. package/dist/chunks/chunk-TLTEUIBY.js +112 -0
  89. package/dist/chunks/chunk-TPBKQ3WC.js +303 -0
  90. package/dist/chunks/chunk-TR5JBBEA.mjs +116 -0
  91. package/dist/chunks/chunk-TWHDXCKR.js +61 -0
  92. package/dist/chunks/chunk-U56AGSLE.mjs +106 -0
  93. package/dist/chunks/chunk-U6KOUYWX.mjs +66 -0
  94. package/dist/chunks/chunk-U76LT5GE.js +70 -0
  95. package/dist/chunks/chunk-UDQXLI5Y.mjs +81 -0
  96. package/dist/chunks/chunk-UH667FUK.mjs +712 -0
  97. package/dist/chunks/chunk-UR6JOKVB.mjs +65 -0
  98. package/dist/chunks/chunk-VH5FF6DZ.mjs +38 -0
  99. package/dist/chunks/chunk-WJ2OVQD3.mjs +105 -0
  100. package/dist/chunks/chunk-WNFJ4NJN.mjs +55 -0
  101. package/dist/chunks/chunk-WSWD5ZUJ.js +106 -0
  102. package/dist/chunks/chunk-XALPBGSC.mjs +23 -0
  103. package/dist/chunks/chunk-XEHFB62A.js +82 -0
  104. package/dist/chunks/chunk-YEGPB7A7.js +83 -0
  105. package/dist/chunks/chunk-YEWKPWK3.mjs +80 -0
  106. package/dist/chunks/chunk-Z7OKV6NW.mjs +59 -0
  107. package/dist/chunks/chunk-ZCMKIB5U.js +140 -0
  108. package/dist/client-only.d.mts +13 -0
  109. package/dist/client-only.d.ts +13 -0
  110. package/dist/client-only.js +11 -0
  111. package/dist/client-only.mjs +2 -0
  112. package/dist/countdown.d.mts +27 -0
  113. package/dist/countdown.d.ts +27 -0
  114. package/dist/countdown.js +16 -0
  115. package/dist/countdown.mjs +3 -0
  116. package/dist/counter.d.mts +15 -0
  117. package/dist/counter.d.ts +15 -0
  118. package/dist/counter.js +11 -0
  119. package/dist/counter.mjs +2 -0
  120. package/dist/divider.d.mts +14 -0
  121. package/dist/divider.d.ts +14 -0
  122. package/dist/divider.js +16 -0
  123. package/dist/divider.mjs +3 -0
  124. package/dist/drawer.d.mts +42 -0
  125. package/dist/drawer.d.ts +42 -0
  126. package/dist/drawer.js +44 -0
  127. package/dist/drawer.mjs +3 -0
  128. package/dist/ellipsis.d.mts +16 -0
  129. package/dist/ellipsis.d.ts +16 -0
  130. package/dist/ellipsis.js +12 -0
  131. package/dist/ellipsis.mjs +3 -0
  132. package/dist/error-boundary.d.mts +20 -0
  133. package/dist/error-boundary.d.ts +20 -0
  134. package/dist/error-boundary.js +11 -0
  135. package/dist/error-boundary.mjs +2 -0
  136. package/dist/hooks/useCheckDevice.d.mts +47 -0
  137. package/dist/hooks/useCheckDevice.d.ts +47 -0
  138. package/dist/hooks/useCheckDevice.js +8 -0
  139. package/dist/hooks/useCheckDevice.mjs +2 -0
  140. package/dist/hooks/useClickOutside.d.mts +12 -0
  141. package/dist/hooks/useClickOutside.d.ts +12 -0
  142. package/dist/hooks/useClickOutside.js +8 -0
  143. package/dist/hooks/useClickOutside.mjs +2 -0
  144. package/dist/hooks/useDraggableBottomSheet.d.mts +24 -0
  145. package/dist/hooks/useDraggableBottomSheet.d.ts +24 -0
  146. package/dist/hooks/useDraggableBottomSheet.js +11 -0
  147. package/dist/hooks/useDraggableBottomSheet.mjs +2 -0
  148. package/dist/hooks/useDraggableWindow.d.mts +21 -0
  149. package/dist/hooks/useDraggableWindow.d.ts +21 -0
  150. package/dist/hooks/useDraggableWindow.js +11 -0
  151. package/dist/hooks/useDraggableWindow.mjs +2 -0
  152. package/dist/hooks/useInView.d.mts +14 -0
  153. package/dist/hooks/useInView.d.ts +14 -0
  154. package/dist/hooks/useInView.js +17 -0
  155. package/dist/hooks/useInView.mjs +2 -0
  156. package/dist/hooks/useModal.d.mts +2 -0
  157. package/dist/hooks/useModal.d.ts +2 -0
  158. package/dist/hooks/useModal.js +11 -0
  159. package/dist/hooks/useModal.mjs +2 -0
  160. package/dist/index.d.mts +74 -0
  161. package/dist/index.d.ts +74 -0
  162. package/dist/index.js +633 -0
  163. package/dist/index.mjs +227 -0
  164. package/dist/infinite-scroll.d.mts +26 -0
  165. package/dist/infinite-scroll.d.ts +26 -0
  166. package/dist/infinite-scroll.js +12 -0
  167. package/dist/infinite-scroll.mjs +3 -0
  168. package/dist/marquee.d.mts +12 -0
  169. package/dist/marquee.d.ts +12 -0
  170. package/dist/marquee.js +12 -0
  171. package/dist/marquee.mjs +3 -0
  172. package/dist/modal/index.d.mts +87 -0
  173. package/dist/modal/index.d.ts +87 -0
  174. package/dist/modal/index.js +54 -0
  175. package/dist/modal/index.mjs +9 -0
  176. package/dist/number-input.d.mts +21 -0
  177. package/dist/number-input.d.ts +21 -0
  178. package/dist/number-input.js +16 -0
  179. package/dist/number-input.mjs +3 -0
  180. package/dist/pagination.d.mts +21 -0
  181. package/dist/pagination.d.ts +21 -0
  182. package/dist/pagination.js +20 -0
  183. package/dist/pagination.mjs +3 -0
  184. package/dist/popover.d.mts +25 -0
  185. package/dist/popover.d.ts +25 -0
  186. package/dist/popover.js +32 -0
  187. package/dist/popover.mjs +3 -0
  188. package/dist/radio-group.d.mts +29 -0
  189. package/dist/radio-group.d.ts +29 -0
  190. package/dist/radio-group.js +24 -0
  191. package/dist/radio-group.mjs +3 -0
  192. package/dist/select.d.mts +31 -0
  193. package/dist/select.d.ts +31 -0
  194. package/dist/select.js +24 -0
  195. package/dist/select.mjs +3 -0
  196. package/dist/spinner.d.mts +9 -0
  197. package/dist/spinner.d.ts +9 -0
  198. package/dist/spinner.js +12 -0
  199. package/dist/spinner.mjs +3 -0
  200. package/dist/styles.css +2 -0
  201. package/dist/styles.d.mts +3 -0
  202. package/dist/styles.d.ts +3 -0
  203. package/dist/styles.js +19 -0
  204. package/dist/styles.mjs +17 -0
  205. package/dist/switch.d.mts +15 -0
  206. package/dist/switch.d.ts +15 -0
  207. package/dist/switch.js +16 -0
  208. package/dist/switch.mjs +3 -0
  209. package/dist/tab.d.mts +36 -0
  210. package/dist/tab.d.ts +36 -0
  211. package/dist/tab.js +20 -0
  212. package/dist/tab.mjs +3 -0
  213. package/dist/table.d.mts +80 -0
  214. package/dist/table.d.ts +80 -0
  215. package/dist/table.js +32 -0
  216. package/dist/table.mjs +3 -0
  217. package/dist/text-area.d.mts +15 -0
  218. package/dist/text-area.d.ts +15 -0
  219. package/dist/text-area.js +16 -0
  220. package/dist/text-area.mjs +3 -0
  221. package/dist/text-input.d.mts +17 -0
  222. package/dist/text-input.d.ts +17 -0
  223. package/dist/text-input.js +16 -0
  224. package/dist/text-input.mjs +3 -0
  225. package/dist/theme-provider.d.mts +25 -0
  226. package/dist/theme-provider.d.ts +25 -0
  227. package/dist/theme-provider.js +15 -0
  228. package/dist/theme-provider.mjs +2 -0
  229. package/dist/toast.d.mts +42 -0
  230. package/dist/toast.d.ts +42 -0
  231. package/dist/toast.js +20 -0
  232. package/dist/toast.mjs +3 -0
  233. package/dist/tooltip.d.mts +24 -0
  234. package/dist/tooltip.d.ts +24 -0
  235. package/dist/tooltip.js +20 -0
  236. package/dist/tooltip.mjs +3 -0
  237. package/dist/typography.d.mts +19 -0
  238. package/dist/typography.d.ts +19 -0
  239. package/dist/typography.js +102 -0
  240. package/dist/typography.mjs +79 -0
  241. package/dist/useModal-BsGIcP8t.d.mts +128 -0
  242. package/dist/useModal-BsGIcP8t.d.ts +128 -0
  243. package/dist/utils/cn.d.mts +15 -0
  244. package/dist/utils/cn.d.ts +15 -0
  245. package/dist/utils/cn.js +11 -0
  246. package/dist/utils/cn.mjs +2 -0
  247. package/dist/utils/scroll.d.mts +4 -0
  248. package/dist/utils/scroll.d.ts +4 -0
  249. package/dist/utils/scroll.js +15 -0
  250. package/dist/utils/scroll.mjs +2 -0
  251. package/dist/virtual-scroll.d.mts +34 -0
  252. package/dist/virtual-scroll.d.ts +34 -0
  253. package/dist/virtual-scroll.js +16 -0
  254. package/dist/virtual-scroll.mjs +3 -0
  255. package/package.json +271 -0
  256. package/scripts/setup-cursor-rules.cjs +92 -0
@@ -0,0 +1,712 @@
1
+ import { scrollRelease, scrollFreeze } from './chunk-54IA2P2Z.mjs';
2
+ import { useCheckDevice_default } from './chunk-YEWKPWK3.mjs';
3
+ import { useClickOutside_default } from './chunk-OTGS6BDQ.mjs';
4
+ import { Modal_default } from './chunk-6H7V2I3X.mjs';
5
+ import { useDraggableBottomSheet } from './chunk-U56AGSLE.mjs';
6
+ import { useDraggableWindow } from './chunk-4J3GCZ7W.mjs';
7
+ import { cn } from './chunk-XALPBGSC.mjs';
8
+ import React, { forwardRef, useState, useMemo, useCallback, useEffect, useImperativeHandle, useRef, Suspense } from 'react';
9
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
+ import { createPortal } from 'react-dom';
11
+ import { cva } from 'class-variance-authority';
12
+
13
+ function wait(ms) {
14
+ return new Promise((resolve) => setTimeout(resolve, ms));
15
+ }
16
+ var LazyLoadComponent = ({
17
+ onLoaded
18
+ }) => {
19
+ useEffect(() => {
20
+ onLoaded();
21
+ }, []);
22
+ return /* @__PURE__ */ jsx(Fragment, {});
23
+ };
24
+ var Component = ({
25
+ is,
26
+ props,
27
+ handleOpenStatus
28
+ }) => {
29
+ const [loading, setLoading] = useState(!is.displayName);
30
+ const component = useMemo(() => {
31
+ if (is.displayName) {
32
+ return /* @__PURE__ */ jsx(Fragment, { children: React.createElement(is, { ...props }) });
33
+ }
34
+ return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsxs(Fragment, { children: [
35
+ React.createElement(is, { ...props }),
36
+ /* @__PURE__ */ jsx(LazyLoadComponent, { onLoaded: () => setLoading(false) })
37
+ ] }) });
38
+ }, [is, props]);
39
+ useEffect(() => {
40
+ if (!loading) {
41
+ handleOpenStatus();
42
+ }
43
+ }, [loading, handleOpenStatus]);
44
+ return component;
45
+ };
46
+ var ModalComponent = forwardRef(
47
+ ({ className, modal, breakPoints, scrollFreeze: scrollFreeze2, scrollRelease: scrollRelease2, deleteModal, resolveModal }, ref) => {
48
+ const { isMobile } = useCheckDevice_default(breakPoints);
49
+ const [status, setStatus] = useState("");
50
+ const clickOutSideTarget = useMemo(() => {
51
+ if (modal.props?.clickOutSideRef) {
52
+ return modal.props.clickOutSideRef.current ?? null;
53
+ }
54
+ if (modal.props?.portalId) {
55
+ return document.querySelector(`#${modal.props.portalId}`);
56
+ }
57
+ return null;
58
+ }, [modal.props?.clickOutSideRef, modal.props?.portalId]);
59
+ const animationInfo = useMemo(() => {
60
+ const animation = modal.props?.animation ?? {};
61
+ return {
62
+ name: isMobile ? animation.mobile ?? animation.name : animation.name,
63
+ duration: animation.duration || "0",
64
+ timingFunction: animation.timingFunc || "cubic-bezier(0.25, 0.1, 0.25, 1.0)",
65
+ leaveTimingFunction: animation.leaveTimingFunc ? animation.leaveTimingFunc : animation.timingFunc || "cubic-bezier(0.25, 0.1, 0.25, 1.0)"
66
+ };
67
+ }, [isMobile, modal.props?.animation]);
68
+ const resolvedLayout = useMemo(() => {
69
+ if (modal.props?.layout) {
70
+ return modal.props.layout;
71
+ }
72
+ if (animationInfo.name === "bottom-sheet") return "bottom-sheet";
73
+ if (animationInfo.name === "slide-left") return "slide-left";
74
+ if (animationInfo.name === "slide-right") return "slide-right";
75
+ if (animationInfo.name === "full-page") return "full-page";
76
+ if (animationInfo.name === "full-page-reverse") return "full-page-reverse";
77
+ return void 0;
78
+ }, [modal.props?.layout, animationInfo.name]);
79
+ const close = useCallback(
80
+ async (modalId, isAnimation = true) => {
81
+ setStatus("leave");
82
+ if (isAnimation && !!animationInfo.name) {
83
+ const duration = modal.props.animation?.duration ?? 0;
84
+ await wait(duration + 50);
85
+ }
86
+ deleteModal(modalId);
87
+ },
88
+ [animationInfo.name, deleteModal, modal.props.animation]
89
+ );
90
+ const resolve = (modal2, result, useClose) => {
91
+ resolveModal({ modal: modal2, result, useClose });
92
+ };
93
+ const handleOpenStatus = useCallback(async () => {
94
+ await wait(
95
+ modal.props?.animation?.delay ?? 0
96
+ );
97
+ setStatus("enter");
98
+ if (animationInfo.name) {
99
+ await wait(
100
+ modal.props.animation?.duration ?? 0
101
+ );
102
+ }
103
+ setStatus("enter-done");
104
+ }, [modal.props.animation, animationInfo.name]);
105
+ useEffect(() => {
106
+ if (!modal.props.scrollEnable) {
107
+ scrollFreeze2?.();
108
+ return () => {
109
+ scrollRelease2?.();
110
+ };
111
+ }
112
+ }, [modal.props.scrollEnable, scrollFreeze2, scrollRelease2]);
113
+ useClickOutside_default(clickOutSideTarget, () => {
114
+ close(modal.id, true);
115
+ });
116
+ useImperativeHandle(ref, () => ({
117
+ modalId: modal.id,
118
+ hasClose: !!modal.close,
119
+ close
120
+ }));
121
+ const getModalClassName = () => {
122
+ const baseClasses = ["nx:opacity-0"];
123
+ if (modal.props.portalId) {
124
+ baseClasses.push("nx:relative");
125
+ }
126
+ if (["enter", "enter-done", "leave"].includes(status)) {
127
+ baseClasses.push("nx:opacity-100");
128
+ }
129
+ if (status === "enter") {
130
+ baseClasses.push(
131
+ "nx:[&_.modal-inner]:[animation-direction:var(--modal-animation-direction)]",
132
+ "nx:[&_.modal-inner]:[animation-duration:var(--modal-animation-duration)]",
133
+ "nx:[&_.modal-inner]:[animation-name:var(--modal-animation-name)]",
134
+ "nx:[&_.modal-inner]:[animation-timing-function:var(--modal-animation-timing-function)]"
135
+ );
136
+ } else if (status === "leave") {
137
+ baseClasses.push(
138
+ "nx:[&_.modal-inner]:[animation-direction:reverse]",
139
+ "nx:[&_.modal-inner]:[animation-duration:var(--modal-animation-duration)]",
140
+ "nx:[&_.modal-inner]:[animation-fill-mode:var(--modal-animation-fill-mode)]",
141
+ "nx:[&_.modal-inner]:[animation-name:var(--modal-animation-name)]",
142
+ "nx:[&_.modal-inner]:[animation-timing-function:var(--modal-animation-timing-function)]"
143
+ );
144
+ }
145
+ if (className) {
146
+ baseClasses.push(className);
147
+ }
148
+ return baseClasses.join(" ");
149
+ };
150
+ const dimOpacity = status === "enter" || status === "enter-done" ? 1 : 0;
151
+ const getModalStyle = () => {
152
+ return {
153
+ "--modal-animation-name": status === "enter" || status === "leave" ? `modal-${animationInfo.name}` : "",
154
+ "--modal-animation-direction": status === "leave" ? "reverse" : "normal",
155
+ "--modal-animation-fill-mode": status === "leave" ? "forwards" : "",
156
+ "--modal-animation-duration": `${animationInfo.duration}ms`,
157
+ "--modal-animation-timing-function": status === "leave" ? animationInfo.leaveTimingFunction : animationInfo.timingFunction,
158
+ "--modal-dim-opacity": dimOpacity
159
+ };
160
+ };
161
+ return /* @__PURE__ */ jsx("div", { className: getModalClassName(), style: getModalStyle(), children: /* @__PURE__ */ jsx(
162
+ Component,
163
+ {
164
+ is: modal.component,
165
+ props: {
166
+ ...modal.props,
167
+ className: status,
168
+ layout: resolvedLayout,
169
+ close: (isAnimation) => close(modal.id, isAnimation),
170
+ resolve: (result, useClose = true) => resolve(modal, result, useClose)
171
+ },
172
+ handleOpenStatus
173
+ },
174
+ modal.id
175
+ ) });
176
+ }
177
+ );
178
+ ModalComponent.displayName = "ModalComponent";
179
+ var ModalComponent_default = ModalComponent;
180
+ var ModalPortal = ({ children, selector }) => {
181
+ const [mounted, setMounted] = useState(false);
182
+ let element = null;
183
+ if (typeof window !== "undefined") {
184
+ const elements = document.querySelectorAll(
185
+ selector.includes("#") ? selector : `#${selector}`
186
+ );
187
+ if (elements.length === 1) {
188
+ element = elements[0];
189
+ }
190
+ }
191
+ useEffect(() => {
192
+ setMounted(true);
193
+ return () => setMounted(false);
194
+ }, []);
195
+ return mounted && element && children ? createPortal(children, element) : null;
196
+ };
197
+ var ModalPortal_default = ModalPortal;
198
+ var ModalContainer = ({ className = "", breakPoints, ...defaultOption }) => {
199
+ const [modals, setModals] = useState(Modal_default.modalList);
200
+ const setModalClose = useCallback((params) => {
201
+ if (!params) return;
202
+ const { modalId, hasClose, close } = params;
203
+ if (!hasClose) {
204
+ Modal_default.modalList = Modal_default.modalList.map(
205
+ (m) => m.id === modalId ? { ...m, close } : m
206
+ );
207
+ }
208
+ }, []);
209
+ useEffect(() => {
210
+ Modal_default.observe({ options: defaultOption, observeFunction: setModals });
211
+ return () => {
212
+ Modal_default.unobserve();
213
+ };
214
+ }, [defaultOption]);
215
+ return /* @__PURE__ */ jsx("div", { id: "modal-wrapper", className, children: modals.map(
216
+ (m) => m.props.portalId ? /* @__PURE__ */ jsx(ModalPortal_default, { selector: m.props.portalId, children: /* @__PURE__ */ jsx(
217
+ ModalComponent_default,
218
+ {
219
+ ref: setModalClose,
220
+ modal: m,
221
+ breakPoints,
222
+ deleteModal: (id) => Modal_default.deleteModal(id),
223
+ resolveModal: (params) => Modal_default.resolveModal(params),
224
+ scrollFreeze,
225
+ scrollRelease
226
+ },
227
+ m.id
228
+ ) }, m.id) : /* @__PURE__ */ jsx(
229
+ ModalComponent_default,
230
+ {
231
+ ref: setModalClose,
232
+ modal: m,
233
+ breakPoints,
234
+ deleteModal: (id) => Modal_default.deleteModal(id),
235
+ resolveModal: (params) => Modal_default.resolveModal(params),
236
+ scrollFreeze,
237
+ scrollRelease
238
+ },
239
+ m.id
240
+ )
241
+ ) });
242
+ };
243
+ var ModalContainer_default = ModalContainer;
244
+ var ModalPortalTarget = ({ id, className }) => {
245
+ return /* @__PURE__ */ jsx("div", { id, className: `nx:absolute nx:z-[9999] ${className || ""}` });
246
+ };
247
+ var ModalPortalTarget_default = ModalPortalTarget;
248
+ var modalWrapVariants = cva(
249
+ "modal-wrap nx:pointer-events-none nx:fixed nx:inset-0 nx:z-[99999] nx:flex nx:h-full nx:items-center nx:justify-center nx:text-text-primary",
250
+ {
251
+ variants: {
252
+ layout: {
253
+ default: "",
254
+ "bottom-sheet": "nx:items-end",
255
+ "slide-left": "nx:h-full nx:justify-start",
256
+ "slide-right": "nx:h-full nx:justify-end",
257
+ "full-page": "nx:h-full nx:justify-start",
258
+ "full-page-reverse": "nx:h-full nx:justify-start",
259
+ draggable: ""
260
+ }
261
+ },
262
+ defaultVariants: {
263
+ layout: "default"
264
+ }
265
+ }
266
+ );
267
+ var modalInnerVariants = cva(
268
+ [
269
+ "modal-inner",
270
+ "nx:relative nx:z-[2] nx:min-h-[200px] nx:w-full nx:overflow-hidden",
271
+ "nx:pointer-events-auto nx:rounded-corner-lg nx:border nx:border-border-default nx:bg-surface-default nx:text-text-primary",
272
+ "nx:sm:w-[480px] nx:sm:min-h-auto",
273
+ "nx:[&>div]:contents"
274
+ ],
275
+ {
276
+ variants: {
277
+ layout: {
278
+ default: "",
279
+ "bottom-sheet": "nx:mx-0 nx:my-0 nx:w-full nx:rounded-t-2xl nx:rounded-b-none nx:border-t nx:border-border-default nx:px-4 nx:pt-6",
280
+ "slide-left": "nx:h-full nx:rounded-none",
281
+ "slide-right": "nx:h-full nx:rounded-none",
282
+ "full-page": "nx:h-full nx:w-full nx:sm:w-full nx:rounded-none nx:border-transparent",
283
+ "full-page-reverse": "nx:h-full nx:w-full nx:sm:w-full nx:rounded-none nx:border-transparent",
284
+ draggable: "nx:w-auto nx:min-w-[320px] nx:sm:w-auto nx:overflow-visible"
285
+ },
286
+ hasFooter: {
287
+ true: "",
288
+ false: ""
289
+ }
290
+ },
291
+ compoundVariants: [
292
+ { layout: "default", hasFooter: true, class: "nx:pb-[88px]" },
293
+ { layout: "bottom-sheet", hasFooter: true, class: "nx:pb-20" }
294
+ ],
295
+ defaultVariants: {
296
+ layout: "default",
297
+ hasFooter: false
298
+ }
299
+ }
300
+ );
301
+ var modalHeaderVariants = cva("modal-header nx:relative nx:px-5 nx:pt-6", {
302
+ variants: {
303
+ layout: {
304
+ default: "",
305
+ "bottom-sheet": "nx:p-0",
306
+ "slide-left": "",
307
+ "slide-right": "",
308
+ "full-page": "",
309
+ "full-page-reverse": "",
310
+ draggable: "nx:cursor-grab nx:active:cursor-grabbing nx:select-none"
311
+ }
312
+ },
313
+ defaultVariants: {
314
+ layout: "default"
315
+ }
316
+ });
317
+ var modalCloseButtonVariants = cva(
318
+ "btn-close nx:absolute nx:top-6 nx:right-5 nx:z-[1] nx:ml-auto nx:flex nx:cursor-pointer nx:items-center nx:justify-end",
319
+ {
320
+ variants: {
321
+ layout: {
322
+ default: "",
323
+ "bottom-sheet": "nx:relative nx:top-0 nx:right-0",
324
+ "slide-left": "",
325
+ "slide-right": "",
326
+ "full-page": "",
327
+ "full-page-reverse": "",
328
+ draggable: ""
329
+ }
330
+ },
331
+ defaultVariants: {
332
+ layout: "default"
333
+ }
334
+ }
335
+ );
336
+ var modalTitleVariants = cva(
337
+ "modal-title nx:m-0 nx:pr-[42px] nx:text-text-lg nx:font-semibold nx:leading-[26px] nx:tracking-[-0.002em] nx:text-text-primary",
338
+ {
339
+ variants: {
340
+ layout: {
341
+ default: "",
342
+ "bottom-sheet": "nx:pt-1.5 nx:leading-7 nx:tracking-[-0.012em]",
343
+ "slide-left": "",
344
+ "slide-right": "",
345
+ "full-page": "",
346
+ "full-page-reverse": "",
347
+ draggable: ""
348
+ }
349
+ },
350
+ defaultVariants: {
351
+ layout: "default"
352
+ }
353
+ }
354
+ );
355
+ var modalBodyVariants = cva(
356
+ ["modal-body", "nx:relative nx:overflow-y-auto nx:px-5 nx:pt-6", "nx:scrollbar-none"],
357
+ {
358
+ variants: {
359
+ layout: {
360
+ default: "",
361
+ "bottom-sheet": "nx:mt-6 nx:max-h-[calc(100vh-108px)] nx:p-0 nx:pb-6",
362
+ "slide-left": "nx:h-full nx:max-h-full nx:overflow-y-auto",
363
+ "slide-right": "nx:h-full nx:max-h-full nx:overflow-y-auto",
364
+ "full-page": "nx:h-full nx:max-h-full nx:overflow-y-auto nx:pb-0",
365
+ "full-page-reverse": "nx:h-full nx:max-h-full nx:overflow-y-auto nx:pb-0",
366
+ draggable: ""
367
+ },
368
+ hasHeader: {
369
+ true: "",
370
+ false: ""
371
+ },
372
+ hasFooter: {
373
+ true: "",
374
+ false: "nx:pb-6"
375
+ }
376
+ },
377
+ compoundVariants: [
378
+ {
379
+ layout: "default",
380
+ hasHeader: true,
381
+ class: "nx:max-h-[calc(90vh-var(--hd-height,60px))]"
382
+ },
383
+ {
384
+ layout: "default",
385
+ hasHeader: true,
386
+ hasFooter: true,
387
+ class: "nx:max-h-[calc(90vh-var(--ft-height,88px)-var(--hd-height,60px))]"
388
+ },
389
+ {
390
+ layout: "default",
391
+ hasFooter: true,
392
+ hasHeader: false,
393
+ class: "nx:max-h-[calc(90vh-var(--ft-height,88px))]"
394
+ },
395
+ {
396
+ layout: "bottom-sheet",
397
+ hasHeader: true,
398
+ class: "nx:max-h-[calc(100vh-var(--hd-height,60px)-124px)] nx:pb-0"
399
+ },
400
+ {
401
+ layout: "bottom-sheet",
402
+ hasHeader: true,
403
+ hasFooter: true,
404
+ class: "nx:max-h-[calc(100vh-var(--ft-height,88px)-var(--hd-height,60px)-100px)]"
405
+ },
406
+ {
407
+ layout: "full-page",
408
+ hasHeader: true,
409
+ class: "nx:max-h-[calc(100vh-var(--hd-height,60px))] nx:pb-0"
410
+ },
411
+ {
412
+ layout: "full-page",
413
+ hasHeader: true,
414
+ hasFooter: true,
415
+ class: "nx:max-h-[calc(100vh-var(--ft-height,88px)-var(--hd-height,60px))]"
416
+ },
417
+ {
418
+ layout: "full-page-reverse",
419
+ hasHeader: true,
420
+ class: "nx:max-h-[calc(100vh-var(--hd-height,60px))] nx:pb-0"
421
+ },
422
+ {
423
+ layout: "full-page-reverse",
424
+ hasHeader: true,
425
+ hasFooter: true,
426
+ class: "nx:max-h-[calc(100vh-var(--ft-height,88px)-var(--hd-height,60px))]"
427
+ },
428
+ {
429
+ layout: "slide-left",
430
+ hasHeader: true,
431
+ class: "nx:max-h-[calc(100%-var(--hd-height,60px))]"
432
+ },
433
+ {
434
+ layout: "slide-right",
435
+ hasHeader: true,
436
+ class: "nx:max-h-[calc(100%-var(--hd-height,60px))]"
437
+ }
438
+ ],
439
+ defaultVariants: {
440
+ layout: "default",
441
+ hasHeader: false,
442
+ hasFooter: false
443
+ }
444
+ }
445
+ );
446
+ var modalFooterVariants = cva(
447
+ [
448
+ "modal-footer",
449
+ "nx:absolute nx:bottom-0 nx:left-0 nx:z-[2] nx:flex nx:w-full nx:px-5 nx:py-6 nx:pb-5",
450
+ "nx:[&_button]:h-12 nx:[&_button]:flex-1"
451
+ ],
452
+ {
453
+ variants: {
454
+ layout: {
455
+ default: "",
456
+ "bottom-sheet": "nx:px-4 nx:py-3 nx:pb-6",
457
+ "slide-left": "",
458
+ "slide-right": "",
459
+ "full-page": "",
460
+ "full-page-reverse": "",
461
+ draggable: "nx:relative"
462
+ }
463
+ },
464
+ defaultVariants: {
465
+ layout: "default"
466
+ }
467
+ }
468
+ );
469
+ var modalDimVariants = cva(
470
+ "dim nx:pointer-events-auto nx:fixed nx:inset-0 nx:z-[1] nx:block nx:h-screen nx:w-screen nx:bg-static-black/75",
471
+ {
472
+ variants: {
473
+ visible: {
474
+ true: "",
475
+ false: "nx:hidden"
476
+ }
477
+ },
478
+ defaultVariants: {
479
+ visible: true
480
+ }
481
+ }
482
+ );
483
+ var CloseIcon = () => /* @__PURE__ */ jsx(
484
+ "svg",
485
+ {
486
+ className: "nx:w-5 nx:h-5 nx:text-text-muted",
487
+ fill: "none",
488
+ stroke: "currentColor",
489
+ viewBox: "0 0 24 24",
490
+ children: /* @__PURE__ */ jsx(
491
+ "path",
492
+ {
493
+ strokeLinecap: "round",
494
+ strokeLinejoin: "round",
495
+ strokeWidth: 2,
496
+ d: "M6 18L18 6M6 6l12 12"
497
+ }
498
+ )
499
+ }
500
+ );
501
+ var ModalTemplate = forwardRef(
502
+ ({
503
+ className,
504
+ layout = "default",
505
+ showDim = true,
506
+ innerClassName,
507
+ bodyClassName,
508
+ footerClassName,
509
+ dimClassName,
510
+ headerClassName,
511
+ children,
512
+ title,
513
+ desc,
514
+ hideHeader = false,
515
+ hideFooter = true,
516
+ dimClose,
517
+ footer,
518
+ close,
519
+ enableDrag = true,
520
+ dragPersistKey
521
+ }, ref) => {
522
+ const elRef = useRef(null);
523
+ const modalFooterRef = useRef(null);
524
+ const modalHeaderRef = useRef(null);
525
+ const innerRef = useRef(null);
526
+ const { dimCloseEnable } = getModalDefaultOption();
527
+ const isBottomSheet = layout === "bottom-sheet";
528
+ const isDraggable = layout === "draggable";
529
+ const dragHandlers = useDraggableBottomSheet({
530
+ enabled: isBottomSheet && enableDrag,
531
+ onClose: () => close(false),
532
+ threshold: 0.5,
533
+ velocityThreshold: 0.3
534
+ });
535
+ const windowDrag = useDraggableWindow({
536
+ persistKey: dragPersistKey,
537
+ initialPosition: { x: -1, y: -1 },
538
+ targetRef: innerRef
539
+ });
540
+ const closeModal2 = useCallback(() => {
541
+ if (!(dimClose ?? dimCloseEnable)) return;
542
+ close();
543
+ }, [close, dimClose, dimCloseEnable]);
544
+ useEffect(() => {
545
+ const modalFooterHeight = modalFooterRef.current?.getBoundingClientRect().height;
546
+ const modalHeaderHeight = modalHeaderRef.current?.getBoundingClientRect().height;
547
+ if (modalFooterHeight) {
548
+ document.documentElement.style.setProperty(
549
+ "--ft-height",
550
+ modalFooterHeight + "px"
551
+ );
552
+ }
553
+ if (modalHeaderHeight) {
554
+ document.documentElement.style.setProperty(
555
+ "--hd-height",
556
+ modalHeaderHeight + "px"
557
+ );
558
+ }
559
+ }, []);
560
+ useImperativeHandle(ref, () => elRef.current);
561
+ const hasHeader = !hideHeader;
562
+ const hasFooter = !hideFooter;
563
+ const wrapStyle = {};
564
+ const innerStyle = {};
565
+ if (isDraggable && !windowDrag.isDefaultPosition) {
566
+ wrapStyle.alignItems = "flex-start";
567
+ wrapStyle.justifyContent = "flex-start";
568
+ innerStyle.position = "fixed";
569
+ innerStyle.left = windowDrag.position.x;
570
+ innerStyle.top = windowDrag.position.y;
571
+ }
572
+ if (isBottomSheet) {
573
+ if (dragHandlers.translateY !== 0) {
574
+ innerStyle.transform = `translateY(${dragHandlers.translateY}px)`;
575
+ }
576
+ if (dragHandlers.isAnimating) {
577
+ innerStyle.transition = "transform 250ms cubic-bezier(0.32, 0.72, 0, 1)";
578
+ }
579
+ }
580
+ return /* @__PURE__ */ jsxs(
581
+ "div",
582
+ {
583
+ ref: elRef,
584
+ className: cn(modalWrapVariants({ layout }), className),
585
+ style: wrapStyle,
586
+ onTouchStart: isBottomSheet ? dragHandlers.onTouchStart : void 0,
587
+ onTouchMove: isBottomSheet ? dragHandlers.onTouchMove : void 0,
588
+ onTouchEnd: isBottomSheet ? dragHandlers.onTouchEnd : void 0,
589
+ children: [
590
+ showDim && !isDraggable && /* @__PURE__ */ jsx(
591
+ "div",
592
+ {
593
+ tabIndex: -1,
594
+ role: "button",
595
+ "aria-label": "modal-dim",
596
+ className: cn(modalDimVariants({ visible: showDim }), dimClassName),
597
+ style: isBottomSheet ? {
598
+ opacity: dragHandlers.dimOpacity,
599
+ transition: dragHandlers.isAnimating ? "opacity 250ms ease-out" : void 0
600
+ } : {
601
+ opacity: "var(--modal-dim-opacity, 0)",
602
+ transition: "opacity var(--modal-animation-duration, 300ms) ease"
603
+ },
604
+ onClick: closeModal2
605
+ }
606
+ ),
607
+ isDraggable && showDim && /* @__PURE__ */ jsx(
608
+ "div",
609
+ {
610
+ tabIndex: -1,
611
+ role: "button",
612
+ "aria-label": "modal-dim",
613
+ className: cn(
614
+ "dim nx:pointer-events-auto nx:fixed nx:inset-0 nx:z-[1] nx:block nx:h-screen nx:w-screen nx:bg-static-black/30",
615
+ dimClassName
616
+ ),
617
+ onClick: closeModal2
618
+ }
619
+ ),
620
+ /* @__PURE__ */ jsxs(
621
+ "div",
622
+ {
623
+ ref: innerRef,
624
+ className: cn(
625
+ modalInnerVariants({ layout, hasFooter }),
626
+ innerClassName
627
+ ),
628
+ style: innerStyle,
629
+ children: [
630
+ isBottomSheet && /* @__PURE__ */ jsx("span", { className: "nx:flex nx:w-full nx:justify-center nx:pt-3 nx:pb-2", children: /* @__PURE__ */ jsx("span", { className: "nx:bg-border-default nx:h-1.5 nx:w-16 nx:rounded-full" }) }),
631
+ /* @__PURE__ */ jsxs("div", { className: "nx:contents", children: [
632
+ hasHeader && /* @__PURE__ */ jsxs(
633
+ "header",
634
+ {
635
+ className: cn(modalHeaderVariants({ layout }), headerClassName),
636
+ ref: modalHeaderRef,
637
+ onMouseDown: isDraggable && enableDrag ? windowDrag.handleMouseDown : void 0,
638
+ children: [
639
+ /* @__PURE__ */ jsx(
640
+ "button",
641
+ {
642
+ className: modalCloseButtonVariants({ layout }),
643
+ onClick: () => close(),
644
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
645
+ }
646
+ ),
647
+ /* @__PURE__ */ jsxs("div", { className: "modal-header-inner", children: [
648
+ title && /* @__PURE__ */ jsx("h1", { className: modalTitleVariants({ layout }), children: title }),
649
+ desc && /* @__PURE__ */ jsx("p", { className: "modal-desc nx:text-text-muted nx:text-xs nx:mt-1", children: desc })
650
+ ] })
651
+ ]
652
+ }
653
+ ),
654
+ /* @__PURE__ */ jsx(
655
+ "section",
656
+ {
657
+ className: cn(
658
+ modalBodyVariants({ layout, hasHeader, hasFooter }),
659
+ bodyClassName
660
+ ),
661
+ children
662
+ }
663
+ ),
664
+ hasFooter && /* @__PURE__ */ jsx(
665
+ "footer",
666
+ {
667
+ ref: modalFooterRef,
668
+ className: cn(modalFooterVariants({ layout }), footerClassName),
669
+ children: footer
670
+ }
671
+ )
672
+ ] })
673
+ ]
674
+ }
675
+ )
676
+ ]
677
+ }
678
+ );
679
+ }
680
+ );
681
+ ModalTemplate.displayName = "ModalTemplate";
682
+ var ModalTemplate_default = ModalTemplate;
683
+
684
+ // src/modal/index.ts
685
+ var openModal = ((arg1, arg2 = {}) => {
686
+ if ("component" in arg1) {
687
+ const { component, props = {}, options = {} } = arg1;
688
+ return Modal_default.openModal({
689
+ component,
690
+ props: { ...props, ...options }
691
+ });
692
+ } else {
693
+ return Modal_default.openModal({
694
+ component: arg1,
695
+ props: arg2
696
+ });
697
+ }
698
+ });
699
+ var closeModal = (id, isAnimation) => {
700
+ return Modal_default.closeModal(id, isAnimation);
701
+ };
702
+ var checkModal = (params) => {
703
+ return Modal_default.checkModal(params);
704
+ };
705
+ var resetModal = () => {
706
+ return Modal_default.resetModal();
707
+ };
708
+ var getModalDefaultOption = () => {
709
+ return Modal_default.getDefaultOption();
710
+ };
711
+
712
+ export { ModalContainer_default, ModalPortalTarget_default, ModalTemplate_default, checkModal, closeModal, getModalDefaultOption, openModal, resetModal };