@js-empire/emperor-ui 1.2.6 → 1.2.8
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/emperor-ui.js +137 -124
- package/dist/emperor-ui.umd.cjs +18 -18
- package/dist/globals.css +1 -1
- package/dist/{index-KrC7oBFa.js → index-Ce6gZgMP.js} +9104 -8811
- package/dist/index-DFtrxNxu.js +5 -0
- package/dist/{index-CLEmvl4g.js → index-DldjZoDc.js} +2 -2
- package/dist/index.d.ts +97 -10
- package/dist/src-UW24ZMRV-5Sa4wZ5f.js +5 -0
- package/package.json +2 -4
- package/src/components/atoms/uploader/{avatar-label.tsx → components/avatar-label.tsx} +17 -5
- package/src/components/atoms/uploader/components/index.ts +8 -0
- package/src/components/atoms/uploader/components/upload-file-error-box.tsx +40 -0
- package/src/components/atoms/uploader/{upload-file-label.tsx → components/upload-file-label.tsx} +18 -11
- package/src/components/atoms/uploader/index.ts +1 -8
- package/src/components/atoms/uploader/stories/uploader.stories.tsx +17 -10
- package/src/components/molecules/item-card/index.ts +2 -0
- package/src/components/molecules/item-card/item-actions-buttons.tsx +43 -0
- package/src/components/molecules/item-card/item-actions-overlay.tsx +41 -0
- package/src/components/molecules/item-card/item-card-body.tsx +8 -2
- package/src/components/molecules/item-card/item-card-footer.tsx +22 -1
- package/src/components/molecules/item-card/item-card-header.tsx +8 -2
- package/src/components/molecules/item-card/item-card.tsx +39 -1
- package/src/components/molecules/item-card/stories/item-card.stories.tsx +36 -0
- package/src/components/organisms/deletion-confirmor/deletion-confirmor.tsx +114 -0
- package/src/components/organisms/deletion-confirmor/index.ts +3 -0
- package/src/components/organisms/deletion-confirmor/stories/components.tsx +22 -0
- package/src/components/organisms/deletion-confirmor/stories/deletion-confirmor.stories.tsx +78 -0
- package/src/components/organisms/deletion-confirmor/styles/classes.ts +28 -0
- package/src/components/organisms/deletion-confirmor/styles/index.ts +2 -0
- package/src/components/organisms/deletion-confirmor/styles/styles.ts +4 -0
- package/src/components/organisms/index.ts +1 -0
- package/src/constants/card.tsx +5 -2
- package/src/hooks/use-uploader.tsx +21 -9
- package/src/i18n/locales/atoms/ar.ts +1 -1
- package/src/i18n/locales/atoms/en.ts +1 -1
- package/src/i18n/locales/organisms/ar.ts +4 -0
- package/src/i18n/locales/organisms/en.ts +4 -0
- package/src/mocks/deletion-confirmor.ts +16 -0
- package/src/mocks/index.ts +2 -0
- package/src/mocks/locales/index.ts +1 -0
- package/src/mocks/locales/uploader.ts +33 -0
- package/src/types/components/atoms/uploader.ts +4 -0
- package/src/types/components/molecules/item-card/item-card.ts +14 -4
- package/src/types/components/organisms/deletion-confirmor/deletion-confirmor.ts +22 -0
- package/src/types/components/organisms/deletion-confirmor/index.ts +1 -0
- package/src/types/components/organisms/index.ts +1 -0
- package/src/utils/uploader.ts +25 -7
- package/dist/index-DceZlwg2.js +0 -5
- package/dist/src-UW24ZMRV-DfI_MdGD.js +0 -5
- package/src/components/atoms/uploader/upload-file-error-box.tsx +0 -29
- /package/src/components/atoms/uploader/{upload-file-input.tsx → components/upload-file-input.tsx} +0 -0
- /package/src/components/atoms/uploader/{upload-file-listing.tsx → components/upload-file-listing.tsx} +0 -0
- /package/src/components/atoms/uploader/{uploader-title.tsx → components/uploader-title.tsx} +0 -0
- /package/src/components/atoms/uploader/{uploader.tsx → components/uploader.tsx} +0 -0
- /package/src/components/atoms/uploader/{view-image-modal.tsx → components/view-image-modal.tsx} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LangKey, Locale } from "@/i18n";
|
|
2
|
+
|
|
3
|
+
export const uploaderLocalesMock: Record<
|
|
4
|
+
LangKey,
|
|
5
|
+
Partial<Locale["atoms"]["uploader"]>
|
|
6
|
+
> = {
|
|
7
|
+
[LangKey.ENGLISH]: {
|
|
8
|
+
dropHere: "Drop your custom file here",
|
|
9
|
+
selectFile: "Choose a custom file or drag it here",
|
|
10
|
+
selectionTypes: "PNG, JPG or PDF, max size 5MB (custom localized)",
|
|
11
|
+
selectBtn: "Browse custom files",
|
|
12
|
+
errorUploadingFile: "Custom error: please upload at least one file",
|
|
13
|
+
maxNumImages: "Custom limit reached for uploaded images: ",
|
|
14
|
+
errorUploadedTypes: "Custom error: allowed file types are only: ",
|
|
15
|
+
maxSizeExceededError:
|
|
16
|
+
"Custom error: maximum allowed size is MAX_FILE_SIZE MB, but your file is UPLOADED_FILE_SIZE MB",
|
|
17
|
+
duplicatesDenied:
|
|
18
|
+
"Custom error: duplicate file names are not allowed, please rename before uploading",
|
|
19
|
+
},
|
|
20
|
+
[LangKey.ARABIC]: {
|
|
21
|
+
dropHere: "أسقط الملف المخصص هنا",
|
|
22
|
+
selectFile: "اختر ملفًا مخصصًا أو اسحبه إلى هنا",
|
|
23
|
+
selectionTypes: "PNG، JPG أو PDF، الحجم الأقصى 5MB (نص مخصص)",
|
|
24
|
+
selectBtn: "استعراض الملفات المخصصة",
|
|
25
|
+
errorUploadingFile: "خطأ مخصص: يرجى رفع ملف واحد على الأقل",
|
|
26
|
+
maxNumImages: "خطأ مخصص: تم الوصول إلى الحد الأقصى للصور المرفوعة: ",
|
|
27
|
+
errorUploadedTypes: "خطأ مخصص: يمكنك فقط رفع الملفات من الأنواع التالية: ",
|
|
28
|
+
maxSizeExceededError:
|
|
29
|
+
"خطأ مخصص: الحد الأقصى المسموح هو MAX_FILE_SIZE ميغابايت، بينما حجم ملفك هو UPLOADED_FILE_SIZE ميغابايت",
|
|
30
|
+
duplicatesDenied:
|
|
31
|
+
"خطأ مخصص: لا يمكنك رفع ملفات بأسماء مكررة، يرجى إعادة تسميتها قبل الرفع",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SharedComponentProps } from "@/types";
|
|
2
2
|
import { ModalProps } from "@heroui/modal";
|
|
3
3
|
import { Dispatch, ReactNode, SetStateAction } from "react";
|
|
4
|
+
import type { Locale } from "@/i18n";
|
|
4
5
|
|
|
5
6
|
export type UploaderProps = SharedComponentProps &
|
|
6
7
|
UploaderContextState & {
|
|
@@ -39,6 +40,7 @@ export type UseUploadFileProps = {
|
|
|
39
40
|
compressFiles?: boolean;
|
|
40
41
|
preventDuplicates?: boolean;
|
|
41
42
|
onChange?: () => void;
|
|
43
|
+
locales?: Partial<Locale["atoms"]["uploader"]>;
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
export type UseUploadFileReturn = {
|
|
@@ -53,6 +55,7 @@ export type UseUploadFileReturn = {
|
|
|
53
55
|
setFiles: Dispatch<SetStateAction<FileObject[]>>;
|
|
54
56
|
handleClearFile: (fileName?: string) => void;
|
|
55
57
|
onInputChange: SharedOnInputChangeType;
|
|
58
|
+
locales?: Partial<Locale["atoms"]["uploader"]>;
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
export type UploaderContextState = {
|
|
@@ -91,6 +94,7 @@ export type UploaderContextState = {
|
|
|
91
94
|
input?: string;
|
|
92
95
|
title?: string;
|
|
93
96
|
};
|
|
97
|
+
locales?: Partial<Locale["atoms"]["uploader"]>;
|
|
94
98
|
};
|
|
95
99
|
|
|
96
100
|
export type UploaderProviderProps = UploaderContextState & {
|
|
@@ -3,6 +3,7 @@ import { ReactNode } from "react";
|
|
|
3
3
|
import { Variants } from "framer-motion";
|
|
4
4
|
import { ChipProps } from "@heroui/chip";
|
|
5
5
|
import { DropdownItemProps } from "@heroui/dropdown";
|
|
6
|
+
import type { ButtonProps } from "@heroui/button";
|
|
6
7
|
|
|
7
8
|
export type ItemCardClassnames = {
|
|
8
9
|
base?: string;
|
|
@@ -19,17 +20,25 @@ export type ItemCardClassnames = {
|
|
|
19
20
|
description?: string;
|
|
20
21
|
chips?: string;
|
|
21
22
|
chip?: string;
|
|
23
|
+
actions?: string;
|
|
24
|
+
action?: string;
|
|
22
25
|
};
|
|
23
26
|
|
|
24
|
-
export type ItemCardAction = DropdownItemProps &
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
export type ItemCardAction = DropdownItemProps &
|
|
28
|
+
ButtonProps & {
|
|
29
|
+
key: string;
|
|
30
|
+
label: string;
|
|
31
|
+
};
|
|
28
32
|
|
|
29
33
|
export type ItemCardHoverEffect = "none" | "zoom" | "rotate";
|
|
30
34
|
|
|
31
35
|
export type ItemCardOrientation = "horizontal" | "vertical";
|
|
32
36
|
|
|
37
|
+
export type ItemCardActionsViewVariant =
|
|
38
|
+
| "dropdown"
|
|
39
|
+
| "buttons"
|
|
40
|
+
| "hover-overlay";
|
|
41
|
+
|
|
33
42
|
export type ItemChipProps = ChipProps & {
|
|
34
43
|
label: string;
|
|
35
44
|
};
|
|
@@ -56,4 +65,5 @@ export type ItemCardProps = SharedComponentProps & {
|
|
|
56
65
|
actions?: ItemCardAction[];
|
|
57
66
|
onActionClick?: (key: string) => void;
|
|
58
67
|
orientation?: ItemCardOrientation;
|
|
68
|
+
actionsViewVariant?: ItemCardActionsViewVariant;
|
|
59
69
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ButtonProps } from "@heroui/button";
|
|
2
|
+
|
|
3
|
+
export type DeletionConfirmorClassnames = {
|
|
4
|
+
base?: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
header?: string;
|
|
7
|
+
body?: string;
|
|
8
|
+
footer?: string;
|
|
9
|
+
confirmButton?: string;
|
|
10
|
+
declineButton?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type DeletionConfirmorProps = {
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
title: string;
|
|
17
|
+
description: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
classNames?: DeletionConfirmorClassnames;
|
|
20
|
+
confirmProps?: ButtonProps;
|
|
21
|
+
declineProps?: ButtonProps;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./deletion-confirmor";
|
package/src/utils/uploader.ts
CHANGED
|
@@ -53,14 +53,14 @@ export async function validateUploadedFiles({
|
|
|
53
53
|
uploadedFiles,
|
|
54
54
|
maxFileSize = ONE_MEGABYTE * 10,
|
|
55
55
|
compressFiles,
|
|
56
|
-
|
|
56
|
+
uploaderLocale,
|
|
57
57
|
preventDuplicates,
|
|
58
58
|
files,
|
|
59
59
|
}: {
|
|
60
60
|
uploadedFiles: File[];
|
|
61
61
|
maxFileSize?: number;
|
|
62
62
|
compressFiles?: boolean;
|
|
63
|
-
|
|
63
|
+
uploaderLocale: Locale["atoms"]["uploader"];
|
|
64
64
|
preventDuplicates?: boolean;
|
|
65
65
|
files: FileObject[];
|
|
66
66
|
}) {
|
|
@@ -70,7 +70,7 @@ export async function validateUploadedFiles({
|
|
|
70
70
|
uploadedFiles?.map(async (file) => {
|
|
71
71
|
if (isMaxFileSizeExceeded({ fileSize: file?.size, maxFileSize })) {
|
|
72
72
|
addToast({
|
|
73
|
-
title:
|
|
73
|
+
title: uploaderLocale.maxSizeExceededError
|
|
74
74
|
.replace("MAX_FILE_SIZE", (maxFileSize / 1024 || 0)?.toString())
|
|
75
75
|
.replace(
|
|
76
76
|
"UPLOADED_FILE_SIZE",
|
|
@@ -91,7 +91,7 @@ export async function validateUploadedFiles({
|
|
|
91
91
|
isFileDuplicated({ fileName: file?.name, files })
|
|
92
92
|
) {
|
|
93
93
|
addToast({
|
|
94
|
-
title:
|
|
94
|
+
title: uploaderLocale.duplicatesDenied,
|
|
95
95
|
});
|
|
96
96
|
isInValid = true;
|
|
97
97
|
}
|
|
@@ -108,13 +108,13 @@ export async function validateUploadedFiles({
|
|
|
108
108
|
|
|
109
109
|
export async function refineUploadedFiles({
|
|
110
110
|
uploadedFiles,
|
|
111
|
-
|
|
111
|
+
uploaderLocale,
|
|
112
112
|
allowedTypes,
|
|
113
113
|
isMulti,
|
|
114
114
|
setFiles,
|
|
115
115
|
}: {
|
|
116
116
|
uploadedFiles: (File | undefined)[];
|
|
117
|
-
|
|
117
|
+
uploaderLocale: Locale["atoms"]["uploader"];
|
|
118
118
|
allowedTypes: string[];
|
|
119
119
|
isMulti: boolean;
|
|
120
120
|
setFiles: Dispatch<SetStateAction<FileObject[]>>;
|
|
@@ -125,7 +125,7 @@ export async function refineUploadedFiles({
|
|
|
125
125
|
const fileType = mapFileType(uploadedFile?.type);
|
|
126
126
|
if (!fileType) {
|
|
127
127
|
addToast({
|
|
128
|
-
title: `${
|
|
128
|
+
title: `${uploaderLocale.errorUploadedTypes} ${allowedTypes.join(", ")}`,
|
|
129
129
|
});
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
@@ -147,3 +147,21 @@ export async function refineUploadedFiles({
|
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Merges uploader-specific locales with priority:
|
|
153
|
+
* 1) context-level overrides, 2) config-level locales, 3) default static locales.
|
|
154
|
+
*/
|
|
155
|
+
export const mergeUploaderLocale = ({
|
|
156
|
+
defaultUploaderLocale,
|
|
157
|
+
configUploaderLocale,
|
|
158
|
+
contextUploaderLocale,
|
|
159
|
+
}: {
|
|
160
|
+
defaultUploaderLocale: Locale["atoms"]["uploader"];
|
|
161
|
+
configUploaderLocale?: Locale["atoms"]["uploader"];
|
|
162
|
+
contextUploaderLocale?: Partial<Locale["atoms"]["uploader"]>;
|
|
163
|
+
}): Locale["atoms"]["uploader"] => ({
|
|
164
|
+
...defaultUploaderLocale,
|
|
165
|
+
...(configUploaderLocale || {}),
|
|
166
|
+
...(contextUploaderLocale || {}),
|
|
167
|
+
});
|
package/dist/index-DceZlwg2.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@/utils";
|
|
4
|
-
import { useEmperorUI, useUploaderContext } from "@/hooks";
|
|
5
|
-
import { useMemo } from "react";
|
|
6
|
-
|
|
7
|
-
export function UploadFileErrorBox() {
|
|
8
|
-
const { config } = useEmperorUI();
|
|
9
|
-
const { files, isRequired, classNames, errorMessage } = useUploaderContext();
|
|
10
|
-
|
|
11
|
-
const locales = config?.interLocalization?.locales;
|
|
12
|
-
const lang = config?.interLocalization?.lang;
|
|
13
|
-
|
|
14
|
-
const locale = locales?.[lang || "en"];
|
|
15
|
-
|
|
16
|
-
const isError = useMemo(
|
|
17
|
-
() => files?.length === 0 && isRequired,
|
|
18
|
-
[files, isRequired],
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
if (isError)
|
|
22
|
-
return (
|
|
23
|
-
<p className={cn("text-[14px] text-danger", classNames?.error)}>
|
|
24
|
-
{errorMessage || locale?.atoms?.uploader?.errorUploadingFile}
|
|
25
|
-
</p>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
return null;
|
|
29
|
-
}
|
/package/src/components/atoms/uploader/{upload-file-input.tsx → components/upload-file-input.tsx}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/components/atoms/uploader/{view-image-modal.tsx → components/view-image-modal.tsx}
RENAMED
|
File without changes
|