dn-react-router-toolkit 0.2.7 → 0.3.2
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/api/create_handler.d.mts +13 -0
- package/dist/api/create_handler.d.ts +13 -0
- package/dist/api/create_handler.js +298 -0
- package/dist/api/create_handler.mjs +304 -0
- package/dist/api/index.d.mts +4 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +298 -0
- package/dist/api/index.mjs +304 -0
- package/dist/auth/client/index.d.mts +3 -0
- package/dist/auth/client/index.d.ts +3 -0
- package/dist/{date.js → auth/client/index.js} +25 -32
- package/dist/auth/client/index.mjs +21 -0
- package/dist/auth/client/redirect_page.d.mts +1 -0
- package/dist/auth/client/redirect_page.d.ts +1 -0
- package/dist/auth/cookie_store.d.mts +13 -0
- package/dist/auth/cookie_store.d.ts +13 -0
- package/dist/{text_editor/plugins/keymap.js → auth/cookie_store.js} +24 -16
- package/dist/auth/cookie_store.mjs +23 -0
- package/dist/auth/index.d.mts +5 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.js +139 -0
- package/dist/auth/index.mjs +111 -0
- package/dist/auth/server/index.d.mts +1 -0
- package/dist/auth/server/index.d.ts +1 -0
- package/dist/{slug.js → auth/server/index.js} +6 -14
- package/dist/auth/server/index.mjs +2 -0
- package/dist/auth/with_auth.d.mts +2 -6
- package/dist/auth/with_auth.d.ts +2 -6
- package/dist/auth/with_auth.js +3 -0
- package/dist/auth/with_auth.mjs +3 -0
- package/dist/{components → client}/client_env.d.mts +1 -1
- package/dist/{components → client}/client_env.d.ts +1 -1
- package/dist/{components → client}/client_env.js +6 -2
- package/dist/{components → client}/client_env.mjs +2 -2
- package/dist/client/index.d.mts +3 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/{auth/client/google_login_button.js → client/index.js} +30 -33
- package/dist/client/index.mjs +31 -0
- package/dist/client/use_user_agent.d.mts +8 -0
- package/dist/client/use_user_agent.d.ts +8 -0
- package/dist/{file/client/format_size.js → client/use_user_agent.js} +14 -14
- package/dist/client/use_user_agent.mjs +13 -0
- package/dist/file/client/index.d.mts +1 -0
- package/dist/file/client/index.d.ts +1 -0
- package/dist/file/{cdn.js → client/index.js} +6 -16
- package/dist/file/client/index.mjs +2 -0
- package/dist/file/index.d.mts +1 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/{cn.js → file/index.js} +6 -14
- package/dist/file/index.mjs +2 -0
- package/dist/file/server/index.d.mts +1 -0
- package/dist/file/server/index.d.ts +1 -0
- package/dist/file/server/index.js +24 -0
- package/dist/file/server/index.mjs +2 -0
- package/dist/http/index.d.mts +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +3 -90
- package/dist/http/index.mjs +2 -68
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +3 -79
- package/dist/index.mjs +2 -58
- package/dist/modal/index.d.mts +1 -0
- package/dist/modal/index.d.ts +1 -0
- package/dist/{sleep.js → modal/index.js} +6 -14
- package/dist/modal/index.mjs +2 -0
- package/dist/seo/index.d.mts +4 -0
- package/dist/seo/index.d.ts +4 -0
- package/dist/seo/index.js +304 -0
- package/dist/seo/index.mjs +267 -0
- package/dist/text_editor/index.d.mts +1 -0
- package/dist/text_editor/index.d.ts +1 -0
- package/dist/text_editor/index.js +24 -0
- package/dist/text_editor/index.mjs +2 -0
- package/package.json +58 -32
- package/dist/auth/apple_auth.d.mts +0 -38
- package/dist/auth/apple_auth.d.ts +0 -38
- package/dist/auth/apple_auth.js +0 -88
- package/dist/auth/apple_auth.mjs +0 -63
- package/dist/auth/auth_repository.d.mts +0 -41
- package/dist/auth/auth_repository.d.ts +0 -41
- package/dist/auth/auth_repository.js +0 -18
- package/dist/auth/auth_repository.mjs +0 -0
- package/dist/auth/auth_service.d.mts +0 -63
- package/dist/auth/auth_service.d.ts +0 -63
- package/dist/auth/auth_service.js +0 -210
- package/dist/auth/auth_service.mjs +0 -171
- package/dist/auth/client/google_login_button.d.mts +0 -7
- package/dist/auth/client/google_login_button.d.ts +0 -7
- package/dist/auth/client/google_login_button.mjs +0 -37
- package/dist/auth/client/provider.d.mts +0 -24
- package/dist/auth/client/provider.d.ts +0 -24
- package/dist/auth/client/provider.js +0 -154
- package/dist/auth/client/provider.mjs +0 -118
- package/dist/auth/google_auth.d.mts +0 -33
- package/dist/auth/google_auth.d.ts +0 -33
- package/dist/auth/google_auth.js +0 -135
- package/dist/auth/google_auth.mjs +0 -108
- package/dist/auth/handlers/find_auth.d.mts +0 -13
- package/dist/auth/handlers/find_auth.d.ts +0 -13
- package/dist/auth/handlers/find_auth.js +0 -82
- package/dist/auth/handlers/find_auth.mjs +0 -55
- package/dist/auth/handlers/login.d.mts +0 -13
- package/dist/auth/handlers/login.d.ts +0 -13
- package/dist/auth/handlers/login.js +0 -107
- package/dist/auth/handlers/login.mjs +0 -80
- package/dist/auth/handlers/login_with_thirdparty.d.mts +0 -15
- package/dist/auth/handlers/login_with_thirdparty.d.ts +0 -15
- package/dist/auth/handlers/login_with_thirdparty.js +0 -98
- package/dist/auth/handlers/login_with_thirdparty.mjs +0 -71
- package/dist/auth/handlers/logout.d.mts +0 -13
- package/dist/auth/handlers/logout.d.ts +0 -13
- package/dist/auth/handlers/logout.js +0 -102
- package/dist/auth/handlers/logout.mjs +0 -75
- package/dist/auth/handlers/refresh.d.mts +0 -13
- package/dist/auth/handlers/refresh.d.ts +0 -13
- package/dist/auth/handlers/refresh.js +0 -92
- package/dist/auth/handlers/refresh.mjs +0 -65
- package/dist/auth/handlers/request_password_reset.d.mts +0 -10
- package/dist/auth/handlers/request_password_reset.d.ts +0 -10
- package/dist/auth/handlers/request_password_reset.js +0 -87
- package/dist/auth/handlers/request_password_reset.mjs +0 -60
- package/dist/auth/handlers/reset_password.d.mts +0 -10
- package/dist/auth/handlers/reset_password.d.ts +0 -10
- package/dist/auth/handlers/reset_password.js +0 -88
- package/dist/auth/handlers/reset_password.mjs +0 -61
- package/dist/auth/handlers/signup.d.mts +0 -15
- package/dist/auth/handlers/signup.d.ts +0 -15
- package/dist/auth/handlers/signup.js +0 -147
- package/dist/auth/handlers/signup.mjs +0 -112
- package/dist/auth/handlers/signup_with_thirdparty.d.mts +0 -17
- package/dist/auth/handlers/signup_with_thirdparty.d.ts +0 -17
- package/dist/auth/handlers/signup_with_thirdparty.js +0 -123
- package/dist/auth/handlers/signup_with_thirdparty.mjs +0 -98
- package/dist/auth/handlers/thirdparty_auth_callback.d.mts +0 -16
- package/dist/auth/handlers/thirdparty_auth_callback.d.ts +0 -16
- package/dist/auth/handlers/thirdparty_auth_callback.js +0 -129
- package/dist/auth/handlers/thirdparty_auth_callback.mjs +0 -102
- package/dist/auth/jwt_manager.d.mts +0 -38
- package/dist/auth/jwt_manager.d.ts +0 -38
- package/dist/auth/jwt_manager.js +0 -90
- package/dist/auth/jwt_manager.mjs +0 -65
- package/dist/auth/kakao_auth.d.mts +0 -27
- package/dist/auth/kakao_auth.d.ts +0 -27
- package/dist/auth/kakao_auth.js +0 -56
- package/dist/auth/kakao_auth.mjs +0 -31
- package/dist/auth/password_recovery.d.mts +0 -34
- package/dist/auth/password_recovery.d.ts +0 -34
- package/dist/auth/password_recovery.js +0 -169
- package/dist/auth/password_recovery.mjs +0 -134
- package/dist/auth/thirdparty_auth.d.mts +0 -41
- package/dist/auth/thirdparty_auth.d.ts +0 -41
- package/dist/auth/thirdparty_auth.js +0 -113
- package/dist/auth/thirdparty_auth.mjs +0 -86
- package/dist/cn.d.mts +0 -3
- package/dist/cn.d.ts +0 -3
- package/dist/cn.mjs +0 -7
- package/dist/components/index.d.mts +0 -5
- package/dist/components/index.d.ts +0 -5
- package/dist/components/index.js +0 -261
- package/dist/components/index.mjs +0 -219
- package/dist/components/modal/fullscreen_container.d.mts +0 -7
- package/dist/components/modal/fullscreen_container.d.ts +0 -7
- package/dist/components/modal/fullscreen_container.js +0 -102
- package/dist/components/modal/fullscreen_container.mjs +0 -68
- package/dist/components/modal/hooks.d.mts +0 -18
- package/dist/components/modal/hooks.d.ts +0 -18
- package/dist/components/modal/hooks.js +0 -236
- package/dist/components/modal/hooks.mjs +0 -204
- package/dist/components/modal/index.d.mts +0 -4
- package/dist/components/modal/index.d.ts +0 -4
- package/dist/components/modal/index.js +0 -238
- package/dist/components/modal/index.mjs +0 -203
- package/dist/components/modal/modal.d.mts +0 -13
- package/dist/components/modal/modal.d.ts +0 -13
- package/dist/components/modal/modal.js +0 -155
- package/dist/components/modal/modal.mjs +0 -130
- package/dist/components/styles.d.mts +0 -9
- package/dist/components/styles.d.ts +0 -9
- package/dist/components/styles.js +0 -48
- package/dist/components/styles.mjs +0 -17
- package/dist/date.d.mts +0 -5
- package/dist/date.d.ts +0 -5
- package/dist/date.mjs +0 -29
- package/dist/file/cdn.d.mts +0 -6
- package/dist/file/cdn.d.ts +0 -6
- package/dist/file/cdn.mjs +0 -9
- package/dist/file/client/drop_file_input.d.mts +0 -36
- package/dist/file/client/drop_file_input.d.ts +0 -36
- package/dist/file/client/drop_file_input.js +0 -323
- package/dist/file/client/drop_file_input.mjs +0 -294
- package/dist/file/client/file_upload_button.d.mts +0 -10
- package/dist/file/client/file_upload_button.d.ts +0 -10
- package/dist/file/client/file_upload_button.js +0 -89
- package/dist/file/client/file_upload_button.mjs +0 -58
- package/dist/file/client/file_uploader.d.mts +0 -13
- package/dist/file/client/file_uploader.d.ts +0 -13
- package/dist/file/client/file_uploader.js +0 -163
- package/dist/file/client/file_uploader.mjs +0 -136
- package/dist/file/client/format_size.d.mts +0 -3
- package/dist/file/client/format_size.d.ts +0 -3
- package/dist/file/client/format_size.mjs +0 -13
- package/dist/file/client/metadata.d.mts +0 -7
- package/dist/file/client/metadata.d.ts +0 -7
- package/dist/file/client/metadata.js +0 -85
- package/dist/file/client/metadata.mjs +0 -60
- package/dist/file/file_repository.d.mts +0 -16
- package/dist/file/file_repository.d.ts +0 -16
- package/dist/file/file_repository.js +0 -18
- package/dist/file/file_repository.mjs +0 -0
- package/dist/file/file_service.d.mts +0 -32
- package/dist/file/file_service.d.ts +0 -32
- package/dist/file/file_service.js +0 -66
- package/dist/file/file_service.mjs +0 -41
- package/dist/file/handlers/delete_file.d.mts +0 -17
- package/dist/file/handlers/delete_file.d.ts +0 -17
- package/dist/file/handlers/delete_file.js +0 -99
- package/dist/file/handlers/delete_file.mjs +0 -72
- package/dist/file/handlers/upload_file.d.mts +0 -16
- package/dist/file/handlers/upload_file.d.ts +0 -16
- package/dist/file/handlers/upload_file.js +0 -106
- package/dist/file/handlers/upload_file.mjs +0 -79
- package/dist/file/object_storage.d.mts +0 -20
- package/dist/file/object_storage.d.ts +0 -20
- package/dist/file/object_storage.js +0 -90
- package/dist/file/object_storage.mjs +0 -70
- package/dist/file/responsive_image.d.mts +0 -20
- package/dist/file/responsive_image.d.ts +0 -20
- package/dist/file/responsive_image.js +0 -132
- package/dist/file/responsive_image.mjs +0 -96
- package/dist/http/response.d.mts +0 -19
- package/dist/http/response.d.ts +0 -19
- package/dist/http/response.js +0 -109
- package/dist/http/response.mjs +0 -68
- package/dist/route/api.d.mts +0 -21
- package/dist/route/api.d.ts +0 -21
- package/dist/route/api.js +0 -584
- package/dist/route/api.mjs +0 -547
- package/dist/singleton.d.mts +0 -3
- package/dist/singleton.d.ts +0 -3
- package/dist/singleton.js +0 -37
- package/dist/singleton.mjs +0 -12
- package/dist/sleep.d.mts +0 -3
- package/dist/sleep.d.ts +0 -3
- package/dist/sleep.mjs +0 -7
- package/dist/slug.d.mts +0 -3
- package/dist/slug.d.ts +0 -3
- package/dist/slug.mjs +0 -7
- package/dist/text_editor/attach_media.d.mts +0 -16
- package/dist/text_editor/attach_media.d.ts +0 -16
- package/dist/text_editor/attach_media.js +0 -237
- package/dist/text_editor/attach_media.mjs +0 -210
- package/dist/text_editor/plugins/drag_and_drop.d.mts +0 -13
- package/dist/text_editor/plugins/drag_and_drop.d.ts +0 -13
- package/dist/text_editor/plugins/drag_and_drop.js +0 -59
- package/dist/text_editor/plugins/drag_and_drop.mjs +0 -34
- package/dist/text_editor/plugins/keymap.d.mts +0 -5
- package/dist/text_editor/plugins/keymap.d.ts +0 -5
- package/dist/text_editor/plugins/keymap.mjs +0 -15
- package/dist/text_editor/plugins/placehoder.d.mts +0 -5
- package/dist/text_editor/plugins/placehoder.d.ts +0 -5
- package/dist/text_editor/plugins/placehoder.js +0 -112
- package/dist/text_editor/plugins/placehoder.mjs +0 -87
- package/dist/text_editor/plugins/trailing_paragraph.d.mts +0 -5
- package/dist/text_editor/plugins/trailing_paragraph.d.ts +0 -5
- package/dist/text_editor/plugins/trailing_paragraph.js +0 -46
- package/dist/text_editor/plugins/trailing_paragraph.mjs +0 -21
- package/dist/text_editor/plugins/upload_placeholder.d.mts +0 -7
- package/dist/text_editor/plugins/upload_placeholder.d.ts +0 -7
- package/dist/text_editor/plugins/upload_placeholder.js +0 -94
- package/dist/text_editor/plugins/upload_placeholder.mjs +0 -68
- package/dist/text_editor/schema.d.mts +0 -9
- package/dist/text_editor/schema.d.ts +0 -9
- package/dist/text_editor/schema.js +0 -354
- package/dist/text_editor/schema.mjs +0 -319
- package/dist/text_editor/text_editor.d.mts +0 -45
- package/dist/text_editor/text_editor.d.ts +0 -45
- package/dist/text_editor/text_editor.js +0 -834
- package/dist/text_editor/text_editor.mjs +0 -806
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileUploaderOptions } from './file_uploader.mjs';
|
|
3
|
-
|
|
4
|
-
type FileInputProps = Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "onChange"> & {
|
|
5
|
-
container?: string;
|
|
6
|
-
accept?: string;
|
|
7
|
-
multiple?: boolean;
|
|
8
|
-
name?: string;
|
|
9
|
-
hideMessage?: boolean;
|
|
10
|
-
draggingClassName?: (value: boolean) => string;
|
|
11
|
-
};
|
|
12
|
-
type FileItem<T> = {
|
|
13
|
-
key: string;
|
|
14
|
-
width?: number;
|
|
15
|
-
height?: number;
|
|
16
|
-
item?: T;
|
|
17
|
-
};
|
|
18
|
-
type Props<TFile> = {
|
|
19
|
-
defaultValue?: TFile | TFile[];
|
|
20
|
-
options?: FileUploaderOptions;
|
|
21
|
-
onFileInput?: (files: File[]) => void;
|
|
22
|
-
onFileUploaded?: (file: TFile) => Promise<void>;
|
|
23
|
-
onChange?: (files: TFile[]) => void;
|
|
24
|
-
limit?: number;
|
|
25
|
-
};
|
|
26
|
-
declare function createUseDropFileInput<TFile>({ uploadFile, }: {
|
|
27
|
-
uploadFile: (file: File, options?: FileUploaderOptions) => Promise<TFile>;
|
|
28
|
-
}): ({ defaultValue, options, onChange, onFileInput, onFileUploaded, limit, }?: Props<TFile>) => {
|
|
29
|
-
fileIds: string[];
|
|
30
|
-
files: FileItem<TFile>[];
|
|
31
|
-
setFiles: React.Dispatch<React.SetStateAction<FileItem<TFile>[]>>;
|
|
32
|
-
Component: ({ className, container, draggingClassName, name, hideMessage, children, ...props }: FileInputProps) => React.JSX.Element;
|
|
33
|
-
};
|
|
34
|
-
declare function DropFileMessageBox(): React.JSX.Element;
|
|
35
|
-
|
|
36
|
-
export { DropFileMessageBox, type FileInputProps, type FileItem, createUseDropFileInput as default };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileUploaderOptions } from './file_uploader.js';
|
|
3
|
-
|
|
4
|
-
type FileInputProps = Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "onChange"> & {
|
|
5
|
-
container?: string;
|
|
6
|
-
accept?: string;
|
|
7
|
-
multiple?: boolean;
|
|
8
|
-
name?: string;
|
|
9
|
-
hideMessage?: boolean;
|
|
10
|
-
draggingClassName?: (value: boolean) => string;
|
|
11
|
-
};
|
|
12
|
-
type FileItem<T> = {
|
|
13
|
-
key: string;
|
|
14
|
-
width?: number;
|
|
15
|
-
height?: number;
|
|
16
|
-
item?: T;
|
|
17
|
-
};
|
|
18
|
-
type Props<TFile> = {
|
|
19
|
-
defaultValue?: TFile | TFile[];
|
|
20
|
-
options?: FileUploaderOptions;
|
|
21
|
-
onFileInput?: (files: File[]) => void;
|
|
22
|
-
onFileUploaded?: (file: TFile) => Promise<void>;
|
|
23
|
-
onChange?: (files: TFile[]) => void;
|
|
24
|
-
limit?: number;
|
|
25
|
-
};
|
|
26
|
-
declare function createUseDropFileInput<TFile>({ uploadFile, }: {
|
|
27
|
-
uploadFile: (file: File, options?: FileUploaderOptions) => Promise<TFile>;
|
|
28
|
-
}): ({ defaultValue, options, onChange, onFileInput, onFileUploaded, limit, }?: Props<TFile>) => {
|
|
29
|
-
fileIds: string[];
|
|
30
|
-
files: FileItem<TFile>[];
|
|
31
|
-
setFiles: React.Dispatch<React.SetStateAction<FileItem<TFile>[]>>;
|
|
32
|
-
Component: ({ className, container, draggingClassName, name, hideMessage, children, ...props }: FileInputProps) => React.JSX.Element;
|
|
33
|
-
};
|
|
34
|
-
declare function DropFileMessageBox(): React.JSX.Element;
|
|
35
|
-
|
|
36
|
-
export { DropFileMessageBox, type FileInputProps, type FileItem, createUseDropFileInput as default };
|
|
@@ -1,323 +0,0 @@
|
|
|
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/file/client/drop_file_input.tsx
|
|
31
|
-
var drop_file_input_exports = {};
|
|
32
|
-
__export(drop_file_input_exports, {
|
|
33
|
-
DropFileMessageBox: () => DropFileMessageBox,
|
|
34
|
-
default: () => createUseDropFileInput
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(drop_file_input_exports);
|
|
37
|
-
var import_react = __toESM(require("react"));
|
|
38
|
-
var import_uuid = require("uuid");
|
|
39
|
-
|
|
40
|
-
// src/cn.ts
|
|
41
|
-
function cn(...classes) {
|
|
42
|
-
return classes.filter(Boolean).join(" ").trim();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// src/file/client/metadata.ts
|
|
46
|
-
function generateMetadata(blob, {
|
|
47
|
-
uploadBlob
|
|
48
|
-
} = {}) {
|
|
49
|
-
return new Promise((resolve) => {
|
|
50
|
-
if (blob.type.startsWith("image/")) {
|
|
51
|
-
const img = new Image();
|
|
52
|
-
img.src = URL.createObjectURL(blob);
|
|
53
|
-
img.onload = () => {
|
|
54
|
-
resolve({
|
|
55
|
-
width: img.width,
|
|
56
|
-
height: img.height
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
img.onerror = () => resolve({});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (blob.type.startsWith("video/")) {
|
|
63
|
-
const video = document.createElement("video");
|
|
64
|
-
video.onloadeddata = () => {
|
|
65
|
-
const canvas = document.createElement("canvas");
|
|
66
|
-
canvas.width = video.videoWidth;
|
|
67
|
-
canvas.height = video.videoHeight;
|
|
68
|
-
const context = canvas.getContext("2d");
|
|
69
|
-
if (!context || !uploadBlob) {
|
|
70
|
-
return resolve({
|
|
71
|
-
width: video.videoWidth,
|
|
72
|
-
height: video.videoHeight
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
video.addEventListener("seeked", () => {
|
|
76
|
-
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
77
|
-
canvas.toBlob((blob2) => {
|
|
78
|
-
if (!blob2) {
|
|
79
|
-
return resolve({
|
|
80
|
-
width: video.videoWidth,
|
|
81
|
-
height: video.videoHeight
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
uploadBlob(blob2, "poster").then(({ url }) => {
|
|
85
|
-
resolve({
|
|
86
|
-
width: video.videoWidth,
|
|
87
|
-
height: video.videoHeight,
|
|
88
|
-
poster: url
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}, "image/jpeg");
|
|
92
|
-
});
|
|
93
|
-
video.currentTime = 0;
|
|
94
|
-
};
|
|
95
|
-
video.onerror = () => resolve({});
|
|
96
|
-
video.src = URL.createObjectURL(blob);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
resolve({});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/file/client/drop_file_input.tsx
|
|
104
|
-
function createUseDropFileInput({
|
|
105
|
-
uploadFile
|
|
106
|
-
}) {
|
|
107
|
-
return function useDropFileInput({
|
|
108
|
-
defaultValue,
|
|
109
|
-
options,
|
|
110
|
-
onChange,
|
|
111
|
-
onFileInput,
|
|
112
|
-
onFileUploaded,
|
|
113
|
-
limit
|
|
114
|
-
} = {}) {
|
|
115
|
-
const [files, setFiles] = (0, import_react.useState)(
|
|
116
|
-
defaultValue ? (Array.isArray(defaultValue) ? defaultValue : [defaultValue]).map((v) => {
|
|
117
|
-
return {
|
|
118
|
-
key: (0, import_uuid.v4)(),
|
|
119
|
-
item: v
|
|
120
|
-
};
|
|
121
|
-
}).slice(0, limit ? limit : Infinity) : []
|
|
122
|
-
);
|
|
123
|
-
const fileRef = (0, import_react.useRef)([]);
|
|
124
|
-
(0, import_react.useEffect)(() => {
|
|
125
|
-
fileRef.current = files;
|
|
126
|
-
onChange?.(files.map((f) => f.item).filter(Boolean));
|
|
127
|
-
}, [files]);
|
|
128
|
-
const Component = (0, import_react.useCallback)(
|
|
129
|
-
function Component2({
|
|
130
|
-
className,
|
|
131
|
-
container = "border border-dashed border-neutral-300 rounded flex items-center justify-center",
|
|
132
|
-
draggingClassName,
|
|
133
|
-
name,
|
|
134
|
-
hideMessage = false,
|
|
135
|
-
children,
|
|
136
|
-
...props
|
|
137
|
-
}) {
|
|
138
|
-
const [isDragging, setIsDragging] = (0, import_react.useState)(false);
|
|
139
|
-
const handleDragEnter = (0, import_react.useCallback)((e) => {
|
|
140
|
-
e.preventDefault();
|
|
141
|
-
e.stopPropagation();
|
|
142
|
-
setIsDragging(true);
|
|
143
|
-
}, []);
|
|
144
|
-
const handleDragLeave = (0, import_react.useCallback)((e) => {
|
|
145
|
-
e.preventDefault();
|
|
146
|
-
e.stopPropagation();
|
|
147
|
-
setIsDragging(false);
|
|
148
|
-
}, []);
|
|
149
|
-
const handleDragOver = (0, import_react.useCallback)((e) => {
|
|
150
|
-
e.preventDefault();
|
|
151
|
-
e.stopPropagation();
|
|
152
|
-
}, []);
|
|
153
|
-
const handleFiles = (0, import_react.useCallback)(
|
|
154
|
-
async (files2) => {
|
|
155
|
-
if (limit && fileRef.current.length >= limit) {
|
|
156
|
-
alert(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${limit}\uAC1C \uC5C5\uB85C\uB4DC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
const filteredFiles = files2.filter((file) => {
|
|
160
|
-
if (!props.accept) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
const accepts = props.accept.split(",");
|
|
164
|
-
for (const accept of accepts) {
|
|
165
|
-
const trimmedAccept = accept.trim();
|
|
166
|
-
if (file.type === trimmedAccept || file.type.endsWith(trimmedAccept) || file.name.endsWith(trimmedAccept)) {
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
if (trimmedAccept.endsWith("/*")) {
|
|
170
|
-
const baseType = trimmedAccept.replace("/*", "");
|
|
171
|
-
if (file.type.startsWith(baseType + "/")) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return false;
|
|
177
|
-
});
|
|
178
|
-
if (files2.length !== filteredFiles.length) {
|
|
179
|
-
alert(`${props.accept} \uD615\uC2DD\uC758 \uD30C\uC77C\uB9CC \uC5C5\uB85C\uB4DC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
180
|
-
}
|
|
181
|
-
const limitedFiles = filteredFiles.slice(
|
|
182
|
-
0,
|
|
183
|
-
limit ? limit - fileRef.current.length : Infinity
|
|
184
|
-
);
|
|
185
|
-
if (limitedFiles.length === 0) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (onFileInput) {
|
|
189
|
-
onFileInput(limitedFiles);
|
|
190
|
-
}
|
|
191
|
-
for (const file of limitedFiles) {
|
|
192
|
-
const { width, height } = await generateMetadata(file);
|
|
193
|
-
const fileItem = {
|
|
194
|
-
key: (0, import_uuid.v4)(),
|
|
195
|
-
width: Number(width) || void 0,
|
|
196
|
-
height: Number(height) || void 0
|
|
197
|
-
};
|
|
198
|
-
setFiles((prevFiles) => [...prevFiles, fileItem]);
|
|
199
|
-
uploadFile?.(file, options).then(async (item) => {
|
|
200
|
-
await onFileUploaded?.(item);
|
|
201
|
-
setFiles(
|
|
202
|
-
(prevFiles) => prevFiles.map((f) => {
|
|
203
|
-
if (f.key === fileItem.key) {
|
|
204
|
-
return {
|
|
205
|
-
...f,
|
|
206
|
-
item
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
return f;
|
|
210
|
-
})
|
|
211
|
-
);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
[props.accept]
|
|
216
|
-
);
|
|
217
|
-
const handleDrop = (0, import_react.useCallback)(
|
|
218
|
-
(e) => {
|
|
219
|
-
e.preventDefault();
|
|
220
|
-
e.stopPropagation();
|
|
221
|
-
setIsDragging(false);
|
|
222
|
-
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
223
|
-
handleFiles(Array.from(e.dataTransfer.files));
|
|
224
|
-
e.dataTransfer.clearData();
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
[handleFiles]
|
|
228
|
-
);
|
|
229
|
-
const inputRef = (0, import_react.useRef)(null);
|
|
230
|
-
const handleClick = (0, import_react.useCallback)(() => {
|
|
231
|
-
inputRef.current?.click();
|
|
232
|
-
}, []);
|
|
233
|
-
const handleKeyDown = (0, import_react.useCallback)(
|
|
234
|
-
(e) => {
|
|
235
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
236
|
-
handleClick();
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
[handleClick]
|
|
240
|
-
);
|
|
241
|
-
const handleChange = (0, import_react.useCallback)(
|
|
242
|
-
(e) => {
|
|
243
|
-
if (e.target.files && e.target.files.length > 0) {
|
|
244
|
-
handleFiles(Array.from(e.target.files));
|
|
245
|
-
e.target.value = "";
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
[handleFiles]
|
|
249
|
-
);
|
|
250
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
251
|
-
"div",
|
|
252
|
-
{
|
|
253
|
-
className: cn(
|
|
254
|
-
className,
|
|
255
|
-
container,
|
|
256
|
-
draggingClassName?.(isDragging) || (isDragging ? "bg-neutral-300/25" : "hover:bg-neutral-300/25"),
|
|
257
|
-
"transition-colors cursor-pointer"
|
|
258
|
-
),
|
|
259
|
-
onDragEnter: handleDragEnter,
|
|
260
|
-
onDragLeave: handleDragLeave,
|
|
261
|
-
onDragOver: handleDragOver,
|
|
262
|
-
onDrop: handleDrop,
|
|
263
|
-
onClick: handleClick,
|
|
264
|
-
onChange: handleChange,
|
|
265
|
-
onKeyDown: handleKeyDown,
|
|
266
|
-
tabIndex: 0,
|
|
267
|
-
role: "button"
|
|
268
|
-
},
|
|
269
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
270
|
-
"input",
|
|
271
|
-
{
|
|
272
|
-
...props,
|
|
273
|
-
defaultValue: "",
|
|
274
|
-
type: "file",
|
|
275
|
-
hidden: true,
|
|
276
|
-
ref: inputRef
|
|
277
|
-
}
|
|
278
|
-
),
|
|
279
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
280
|
-
"input",
|
|
281
|
-
{
|
|
282
|
-
name,
|
|
283
|
-
hidden: true,
|
|
284
|
-
readOnly: true,
|
|
285
|
-
value: files.map((file) => {
|
|
286
|
-
if (file.item && typeof file.item === "object" && "id" in file.item) {
|
|
287
|
-
return file.item.id;
|
|
288
|
-
}
|
|
289
|
-
return null;
|
|
290
|
-
}).filter(Boolean).join(",")
|
|
291
|
-
}
|
|
292
|
-
),
|
|
293
|
-
children || !(hideMessage && !isDragging) && /* @__PURE__ */ import_react.default.createElement(DropFileMessageBox, null)
|
|
294
|
-
);
|
|
295
|
-
},
|
|
296
|
-
[limit, fileRef, files, options, uploadFile, onFileInput, onFileUploaded]
|
|
297
|
-
);
|
|
298
|
-
const loadedFileIds = files.map((file) => {
|
|
299
|
-
if (file.item && typeof file.item === "object" && "id" in file.item) {
|
|
300
|
-
return file.item.id;
|
|
301
|
-
}
|
|
302
|
-
return null;
|
|
303
|
-
}).filter(Boolean);
|
|
304
|
-
const loadedFileIdsString = loadedFileIds.join(",");
|
|
305
|
-
const fileIds = (0, import_react.useMemo)(
|
|
306
|
-
() => loadedFileIdsString.split(",").filter(Boolean),
|
|
307
|
-
[loadedFileIdsString]
|
|
308
|
-
);
|
|
309
|
-
return {
|
|
310
|
-
fileIds,
|
|
311
|
-
files,
|
|
312
|
-
setFiles,
|
|
313
|
-
Component
|
|
314
|
-
};
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
function DropFileMessageBox() {
|
|
318
|
-
return /* @__PURE__ */ import_react.default.createElement("div", { className: "text-sm pointer-events-none flex justify-center items-center" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "flex flex-col items-center" }, /* @__PURE__ */ import_react.default.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")));
|
|
319
|
-
}
|
|
320
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
321
|
-
0 && (module.exports = {
|
|
322
|
-
DropFileMessageBox
|
|
323
|
-
});
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
// src/file/client/drop_file_input.tsx
|
|
2
|
-
import React, {
|
|
3
|
-
useState,
|
|
4
|
-
useCallback,
|
|
5
|
-
useRef,
|
|
6
|
-
useEffect,
|
|
7
|
-
useMemo
|
|
8
|
-
} from "react";
|
|
9
|
-
import { v4 } from "uuid";
|
|
10
|
-
|
|
11
|
-
// src/cn.ts
|
|
12
|
-
function cn(...classes) {
|
|
13
|
-
return classes.filter(Boolean).join(" ").trim();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// src/file/client/metadata.ts
|
|
17
|
-
function generateMetadata(blob, {
|
|
18
|
-
uploadBlob
|
|
19
|
-
} = {}) {
|
|
20
|
-
return new Promise((resolve) => {
|
|
21
|
-
if (blob.type.startsWith("image/")) {
|
|
22
|
-
const img = new Image();
|
|
23
|
-
img.src = URL.createObjectURL(blob);
|
|
24
|
-
img.onload = () => {
|
|
25
|
-
resolve({
|
|
26
|
-
width: img.width,
|
|
27
|
-
height: img.height
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
img.onerror = () => resolve({});
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (blob.type.startsWith("video/")) {
|
|
34
|
-
const video = document.createElement("video");
|
|
35
|
-
video.onloadeddata = () => {
|
|
36
|
-
const canvas = document.createElement("canvas");
|
|
37
|
-
canvas.width = video.videoWidth;
|
|
38
|
-
canvas.height = video.videoHeight;
|
|
39
|
-
const context = canvas.getContext("2d");
|
|
40
|
-
if (!context || !uploadBlob) {
|
|
41
|
-
return resolve({
|
|
42
|
-
width: video.videoWidth,
|
|
43
|
-
height: video.videoHeight
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
video.addEventListener("seeked", () => {
|
|
47
|
-
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
48
|
-
canvas.toBlob((blob2) => {
|
|
49
|
-
if (!blob2) {
|
|
50
|
-
return resolve({
|
|
51
|
-
width: video.videoWidth,
|
|
52
|
-
height: video.videoHeight
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
uploadBlob(blob2, "poster").then(({ url }) => {
|
|
56
|
-
resolve({
|
|
57
|
-
width: video.videoWidth,
|
|
58
|
-
height: video.videoHeight,
|
|
59
|
-
poster: url
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}, "image/jpeg");
|
|
63
|
-
});
|
|
64
|
-
video.currentTime = 0;
|
|
65
|
-
};
|
|
66
|
-
video.onerror = () => resolve({});
|
|
67
|
-
video.src = URL.createObjectURL(blob);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
resolve({});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/file/client/drop_file_input.tsx
|
|
75
|
-
function createUseDropFileInput({
|
|
76
|
-
uploadFile
|
|
77
|
-
}) {
|
|
78
|
-
return function useDropFileInput({
|
|
79
|
-
defaultValue,
|
|
80
|
-
options,
|
|
81
|
-
onChange,
|
|
82
|
-
onFileInput,
|
|
83
|
-
onFileUploaded,
|
|
84
|
-
limit
|
|
85
|
-
} = {}) {
|
|
86
|
-
const [files, setFiles] = useState(
|
|
87
|
-
defaultValue ? (Array.isArray(defaultValue) ? defaultValue : [defaultValue]).map((v) => {
|
|
88
|
-
return {
|
|
89
|
-
key: v4(),
|
|
90
|
-
item: v
|
|
91
|
-
};
|
|
92
|
-
}).slice(0, limit ? limit : Infinity) : []
|
|
93
|
-
);
|
|
94
|
-
const fileRef = useRef([]);
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
fileRef.current = files;
|
|
97
|
-
onChange?.(files.map((f) => f.item).filter(Boolean));
|
|
98
|
-
}, [files]);
|
|
99
|
-
const Component = useCallback(
|
|
100
|
-
function Component2({
|
|
101
|
-
className,
|
|
102
|
-
container = "border border-dashed border-neutral-300 rounded flex items-center justify-center",
|
|
103
|
-
draggingClassName,
|
|
104
|
-
name,
|
|
105
|
-
hideMessage = false,
|
|
106
|
-
children,
|
|
107
|
-
...props
|
|
108
|
-
}) {
|
|
109
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
110
|
-
const handleDragEnter = useCallback((e) => {
|
|
111
|
-
e.preventDefault();
|
|
112
|
-
e.stopPropagation();
|
|
113
|
-
setIsDragging(true);
|
|
114
|
-
}, []);
|
|
115
|
-
const handleDragLeave = useCallback((e) => {
|
|
116
|
-
e.preventDefault();
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
setIsDragging(false);
|
|
119
|
-
}, []);
|
|
120
|
-
const handleDragOver = useCallback((e) => {
|
|
121
|
-
e.preventDefault();
|
|
122
|
-
e.stopPropagation();
|
|
123
|
-
}, []);
|
|
124
|
-
const handleFiles = useCallback(
|
|
125
|
-
async (files2) => {
|
|
126
|
-
if (limit && fileRef.current.length >= limit) {
|
|
127
|
-
alert(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${limit}\uAC1C \uC5C5\uB85C\uB4DC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
const filteredFiles = files2.filter((file) => {
|
|
131
|
-
if (!props.accept) {
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
const accepts = props.accept.split(",");
|
|
135
|
-
for (const accept of accepts) {
|
|
136
|
-
const trimmedAccept = accept.trim();
|
|
137
|
-
if (file.type === trimmedAccept || file.type.endsWith(trimmedAccept) || file.name.endsWith(trimmedAccept)) {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
if (trimmedAccept.endsWith("/*")) {
|
|
141
|
-
const baseType = trimmedAccept.replace("/*", "");
|
|
142
|
-
if (file.type.startsWith(baseType + "/")) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return false;
|
|
148
|
-
});
|
|
149
|
-
if (files2.length !== filteredFiles.length) {
|
|
150
|
-
alert(`${props.accept} \uD615\uC2DD\uC758 \uD30C\uC77C\uB9CC \uC5C5\uB85C\uB4DC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
151
|
-
}
|
|
152
|
-
const limitedFiles = filteredFiles.slice(
|
|
153
|
-
0,
|
|
154
|
-
limit ? limit - fileRef.current.length : Infinity
|
|
155
|
-
);
|
|
156
|
-
if (limitedFiles.length === 0) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
if (onFileInput) {
|
|
160
|
-
onFileInput(limitedFiles);
|
|
161
|
-
}
|
|
162
|
-
for (const file of limitedFiles) {
|
|
163
|
-
const { width, height } = await generateMetadata(file);
|
|
164
|
-
const fileItem = {
|
|
165
|
-
key: v4(),
|
|
166
|
-
width: Number(width) || void 0,
|
|
167
|
-
height: Number(height) || void 0
|
|
168
|
-
};
|
|
169
|
-
setFiles((prevFiles) => [...prevFiles, fileItem]);
|
|
170
|
-
uploadFile?.(file, options).then(async (item) => {
|
|
171
|
-
await onFileUploaded?.(item);
|
|
172
|
-
setFiles(
|
|
173
|
-
(prevFiles) => prevFiles.map((f) => {
|
|
174
|
-
if (f.key === fileItem.key) {
|
|
175
|
-
return {
|
|
176
|
-
...f,
|
|
177
|
-
item
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
return f;
|
|
181
|
-
})
|
|
182
|
-
);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
[props.accept]
|
|
187
|
-
);
|
|
188
|
-
const handleDrop = useCallback(
|
|
189
|
-
(e) => {
|
|
190
|
-
e.preventDefault();
|
|
191
|
-
e.stopPropagation();
|
|
192
|
-
setIsDragging(false);
|
|
193
|
-
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
194
|
-
handleFiles(Array.from(e.dataTransfer.files));
|
|
195
|
-
e.dataTransfer.clearData();
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
[handleFiles]
|
|
199
|
-
);
|
|
200
|
-
const inputRef = useRef(null);
|
|
201
|
-
const handleClick = useCallback(() => {
|
|
202
|
-
inputRef.current?.click();
|
|
203
|
-
}, []);
|
|
204
|
-
const handleKeyDown = useCallback(
|
|
205
|
-
(e) => {
|
|
206
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
207
|
-
handleClick();
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
[handleClick]
|
|
211
|
-
);
|
|
212
|
-
const handleChange = useCallback(
|
|
213
|
-
(e) => {
|
|
214
|
-
if (e.target.files && e.target.files.length > 0) {
|
|
215
|
-
handleFiles(Array.from(e.target.files));
|
|
216
|
-
e.target.value = "";
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
[handleFiles]
|
|
220
|
-
);
|
|
221
|
-
return /* @__PURE__ */ React.createElement(
|
|
222
|
-
"div",
|
|
223
|
-
{
|
|
224
|
-
className: cn(
|
|
225
|
-
className,
|
|
226
|
-
container,
|
|
227
|
-
draggingClassName?.(isDragging) || (isDragging ? "bg-neutral-300/25" : "hover:bg-neutral-300/25"),
|
|
228
|
-
"transition-colors cursor-pointer"
|
|
229
|
-
),
|
|
230
|
-
onDragEnter: handleDragEnter,
|
|
231
|
-
onDragLeave: handleDragLeave,
|
|
232
|
-
onDragOver: handleDragOver,
|
|
233
|
-
onDrop: handleDrop,
|
|
234
|
-
onClick: handleClick,
|
|
235
|
-
onChange: handleChange,
|
|
236
|
-
onKeyDown: handleKeyDown,
|
|
237
|
-
tabIndex: 0,
|
|
238
|
-
role: "button"
|
|
239
|
-
},
|
|
240
|
-
/* @__PURE__ */ React.createElement(
|
|
241
|
-
"input",
|
|
242
|
-
{
|
|
243
|
-
...props,
|
|
244
|
-
defaultValue: "",
|
|
245
|
-
type: "file",
|
|
246
|
-
hidden: true,
|
|
247
|
-
ref: inputRef
|
|
248
|
-
}
|
|
249
|
-
),
|
|
250
|
-
/* @__PURE__ */ React.createElement(
|
|
251
|
-
"input",
|
|
252
|
-
{
|
|
253
|
-
name,
|
|
254
|
-
hidden: true,
|
|
255
|
-
readOnly: true,
|
|
256
|
-
value: files.map((file) => {
|
|
257
|
-
if (file.item && typeof file.item === "object" && "id" in file.item) {
|
|
258
|
-
return file.item.id;
|
|
259
|
-
}
|
|
260
|
-
return null;
|
|
261
|
-
}).filter(Boolean).join(",")
|
|
262
|
-
}
|
|
263
|
-
),
|
|
264
|
-
children || !(hideMessage && !isDragging) && /* @__PURE__ */ React.createElement(DropFileMessageBox, null)
|
|
265
|
-
);
|
|
266
|
-
},
|
|
267
|
-
[limit, fileRef, files, options, uploadFile, onFileInput, onFileUploaded]
|
|
268
|
-
);
|
|
269
|
-
const loadedFileIds = files.map((file) => {
|
|
270
|
-
if (file.item && typeof file.item === "object" && "id" in file.item) {
|
|
271
|
-
return file.item.id;
|
|
272
|
-
}
|
|
273
|
-
return null;
|
|
274
|
-
}).filter(Boolean);
|
|
275
|
-
const loadedFileIdsString = loadedFileIds.join(",");
|
|
276
|
-
const fileIds = useMemo(
|
|
277
|
-
() => loadedFileIdsString.split(",").filter(Boolean),
|
|
278
|
-
[loadedFileIdsString]
|
|
279
|
-
);
|
|
280
|
-
return {
|
|
281
|
-
fileIds,
|
|
282
|
-
files,
|
|
283
|
-
setFiles,
|
|
284
|
-
Component
|
|
285
|
-
};
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
function DropFileMessageBox() {
|
|
289
|
-
return /* @__PURE__ */ React.createElement("div", { className: "text-sm pointer-events-none flex justify-center items-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-col items-center" }, /* @__PURE__ */ 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")));
|
|
290
|
-
}
|
|
291
|
-
export {
|
|
292
|
-
DropFileMessageBox,
|
|
293
|
-
createUseDropFileInput as default
|
|
294
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
type Props<TFile> = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> & {
|
|
4
|
-
onUpload?: (files: TFile[]) => Promise<void> | void;
|
|
5
|
-
};
|
|
6
|
-
declare function createFileUploadButton<TFile>({ uploadFile, }: {
|
|
7
|
-
uploadFile: (file: File) => Promise<TFile>;
|
|
8
|
-
}): ({ onUpload, children, className, style, ...props }: Props<TFile>) => React.JSX.Element;
|
|
9
|
-
|
|
10
|
-
export { createFileUploadButton as default };
|