@nexus-cross/design-system 1.0.0

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 (319) hide show
  1. package/cursor-rules/nexus-project-setup.mdc +292 -0
  2. package/cursor-rules/nexus-ui-api.mdc +698 -0
  3. package/cursor-rules/nexus-ui-components.mdc +136 -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 +17 -0
  13. package/dist/button.d.ts +17 -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-26BUGBOY.mjs +57 -0
  30. package/dist/chunks/chunk-2JTPRBHZ.mjs +36 -0
  31. package/dist/chunks/chunk-2MC7XJSE.js +98 -0
  32. package/dist/chunks/chunk-2RPRCWKV.mjs +139 -0
  33. package/dist/chunks/chunk-2ZXDXO4I.js +166 -0
  34. package/dist/chunks/chunk-33UFQJIO.mjs +135 -0
  35. package/dist/chunks/chunk-3HHJORN7.mjs +137 -0
  36. package/dist/chunks/chunk-3PCNRCTB.js +61 -0
  37. package/dist/chunks/chunk-3VFBPFZF.mjs +640 -0
  38. package/dist/chunks/chunk-4J3GCZ7W.mjs +102 -0
  39. package/dist/chunks/chunk-54IA2P2Z.mjs +40 -0
  40. package/dist/chunks/chunk-54RBL7J4.mjs +179 -0
  41. package/dist/chunks/chunk-5JHJNN2K.js +83 -0
  42. package/dist/chunks/chunk-5JHN4FCY.mjs +58 -0
  43. package/dist/chunks/chunk-6FMDO6TT.mjs +114 -0
  44. package/dist/chunks/chunk-6H7V2I3X.mjs +270 -0
  45. package/dist/chunks/chunk-7AISZYWL.js +7 -0
  46. package/dist/chunks/chunk-7G65JBTN.js +133 -0
  47. package/dist/chunks/chunk-ADO7PDLY.mjs +66 -0
  48. package/dist/chunks/chunk-AFSEYJZT.js +267 -0
  49. package/dist/chunks/chunk-AOXXE5UQ.mjs +14 -0
  50. package/dist/chunks/chunk-AZ2URLDD.js +39 -0
  51. package/dist/chunks/chunk-B6G5TJRO.js +116 -0
  52. package/dist/chunks/chunk-BLGQHR3M.js +56 -0
  53. package/dist/chunks/chunk-BPUQ2CO2.mjs +48 -0
  54. package/dist/chunks/chunk-BSZ2LN6E.js +129 -0
  55. package/dist/chunks/chunk-CA3SOLI3.mjs +78 -0
  56. package/dist/chunks/chunk-CSJDDREF.js +90 -0
  57. package/dist/chunks/chunk-CVYXRSXT.mjs +8 -0
  58. package/dist/chunks/chunk-CZC76ZD5.js +10 -0
  59. package/dist/chunks/chunk-D6FII7HW.js +202 -0
  60. package/dist/chunks/chunk-DLFV7ZZV.js +112 -0
  61. package/dist/chunks/chunk-DO6VK2QQ.mjs +108 -0
  62. package/dist/chunks/chunk-ECVAVQUY.mjs +243 -0
  63. package/dist/chunks/chunk-EHAUUUWB.mjs +120 -0
  64. package/dist/chunks/chunk-EVOOTSY5.js +59 -0
  65. package/dist/chunks/chunk-GX6GSWX3.mjs +38 -0
  66. package/dist/chunks/chunk-HHXDOKXY.js +108 -0
  67. package/dist/chunks/chunk-HNLI646G.mjs +325 -0
  68. package/dist/chunks/chunk-HUPAHDJ7.js +273 -0
  69. package/dist/chunks/chunk-I252NERB.mjs +21 -0
  70. package/dist/chunks/chunk-IE4DGLMH.js +75 -0
  71. package/dist/chunks/chunk-INP2AH3B.js +27 -0
  72. package/dist/chunks/chunk-IOSIQLZL.js +70 -0
  73. package/dist/chunks/chunk-J5ZKGPBY.js +132 -0
  74. package/dist/chunks/chunk-JNMCYWGY.js +10 -0
  75. package/dist/chunks/chunk-LI7SFBUQ.mjs +89 -0
  76. package/dist/chunks/chunk-LMMON5AU.mjs +81 -0
  77. package/dist/chunks/chunk-LOQXCHKL.js +74 -0
  78. package/dist/chunks/chunk-MA2VCCIY.js +71 -0
  79. package/dist/chunks/chunk-MCKOWMLS.mjs +8 -0
  80. package/dist/chunks/chunk-MRRKW5QN.mjs +108 -0
  81. package/dist/chunks/chunk-MTX7GD3H.js +80 -0
  82. package/dist/chunks/chunk-NFIPQZ4O.js +100 -0
  83. package/dist/chunks/chunk-NHDGKOAM.js +104 -0
  84. package/dist/chunks/chunk-OMN5YQCE.js +143 -0
  85. package/dist/chunks/chunk-OTGS6BDQ.mjs +25 -0
  86. package/dist/chunks/chunk-P2T72N62.mjs +34 -0
  87. package/dist/chunks/chunk-P3DZKXG4.js +116 -0
  88. package/dist/chunks/chunk-QK6NCII4.js +36 -0
  89. package/dist/chunks/chunk-QZ4QR3XV.mjs +142 -0
  90. package/dist/chunks/chunk-RS3SBY3I.js +163 -0
  91. package/dist/chunks/chunk-RX5UKRYK.mjs +76 -0
  92. package/dist/chunks/chunk-SGNRVYYQ.mjs +99 -0
  93. package/dist/chunks/chunk-SJMCPSVH.mjs +76 -0
  94. package/dist/chunks/chunk-T2IY2TSR.js +43 -0
  95. package/dist/chunks/chunk-U53UA76K.js +653 -0
  96. package/dist/chunks/chunk-U56AGSLE.mjs +106 -0
  97. package/dist/chunks/chunk-ULGYTBCT.mjs +47 -0
  98. package/dist/chunks/chunk-V5OTJP6H.mjs +5 -0
  99. package/dist/chunks/chunk-VGO4Z2WH.js +336 -0
  100. package/dist/chunks/chunk-VIGRCJAE.mjs +37 -0
  101. package/dist/chunks/chunk-VVXQZ4XH.mjs +93 -0
  102. package/dist/chunks/chunk-W4GG5A7K.mjs +51 -0
  103. package/dist/chunks/chunk-WKCXACMZ.js +99 -0
  104. package/dist/chunks/chunk-WR55D4ZS.js +80 -0
  105. package/dist/chunks/chunk-X2SHTVZQ.js +89 -0
  106. package/dist/chunks/chunk-XEHFB62A.js +82 -0
  107. package/dist/chunks/chunk-XG6QG65W.mjs +63 -0
  108. package/dist/chunks/chunk-YB5ZKHVB.js +64 -0
  109. package/dist/chunks/chunk-YCG4FZC3.js +167 -0
  110. package/dist/chunks/chunk-YEWKPWK3.mjs +80 -0
  111. package/dist/chunks/chunk-YLO4UKSC.mjs +48 -0
  112. package/dist/chunks/chunk-YZV6FWE7.js +160 -0
  113. package/dist/chunks/chunk-ZWSIIGA3.mjs +58 -0
  114. package/dist/client-only.d.mts +13 -0
  115. package/dist/client-only.d.ts +13 -0
  116. package/dist/client-only.js +11 -0
  117. package/dist/client-only.mjs +2 -0
  118. package/dist/countdown.d.mts +27 -0
  119. package/dist/countdown.d.ts +27 -0
  120. package/dist/countdown.js +16 -0
  121. package/dist/countdown.mjs +3 -0
  122. package/dist/counter.d.mts +15 -0
  123. package/dist/counter.d.ts +15 -0
  124. package/dist/counter.js +11 -0
  125. package/dist/counter.mjs +2 -0
  126. package/dist/data-list.d.mts +33 -0
  127. package/dist/data-list.d.ts +33 -0
  128. package/dist/data-list.js +14 -0
  129. package/dist/data-list.mjs +5 -0
  130. package/dist/divider.d.mts +14 -0
  131. package/dist/divider.d.ts +14 -0
  132. package/dist/divider.js +16 -0
  133. package/dist/divider.mjs +3 -0
  134. package/dist/drawer.d.mts +42 -0
  135. package/dist/drawer.d.ts +42 -0
  136. package/dist/drawer.js +44 -0
  137. package/dist/drawer.mjs +3 -0
  138. package/dist/ellipsis.d.mts +16 -0
  139. package/dist/ellipsis.d.ts +16 -0
  140. package/dist/ellipsis.js +12 -0
  141. package/dist/ellipsis.mjs +3 -0
  142. package/dist/error-boundary.d.mts +20 -0
  143. package/dist/error-boundary.d.ts +20 -0
  144. package/dist/error-boundary.js +11 -0
  145. package/dist/error-boundary.mjs +2 -0
  146. package/dist/hooks/useCheckDevice.d.mts +47 -0
  147. package/dist/hooks/useCheckDevice.d.ts +47 -0
  148. package/dist/hooks/useCheckDevice.js +8 -0
  149. package/dist/hooks/useCheckDevice.mjs +2 -0
  150. package/dist/hooks/useClickOutside.d.mts +12 -0
  151. package/dist/hooks/useClickOutside.d.ts +12 -0
  152. package/dist/hooks/useClickOutside.js +8 -0
  153. package/dist/hooks/useClickOutside.mjs +2 -0
  154. package/dist/hooks/useDraggableBottomSheet.d.mts +24 -0
  155. package/dist/hooks/useDraggableBottomSheet.d.ts +24 -0
  156. package/dist/hooks/useDraggableBottomSheet.js +11 -0
  157. package/dist/hooks/useDraggableBottomSheet.mjs +2 -0
  158. package/dist/hooks/useDraggableWindow.d.mts +21 -0
  159. package/dist/hooks/useDraggableWindow.d.ts +21 -0
  160. package/dist/hooks/useDraggableWindow.js +11 -0
  161. package/dist/hooks/useDraggableWindow.mjs +2 -0
  162. package/dist/hooks/useInView.d.mts +14 -0
  163. package/dist/hooks/useInView.d.ts +14 -0
  164. package/dist/hooks/useInView.js +17 -0
  165. package/dist/hooks/useInView.mjs +2 -0
  166. package/dist/hooks/useModal.d.mts +2 -0
  167. package/dist/hooks/useModal.d.ts +2 -0
  168. package/dist/hooks/useModal.js +11 -0
  169. package/dist/hooks/useModal.mjs +2 -0
  170. package/dist/index.d.mts +76 -0
  171. package/dist/index.d.ts +76 -0
  172. package/dist/index.js +746 -0
  173. package/dist/index.mjs +328 -0
  174. package/dist/infinite-scroll.d.mts +26 -0
  175. package/dist/infinite-scroll.d.ts +26 -0
  176. package/dist/infinite-scroll.js +12 -0
  177. package/dist/infinite-scroll.mjs +3 -0
  178. package/dist/marquee.d.mts +12 -0
  179. package/dist/marquee.d.ts +12 -0
  180. package/dist/marquee.js +12 -0
  181. package/dist/marquee.mjs +3 -0
  182. package/dist/modal/index.d.mts +87 -0
  183. package/dist/modal/index.d.ts +87 -0
  184. package/dist/modal/index.js +54 -0
  185. package/dist/modal/index.mjs +9 -0
  186. package/dist/number-input.d.mts +38 -0
  187. package/dist/number-input.d.ts +38 -0
  188. package/dist/number-input.js +20 -0
  189. package/dist/number-input.mjs +3 -0
  190. package/dist/pagination.d.mts +22 -0
  191. package/dist/pagination.d.ts +22 -0
  192. package/dist/pagination.js +20 -0
  193. package/dist/pagination.mjs +3 -0
  194. package/dist/popover.d.mts +25 -0
  195. package/dist/popover.d.ts +25 -0
  196. package/dist/popover.js +32 -0
  197. package/dist/popover.mjs +3 -0
  198. package/dist/radio-group.d.mts +29 -0
  199. package/dist/radio-group.d.ts +29 -0
  200. package/dist/radio-group.js +24 -0
  201. package/dist/radio-group.mjs +3 -0
  202. package/dist/schemas/_all.json +2250 -0
  203. package/dist/schemas/accordion.json +101 -0
  204. package/dist/schemas/avatar.json +55 -0
  205. package/dist/schemas/button.json +71 -0
  206. package/dist/schemas/carousel.json +32 -0
  207. package/dist/schemas/carouselButton.json +20 -0
  208. package/dist/schemas/carouselDots.json +17 -0
  209. package/dist/schemas/carouselSlide.json +20 -0
  210. package/dist/schemas/checkBox.json +57 -0
  211. package/dist/schemas/chip.json +49 -0
  212. package/dist/schemas/clientOnly.json +19 -0
  213. package/dist/schemas/countdown.json +58 -0
  214. package/dist/schemas/counter.json +57 -0
  215. package/dist/schemas/dataList.json +56 -0
  216. package/dist/schemas/divider.json +40 -0
  217. package/dist/schemas/drawer.json +27 -0
  218. package/dist/schemas/drawerContent.json +50 -0
  219. package/dist/schemas/ellipsis.json +49 -0
  220. package/dist/schemas/errorBoundary.json +22 -0
  221. package/dist/schemas/infiniteScroll.json +65 -0
  222. package/dist/schemas/marquee.json +46 -0
  223. package/dist/schemas/modalCall.json +21 -0
  224. package/dist/schemas/modalTemplate.json +123 -0
  225. package/dist/schemas/numberInput.json +77 -0
  226. package/dist/schemas/pagination.json +50 -0
  227. package/dist/schemas/popover.json +67 -0
  228. package/dist/schemas/radioGroup.json +61 -0
  229. package/dist/schemas/radioItem.json +35 -0
  230. package/dist/schemas/select.json +62 -0
  231. package/dist/schemas/selectItem.json +31 -0
  232. package/dist/schemas/skeleton.json +48 -0
  233. package/dist/schemas/spinner.json +27 -0
  234. package/dist/schemas/switch.json +41 -0
  235. package/dist/schemas/tab.json +89 -0
  236. package/dist/schemas/table.json +75 -0
  237. package/dist/schemas/tableRow.json +32 -0
  238. package/dist/schemas/tdColumn.json +107 -0
  239. package/dist/schemas/textArea.json +44 -0
  240. package/dist/schemas/textInput.json +67 -0
  241. package/dist/schemas/themeProvider.json +65 -0
  242. package/dist/schemas/toaster.json +31 -0
  243. package/dist/schemas/tooltip.json +67 -0
  244. package/dist/schemas/virtualGrid.json +59 -0
  245. package/dist/schemas/virtualList.json +54 -0
  246. package/dist/schemas.d.mts +1263 -0
  247. package/dist/schemas.d.ts +1263 -0
  248. package/dist/schemas.js +513 -0
  249. package/dist/schemas.mjs +469 -0
  250. package/dist/select.d.mts +31 -0
  251. package/dist/select.d.ts +31 -0
  252. package/dist/select.js +24 -0
  253. package/dist/select.mjs +3 -0
  254. package/dist/skeleton.d.mts +15 -0
  255. package/dist/skeleton.d.ts +15 -0
  256. package/dist/skeleton.js +12 -0
  257. package/dist/skeleton.mjs +3 -0
  258. package/dist/spinner.d.mts +9 -0
  259. package/dist/spinner.d.ts +9 -0
  260. package/dist/spinner.js +12 -0
  261. package/dist/spinner.mjs +3 -0
  262. package/dist/styles/layer.d.mts +3 -0
  263. package/dist/styles/layer.d.ts +3 -0
  264. package/dist/styles/layer.js +18 -0
  265. package/dist/styles/layer.mjs +16 -0
  266. package/dist/styles.css +2401 -0
  267. package/dist/styles.d.mts +3 -0
  268. package/dist/styles.d.ts +3 -0
  269. package/dist/styles.js +16 -0
  270. package/dist/styles.layered.css +2404 -0
  271. package/dist/styles.mjs +14 -0
  272. package/dist/switch.d.mts +15 -0
  273. package/dist/switch.d.ts +15 -0
  274. package/dist/switch.js +16 -0
  275. package/dist/switch.mjs +3 -0
  276. package/dist/tab.d.mts +36 -0
  277. package/dist/tab.d.ts +36 -0
  278. package/dist/tab.js +20 -0
  279. package/dist/tab.mjs +3 -0
  280. package/dist/table.d.mts +80 -0
  281. package/dist/table.d.ts +80 -0
  282. package/dist/table.js +33 -0
  283. package/dist/table.mjs +4 -0
  284. package/dist/text-area.d.mts +15 -0
  285. package/dist/text-area.d.ts +15 -0
  286. package/dist/text-area.js +16 -0
  287. package/dist/text-area.mjs +3 -0
  288. package/dist/text-input.d.mts +21 -0
  289. package/dist/text-input.d.ts +21 -0
  290. package/dist/text-input.js +16 -0
  291. package/dist/text-input.mjs +3 -0
  292. package/dist/theme-provider.d.mts +25 -0
  293. package/dist/theme-provider.d.ts +25 -0
  294. package/dist/theme-provider.js +15 -0
  295. package/dist/theme-provider.mjs +2 -0
  296. package/dist/toast.d.mts +42 -0
  297. package/dist/toast.d.ts +42 -0
  298. package/dist/toast.js +20 -0
  299. package/dist/toast.mjs +3 -0
  300. package/dist/tooltip.d.mts +24 -0
  301. package/dist/tooltip.d.ts +24 -0
  302. package/dist/tooltip.js +20 -0
  303. package/dist/tooltip.mjs +3 -0
  304. package/dist/useModal-BsGIcP8t.d.mts +128 -0
  305. package/dist/useModal-BsGIcP8t.d.ts +128 -0
  306. package/dist/utils/cn.d.mts +5 -0
  307. package/dist/utils/cn.d.ts +5 -0
  308. package/dist/utils/cn.js +11 -0
  309. package/dist/utils/cn.mjs +2 -0
  310. package/dist/utils/scroll.d.mts +4 -0
  311. package/dist/utils/scroll.d.ts +4 -0
  312. package/dist/utils/scroll.js +15 -0
  313. package/dist/utils/scroll.mjs +2 -0
  314. package/dist/virtual-scroll.d.mts +34 -0
  315. package/dist/virtual-scroll.d.ts +34 -0
  316. package/dist/virtual-scroll.js +16 -0
  317. package/dist/virtual-scroll.mjs +3 -0
  318. package/package.json +291 -0
  319. package/scripts/setup-cursor-rules.cjs +92 -0
@@ -0,0 +1,640 @@
1
+ import { useDraggableBottomSheet } from './chunk-U56AGSLE.mjs';
2
+ import { useDraggableWindow } from './chunk-4J3GCZ7W.mjs';
3
+ import { scrollRelease, scrollFreeze } from './chunk-54IA2P2Z.mjs';
4
+ import { useCheckDevice_default } from './chunk-YEWKPWK3.mjs';
5
+ import { useClickOutside_default } from './chunk-OTGS6BDQ.mjs';
6
+ import { Modal_default } from './chunk-6H7V2I3X.mjs';
7
+ import { cn } from './chunk-MCKOWMLS.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 = ["nexus-modal-component"];
123
+ if (modal.props.portalId) {
124
+ baseClasses.push("nexus-modal-component--portal");
125
+ }
126
+ if (["enter", "enter-done", "leave"].includes(status)) {
127
+ baseClasses.push("nexus-modal-component--visible");
128
+ }
129
+ if (status === "enter") {
130
+ baseClasses.push("nexus-modal-component--enter");
131
+ } else if (status === "leave") {
132
+ baseClasses.push("nexus-modal-component--leave");
133
+ }
134
+ if (className) {
135
+ baseClasses.push(className);
136
+ }
137
+ return baseClasses.join(" ");
138
+ };
139
+ const dimOpacity = status === "enter" || status === "enter-done" ? 1 : 0;
140
+ const getModalStyle = () => {
141
+ return {
142
+ "--modal-animation-name": status === "enter" || status === "leave" ? `modal-${animationInfo.name}` : "",
143
+ "--modal-animation-direction": status === "leave" ? "reverse" : "normal",
144
+ "--modal-animation-fill-mode": status === "leave" ? "forwards" : "",
145
+ "--modal-animation-duration": `${animationInfo.duration}ms`,
146
+ "--modal-animation-timing-function": status === "leave" ? animationInfo.leaveTimingFunction : animationInfo.timingFunction,
147
+ "--modal-dim-opacity": dimOpacity
148
+ };
149
+ };
150
+ return /* @__PURE__ */ jsx("div", { className: getModalClassName(), style: getModalStyle(), children: /* @__PURE__ */ jsx(
151
+ Component,
152
+ {
153
+ is: modal.component,
154
+ props: {
155
+ ...modal.props,
156
+ className: status,
157
+ layout: resolvedLayout,
158
+ close: (isAnimation) => close(modal.id, isAnimation),
159
+ resolve: (result, useClose = true) => resolve(modal, result, useClose)
160
+ },
161
+ handleOpenStatus
162
+ },
163
+ modal.id
164
+ ) });
165
+ }
166
+ );
167
+ ModalComponent.displayName = "ModalComponent";
168
+ var ModalComponent_default = ModalComponent;
169
+ var ModalPortal = ({ children, selector }) => {
170
+ const [mounted, setMounted] = useState(false);
171
+ let element = null;
172
+ if (typeof window !== "undefined") {
173
+ const elements = document.querySelectorAll(
174
+ selector.includes("#") ? selector : `#${selector}`
175
+ );
176
+ if (elements.length === 1) {
177
+ element = elements[0];
178
+ }
179
+ }
180
+ useEffect(() => {
181
+ setMounted(true);
182
+ return () => setMounted(false);
183
+ }, []);
184
+ return mounted && element && children ? createPortal(children, element) : null;
185
+ };
186
+ var ModalPortal_default = ModalPortal;
187
+ var ModalContainer = ({ className = "", breakPoints, ...defaultOption }) => {
188
+ const [modals, setModals] = useState(Modal_default.modalList);
189
+ const setModalClose = useCallback((params) => {
190
+ if (!params) return;
191
+ const { modalId, hasClose, close } = params;
192
+ if (!hasClose) {
193
+ Modal_default.modalList = Modal_default.modalList.map(
194
+ (m) => m.id === modalId ? { ...m, close } : m
195
+ );
196
+ }
197
+ }, []);
198
+ useEffect(() => {
199
+ Modal_default.observe({ options: defaultOption, observeFunction: setModals });
200
+ return () => {
201
+ Modal_default.unobserve();
202
+ };
203
+ }, [defaultOption]);
204
+ return /* @__PURE__ */ jsx("div", { id: "modal-wrapper", className, children: modals.map(
205
+ (m) => m.props.portalId ? /* @__PURE__ */ jsx(ModalPortal_default, { selector: m.props.portalId, children: /* @__PURE__ */ jsx(
206
+ ModalComponent_default,
207
+ {
208
+ ref: setModalClose,
209
+ modal: m,
210
+ breakPoints,
211
+ deleteModal: (id) => Modal_default.deleteModal(id),
212
+ resolveModal: (params) => Modal_default.resolveModal(params),
213
+ scrollFreeze,
214
+ scrollRelease
215
+ },
216
+ m.id
217
+ ) }, m.id) : /* @__PURE__ */ jsx(
218
+ ModalComponent_default,
219
+ {
220
+ ref: setModalClose,
221
+ modal: m,
222
+ breakPoints,
223
+ deleteModal: (id) => Modal_default.deleteModal(id),
224
+ resolveModal: (params) => Modal_default.resolveModal(params),
225
+ scrollFreeze,
226
+ scrollRelease
227
+ },
228
+ m.id
229
+ )
230
+ ) });
231
+ };
232
+ var ModalContainer_default = ModalContainer;
233
+ var ModalPortalTarget = ({ id, className }) => {
234
+ return /* @__PURE__ */ jsx("div", { id, className: cn("nexus-modal-portal-target", className) });
235
+ };
236
+ var ModalPortalTarget_default = ModalPortalTarget;
237
+ var modalWrapVariants = cva("nexus-modal-wrap", {
238
+ variants: {
239
+ layout: {
240
+ default: "",
241
+ "bottom-sheet": "nexus-modal-wrap--bottom-sheet",
242
+ "slide-left": "nexus-modal-wrap--slide-left",
243
+ "slide-right": "nexus-modal-wrap--slide-right",
244
+ "full-page": "nexus-modal-wrap--full-page",
245
+ "full-page-reverse": "nexus-modal-wrap--full-page-reverse",
246
+ draggable: ""
247
+ }
248
+ },
249
+ defaultVariants: {
250
+ layout: "default"
251
+ }
252
+ });
253
+ var modalInnerVariants = cva("nexus-modal-inner", {
254
+ variants: {
255
+ layout: {
256
+ default: "",
257
+ "bottom-sheet": "nexus-modal-inner--bottom-sheet",
258
+ "slide-left": "nexus-modal-inner--slide-left",
259
+ "slide-right": "nexus-modal-inner--slide-right",
260
+ "full-page": "nexus-modal-inner--full-page",
261
+ "full-page-reverse": "nexus-modal-inner--full-page-reverse",
262
+ draggable: "nexus-modal-inner--draggable"
263
+ },
264
+ hasFooter: {
265
+ true: "nexus-modal-inner--has-footer",
266
+ false: ""
267
+ }
268
+ },
269
+ compoundVariants: [
270
+ { layout: "bottom-sheet", hasFooter: true, class: "nexus-modal-inner--bottom-sheet nexus-modal-inner--has-footer" }
271
+ ],
272
+ defaultVariants: {
273
+ layout: "default",
274
+ hasFooter: false
275
+ }
276
+ });
277
+ var modalHeaderVariants = cva("nexus-modal-header", {
278
+ variants: {
279
+ layout: {
280
+ default: "",
281
+ "bottom-sheet": "nexus-modal-header--bottom-sheet",
282
+ "slide-left": "",
283
+ "slide-right": "",
284
+ "full-page": "",
285
+ "full-page-reverse": "",
286
+ draggable: "nexus-modal-header--draggable"
287
+ }
288
+ },
289
+ defaultVariants: {
290
+ layout: "default"
291
+ }
292
+ });
293
+ var modalCloseButtonVariants = cva("nexus-modal-close-btn", {
294
+ variants: {
295
+ layout: {
296
+ default: "",
297
+ "bottom-sheet": "nexus-modal-close-btn--bottom-sheet",
298
+ "slide-left": "",
299
+ "slide-right": "",
300
+ "full-page": "",
301
+ "full-page-reverse": "",
302
+ draggable: ""
303
+ }
304
+ },
305
+ defaultVariants: {
306
+ layout: "default"
307
+ }
308
+ });
309
+ var modalTitleVariants = cva("nexus-modal-title", {
310
+ variants: {
311
+ layout: {
312
+ default: "",
313
+ "bottom-sheet": "nexus-modal-title--bottom-sheet",
314
+ "slide-left": "",
315
+ "slide-right": "",
316
+ "full-page": "",
317
+ "full-page-reverse": "",
318
+ draggable: ""
319
+ }
320
+ },
321
+ defaultVariants: {
322
+ layout: "default"
323
+ }
324
+ });
325
+ var modalBodyVariants = cva("nexus-modal-body", {
326
+ variants: {
327
+ layout: {
328
+ default: "",
329
+ "bottom-sheet": "nexus-modal-body--bottom-sheet",
330
+ "slide-left": "nexus-modal-body--slide",
331
+ "slide-right": "nexus-modal-body--slide",
332
+ "full-page": "nexus-modal-body--full-page",
333
+ "full-page-reverse": "nexus-modal-body--full-page",
334
+ draggable: ""
335
+ },
336
+ hasHeader: {
337
+ true: "",
338
+ false: ""
339
+ },
340
+ hasFooter: {
341
+ true: "",
342
+ false: "nexus-modal-body--no-footer"
343
+ }
344
+ },
345
+ defaultVariants: {
346
+ layout: "default",
347
+ hasHeader: false,
348
+ hasFooter: false
349
+ }
350
+ });
351
+ var modalFooterVariants = cva("nexus-modal-footer", {
352
+ variants: {
353
+ layout: {
354
+ default: "",
355
+ "bottom-sheet": "nexus-modal-footer--bottom-sheet",
356
+ "slide-left": "",
357
+ "slide-right": "",
358
+ "full-page": "",
359
+ "full-page-reverse": "",
360
+ draggable: "nexus-modal-footer--draggable"
361
+ }
362
+ },
363
+ defaultVariants: {
364
+ layout: "default"
365
+ }
366
+ });
367
+ var modalDimVariants = cva("nexus-modal-dim", {
368
+ variants: {
369
+ visible: {
370
+ true: "",
371
+ false: "nexus-modal-dim--hidden"
372
+ }
373
+ },
374
+ defaultVariants: {
375
+ visible: true
376
+ }
377
+ });
378
+ var CloseIcon = () => /* @__PURE__ */ jsx(
379
+ "svg",
380
+ {
381
+ className: "nexus-modal-close-icon",
382
+ fill: "none",
383
+ stroke: "currentColor",
384
+ viewBox: "0 0 24 24",
385
+ children: /* @__PURE__ */ jsx(
386
+ "path",
387
+ {
388
+ strokeLinecap: "round",
389
+ strokeLinejoin: "round",
390
+ strokeWidth: 2,
391
+ d: "M6 18L18 6M6 6l12 12"
392
+ }
393
+ )
394
+ }
395
+ );
396
+ var ModalTemplate = forwardRef(
397
+ ({
398
+ className,
399
+ layout = "default",
400
+ showDim = true,
401
+ innerClassName,
402
+ bodyClassName,
403
+ footerClassName,
404
+ dimClassName,
405
+ headerClassName,
406
+ children,
407
+ title,
408
+ desc,
409
+ hideHeader = false,
410
+ hideFooter = true,
411
+ dimClose,
412
+ footer,
413
+ close,
414
+ enableDrag = true,
415
+ dragPersistKey
416
+ }, ref) => {
417
+ const elRef = useRef(null);
418
+ const modalFooterRef = useRef(null);
419
+ const modalHeaderRef = useRef(null);
420
+ const innerRef = useRef(null);
421
+ const { dimCloseEnable } = getModalDefaultOption();
422
+ const isBottomSheet = layout === "bottom-sheet";
423
+ const isDraggable = layout === "draggable";
424
+ const dragHandlers = useDraggableBottomSheet({
425
+ enabled: isBottomSheet && enableDrag,
426
+ onClose: () => close(false),
427
+ threshold: 0.5,
428
+ velocityThreshold: 0.3
429
+ });
430
+ const windowDrag = useDraggableWindow({
431
+ persistKey: dragPersistKey,
432
+ initialPosition: { x: -1, y: -1 },
433
+ targetRef: innerRef
434
+ });
435
+ const closeModal2 = useCallback(() => {
436
+ if (!(dimClose ?? dimCloseEnable)) return;
437
+ close();
438
+ }, [close, dimClose, dimCloseEnable]);
439
+ useEffect(() => {
440
+ const modalFooterHeight = modalFooterRef.current?.getBoundingClientRect().height;
441
+ const modalHeaderHeight = modalHeaderRef.current?.getBoundingClientRect().height;
442
+ if (modalFooterHeight) {
443
+ document.documentElement.style.setProperty(
444
+ "--ft-height",
445
+ modalFooterHeight + "px"
446
+ );
447
+ }
448
+ if (modalHeaderHeight) {
449
+ document.documentElement.style.setProperty(
450
+ "--hd-height",
451
+ modalHeaderHeight + "px"
452
+ );
453
+ }
454
+ }, []);
455
+ useImperativeHandle(ref, () => elRef.current);
456
+ useEffect(() => {
457
+ const inner = innerRef.current;
458
+ if (!inner) return;
459
+ const focusableSelector = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
460
+ const handleKeyDown = (e) => {
461
+ if (e.key !== "Tab") return;
462
+ const focusable = inner.querySelectorAll(focusableSelector);
463
+ if (focusable.length === 0) return;
464
+ const first = focusable[0];
465
+ const last = focusable[focusable.length - 1];
466
+ if (e.shiftKey) {
467
+ if (document.activeElement === first) {
468
+ e.preventDefault();
469
+ last.focus();
470
+ }
471
+ } else {
472
+ if (document.activeElement === last) {
473
+ e.preventDefault();
474
+ first.focus();
475
+ }
476
+ }
477
+ };
478
+ inner.addEventListener("keydown", handleKeyDown);
479
+ const prev = document.activeElement;
480
+ const firstFocusable = inner.querySelector(focusableSelector);
481
+ firstFocusable?.focus();
482
+ return () => {
483
+ inner.removeEventListener("keydown", handleKeyDown);
484
+ prev?.focus();
485
+ };
486
+ }, []);
487
+ const hasHeader = !hideHeader;
488
+ const hasFooter = !hideFooter;
489
+ const wrapStyle = {};
490
+ const innerStyle = {};
491
+ if (isDraggable && !windowDrag.isDefaultPosition) {
492
+ wrapStyle.alignItems = "flex-start";
493
+ wrapStyle.justifyContent = "flex-start";
494
+ innerStyle.position = "fixed";
495
+ innerStyle.left = windowDrag.position.x;
496
+ innerStyle.top = windowDrag.position.y;
497
+ }
498
+ if (isBottomSheet) {
499
+ if (dragHandlers.translateY !== 0) {
500
+ innerStyle.transform = `translateY(${dragHandlers.translateY}px)`;
501
+ }
502
+ if (dragHandlers.isAnimating) {
503
+ innerStyle.transition = "transform 250ms cubic-bezier(0.32, 0.72, 0, 1)";
504
+ }
505
+ }
506
+ return /* @__PURE__ */ jsxs(
507
+ "div",
508
+ {
509
+ ref: elRef,
510
+ className: cn(modalWrapVariants({ layout }), className),
511
+ style: wrapStyle,
512
+ onTouchStart: isBottomSheet ? dragHandlers.onTouchStart : void 0,
513
+ onTouchMove: isBottomSheet ? dragHandlers.onTouchMove : void 0,
514
+ onTouchEnd: isBottomSheet ? dragHandlers.onTouchEnd : void 0,
515
+ children: [
516
+ showDim && !isDraggable && /* @__PURE__ */ jsx(
517
+ "div",
518
+ {
519
+ tabIndex: -1,
520
+ role: "button",
521
+ "aria-label": "modal-dim",
522
+ className: cn(modalDimVariants({ visible: showDim }), dimClassName),
523
+ style: isBottomSheet ? {
524
+ opacity: dragHandlers.dimOpacity,
525
+ transition: dragHandlers.isAnimating ? "opacity 250ms ease-out" : void 0
526
+ } : {
527
+ opacity: "var(--modal-dim-opacity, 0)",
528
+ transition: "opacity var(--modal-animation-duration, 300ms) ease"
529
+ },
530
+ onClick: closeModal2
531
+ }
532
+ ),
533
+ isDraggable && showDim && /* @__PURE__ */ jsx(
534
+ "div",
535
+ {
536
+ tabIndex: -1,
537
+ role: "button",
538
+ "aria-label": "modal-dim",
539
+ className: cn("nexus-modal-dim nexus-modal-dim--draggable", dimClassName),
540
+ onClick: closeModal2
541
+ }
542
+ ),
543
+ /* @__PURE__ */ jsxs(
544
+ "div",
545
+ {
546
+ ref: innerRef,
547
+ role: "dialog",
548
+ "aria-modal": "true",
549
+ "aria-label": typeof title === "string" ? title : void 0,
550
+ className: cn(
551
+ modalInnerVariants({ layout, hasFooter }),
552
+ innerClassName
553
+ ),
554
+ style: innerStyle,
555
+ children: [
556
+ isBottomSheet && /* @__PURE__ */ jsx("span", { className: "nexus-modal-bottom-sheet-handle", children: /* @__PURE__ */ jsx("span", { className: "nexus-modal-bottom-sheet-bar" }) }),
557
+ /* @__PURE__ */ jsxs("div", { className: "nexus-contents", children: [
558
+ hasHeader && /* @__PURE__ */ jsxs(
559
+ "header",
560
+ {
561
+ className: cn(modalHeaderVariants({ layout }), headerClassName),
562
+ ref: modalHeaderRef,
563
+ onMouseDown: isDraggable && enableDrag ? windowDrag.handleMouseDown : void 0,
564
+ children: [
565
+ /* @__PURE__ */ jsx(
566
+ "button",
567
+ {
568
+ type: "button",
569
+ className: modalCloseButtonVariants({ layout }),
570
+ onClick: () => close(),
571
+ "aria-label": "Close",
572
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
573
+ }
574
+ ),
575
+ /* @__PURE__ */ jsxs("div", { className: "modal-header-inner", children: [
576
+ title && /* @__PURE__ */ jsx("h1", { className: modalTitleVariants({ layout }), children: title }),
577
+ desc && /* @__PURE__ */ jsx("p", { className: "nexus-modal-desc", children: desc })
578
+ ] })
579
+ ]
580
+ }
581
+ ),
582
+ /* @__PURE__ */ jsx(
583
+ "section",
584
+ {
585
+ className: cn(
586
+ modalBodyVariants({ layout, hasHeader, hasFooter }),
587
+ bodyClassName
588
+ ),
589
+ children
590
+ }
591
+ ),
592
+ hasFooter && /* @__PURE__ */ jsx(
593
+ "footer",
594
+ {
595
+ ref: modalFooterRef,
596
+ className: cn(modalFooterVariants({ layout }), footerClassName),
597
+ children: footer
598
+ }
599
+ )
600
+ ] })
601
+ ]
602
+ }
603
+ )
604
+ ]
605
+ }
606
+ );
607
+ }
608
+ );
609
+ ModalTemplate.displayName = "ModalTemplate";
610
+ var ModalTemplate_default = ModalTemplate;
611
+
612
+ // src/modal/index.ts
613
+ var openModal = ((arg1, arg2 = {}) => {
614
+ if ("component" in arg1) {
615
+ const { component, props = {}, options = {} } = arg1;
616
+ return Modal_default.openModal({
617
+ component,
618
+ props: { ...props, ...options }
619
+ });
620
+ } else {
621
+ return Modal_default.openModal({
622
+ component: arg1,
623
+ props: arg2
624
+ });
625
+ }
626
+ });
627
+ var closeModal = (id, isAnimation) => {
628
+ return Modal_default.closeModal(id, isAnimation);
629
+ };
630
+ var checkModal = (params) => {
631
+ return Modal_default.checkModal(params);
632
+ };
633
+ var resetModal = () => {
634
+ return Modal_default.resetModal();
635
+ };
636
+ var getModalDefaultOption = () => {
637
+ return Modal_default.getDefaultOption();
638
+ };
639
+
640
+ export { ModalContainer_default, ModalPortalTarget_default, ModalTemplate_default, checkModal, closeModal, getModalDefaultOption, openModal, resetModal };