dn-react-router-toolkit 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/auth-kit/apple_auth.js +1 -0
- package/dist/cjs/auth-kit/auth_service.js +6 -6
- package/dist/cjs/auth-kit/client/google_login_button.js +2 -8
- package/dist/cjs/auth-kit/client/redirect_page.js +4 -7
- package/dist/cjs/auth-kit/google_auth.js +4 -0
- package/dist/cjs/auth-kit/jwt.js +1 -0
- package/dist/cjs/auth-kit/kakao_auth.js +6 -1
- package/dist/cjs/components/modal/fullscreen_container.js +9 -24
- package/dist/cjs/components/modal/hooks.js +4 -6
- package/dist/cjs/components/modal/modal.js +7 -19
- package/dist/cjs/file-kit/client/drop_file_input.js +24 -71
- package/dist/cjs/file-kit/client/file_uploader.js +21 -11
- package/dist/cjs/file-kit/file_service.js +3 -0
- package/dist/cjs/file-kit/object_storage.js +4 -3
- package/dist/cjs/file-kit/responsive_image.js +4 -19
- package/dist/cjs/http-kit/response.js +5 -2
- package/dist/cjs/route/api/auth/refresh/route.js +1 -2
- package/dist/cjs/route/api/files/[fileId]/route.js +1 -1
- package/dist/cjs/route/api/files/route.js +1 -1
- package/dist/cjs/route/auth/callback/[provider]/route.js +4 -1
- package/dist/cjs/seo-kit/seo.js +33 -41
- package/dist/cjs/seo-kit/seo_loader.js +8 -12
- package/dist/esm/auth-kit/apple_auth.js +1 -0
- package/dist/esm/auth-kit/auth_service.js +6 -6
- package/dist/esm/auth-kit/client/google_login_button.d.ts +1 -2
- package/dist/esm/auth-kit/client/google_login_button.js +2 -5
- package/dist/esm/auth-kit/client/redirect_page.d.ts +1 -2
- package/dist/esm/auth-kit/client/redirect_page.js +2 -2
- package/dist/esm/auth-kit/google_auth.js +4 -0
- package/dist/esm/auth-kit/jwt.js +1 -0
- package/dist/esm/auth-kit/kakao_auth.js +6 -1
- package/dist/esm/components/modal/fullscreen_container.d.ts +1 -1
- package/dist/esm/components/modal/fullscreen_container.js +6 -18
- package/dist/esm/components/modal/hooks.d.ts +1 -1
- package/dist/esm/components/modal/hooks.js +4 -6
- package/dist/esm/components/modal/modal.d.ts +1 -1
- package/dist/esm/components/modal/modal.js +7 -19
- package/dist/esm/file-kit/client/drop_file_input.d.ts +2 -2
- package/dist/esm/file-kit/client/drop_file_input.js +24 -38
- package/dist/esm/file-kit/client/file_uploader.js +21 -11
- package/dist/esm/file-kit/file_service.js +3 -0
- package/dist/esm/file-kit/object_storage.js +4 -3
- package/dist/esm/file-kit/responsive_image.js +4 -16
- package/dist/esm/http-kit/response.js +5 -2
- package/dist/esm/route/api/auth/refresh/route.js +1 -2
- package/dist/esm/route/api/files/[fileId]/route.js +1 -1
- package/dist/esm/route/api/files/route.js +1 -1
- package/dist/esm/route/auth/callback/[provider]/route.js +4 -1
- package/dist/esm/seo-kit/seo.d.ts +1 -2
- package/dist/esm/seo-kit/seo.js +33 -38
- package/dist/esm/seo-kit/seo_loader.d.ts +1 -1
- package/dist/esm/seo-kit/seo_loader.js +8 -9
- package/package.json +1 -1
package/dist/cjs/seo-kit/seo.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.configSEO = configSEO;
|
|
7
|
-
const
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
5
|
function configSEO(config) {
|
|
9
6
|
return {
|
|
10
7
|
config,
|
|
11
8
|
async init(props = {}) {
|
|
12
|
-
var _a;
|
|
13
9
|
const canonicalPath = props.canonicalPath;
|
|
14
10
|
const url = canonicalPath
|
|
15
11
|
? `${config.origin}${canonicalPath}`
|
|
@@ -34,7 +30,7 @@ function configSEO(config) {
|
|
|
34
30
|
(typeof config.thumbnail === "function"
|
|
35
31
|
? await config.thumbnail()
|
|
36
32
|
: config.thumbnail);
|
|
37
|
-
const thumbnailUrl = thumbnail
|
|
33
|
+
const thumbnailUrl = thumbnail?.url;
|
|
38
34
|
const socialImage = thumbnail
|
|
39
35
|
? [
|
|
40
36
|
typeof thumbnail === "string"
|
|
@@ -56,7 +52,7 @@ function configSEO(config) {
|
|
|
56
52
|
]
|
|
57
53
|
: []),
|
|
58
54
|
...(props.images || []),
|
|
59
|
-
...(
|
|
55
|
+
...(props.collection?.map((portfolio) => portfolio.thumbnail) || []),
|
|
60
56
|
].filter(Boolean);
|
|
61
57
|
const image = images
|
|
62
58
|
.filter((file) => file.id)
|
|
@@ -71,7 +67,7 @@ function configSEO(config) {
|
|
|
71
67
|
return [
|
|
72
68
|
{ title: pageTitle },
|
|
73
69
|
{ name: "description", content: description },
|
|
74
|
-
{ name: "keywords", content:
|
|
70
|
+
{ name: "keywords", content: keywords?.join(", ") || "" },
|
|
75
71
|
{
|
|
76
72
|
tagName: "link",
|
|
77
73
|
rel: "canonical",
|
|
@@ -111,24 +107,21 @@ function configSEO(config) {
|
|
|
111
107
|
? {
|
|
112
108
|
"@type": "ItemList",
|
|
113
109
|
numberOfItems: props.collection.length,
|
|
114
|
-
itemListElement: props.collection.map((item, index) => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
itemListElement: props.collection.map((item, index) => ({
|
|
111
|
+
"@type": "ListItem",
|
|
112
|
+
position: index + 1,
|
|
113
|
+
url: item.url,
|
|
114
|
+
item: {
|
|
115
|
+
"@type": "WebPage",
|
|
116
|
+
"@id": `${item.url}#webpage`,
|
|
119
117
|
url: item.url,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
dateCreated: (_c = item.createdAt) === null || _c === void 0 ? void 0 : _c.toISOString(),
|
|
128
|
-
datePublished: (_d = item.createdAt) === null || _d === void 0 ? void 0 : _d.toISOString(),
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
}),
|
|
118
|
+
name: item.title,
|
|
119
|
+
thumbnailUrl: item.thumbnail?.url,
|
|
120
|
+
dateModified: item.updatedAt?.toISOString(),
|
|
121
|
+
dateCreated: item.createdAt?.toISOString(),
|
|
122
|
+
datePublished: item.createdAt?.toISOString(),
|
|
123
|
+
},
|
|
124
|
+
})),
|
|
132
125
|
}
|
|
133
126
|
: undefined;
|
|
134
127
|
return {
|
|
@@ -141,9 +134,9 @@ function configSEO(config) {
|
|
|
141
134
|
name: pageTitle,
|
|
142
135
|
description,
|
|
143
136
|
keywords: keywords,
|
|
144
|
-
dateModified: updatedAt
|
|
145
|
-
datePublished: createdAt
|
|
146
|
-
dateCreated: createdAt
|
|
137
|
+
dateModified: updatedAt?.toISOString(),
|
|
138
|
+
datePublished: createdAt?.toISOString(),
|
|
139
|
+
dateCreated: createdAt?.toISOString(),
|
|
147
140
|
primaryImageOfPage: thumbnail
|
|
148
141
|
? {
|
|
149
142
|
"@id": thumbnailSchemaId,
|
|
@@ -170,9 +163,9 @@ function configSEO(config) {
|
|
|
170
163
|
description,
|
|
171
164
|
keywords: keywords,
|
|
172
165
|
headline: pageTitle,
|
|
173
|
-
dateModified: updatedAt
|
|
174
|
-
datePublished: createdAt
|
|
175
|
-
dateCreated: createdAt
|
|
166
|
+
dateModified: updatedAt?.toISOString(),
|
|
167
|
+
datePublished: createdAt?.toISOString(),
|
|
168
|
+
dateCreated: createdAt?.toISOString(),
|
|
176
169
|
isPartOf: {
|
|
177
170
|
"@id": websiteSchemaId,
|
|
178
171
|
},
|
|
@@ -187,8 +180,8 @@ function configSEO(config) {
|
|
|
187
180
|
headline: pageTitle,
|
|
188
181
|
description: description,
|
|
189
182
|
thumbnailUrl,
|
|
190
|
-
datePublished: createdAt
|
|
191
|
-
dateModified: updatedAt
|
|
183
|
+
datePublished: createdAt?.toISOString(),
|
|
184
|
+
dateModified: updatedAt?.toISOString(),
|
|
192
185
|
isPartOf: { "@id": websiteSchemaId },
|
|
193
186
|
image,
|
|
194
187
|
},
|
|
@@ -199,8 +192,8 @@ function configSEO(config) {
|
|
|
199
192
|
url,
|
|
200
193
|
name: pageTitle,
|
|
201
194
|
description: description,
|
|
202
|
-
datePublished: createdAt
|
|
203
|
-
dateModified: updatedAt
|
|
195
|
+
datePublished: createdAt?.toISOString(),
|
|
196
|
+
dateModified: updatedAt?.toISOString(),
|
|
204
197
|
isPartOf: { "@id": websiteSchemaId },
|
|
205
198
|
thumbnailUrl,
|
|
206
199
|
image,
|
|
@@ -212,8 +205,8 @@ function configSEO(config) {
|
|
|
212
205
|
url,
|
|
213
206
|
name: pageTitle,
|
|
214
207
|
description: description,
|
|
215
|
-
datePublished: createdAt
|
|
216
|
-
dateModified: updatedAt
|
|
208
|
+
datePublished: createdAt?.toISOString(),
|
|
209
|
+
dateModified: updatedAt?.toISOString(),
|
|
217
210
|
isPartOf: { "@id": websiteSchemaId },
|
|
218
211
|
thumbnailUrl,
|
|
219
212
|
image,
|
|
@@ -250,7 +243,6 @@ function configSEO(config) {
|
|
|
250
243
|
},
|
|
251
244
|
...additionalStructedData,
|
|
252
245
|
...images.map((file) => {
|
|
253
|
-
var _a, _b;
|
|
254
246
|
return {
|
|
255
247
|
"@type": "ImageObject",
|
|
256
248
|
"@id": `${url}/#${file.id}`,
|
|
@@ -258,8 +250,8 @@ function configSEO(config) {
|
|
|
258
250
|
contentUrl: file.url,
|
|
259
251
|
name: file.alt,
|
|
260
252
|
description: file.alt,
|
|
261
|
-
width:
|
|
262
|
-
height:
|
|
253
|
+
width: file?.width?.toString(),
|
|
254
|
+
height: file?.height?.toString(),
|
|
263
255
|
creditText: config.copyright,
|
|
264
256
|
license: `${config.origin}/terms`,
|
|
265
257
|
copyrightNotice: config.copyright,
|
|
@@ -271,7 +263,7 @@ function configSEO(config) {
|
|
|
271
263
|
}
|
|
272
264
|
function generateJSONLD() {
|
|
273
265
|
const structedData = getStructedData();
|
|
274
|
-
return (
|
|
266
|
+
return ((0, jsx_runtime_1.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
275
267
|
__html: JSON.stringify(structedData).replace(/</g, "\\u003c"),
|
|
276
268
|
} }));
|
|
277
269
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.createSEOLoader = createSEOLoader;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
5
|
const loader_1 = require("./loader");
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
6
|
function createSEOLoader(fn = () => ({})) {
|
|
10
7
|
const loader = (0, loader_1.createLoader)(fn);
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} });
|
|
8
|
+
return {
|
|
9
|
+
...loader,
|
|
10
|
+
meta: loader.wrap((data) => data.seo.meta),
|
|
11
|
+
Page(Fc) {
|
|
12
|
+
return loader.wrap((data) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [data.seo?.generateJSONLD(), (0, jsx_runtime_1.jsx)(Fc, { ...data })] })));
|
|
13
|
+
},
|
|
14
|
+
};
|
|
19
15
|
}
|
|
@@ -16,14 +16,16 @@ export const REFRESH_TOKEN_COOKIE = createCookie(REFRESH_TOKEN_KEY, {
|
|
|
16
16
|
sameSite: "strict",
|
|
17
17
|
});
|
|
18
18
|
export class AuthService {
|
|
19
|
+
repository;
|
|
20
|
+
JWT_MANAGER;
|
|
21
|
+
OBJECT_STORAGE;
|
|
19
22
|
constructor({ repository, JWT_MANAGER, OBJECT_STORAGE, }) {
|
|
20
23
|
this.repository = repository;
|
|
21
24
|
this.JWT_MANAGER = JWT_MANAGER;
|
|
22
25
|
this.OBJECT_STORAGE = OBJECT_STORAGE;
|
|
23
26
|
}
|
|
24
27
|
async verify(request) {
|
|
25
|
-
|
|
26
|
-
const accessToken = ((_a = request === null || request === void 0 ? void 0 : request.headers.get("Authorization")) === null || _a === void 0 ? void 0 : _a.replace("Bearer ", "")) ||
|
|
28
|
+
const accessToken = request?.headers.get("Authorization")?.replace("Bearer ", "") ||
|
|
27
29
|
(await this.getAccessTokenFromCookies(request));
|
|
28
30
|
if (accessToken) {
|
|
29
31
|
return this.JWT_MANAGER.verifyAccessToken(accessToken);
|
|
@@ -37,14 +39,12 @@ export class AuthService {
|
|
|
37
39
|
return this.refresh(request);
|
|
38
40
|
}
|
|
39
41
|
async getAccessTokenFromCookies(request) {
|
|
40
|
-
var _a;
|
|
41
42
|
const cookieStore = await ACCESS_TOKEN_COOKIE.parse(request.headers.get("cookie"));
|
|
42
|
-
return
|
|
43
|
+
return cookieStore.get(ACCESS_TOKEN_KEY)?.value;
|
|
43
44
|
}
|
|
44
45
|
async getRefreshTokenFromCookies(request) {
|
|
45
|
-
var _a;
|
|
46
46
|
const cookieStore = await REFRESH_TOKEN_COOKIE.parse(request.headers.get("cookie"));
|
|
47
|
-
return
|
|
47
|
+
return cookieStore.get(REFRESH_TOKEN_KEY)?.value;
|
|
48
48
|
}
|
|
49
49
|
async refresh(request) {
|
|
50
50
|
const refreshToken = await this.getRefreshTokenFromCookies(request);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
export declare function GoogleLoginButton({ className, GOOGLE_CLIENT_ID, GOOGLE_REDIRECT_URI, }: {
|
|
3
2
|
className?: string;
|
|
4
3
|
GOOGLE_CLIENT_ID: string;
|
|
5
4
|
GOOGLE_REDIRECT_URI: string;
|
|
6
|
-
}):
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { FcGoogle } from "react-icons/fc";
|
|
3
3
|
import { useSearchParams } from "react-router";
|
|
4
4
|
export function GoogleLoginButton({ className = "max-w-[300px] w-full", GOOGLE_CLIENT_ID, GOOGLE_REDIRECT_URI, }) {
|
|
@@ -12,8 +12,5 @@ export function GoogleLoginButton({ className = "max-w-[300px] w-full", GOOGLE_C
|
|
|
12
12
|
href.searchParams.append("response_type", "code");
|
|
13
13
|
href.searchParams.append("scope", "email profile");
|
|
14
14
|
href.searchParams.append("state", redirectUrl);
|
|
15
|
-
return (
|
|
16
|
-
React.createElement("a", { href: href.toString(), className: "relative flex items-center border border-neutral-300 px-4 py-3 no-underline hover:no-underline bg-white hover:bg-neutral-100 rounded" },
|
|
17
|
-
React.createElement(FcGoogle, null),
|
|
18
|
-
React.createElement("p", { className: "text-[14px] text-black absolute left-0 right-0 text-center" }, "\uAD6C\uAE00\uB85C \uACC4\uC18D\uD558\uAE30"))));
|
|
15
|
+
return (_jsx("div", { className: className, children: _jsxs("a", { href: href.toString(), className: "relative flex items-center border border-neutral-300 px-4 py-3 no-underline hover:no-underline bg-white hover:bg-neutral-100 rounded", children: [_jsx(FcGoogle, {}), _jsx("p", { className: "text-[14px] text-black absolute left-0 right-0 text-center", children: "\uAD6C\uAE00\uB85C \uACC4\uC18D\uD558\uAE30" })] }) }));
|
|
19
16
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function RedirectPage(): React.JSX.Element;
|
|
1
|
+
export declare function RedirectPage(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { useNavigate } from "react-router";
|
|
4
4
|
export function RedirectPage() {
|
|
@@ -11,5 +11,5 @@ export function RedirectPage() {
|
|
|
11
11
|
navigate(redirectUrl);
|
|
12
12
|
}
|
|
13
13
|
}, [navigate]);
|
|
14
|
-
return
|
|
14
|
+
return _jsx(_Fragment, {});
|
|
15
15
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { BAD_REQUEST, createJsonResponse, INTERNAL_SERVER_ERROR, } from "../http-kit/response";
|
|
2
2
|
export class GoogleAuth {
|
|
3
|
+
AUTH;
|
|
4
|
+
GOOGLE_CLIENT_ID;
|
|
5
|
+
GOOGLE_CLIENT_SECRET;
|
|
6
|
+
GOOGLE_REDIRECT_URI;
|
|
3
7
|
constructor(AUTH, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_REDIRECT_URI) {
|
|
4
8
|
this.GOOGLE_CLIENT_ID = GOOGLE_CLIENT_ID;
|
|
5
9
|
this.GOOGLE_CLIENT_SECRET = GOOGLE_CLIENT_SECRET;
|
package/dist/esm/auth-kit/jwt.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createJsonResponse } from "../http-kit";
|
|
2
2
|
export class KakaoAuth {
|
|
3
|
+
AUTH;
|
|
3
4
|
constructor(AUTH) {
|
|
4
5
|
this.AUTH = AUTH;
|
|
5
6
|
}
|
|
@@ -22,7 +23,11 @@ export class KakaoAuth {
|
|
|
22
23
|
};
|
|
23
24
|
const user = await this.AUTH.findUser("kakao", payload);
|
|
24
25
|
if (!user) {
|
|
25
|
-
throw createJsonResponse(404)(
|
|
26
|
+
throw createJsonResponse(404)({
|
|
27
|
+
provider: "kakao",
|
|
28
|
+
...payload,
|
|
29
|
+
message: "사용자를 찾을 수 없습니다.",
|
|
30
|
+
});
|
|
26
31
|
}
|
|
27
32
|
const { accessToken, refreshToken } = await this.AUTH.issueTokenPair(user);
|
|
28
33
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type DetailedHTMLProps, type HTMLAttributes } from "react";
|
|
3
3
|
export type Props = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
4
|
-
export default function FullscreenContainer({ className, children, ...props }: Props):
|
|
4
|
+
export default function FullscreenContainer({ className, children, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare function useFullscreen(ref: React.RefObject<HTMLDivElement | null>): string;
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
2
|
import { cn } from "../../cn";
|
|
13
|
-
import React from "react";
|
|
14
3
|
import { useEffect, useRef, } from "react";
|
|
15
|
-
export default function FullscreenContainer(
|
|
16
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
4
|
+
export default function FullscreenContainer({ className, children, ...props }) {
|
|
17
5
|
const containerRef = useRef(null);
|
|
18
6
|
useFullscreen(containerRef);
|
|
19
|
-
return (
|
|
7
|
+
return (_jsx("div", { ref: containerRef, ...props, className: cn("fixed left-0 right-0 top-0 bottom-0", className), children: children }));
|
|
20
8
|
}
|
|
21
9
|
export function useFullscreen(ref) {
|
|
22
10
|
useEffect(() => {
|
|
@@ -37,7 +25,7 @@ export function useFullscreen(ref) {
|
|
|
37
25
|
return;
|
|
38
26
|
}
|
|
39
27
|
container.classList.remove("bottom-0");
|
|
40
|
-
container.style.height = `${visualViewport
|
|
28
|
+
container.style.height = `${visualViewport?.height}px`;
|
|
41
29
|
if (visualViewport.height < window.innerHeight) {
|
|
42
30
|
window.addEventListener("scroll", scroll);
|
|
43
31
|
}
|
|
@@ -46,11 +34,11 @@ export function useFullscreen(ref) {
|
|
|
46
34
|
}
|
|
47
35
|
};
|
|
48
36
|
resize();
|
|
49
|
-
visualViewport
|
|
37
|
+
visualViewport?.addEventListener("resize", resize);
|
|
50
38
|
scroll();
|
|
51
39
|
return () => {
|
|
52
40
|
window.removeEventListener("scroll", scroll);
|
|
53
|
-
visualViewport
|
|
41
|
+
visualViewport?.removeEventListener("resize", resize);
|
|
54
42
|
};
|
|
55
43
|
}, [ref]);
|
|
56
44
|
return "fixed inset-0";
|
|
@@ -11,5 +11,5 @@ export declare const ModalContext: React.Context<ModalContextProps>;
|
|
|
11
11
|
export declare function useModal(): {
|
|
12
12
|
open: () => void;
|
|
13
13
|
close: () => void;
|
|
14
|
-
Modal: (props: Omit<ModalProps, "open">) =>
|
|
14
|
+
Modal: (props: Omit<ModalProps, "open">) => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { createContext, useCallback, useEffect, useRef, useState } from "react";
|
|
2
3
|
import { createPortal } from "react-dom";
|
|
3
4
|
import Modal from "./modal";
|
|
4
|
-
import React from "react";
|
|
5
5
|
export function useModalRoot() {
|
|
6
6
|
const [container, setContainer] = useState(null);
|
|
7
7
|
useEffect(() => {
|
|
@@ -30,12 +30,10 @@ export const ModalContext = createContext({});
|
|
|
30
30
|
export function useModal() {
|
|
31
31
|
const ch2 = useRef(null);
|
|
32
32
|
const open = () => {
|
|
33
|
-
|
|
34
|
-
(_a = ch2.current) === null || _a === void 0 ? void 0 : _a.call(ch2, true);
|
|
33
|
+
ch2.current?.(true);
|
|
35
34
|
};
|
|
36
35
|
const close = () => {
|
|
37
|
-
|
|
38
|
-
(_a = ch2.current) === null || _a === void 0 ? void 0 : _a.call(ch2, false);
|
|
36
|
+
ch2.current?.(false);
|
|
39
37
|
};
|
|
40
38
|
const Component = useCallback(function Component(props) {
|
|
41
39
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -59,7 +57,7 @@ export function useModal() {
|
|
|
59
57
|
// document.body.style.overflow = "";
|
|
60
58
|
};
|
|
61
59
|
}, [isOpen]);
|
|
62
|
-
return (
|
|
60
|
+
return (_jsx(ModalContext.Provider, { value: { open, close, isOpen }, children: createPortal(_jsx(Modal, { ...props, open: isOpen, onBackgroundClick: close })) }));
|
|
63
61
|
}, []);
|
|
64
62
|
return {
|
|
65
63
|
open,
|
|
@@ -7,4 +7,4 @@ export type ModalProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivEle
|
|
|
7
7
|
always?: boolean;
|
|
8
8
|
background?: string;
|
|
9
9
|
};
|
|
10
|
-
export default function Modal({ open, className, background, onBackgroundClick, children, ...props }: ModalProps):
|
|
10
|
+
export default function Modal({ open, className, background, onBackgroundClick, children, ...props }: ModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
2
|
import React, { useEffect, useRef, } from "react";
|
|
13
3
|
import { useFullscreen } from "./fullscreen_container";
|
|
14
4
|
import { cn } from "../../cn";
|
|
15
|
-
export default function Modal(
|
|
16
|
-
var { open, className, background = "bg-gray-500/25", onBackgroundClick, children } = _a, props = __rest(_a, ["open", "className", "background", "onBackgroundClick", "children"]);
|
|
5
|
+
export default function Modal({ open, className, background = "bg-gray-500/25", onBackgroundClick, children, ...props }) {
|
|
17
6
|
const containerRef = useRef(null);
|
|
18
7
|
const fullscreen = useFullscreen(containerRef);
|
|
19
8
|
const [mounted, setMounted] = React.useState(false);
|
|
@@ -34,22 +23,21 @@ export default function Modal(_a) {
|
|
|
34
23
|
}, [open]);
|
|
35
24
|
const onBackgroundMouseDown = (event) => {
|
|
36
25
|
event.preventDefault();
|
|
37
|
-
onBackgroundClick
|
|
26
|
+
onBackgroundClick?.();
|
|
38
27
|
};
|
|
39
28
|
const onModalMouseDown = (event) => {
|
|
40
29
|
event.stopPropagation();
|
|
41
30
|
};
|
|
42
31
|
const onBackgroundTouchStart = (event) => {
|
|
43
32
|
event.preventDefault();
|
|
44
|
-
onBackgroundClick
|
|
33
|
+
onBackgroundClick?.();
|
|
45
34
|
};
|
|
46
35
|
const onModalTouchStart = (event) => {
|
|
47
36
|
event.stopPropagation();
|
|
48
37
|
};
|
|
49
|
-
return (
|
|
38
|
+
return (_jsx("div", { ref: containerRef, className: cn(fullscreen, "z-[999] flex flex-col justify-center transition-bg duration-200 md:px-6 overflow-hidden print:px-0 print:block print:overflow-auto", open && mounted
|
|
50
39
|
? cn(background, "ease-out")
|
|
51
|
-
: "bg-transparent ease-in pointer-events-none"), onMouseDown: onBackgroundMouseDown, onTouchStart: onBackgroundTouchStart
|
|
52
|
-
React.createElement("div", { className: cn("relative flex-1 flex flex-col justify-end md:justify-center items-center transition-[opacity transform] duration-200 print:block", open && mounted
|
|
40
|
+
: "bg-transparent ease-in pointer-events-none"), onMouseDown: onBackgroundMouseDown, onTouchStart: onBackgroundTouchStart, children: _jsx("div", { className: cn("relative flex-1 flex flex-col justify-end md:justify-center items-center transition-[opacity transform] duration-200 print:block", open && mounted
|
|
53
41
|
? "translate-y-[0px] opacity-100 ease-out"
|
|
54
|
-
: "translate-y-[100%] md:translate-y-[50px] opacity-0 ease-in")
|
|
42
|
+
: "translate-y-[100%] md:translate-y-[50px] opacity-0 ease-in"), children: (open || mounted) && (_jsx("div", { ...props, className: cn(className, "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"), onMouseDown: onModalMouseDown, onTouchStart: onModalTouchStart, children: children })) }) }));
|
|
55
43
|
}
|
|
@@ -25,7 +25,7 @@ export declare function useDropFileInput<T>({ defaultValue, options, uploadFile,
|
|
|
25
25
|
fileIds: string[];
|
|
26
26
|
files: FileItem<T>[];
|
|
27
27
|
setFiles: React.Dispatch<React.SetStateAction<FileItem<T>[]>>;
|
|
28
|
-
Component: ({ className, container, draggingClassName, name, hideMessage, children, ...props }: FileInputProps) =>
|
|
28
|
+
Component: ({ className, container, draggingClassName, name, hideMessage, children, ...props }: FileInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
29
|
};
|
|
30
|
-
export declare function DropFileMessageBox():
|
|
30
|
+
export declare function DropFileMessageBox(): import("react/jsx-runtime").JSX.Element;
|
|
31
31
|
export default useDropFileInput;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { useState, useCallback, useRef, useEffect, useMemo, } from "react";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback, useRef, useEffect, useMemo, } from "react";
|
|
13
3
|
import { v4 } from "uuid";
|
|
14
4
|
import { cn } from "../../cn";
|
|
15
5
|
export function useDropFileInput({ defaultValue, options, uploadFile, onFileInput, onFileUploaded, limit, } = {}) {
|
|
@@ -27,8 +17,7 @@ export function useDropFileInput({ defaultValue, options, uploadFile, onFileInpu
|
|
|
27
17
|
useEffect(() => {
|
|
28
18
|
fileRef.current = files;
|
|
29
19
|
}, [files]);
|
|
30
|
-
const Component = useCallback(function Component(
|
|
31
|
-
var { className, container = "border border-dashed border-neutral-300 rounded flex items-center justify-center", draggingClassName, name, hideMessage = false, children } = _a, props = __rest(_a, ["className", "container", "draggingClassName", "name", "hideMessage", "children"]);
|
|
20
|
+
const Component = useCallback(function Component({ className, container = "border border-dashed border-neutral-300 rounded flex items-center justify-center", draggingClassName, name, hideMessage = false, children, ...props }) {
|
|
32
21
|
const [isDragging, setIsDragging] = useState(false);
|
|
33
22
|
const handleDragEnter = useCallback((e) => {
|
|
34
23
|
e.preventDefault();
|
|
@@ -80,11 +69,14 @@ export function useDropFileInput({ defaultValue, options, uploadFile, onFileInpu
|
|
|
80
69
|
key: v4(),
|
|
81
70
|
};
|
|
82
71
|
setFiles((prevFiles) => [...prevFiles, fileItem]);
|
|
83
|
-
uploadFile
|
|
84
|
-
await
|
|
72
|
+
uploadFile?.(file, options).then(async (item) => {
|
|
73
|
+
await onFileUploaded?.(item);
|
|
85
74
|
setFiles((prevFiles) => prevFiles.map((f) => {
|
|
86
75
|
if (f.key === fileItem.key) {
|
|
87
|
-
return
|
|
76
|
+
return {
|
|
77
|
+
...f,
|
|
78
|
+
item,
|
|
79
|
+
};
|
|
88
80
|
}
|
|
89
81
|
return f;
|
|
90
82
|
}));
|
|
@@ -102,8 +94,7 @@ export function useDropFileInput({ defaultValue, options, uploadFile, onFileInpu
|
|
|
102
94
|
}, [handleFiles]);
|
|
103
95
|
const inputRef = useRef(null);
|
|
104
96
|
const handleClick = useCallback(() => {
|
|
105
|
-
|
|
106
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
97
|
+
inputRef.current?.click();
|
|
107
98
|
}, []);
|
|
108
99
|
const handleKeyDown = useCallback((e) => {
|
|
109
100
|
if (e.key === "Enter" || e.key === " ") {
|
|
@@ -116,22 +107,19 @@ export function useDropFileInput({ defaultValue, options, uploadFile, onFileInpu
|
|
|
116
107
|
e.target.value = "";
|
|
117
108
|
}
|
|
118
109
|
}, [handleFiles]);
|
|
119
|
-
return (
|
|
120
|
-
(isDragging ? "bg-neutral-300/25" : "hover:bg-neutral-300/25"), "transition-colors cursor-pointer"), onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleClick, onChange: handleChange, onKeyDown: handleKeyDown, tabIndex: 0, role: "button" },
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
.join(",") }),
|
|
133
|
-
children ||
|
|
134
|
-
(!(hideMessage && !isDragging) && React.createElement(DropFileMessageBox, null))));
|
|
110
|
+
return (_jsxs("div", { className: cn(className, container, draggingClassName?.(isDragging) ||
|
|
111
|
+
(isDragging ? "bg-neutral-300/25" : "hover:bg-neutral-300/25"), "transition-colors cursor-pointer"), onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleClick, onChange: handleChange, onKeyDown: handleKeyDown, tabIndex: 0, role: "button", children: [_jsx("input", { ...props, defaultValue: "", type: "file", hidden: true, ref: inputRef }), _jsx("input", { name: name, hidden: true, readOnly: true, value: files
|
|
112
|
+
.map((file) => {
|
|
113
|
+
if (file.item &&
|
|
114
|
+
typeof file.item === "object" &&
|
|
115
|
+
"id" in file.item) {
|
|
116
|
+
return file.item.id;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
})
|
|
120
|
+
.filter(Boolean)
|
|
121
|
+
.join(",") }), children ||
|
|
122
|
+
(!(hideMessage && !isDragging) && _jsx(DropFileMessageBox, {}))] }));
|
|
135
123
|
}, [limit, fileRef, files, options, uploadFile, onFileInput, onFileUploaded]);
|
|
136
124
|
const loadedFileIds = files
|
|
137
125
|
.map((file) => {
|
|
@@ -151,8 +139,6 @@ export function useDropFileInput({ defaultValue, options, uploadFile, onFileInpu
|
|
|
151
139
|
};
|
|
152
140
|
}
|
|
153
141
|
export function DropFileMessageBox() {
|
|
154
|
-
return (
|
|
155
|
-
React.createElement("div", { className: "flex flex-col items-center" },
|
|
156
|
-
React.createElement("span", null, "\uD30C\uC77C\uC744 \uC5EC\uAE30\uB85C \uB04C\uC5B4\uB2E4 \uB193\uAC70\uB098 \uD074\uB9AD\uD574\uC11C \uC120\uD0DD\uD574 \uC8FC\uC138\uC694"))));
|
|
142
|
+
return (_jsx("div", { className: "text-sm pointer-events-none flex justify-center items-center", children: _jsx("div", { className: "flex flex-col items-center", children: _jsx("span", { children: "\uD30C\uC77C\uC744 \uC5EC\uAE30\uB85C \uB04C\uC5B4\uB2E4 \uB193\uAC70\uB098 \uD074\uB9AD\uD574\uC11C \uC120\uD0DD\uD574 \uC8FC\uC138\uC694" }) }) }));
|
|
157
143
|
}
|
|
158
144
|
export default useDropFileInput;
|