dn-react-router-toolkit 0.1.1 → 0.1.3

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 (284) hide show
  1. package/dist/auth-kit/apple_auth.d.mts +24 -0
  2. package/dist/{esm/auth-kit → auth-kit}/apple_auth.d.ts +11 -2
  3. package/dist/auth-kit/apple_auth.js +75 -0
  4. package/dist/auth-kit/apple_auth.mjs +50 -0
  5. package/dist/auth-kit/auth_service.d.mts +73 -0
  6. package/dist/{esm/auth-kit → auth-kit}/auth_service.d.ts +17 -11
  7. package/dist/auth-kit/auth_service.js +257 -0
  8. package/dist/auth-kit/auth_service.mjs +218 -0
  9. package/dist/auth-kit/client/google_login_button.d.mts +9 -0
  10. package/dist/auth-kit/client/google_login_button.d.ts +9 -0
  11. package/dist/auth-kit/client/google_login_button.js +67 -0
  12. package/dist/auth-kit/client/google_login_button.mjs +32 -0
  13. package/dist/auth-kit/client/redirect_page.d.mts +5 -0
  14. package/dist/auth-kit/client/redirect_page.d.ts +5 -0
  15. package/dist/auth-kit/client/redirect_page.js +53 -0
  16. package/dist/auth-kit/client/redirect_page.mjs +18 -0
  17. package/dist/auth-kit/google_auth.d.mts +27 -0
  18. package/dist/{esm/auth-kit → auth-kit}/google_auth.d.ts +11 -2
  19. package/dist/auth-kit/google_auth.js +144 -0
  20. package/dist/auth-kit/google_auth.mjs +117 -0
  21. package/dist/auth-kit/jwt.d.mts +18 -0
  22. package/dist/{esm/auth-kit → auth-kit}/jwt.d.ts +5 -2
  23. package/dist/auth-kit/jwt.js +76 -0
  24. package/dist/auth-kit/jwt.mjs +51 -0
  25. package/dist/auth-kit/kakao_auth.d.mts +24 -0
  26. package/dist/{esm/auth-kit → auth-kit}/kakao_auth.d.ts +11 -2
  27. package/dist/auth-kit/kakao_auth.js +115 -0
  28. package/dist/auth-kit/kakao_auth.mjs +88 -0
  29. package/dist/auth-kit/repository.d.mts +42 -0
  30. package/dist/{esm/auth-kit → auth-kit}/repository.d.ts +3 -1
  31. package/dist/auth-kit/repository.js +18 -0
  32. package/dist/auth-kit/repository.mjs +0 -0
  33. package/dist/auth-kit/with_auth.d.mts +17 -0
  34. package/dist/auth-kit/with_auth.d.ts +17 -0
  35. package/dist/auth-kit/with_auth.js +106 -0
  36. package/dist/auth-kit/with_auth.mjs +69 -0
  37. package/dist/cn.d.mts +3 -0
  38. package/dist/cn.d.ts +3 -0
  39. package/dist/cn.js +32 -0
  40. package/dist/cn.mjs +7 -0
  41. package/dist/components/index.d.mts +5 -0
  42. package/dist/components/index.d.ts +5 -0
  43. package/dist/components/index.js +261 -0
  44. package/dist/components/index.mjs +219 -0
  45. package/dist/components/modal/fullscreen_container.d.mts +7 -0
  46. package/dist/components/modal/fullscreen_container.d.ts +7 -0
  47. package/dist/components/modal/fullscreen_container.js +102 -0
  48. package/dist/components/modal/fullscreen_container.mjs +68 -0
  49. package/dist/components/modal/hooks.d.mts +18 -0
  50. package/dist/components/modal/hooks.d.ts +18 -0
  51. package/dist/components/modal/hooks.js +236 -0
  52. package/dist/components/modal/hooks.mjs +204 -0
  53. package/dist/components/modal/index.d.mts +4 -0
  54. package/dist/components/modal/index.d.ts +4 -0
  55. package/dist/components/modal/index.js +238 -0
  56. package/dist/components/modal/index.mjs +203 -0
  57. package/dist/components/modal/modal.d.mts +13 -0
  58. package/dist/components/modal/modal.d.ts +13 -0
  59. package/dist/components/modal/modal.js +155 -0
  60. package/dist/components/modal/modal.mjs +130 -0
  61. package/dist/components/styles.d.mts +9 -0
  62. package/dist/components/styles.d.ts +9 -0
  63. package/dist/components/styles.js +48 -0
  64. package/dist/components/styles.mjs +17 -0
  65. package/dist/date.d.mts +3 -0
  66. package/dist/date.d.ts +3 -0
  67. package/dist/date.js +63 -0
  68. package/dist/date.mjs +28 -0
  69. package/dist/file-kit/cdn.d.mts +5 -0
  70. package/dist/file-kit/cdn.d.ts +5 -0
  71. package/dist/file-kit/cdn.js +34 -0
  72. package/dist/file-kit/cdn.mjs +9 -0
  73. package/dist/file-kit/client/drop_file_input.d.mts +33 -0
  74. package/dist/{esm/file-kit → file-kit}/client/drop_file_input.d.ts +10 -8
  75. package/dist/file-kit/client/drop_file_input.js +235 -0
  76. package/dist/file-kit/client/drop_file_input.mjs +205 -0
  77. package/dist/file-kit/client/file_uploader.d.mts +13 -0
  78. package/dist/{esm/file-kit → file-kit}/client/file_uploader.d.ts +4 -2
  79. package/dist/file-kit/client/file_uploader.js +115 -0
  80. package/dist/file-kit/client/file_uploader.mjs +90 -0
  81. package/dist/file-kit/file_service.d.mts +26 -0
  82. package/dist/{esm/file-kit → file-kit}/file_service.d.ts +7 -4
  83. package/dist/file-kit/file_service.js +60 -0
  84. package/dist/file-kit/file_service.mjs +35 -0
  85. package/dist/file-kit/object_storage.d.mts +17 -0
  86. package/dist/{esm/file-kit → file-kit}/object_storage.d.ts +6 -2
  87. package/dist/file-kit/object_storage.js +78 -0
  88. package/dist/file-kit/object_storage.mjs +57 -0
  89. package/dist/file-kit/repository.d.mts +16 -0
  90. package/dist/{esm/file-kit → file-kit}/repository.d.ts +3 -1
  91. package/dist/file-kit/repository.js +18 -0
  92. package/dist/file-kit/repository.mjs +0 -0
  93. package/dist/file-kit/responsive_image.d.mts +20 -0
  94. package/dist/file-kit/responsive_image.d.ts +20 -0
  95. package/dist/file-kit/responsive_image.js +123 -0
  96. package/dist/file-kit/responsive_image.mjs +87 -0
  97. package/dist/http-kit/index.d.mts +1 -0
  98. package/dist/http-kit/index.d.ts +1 -0
  99. package/dist/http-kit/index.js +111 -0
  100. package/dist/http-kit/index.mjs +68 -0
  101. package/dist/http-kit/response.d.mts +19 -0
  102. package/dist/http-kit/response.d.ts +19 -0
  103. package/dist/http-kit/response.js +109 -0
  104. package/dist/http-kit/response.mjs +68 -0
  105. package/dist/index.d.mts +4 -0
  106. package/dist/index.d.ts +4 -0
  107. package/dist/index.js +91 -0
  108. package/dist/index.mjs +51 -0
  109. package/dist/route/api/auth/login/[provider]/route.js +113 -0
  110. package/dist/route/api/auth/login/[provider]/route.mjs +86 -0
  111. package/dist/route/api/auth/login/_provider_/route.d.mts +20 -0
  112. package/dist/route/api/auth/login/_provider_/route.d.ts +20 -0
  113. package/dist/route/api/auth/login/route.d.mts +14 -0
  114. package/dist/route/api/auth/login/route.d.ts +14 -0
  115. package/dist/route/api/auth/login/route.js +107 -0
  116. package/dist/route/api/auth/login/route.mjs +80 -0
  117. package/dist/route/api/auth/logout/route.d.mts +14 -0
  118. package/dist/route/api/auth/logout/route.d.ts +14 -0
  119. package/dist/route/api/auth/logout/route.js +98 -0
  120. package/dist/route/api/auth/logout/route.mjs +71 -0
  121. package/dist/route/api/auth/refresh/route.d.mts +13 -0
  122. package/dist/route/api/auth/refresh/route.d.ts +13 -0
  123. package/dist/route/api/auth/refresh/route.js +92 -0
  124. package/dist/route/api/auth/refresh/route.mjs +65 -0
  125. package/dist/route/api/auth/route.d.mts +13 -0
  126. package/dist/route/api/auth/route.d.ts +13 -0
  127. package/dist/route/api/auth/route.js +82 -0
  128. package/dist/route/api/auth/route.mjs +55 -0
  129. package/dist/route/api/files/[fileId]/route.js +99 -0
  130. package/dist/route/api/files/[fileId]/route.mjs +72 -0
  131. package/dist/route/api/files/_fileId_/route.d.mts +17 -0
  132. package/dist/route/api/files/_fileId_/route.d.ts +17 -0
  133. package/dist/route/api/files/route.d.mts +16 -0
  134. package/dist/route/api/files/route.d.ts +16 -0
  135. package/dist/route/api/files/route.js +106 -0
  136. package/dist/route/api/files/route.mjs +79 -0
  137. package/dist/route/api.d.mts +29 -0
  138. package/dist/route/api.d.ts +29 -0
  139. package/dist/route/api.js +395 -0
  140. package/dist/route/api.mjs +368 -0
  141. package/dist/route/auth/callback/[provider]/route.js +120 -0
  142. package/dist/route/auth/callback/[provider]/route.mjs +93 -0
  143. package/dist/route/auth/callback/_provider_/route.d.mts +20 -0
  144. package/dist/route/auth/callback/_provider_/route.d.ts +20 -0
  145. package/dist/seo-kit/index.d.mts +6 -0
  146. package/dist/seo-kit/index.d.ts +6 -0
  147. package/dist/seo-kit/index.js +321 -0
  148. package/dist/seo-kit/index.mjs +282 -0
  149. package/dist/seo-kit/loader.d.mts +7 -0
  150. package/dist/seo-kit/loader.d.ts +7 -0
  151. package/dist/seo-kit/loader.js +43 -0
  152. package/dist/seo-kit/loader.mjs +18 -0
  153. package/dist/seo-kit/seo.d.mts +103 -0
  154. package/dist/{esm/seo-kit → seo-kit}/seo.d.ts +10 -6
  155. package/dist/seo-kit/seo.js +286 -0
  156. package/dist/seo-kit/seo.mjs +251 -0
  157. package/dist/seo-kit/seo_loader.d.mts +16 -0
  158. package/dist/seo-kit/seo_loader.d.ts +16 -0
  159. package/dist/seo-kit/seo_loader.js +68 -0
  160. package/dist/seo-kit/seo_loader.mjs +31 -0
  161. package/dist/singleton.d.mts +3 -0
  162. package/dist/singleton.d.ts +3 -0
  163. package/dist/singleton.js +37 -0
  164. package/dist/singleton.mjs +12 -0
  165. package/dist/slug.d.mts +3 -0
  166. package/dist/slug.d.ts +3 -0
  167. package/dist/slug.js +32 -0
  168. package/dist/slug.mjs +7 -0
  169. package/package.json +36 -34
  170. package/tsup.config.ts +9 -0
  171. package/dist/cjs/auth-kit/apple_auth.js +0 -61
  172. package/dist/cjs/auth-kit/auth_service.js +0 -204
  173. package/dist/cjs/auth-kit/client/google_login_button.js +0 -19
  174. package/dist/cjs/auth-kit/client/redirect_page.js +0 -18
  175. package/dist/cjs/auth-kit/google_auth.js +0 -69
  176. package/dist/cjs/auth-kit/jwt.js +0 -54
  177. package/dist/cjs/auth-kit/kakao_auth.js +0 -43
  178. package/dist/cjs/auth-kit/repository.js +0 -2
  179. package/dist/cjs/auth-kit/with_auth.js +0 -46
  180. package/dist/cjs/cn.js +0 -6
  181. package/dist/cjs/components/index.js +0 -18
  182. package/dist/cjs/components/modal/fullscreen_container.js +0 -49
  183. package/dist/cjs/components/modal/hooks.js +0 -76
  184. package/dist/cjs/components/modal/index.js +0 -19
  185. package/dist/cjs/components/modal/modal.js +0 -79
  186. package/dist/cjs/components/styles.js +0 -10
  187. package/dist/cjs/date.js +0 -31
  188. package/dist/cjs/file-kit/cdn.js +0 -9
  189. package/dist/cjs/file-kit/client/drop_file_input.js +0 -148
  190. package/dist/cjs/file-kit/client/file_uploader.js +0 -88
  191. package/dist/cjs/file-kit/file_service.js +0 -32
  192. package/dist/cjs/file-kit/object_storage.js +0 -51
  193. package/dist/cjs/file-kit/repository.js +0 -2
  194. package/dist/cjs/file-kit/responsive_image.js +0 -63
  195. package/dist/cjs/http-kit/index.js +0 -17
  196. package/dist/cjs/http-kit/response.js +0 -37
  197. package/dist/cjs/index.js +0 -20
  198. package/dist/cjs/route/api/auth/login/[provider]/route.js +0 -36
  199. package/dist/cjs/route/api/auth/login/route.js +0 -35
  200. package/dist/cjs/route/api/auth/logout/route.js +0 -22
  201. package/dist/cjs/route/api/auth/refresh/route.js +0 -22
  202. package/dist/cjs/route/api/auth/route.js +0 -12
  203. package/dist/cjs/route/api/files/[fileId]/route.js +0 -20
  204. package/dist/cjs/route/api/files/route.js +0 -34
  205. package/dist/cjs/route/auth/callback/[provider]/route.js +0 -38
  206. package/dist/cjs/route/index.js +0 -80
  207. package/dist/cjs/seo-kit/index.js +0 -19
  208. package/dist/cjs/seo-kit/loader.js +0 -17
  209. package/dist/cjs/seo-kit/seo.js +0 -278
  210. package/dist/cjs/seo-kit/seo_loader.js +0 -15
  211. package/dist/cjs/singleton.js +0 -12
  212. package/dist/cjs/slug.js +0 -10
  213. package/dist/esm/auth-kit/apple_auth.js +0 -57
  214. package/dist/esm/auth-kit/auth_service.js +0 -197
  215. package/dist/esm/auth-kit/client/google_login_button.d.ts +0 -5
  216. package/dist/esm/auth-kit/client/google_login_button.js +0 -16
  217. package/dist/esm/auth-kit/client/redirect_page.d.ts +0 -1
  218. package/dist/esm/auth-kit/client/redirect_page.js +0 -15
  219. package/dist/esm/auth-kit/google_auth.js +0 -65
  220. package/dist/esm/auth-kit/jwt.js +0 -50
  221. package/dist/esm/auth-kit/kakao_auth.js +0 -39
  222. package/dist/esm/auth-kit/repository.js +0 -1
  223. package/dist/esm/auth-kit/with_auth.d.ts +0 -12
  224. package/dist/esm/auth-kit/with_auth.js +0 -43
  225. package/dist/esm/cn.d.ts +0 -1
  226. package/dist/esm/cn.js +0 -3
  227. package/dist/esm/components/index.d.ts +0 -2
  228. package/dist/esm/components/index.js +0 -2
  229. package/dist/esm/components/modal/fullscreen_container.d.ts +0 -5
  230. package/dist/esm/components/modal/fullscreen_container.js +0 -45
  231. package/dist/esm/components/modal/hooks.d.ts +0 -15
  232. package/dist/esm/components/modal/hooks.js +0 -67
  233. package/dist/esm/components/modal/index.d.ts +0 -3
  234. package/dist/esm/components/modal/index.js +0 -3
  235. package/dist/esm/components/modal/modal.d.ts +0 -10
  236. package/dist/esm/components/modal/modal.js +0 -43
  237. package/dist/esm/components/styles.d.ts +0 -7
  238. package/dist/esm/components/styles.js +0 -7
  239. package/dist/esm/date.d.ts +0 -1
  240. package/dist/esm/date.js +0 -24
  241. package/dist/esm/file-kit/cdn.d.ts +0 -3
  242. package/dist/esm/file-kit/cdn.js +0 -5
  243. package/dist/esm/file-kit/client/drop_file_input.js +0 -144
  244. package/dist/esm/file-kit/client/file_uploader.js +0 -84
  245. package/dist/esm/file-kit/file_service.js +0 -28
  246. package/dist/esm/file-kit/object_storage.js +0 -47
  247. package/dist/esm/file-kit/repository.js +0 -1
  248. package/dist/esm/file-kit/responsive_image.d.ts +0 -17
  249. package/dist/esm/file-kit/responsive_image.js +0 -58
  250. package/dist/esm/http-kit/index.d.ts +0 -1
  251. package/dist/esm/http-kit/index.js +0 -1
  252. package/dist/esm/http-kit/response.d.ts +0 -17
  253. package/dist/esm/http-kit/response.js +0 -31
  254. package/dist/esm/index.d.ts +0 -4
  255. package/dist/esm/index.js +0 -4
  256. package/dist/esm/route/api/auth/login/[provider]/route.d.ts +0 -10
  257. package/dist/esm/route/api/auth/login/[provider]/route.js +0 -32
  258. package/dist/esm/route/api/auth/login/route.d.ts +0 -6
  259. package/dist/esm/route/api/auth/login/route.js +0 -31
  260. package/dist/esm/route/api/auth/logout/route.d.ts +0 -6
  261. package/dist/esm/route/api/auth/logout/route.js +0 -18
  262. package/dist/esm/route/api/auth/refresh/route.d.ts +0 -4
  263. package/dist/esm/route/api/auth/refresh/route.js +0 -18
  264. package/dist/esm/route/api/auth/route.d.ts +0 -4
  265. package/dist/esm/route/api/auth/route.js +0 -8
  266. package/dist/esm/route/api/files/[fileId]/route.d.ts +0 -8
  267. package/dist/esm/route/api/files/[fileId]/route.js +0 -16
  268. package/dist/esm/route/api/files/route.d.ts +0 -6
  269. package/dist/esm/route/api/files/route.js +0 -30
  270. package/dist/esm/route/auth/callback/[provider]/route.d.ts +0 -11
  271. package/dist/esm/route/auth/callback/[provider]/route.js +0 -34
  272. package/dist/esm/route/index.d.ts +0 -22
  273. package/dist/esm/route/index.js +0 -76
  274. package/dist/esm/seo-kit/index.d.ts +0 -3
  275. package/dist/esm/seo-kit/index.js +0 -3
  276. package/dist/esm/seo-kit/loader.d.ts +0 -5
  277. package/dist/esm/seo-kit/loader.js +0 -14
  278. package/dist/esm/seo-kit/seo.js +0 -275
  279. package/dist/esm/seo-kit/seo_loader.d.ts +0 -12
  280. package/dist/esm/seo-kit/seo_loader.js +0 -12
  281. package/dist/esm/singleton.d.ts +0 -1
  282. package/dist/esm/singleton.js +0 -9
  283. package/dist/esm/slug.d.ts +0 -1
  284. package/dist/esm/slug.js +0 -6
@@ -0,0 +1,204 @@
1
+ // src/components/modal/hooks.tsx
2
+ import { createContext, useCallback, useEffect as useEffect3, useRef as useRef3, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+
5
+ // src/components/modal/modal.tsx
6
+ import React2, {
7
+ useEffect as useEffect2,
8
+ useRef as useRef2
9
+ } from "react";
10
+
11
+ // src/cn.ts
12
+ function cn(...classes) {
13
+ return classes.filter(Boolean).join(" ").trim();
14
+ }
15
+
16
+ // src/components/modal/fullscreen_container.tsx
17
+ import React from "react";
18
+ import {
19
+ useEffect,
20
+ useRef
21
+ } from "react";
22
+ function useFullscreen(ref) {
23
+ useEffect(() => {
24
+ const container = ref.current;
25
+ if (!container) {
26
+ return;
27
+ }
28
+ const scroll = () => {
29
+ if (scrollY > 0) {
30
+ window.scrollTo({
31
+ top: 0,
32
+ behavior: "instant"
33
+ });
34
+ }
35
+ };
36
+ const resize = () => {
37
+ if (!visualViewport) {
38
+ return;
39
+ }
40
+ container.classList.remove("bottom-0");
41
+ container.style.height = `${visualViewport?.height}px`;
42
+ if (visualViewport.height < window.innerHeight) {
43
+ window.addEventListener("scroll", scroll);
44
+ } else {
45
+ window.removeEventListener("scroll", scroll);
46
+ }
47
+ };
48
+ resize();
49
+ visualViewport?.addEventListener("resize", resize);
50
+ scroll();
51
+ return () => {
52
+ window.removeEventListener("scroll", scroll);
53
+ visualViewport?.removeEventListener("resize", resize);
54
+ };
55
+ }, [ref]);
56
+ return "fixed inset-0";
57
+ }
58
+
59
+ // src/components/modal/modal.tsx
60
+ function Modal({
61
+ open,
62
+ className,
63
+ background = "bg-gray-500/25",
64
+ onBackgroundClick,
65
+ children,
66
+ ...props
67
+ }) {
68
+ const containerRef = useRef2(null);
69
+ const fullscreen = useFullscreen(containerRef);
70
+ const [mounted, setMounted] = React2.useState(false);
71
+ useEffect2(() => {
72
+ if (open) {
73
+ setMounted(true);
74
+ } else {
75
+ setTimeout(() => {
76
+ setMounted(false);
77
+ }, 200);
78
+ }
79
+ return () => {
80
+ };
81
+ }, [open]);
82
+ const onBackgroundMouseDown = (event) => {
83
+ event.preventDefault();
84
+ onBackgroundClick?.();
85
+ };
86
+ const onModalMouseDown = (event) => {
87
+ event.stopPropagation();
88
+ };
89
+ const onBackgroundTouchStart = (event) => {
90
+ event.preventDefault();
91
+ onBackgroundClick?.();
92
+ };
93
+ const onModalTouchStart = (event) => {
94
+ event.stopPropagation();
95
+ };
96
+ return /* @__PURE__ */ React2.createElement(
97
+ "div",
98
+ {
99
+ ref: containerRef,
100
+ className: cn(
101
+ fullscreen,
102
+ "z-[999] flex flex-col justify-center transition-bg duration-200 md:px-6 overflow-hidden print:px-0 print:block print:overflow-auto",
103
+ open && mounted ? cn(background, "ease-out") : "bg-transparent ease-in pointer-events-none"
104
+ ),
105
+ onMouseDown: onBackgroundMouseDown,
106
+ onTouchStart: onBackgroundTouchStart
107
+ },
108
+ /* @__PURE__ */ React2.createElement(
109
+ "div",
110
+ {
111
+ className: cn(
112
+ "relative flex-1 flex flex-col justify-end md:justify-center items-center transition-[opacity transform] duration-200 print:block",
113
+ open && mounted ? "translate-y-[0px] opacity-100 ease-out" : "translate-y-[100%] md:translate-y-[50px] opacity-0 ease-in"
114
+ )
115
+ },
116
+ (open || mounted) && /* @__PURE__ */ React2.createElement(
117
+ "div",
118
+ {
119
+ ...props,
120
+ className: cn(
121
+ className,
122
+ "w-full max-h-[92vh] print:w-[unset] print:max-h-[unset] rounded-tl-lg rounded-tr-lg md:rounded-lg overflow-auto print:rounded-none"
123
+ ),
124
+ onMouseDown: onModalMouseDown,
125
+ onTouchStart: onModalTouchStart
126
+ },
127
+ children
128
+ )
129
+ )
130
+ );
131
+ }
132
+
133
+ // src/components/modal/hooks.tsx
134
+ import React3 from "react";
135
+ function useModalRoot() {
136
+ const [container, setContainer] = useState(null);
137
+ useEffect3(() => {
138
+ const container2 = document.getElementById("modal-root");
139
+ if (container2) {
140
+ setContainer(container2);
141
+ }
142
+ return () => {
143
+ setContainer(null);
144
+ };
145
+ }, []);
146
+ return container;
147
+ }
148
+ function useModalPortal() {
149
+ const container = useModalRoot();
150
+ if (!container) {
151
+ return (children) => null;
152
+ }
153
+ return (children) => {
154
+ return createPortal(children, container);
155
+ };
156
+ }
157
+ var ModalContext = createContext({});
158
+ function useModal() {
159
+ const ch2 = useRef3(
160
+ null
161
+ );
162
+ const open = () => {
163
+ ch2.current?.(true);
164
+ };
165
+ const close = () => {
166
+ ch2.current?.(false);
167
+ };
168
+ const Component = useCallback(
169
+ function Component2(props) {
170
+ const [isOpen, setIsOpen] = useState(false);
171
+ const createPortal2 = useModalPortal();
172
+ useEffect3(() => {
173
+ ch2.current = (v) => {
174
+ setIsOpen(v);
175
+ };
176
+ return () => {
177
+ ch2.current = null;
178
+ };
179
+ }, []);
180
+ useEffect3(() => {
181
+ if (isOpen) {
182
+ } else {
183
+ }
184
+ return () => {
185
+ };
186
+ }, [isOpen]);
187
+ return /* @__PURE__ */ React3.createElement(ModalContext.Provider, { value: { open, close, isOpen } }, createPortal2(
188
+ /* @__PURE__ */ React3.createElement(Modal, { ...props, open: isOpen, onBackgroundClick: close })
189
+ ));
190
+ },
191
+ []
192
+ );
193
+ return {
194
+ open,
195
+ close,
196
+ Modal: Component
197
+ };
198
+ }
199
+ export {
200
+ ModalContext,
201
+ useModal,
202
+ useModalPortal,
203
+ useModalRoot
204
+ };
@@ -0,0 +1,4 @@
1
+ export { Props, useFullscreen } from './fullscreen_container.mjs';
2
+ export { ModalContext, ModalContextProps, useModal, useModalPortal, useModalRoot } from './hooks.mjs';
3
+ export { ModalProps } from './modal.mjs';
4
+ import 'react';
@@ -0,0 +1,4 @@
1
+ export { Props, useFullscreen } from './fullscreen_container.js';
2
+ export { ModalContext, ModalContextProps, useModal, useModalPortal, useModalRoot } from './hooks.js';
3
+ export { ModalProps } from './modal.js';
4
+ import 'react';
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/modal/index.ts
31
+ var modal_exports = {};
32
+ __export(modal_exports, {
33
+ ModalContext: () => ModalContext,
34
+ useFullscreen: () => useFullscreen,
35
+ useModal: () => useModal,
36
+ useModalPortal: () => useModalPortal,
37
+ useModalRoot: () => useModalRoot
38
+ });
39
+ module.exports = __toCommonJS(modal_exports);
40
+
41
+ // src/cn.ts
42
+ function cn(...classes) {
43
+ return classes.filter(Boolean).join(" ").trim();
44
+ }
45
+
46
+ // src/components/modal/fullscreen_container.tsx
47
+ var import_react = __toESM(require("react"));
48
+ var import_react2 = require("react");
49
+ function useFullscreen(ref) {
50
+ (0, import_react2.useEffect)(() => {
51
+ const container = ref.current;
52
+ if (!container) {
53
+ return;
54
+ }
55
+ const scroll = () => {
56
+ if (scrollY > 0) {
57
+ window.scrollTo({
58
+ top: 0,
59
+ behavior: "instant"
60
+ });
61
+ }
62
+ };
63
+ const resize = () => {
64
+ if (!visualViewport) {
65
+ return;
66
+ }
67
+ container.classList.remove("bottom-0");
68
+ container.style.height = `${visualViewport?.height}px`;
69
+ if (visualViewport.height < window.innerHeight) {
70
+ window.addEventListener("scroll", scroll);
71
+ } else {
72
+ window.removeEventListener("scroll", scroll);
73
+ }
74
+ };
75
+ resize();
76
+ visualViewport?.addEventListener("resize", resize);
77
+ scroll();
78
+ return () => {
79
+ window.removeEventListener("scroll", scroll);
80
+ visualViewport?.removeEventListener("resize", resize);
81
+ };
82
+ }, [ref]);
83
+ return "fixed inset-0";
84
+ }
85
+
86
+ // src/components/modal/hooks.tsx
87
+ var import_react4 = require("react");
88
+ var import_react_dom = require("react-dom");
89
+
90
+ // src/components/modal/modal.tsx
91
+ var import_react3 = __toESM(require("react"));
92
+ function Modal({
93
+ open,
94
+ className,
95
+ background = "bg-gray-500/25",
96
+ onBackgroundClick,
97
+ children,
98
+ ...props
99
+ }) {
100
+ const containerRef = (0, import_react3.useRef)(null);
101
+ const fullscreen = useFullscreen(containerRef);
102
+ const [mounted, setMounted] = import_react3.default.useState(false);
103
+ (0, import_react3.useEffect)(() => {
104
+ if (open) {
105
+ setMounted(true);
106
+ } else {
107
+ setTimeout(() => {
108
+ setMounted(false);
109
+ }, 200);
110
+ }
111
+ return () => {
112
+ };
113
+ }, [open]);
114
+ const onBackgroundMouseDown = (event) => {
115
+ event.preventDefault();
116
+ onBackgroundClick?.();
117
+ };
118
+ const onModalMouseDown = (event) => {
119
+ event.stopPropagation();
120
+ };
121
+ const onBackgroundTouchStart = (event) => {
122
+ event.preventDefault();
123
+ onBackgroundClick?.();
124
+ };
125
+ const onModalTouchStart = (event) => {
126
+ event.stopPropagation();
127
+ };
128
+ return /* @__PURE__ */ import_react3.default.createElement(
129
+ "div",
130
+ {
131
+ ref: containerRef,
132
+ className: cn(
133
+ fullscreen,
134
+ "z-[999] flex flex-col justify-center transition-bg duration-200 md:px-6 overflow-hidden print:px-0 print:block print:overflow-auto",
135
+ open && mounted ? cn(background, "ease-out") : "bg-transparent ease-in pointer-events-none"
136
+ ),
137
+ onMouseDown: onBackgroundMouseDown,
138
+ onTouchStart: onBackgroundTouchStart
139
+ },
140
+ /* @__PURE__ */ import_react3.default.createElement(
141
+ "div",
142
+ {
143
+ className: cn(
144
+ "relative flex-1 flex flex-col justify-end md:justify-center items-center transition-[opacity transform] duration-200 print:block",
145
+ open && mounted ? "translate-y-[0px] opacity-100 ease-out" : "translate-y-[100%] md:translate-y-[50px] opacity-0 ease-in"
146
+ )
147
+ },
148
+ (open || mounted) && /* @__PURE__ */ import_react3.default.createElement(
149
+ "div",
150
+ {
151
+ ...props,
152
+ className: cn(
153
+ className,
154
+ "w-full max-h-[92vh] print:w-[unset] print:max-h-[unset] rounded-tl-lg rounded-tr-lg md:rounded-lg overflow-auto print:rounded-none"
155
+ ),
156
+ onMouseDown: onModalMouseDown,
157
+ onTouchStart: onModalTouchStart
158
+ },
159
+ children
160
+ )
161
+ )
162
+ );
163
+ }
164
+
165
+ // src/components/modal/hooks.tsx
166
+ var import_react5 = __toESM(require("react"));
167
+ function useModalRoot() {
168
+ const [container, setContainer] = (0, import_react4.useState)(null);
169
+ (0, import_react4.useEffect)(() => {
170
+ const container2 = document.getElementById("modal-root");
171
+ if (container2) {
172
+ setContainer(container2);
173
+ }
174
+ return () => {
175
+ setContainer(null);
176
+ };
177
+ }, []);
178
+ return container;
179
+ }
180
+ function useModalPortal() {
181
+ const container = useModalRoot();
182
+ if (!container) {
183
+ return (children) => null;
184
+ }
185
+ return (children) => {
186
+ return (0, import_react_dom.createPortal)(children, container);
187
+ };
188
+ }
189
+ var ModalContext = (0, import_react4.createContext)({});
190
+ function useModal() {
191
+ const ch2 = (0, import_react4.useRef)(
192
+ null
193
+ );
194
+ const open = () => {
195
+ ch2.current?.(true);
196
+ };
197
+ const close = () => {
198
+ ch2.current?.(false);
199
+ };
200
+ const Component = (0, import_react4.useCallback)(
201
+ function Component2(props) {
202
+ const [isOpen, setIsOpen] = (0, import_react4.useState)(false);
203
+ const createPortal2 = useModalPortal();
204
+ (0, import_react4.useEffect)(() => {
205
+ ch2.current = (v) => {
206
+ setIsOpen(v);
207
+ };
208
+ return () => {
209
+ ch2.current = null;
210
+ };
211
+ }, []);
212
+ (0, import_react4.useEffect)(() => {
213
+ if (isOpen) {
214
+ } else {
215
+ }
216
+ return () => {
217
+ };
218
+ }, [isOpen]);
219
+ return /* @__PURE__ */ import_react5.default.createElement(ModalContext.Provider, { value: { open, close, isOpen } }, createPortal2(
220
+ /* @__PURE__ */ import_react5.default.createElement(Modal, { ...props, open: isOpen, onBackgroundClick: close })
221
+ ));
222
+ },
223
+ []
224
+ );
225
+ return {
226
+ open,
227
+ close,
228
+ Modal: Component
229
+ };
230
+ }
231
+ // Annotate the CommonJS export names for ESM import in node:
232
+ 0 && (module.exports = {
233
+ ModalContext,
234
+ useFullscreen,
235
+ useModal,
236
+ useModalPortal,
237
+ useModalRoot
238
+ });
@@ -0,0 +1,203 @@
1
+ // src/cn.ts
2
+ function cn(...classes) {
3
+ return classes.filter(Boolean).join(" ").trim();
4
+ }
5
+
6
+ // src/components/modal/fullscreen_container.tsx
7
+ import React from "react";
8
+ import {
9
+ useEffect,
10
+ useRef
11
+ } from "react";
12
+ function useFullscreen(ref) {
13
+ useEffect(() => {
14
+ const container = ref.current;
15
+ if (!container) {
16
+ return;
17
+ }
18
+ const scroll = () => {
19
+ if (scrollY > 0) {
20
+ window.scrollTo({
21
+ top: 0,
22
+ behavior: "instant"
23
+ });
24
+ }
25
+ };
26
+ const resize = () => {
27
+ if (!visualViewport) {
28
+ return;
29
+ }
30
+ container.classList.remove("bottom-0");
31
+ container.style.height = `${visualViewport?.height}px`;
32
+ if (visualViewport.height < window.innerHeight) {
33
+ window.addEventListener("scroll", scroll);
34
+ } else {
35
+ window.removeEventListener("scroll", scroll);
36
+ }
37
+ };
38
+ resize();
39
+ visualViewport?.addEventListener("resize", resize);
40
+ scroll();
41
+ return () => {
42
+ window.removeEventListener("scroll", scroll);
43
+ visualViewport?.removeEventListener("resize", resize);
44
+ };
45
+ }, [ref]);
46
+ return "fixed inset-0";
47
+ }
48
+
49
+ // src/components/modal/hooks.tsx
50
+ import { createContext, useCallback, useEffect as useEffect3, useRef as useRef3, useState } from "react";
51
+ import { createPortal } from "react-dom";
52
+
53
+ // src/components/modal/modal.tsx
54
+ import React2, {
55
+ useEffect as useEffect2,
56
+ useRef as useRef2
57
+ } from "react";
58
+ function Modal({
59
+ open,
60
+ className,
61
+ background = "bg-gray-500/25",
62
+ onBackgroundClick,
63
+ children,
64
+ ...props
65
+ }) {
66
+ const containerRef = useRef2(null);
67
+ const fullscreen = useFullscreen(containerRef);
68
+ const [mounted, setMounted] = React2.useState(false);
69
+ useEffect2(() => {
70
+ if (open) {
71
+ setMounted(true);
72
+ } else {
73
+ setTimeout(() => {
74
+ setMounted(false);
75
+ }, 200);
76
+ }
77
+ return () => {
78
+ };
79
+ }, [open]);
80
+ const onBackgroundMouseDown = (event) => {
81
+ event.preventDefault();
82
+ onBackgroundClick?.();
83
+ };
84
+ const onModalMouseDown = (event) => {
85
+ event.stopPropagation();
86
+ };
87
+ const onBackgroundTouchStart = (event) => {
88
+ event.preventDefault();
89
+ onBackgroundClick?.();
90
+ };
91
+ const onModalTouchStart = (event) => {
92
+ event.stopPropagation();
93
+ };
94
+ return /* @__PURE__ */ React2.createElement(
95
+ "div",
96
+ {
97
+ ref: containerRef,
98
+ className: cn(
99
+ fullscreen,
100
+ "z-[999] flex flex-col justify-center transition-bg duration-200 md:px-6 overflow-hidden print:px-0 print:block print:overflow-auto",
101
+ open && mounted ? cn(background, "ease-out") : "bg-transparent ease-in pointer-events-none"
102
+ ),
103
+ onMouseDown: onBackgroundMouseDown,
104
+ onTouchStart: onBackgroundTouchStart
105
+ },
106
+ /* @__PURE__ */ React2.createElement(
107
+ "div",
108
+ {
109
+ className: cn(
110
+ "relative flex-1 flex flex-col justify-end md:justify-center items-center transition-[opacity transform] duration-200 print:block",
111
+ open && mounted ? "translate-y-[0px] opacity-100 ease-out" : "translate-y-[100%] md:translate-y-[50px] opacity-0 ease-in"
112
+ )
113
+ },
114
+ (open || mounted) && /* @__PURE__ */ React2.createElement(
115
+ "div",
116
+ {
117
+ ...props,
118
+ className: cn(
119
+ className,
120
+ "w-full max-h-[92vh] print:w-[unset] print:max-h-[unset] rounded-tl-lg rounded-tr-lg md:rounded-lg overflow-auto print:rounded-none"
121
+ ),
122
+ onMouseDown: onModalMouseDown,
123
+ onTouchStart: onModalTouchStart
124
+ },
125
+ children
126
+ )
127
+ )
128
+ );
129
+ }
130
+
131
+ // src/components/modal/hooks.tsx
132
+ import React3 from "react";
133
+ function useModalRoot() {
134
+ const [container, setContainer] = useState(null);
135
+ useEffect3(() => {
136
+ const container2 = document.getElementById("modal-root");
137
+ if (container2) {
138
+ setContainer(container2);
139
+ }
140
+ return () => {
141
+ setContainer(null);
142
+ };
143
+ }, []);
144
+ return container;
145
+ }
146
+ function useModalPortal() {
147
+ const container = useModalRoot();
148
+ if (!container) {
149
+ return (children) => null;
150
+ }
151
+ return (children) => {
152
+ return createPortal(children, container);
153
+ };
154
+ }
155
+ var ModalContext = createContext({});
156
+ function useModal() {
157
+ const ch2 = useRef3(
158
+ null
159
+ );
160
+ const open = () => {
161
+ ch2.current?.(true);
162
+ };
163
+ const close = () => {
164
+ ch2.current?.(false);
165
+ };
166
+ const Component = useCallback(
167
+ function Component2(props) {
168
+ const [isOpen, setIsOpen] = useState(false);
169
+ const createPortal2 = useModalPortal();
170
+ useEffect3(() => {
171
+ ch2.current = (v) => {
172
+ setIsOpen(v);
173
+ };
174
+ return () => {
175
+ ch2.current = null;
176
+ };
177
+ }, []);
178
+ useEffect3(() => {
179
+ if (isOpen) {
180
+ } else {
181
+ }
182
+ return () => {
183
+ };
184
+ }, [isOpen]);
185
+ return /* @__PURE__ */ React3.createElement(ModalContext.Provider, { value: { open, close, isOpen } }, createPortal2(
186
+ /* @__PURE__ */ React3.createElement(Modal, { ...props, open: isOpen, onBackgroundClick: close })
187
+ ));
188
+ },
189
+ []
190
+ );
191
+ return {
192
+ open,
193
+ close,
194
+ Modal: Component
195
+ };
196
+ }
197
+ export {
198
+ ModalContext,
199
+ useFullscreen,
200
+ useModal,
201
+ useModalPortal,
202
+ useModalRoot
203
+ };
@@ -0,0 +1,13 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ type ModalProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
4
+ open: boolean;
5
+ children?: ReactNode;
6
+ onBackgroundClick?: () => void;
7
+ embeded?: boolean;
8
+ always?: boolean;
9
+ background?: string;
10
+ };
11
+ declare function Modal({ open, className, background, onBackgroundClick, children, ...props }: ModalProps): React.JSX.Element;
12
+
13
+ export { type ModalProps, Modal as default };
@@ -0,0 +1,13 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ type ModalProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
4
+ open: boolean;
5
+ children?: ReactNode;
6
+ onBackgroundClick?: () => void;
7
+ embeded?: boolean;
8
+ always?: boolean;
9
+ background?: string;
10
+ };
11
+ declare function Modal({ open, className, background, onBackgroundClick, children, ...props }: ModalProps): React.JSX.Element;
12
+
13
+ export { type ModalProps, Modal as default };