@js-empire/emperor-ui 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +4 -0
- package/.storybook/main.ts +2 -11
- package/.storybook/preview.ts +1 -1
- package/.vscode/extensions.json +3 -0
- package/README.md +68 -1
- package/package.json +16 -4
- package/public/icons/emperor-ui-logo.ico +0 -0
- package/public/images/avatar-female.jpg +0 -0
- package/public/images/avatar-male.jpg +0 -0
- package/public/images/emperor-ui-logo.png +0 -0
- package/src/components/atoms/brand/brand.stories.tsx +27 -0
- package/src/components/atoms/brand/brand.tsx +56 -0
- package/src/components/atoms/brand/index.ts +1 -0
- package/src/components/atoms/brand/styles/classes.ts +9 -0
- package/src/components/atoms/brand/styles/index.ts +2 -0
- package/src/components/atoms/brand/styles/styles.ts +0 -0
- package/src/components/atoms/column/column.stories.tsx +36 -0
- package/src/components/atoms/column/column.tsx +21 -0
- package/src/components/atoms/column/index.ts +1 -0
- package/src/components/atoms/container/column.stories.tsx +36 -0
- package/src/components/atoms/container/container.tsx +28 -0
- package/src/components/atoms/container/index.ts +1 -0
- package/src/components/atoms/index.ts +6 -0
- package/src/components/atoms/portal/index.ts +1 -0
- package/src/components/atoms/portal/portal.stories.tsx +43 -0
- package/src/components/atoms/portal/portal.tsx +23 -0
- package/src/components/atoms/row/index.ts +1 -0
- package/src/components/atoms/row/row.stories.tsx +36 -0
- package/src/components/atoms/row/row.tsx +26 -0
- package/src/components/atoms/uploader/avatar-label.tsx +83 -0
- package/src/components/atoms/uploader/index.ts +7 -0
- package/src/components/atoms/uploader/stories/uploader.stories.tsx +41 -0
- package/src/components/atoms/uploader/upload-file-error-box.tsx +29 -0
- package/src/components/atoms/uploader/upload-file-input.tsx +36 -0
- package/src/components/atoms/uploader/upload-file-label.tsx +74 -0
- package/src/components/atoms/uploader/upload-file-listing.tsx +53 -0
- package/src/components/atoms/uploader/uploader.tsx +55 -0
- package/src/components/atoms/uploader/view-image-modal.tsx +39 -0
- package/src/components/index.ts +4 -8
- package/src/components/molecules/index.ts +5 -0
- package/src/components/molecules/item-card/item-card.tsx +6 -0
- package/src/components/molecules/nav-bar/index.ts +3 -0
- package/src/components/molecules/nav-bar/nav-bar-item.tsx +70 -0
- package/src/components/molecules/nav-bar/nav-bar.tsx +65 -0
- package/src/components/molecules/nav-bar/stories/hover-effect/nav-bar-hover-effect.stories.tsx +52 -0
- package/src/components/molecules/nav-bar/stories/nav-bar.stories.tsx +50 -0
- package/src/components/molecules/nav-bar/styles/classes.ts +68 -0
- package/src/components/molecules/nav-bar/styles/index.ts +2 -0
- package/src/components/molecules/nav-bar/styles/styles.ts +84 -0
- package/src/components/molecules/nav-bar/sub-items-box.tsx +57 -0
- package/src/components/molecules/scaffold/scaffold.stories.tsx +21 -0
- package/src/components/molecules/scaffold/scaffold.tsx +36 -0
- package/src/components/molecules/side-bar/compact-side-bar.tsx +73 -0
- package/src/components/molecules/side-bar/index.ts +1 -0
- package/src/components/molecules/side-bar/side-bar-drawer.tsx +124 -0
- package/src/components/molecules/side-bar/side-bar.stories.tsx +110 -0
- package/src/components/molecules/side-bar/side-bar.tsx +31 -0
- package/src/components/molecules/side-bar/styles/classes.ts +28 -0
- package/src/components/molecules/side-bar/styles/index.ts +2 -0
- package/src/components/molecules/side-bar/styles/styles.ts +13 -0
- package/src/components/organisms/footer/footer.tsx +20 -0
- package/src/components/organisms/footer/styles/classes.ts +15 -0
- package/src/components/organisms/footer/styles/index.ts +2 -0
- package/src/components/organisms/footer/styles/styles.ts +9 -0
- package/src/components/organisms/header/header.tsx +94 -0
- package/src/components/organisms/header/segmented-header-content.tsx +37 -0
- package/src/components/organisms/header/stories/header.stories.tsx +143 -0
- package/src/components/organisms/header/styles/classes.ts +22 -0
- package/src/components/organisms/header/styles/index.ts +2 -0
- package/src/components/organisms/header/styles/styles.ts +39 -0
- package/src/components/organisms/index.ts +4 -0
- package/src/components/templates/index.ts +1 -0
- package/src/components/templates/landing-page/index.ts +1 -0
- package/src/components/templates/landing-page/landing-page.stories.tsx +21 -0
- package/src/components/templates/landing-page/landing-page.tsx +57 -0
- package/src/components/templates/landing-page/styles/classes.ts +11 -0
- package/src/components/templates/landing-page/styles/index.ts +1 -0
- package/src/constants/defaults.ts +42 -7
- package/src/constants/fake.ts +2 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/uploader.ts +27 -0
- package/src/context/emperor-ui-context.ts +4 -4
- package/src/context/index.ts +2 -0
- package/src/context/navigation-context.ts +6 -0
- package/src/context/uploader-context.ts +6 -0
- package/src/enums/index.ts +2 -0
- package/src/enums/placeholders.ts +4 -0
- package/src/enums/preserved-keys.ts +3 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/use-navigation.ts +12 -0
- package/src/hooks/use-uploader-context.ts +14 -0
- package/src/hooks/use-uploader.tsx +215 -0
- package/src/index.ts +9 -5
- package/src/main.tsx +3 -0
- package/src/mocks/header.tsx +118 -0
- package/src/mocks/index.ts +1 -0
- package/src/providers/config-provider.tsx +54 -0
- package/src/providers/emperor-ui-provider.tsx +17 -24
- package/src/providers/index.ts +3 -0
- package/src/providers/navigation-provider.tsx +42 -0
- package/src/providers/uploader-provider.tsx +53 -0
- package/src/styles/globals.css +13 -0
- package/src/styles/hero.ts +2 -0
- package/src/types/components/atoms/brand.ts +13 -0
- package/src/types/components/atoms/column.ts +3 -0
- package/src/types/components/atoms/container.ts +3 -0
- package/src/types/components/atoms/index.ts +6 -0
- package/src/types/components/atoms/portal.ts +6 -0
- package/src/types/components/atoms/row.ts +3 -0
- package/src/types/components/atoms/uploader.ts +104 -0
- package/src/types/components/index.ts +3 -8
- package/src/types/components/molecules/header/header.ts +51 -0
- package/src/types/components/molecules/index.ts +9 -0
- package/src/types/components/molecules/nav-bar/nav-bar.ts +65 -0
- package/src/types/components/molecules/side-bar/index.ts +1 -0
- package/src/types/components/molecules/side-bar/side-bar.ts +40 -0
- package/src/types/components/templates/index.ts +1 -0
- package/src/types/components/templates/landing-page.ts +10 -0
- package/src/types/context/config.ts +54 -0
- package/src/types/context/index.ts +2 -1
- package/src/types/context/navigation.ts +17 -0
- package/src/types/shared/components.ts +4 -0
- package/src/utils/compress-images.ts +36 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/storybook.tsx +15 -0
- package/tsconfig.app.json +3 -2
- package/tsconfig.node.json +0 -1
- package/vite.config.ts +4 -0
- package/dist/emperor-ui.js +0 -3171
- package/dist/emperor-ui.umd.cjs +0 -6
- package/dist/index.d.ts +0 -200
- package/src/components/footer/footer.tsx +0 -6
- package/src/components/header/header.tsx +0 -49
- package/src/components/item-card/item-card.tsx +0 -6
- package/src/components/nav-bar/index.ts +0 -1
- package/src/components/nav-bar/nav-bar.tsx +0 -6
- package/src/components/scaffold/scaffold.tsx +0 -15
- package/src/index.css +0 -1
- package/src/types/components/header/header.ts +0 -21
- package/src/types/components/nav-bar/nav-bar.ts +0 -9
- package/src/types/context/emperor-ui.ts +0 -37
- package/tailwind.config.js +0 -6
- /package/src/components/{filter → molecules/filter}/filter.tsx +0 -0
- /package/src/components/{filter → molecules/filter}/index.ts +0 -0
- /package/src/components/{item-card → molecules/item-card}/index.ts +0 -0
- /package/src/components/{scaffold → molecules/scaffold}/index.ts +0 -0
- /package/src/components/{footer → organisms/footer}/index.ts +0 -0
- /package/src/components/{header → organisms/header}/index.ts +0 -0
- /package/src/components/{item-details → organisms/item-details}/index.ts +0 -0
- /package/src/components/{item-details → organisms/item-details}/item-details.tsx +0 -0
- /package/src/components/{listings → organisms/listings}/index.ts +0 -0
- /package/src/components/{listings → organisms/listings}/listings.tsx +0 -0
- /package/src/types/components/{filter → molecules/filter}/filter.ts +0 -0
- /package/src/types/components/{filter → molecules/filter}/index.ts +0 -0
- /package/src/types/components/{footer → molecules/footer}/footer.ts +0 -0
- /package/src/types/components/{footer → molecules/footer}/index.ts +0 -0
- /package/src/types/components/{header → molecules/header}/index.ts +0 -0
- /package/src/types/components/{item-card → molecules/item-card}/index.ts +0 -0
- /package/src/types/components/{item-card → molecules/item-card}/item-card.ts +0 -0
- /package/src/types/components/{item-details → molecules/item-details}/index.ts +0 -0
- /package/src/types/components/{item-details → molecules/item-details}/item-details.ts +0 -0
- /package/src/types/components/{listings → molecules/listings}/index.ts +0 -0
- /package/src/types/components/{listings → molecules/listings}/listings.ts +0 -0
- /package/src/types/components/{nav-bar → molecules/nav-bar}/index.ts +0 -0
- /package/src/types/components/{scaffold → molecules/scaffold}/index.ts +0 -0
- /package/src/types/components/{scaffold → molecules/scaffold}/scaffold.ts +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { SharedComponentProps } from "@types";
|
|
2
|
+
import { Dispatch, ReactNode, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
export type UploaderProps = SharedComponentProps &
|
|
5
|
+
UploaderContextState & {
|
|
6
|
+
className?: string;
|
|
7
|
+
hideListing?: boolean;
|
|
8
|
+
isAvatar?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type FileType = "image" | "doc" | "pdf" | "video" | "sheet";
|
|
12
|
+
|
|
13
|
+
export type FileObject = {
|
|
14
|
+
view?: string;
|
|
15
|
+
type?: FileType;
|
|
16
|
+
file?: File;
|
|
17
|
+
url?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type SharedFilesType = FileObject[];
|
|
21
|
+
|
|
22
|
+
export type SharedLabelIdType = string;
|
|
23
|
+
|
|
24
|
+
export type SharedOnInputChangeType = (
|
|
25
|
+
event: React.ChangeEvent<HTMLInputElement> &
|
|
26
|
+
React.DragEvent<HTMLLabelElement>,
|
|
27
|
+
) => Promise<void>;
|
|
28
|
+
|
|
29
|
+
export type UseUploadFileProps = {
|
|
30
|
+
labelId: string;
|
|
31
|
+
fileTypes: FileType[];
|
|
32
|
+
labelContent?: ReactNode;
|
|
33
|
+
isRequired?: boolean;
|
|
34
|
+
isMulti?: boolean;
|
|
35
|
+
isDraggable?: boolean;
|
|
36
|
+
maxCount?: number;
|
|
37
|
+
maxFileSize?: number; // in Kilobytes
|
|
38
|
+
compressFiles?: boolean;
|
|
39
|
+
preventDuplicates?: boolean;
|
|
40
|
+
onChange?: () => void;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type UseUploadFileReturn = {
|
|
44
|
+
files: FileObject[];
|
|
45
|
+
fileTypes: FileType[];
|
|
46
|
+
labelId: string;
|
|
47
|
+
isRequired: boolean;
|
|
48
|
+
labelContent: ReactNode;
|
|
49
|
+
isDraggable: boolean;
|
|
50
|
+
isMulti: boolean;
|
|
51
|
+
isLoading: boolean;
|
|
52
|
+
setFiles: Dispatch<SetStateAction<FileObject[]>>;
|
|
53
|
+
handleClearFile: (fileName?: string) => void;
|
|
54
|
+
onInputChange: (
|
|
55
|
+
event: React.ChangeEvent<HTMLInputElement> &
|
|
56
|
+
React.DragEvent<HTMLLabelElement>,
|
|
57
|
+
) => Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type UploaderContextState = {
|
|
61
|
+
isOpen?: boolean;
|
|
62
|
+
onClose?: () => void;
|
|
63
|
+
onOpen?: () => void;
|
|
64
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
65
|
+
|
|
66
|
+
selectedFile?: FileObject | null;
|
|
67
|
+
setSelectedFile?: (file: FileObject | null) => void;
|
|
68
|
+
|
|
69
|
+
labelId: SharedLabelIdType;
|
|
70
|
+
labelContent?: ReactNode;
|
|
71
|
+
avatarLabelContent?: ReactNode;
|
|
72
|
+
|
|
73
|
+
isFileViewable?: boolean;
|
|
74
|
+
isRequired?: boolean;
|
|
75
|
+
isDraggable?: boolean;
|
|
76
|
+
isLoading: boolean;
|
|
77
|
+
hideErrorMessage?: boolean;
|
|
78
|
+
isMulti: boolean;
|
|
79
|
+
|
|
80
|
+
placeholderImage?: string;
|
|
81
|
+
files: SharedFilesType;
|
|
82
|
+
fileTypes: FileType[];
|
|
83
|
+
|
|
84
|
+
onInputChange: SharedOnInputChangeType;
|
|
85
|
+
handleClearFile: (fileName?: string) => void;
|
|
86
|
+
|
|
87
|
+
modal?: {
|
|
88
|
+
isOpen?: boolean;
|
|
89
|
+
onOpen?: () => void;
|
|
90
|
+
onClose?: () => void;
|
|
91
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
92
|
+
};
|
|
93
|
+
classNames?: {
|
|
94
|
+
label?: string;
|
|
95
|
+
avatar?: string;
|
|
96
|
+
listing?: string;
|
|
97
|
+
error?: string;
|
|
98
|
+
input?: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type UploaderProviderProps = UploaderContextState & {
|
|
103
|
+
children: ReactNode;
|
|
104
|
+
};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export type * from "./
|
|
2
|
-
export type * from "./
|
|
3
|
-
export type * from "./
|
|
4
|
-
export type * from "./scaffold";
|
|
5
|
-
export type * from "./filter";
|
|
6
|
-
export type * from "./footer";
|
|
7
|
-
export type * from "./item-card";
|
|
8
|
-
export type * from "./item-details";
|
|
1
|
+
export type * from "./molecules";
|
|
2
|
+
export type * from "./atoms";
|
|
3
|
+
export type * from "./templates";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { SharedComponentProps } from "@types";
|
|
2
|
+
|
|
3
|
+
export type HeaderClassnames = {
|
|
4
|
+
base?: string;
|
|
5
|
+
logo?: string;
|
|
6
|
+
navbar?: string;
|
|
7
|
+
userDropdown?: string;
|
|
8
|
+
sideMenu?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type HeaderActivations = {
|
|
12
|
+
hideLog?: boolean;
|
|
13
|
+
hideNavbar?: boolean;
|
|
14
|
+
hideUserDropdown?: boolean;
|
|
15
|
+
hideSideMenu?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type HeaderVariant =
|
|
19
|
+
| "default"
|
|
20
|
+
| "floating"
|
|
21
|
+
| "light"
|
|
22
|
+
| "segmented-floating";
|
|
23
|
+
|
|
24
|
+
export type HeaderGlassEffect = {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
blur?: number;
|
|
27
|
+
backgroundColor?: string;
|
|
28
|
+
foregroundColor?: string;
|
|
29
|
+
opacity?: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type HeaderProps = SharedComponentProps & {
|
|
33
|
+
variant?: HeaderVariant;
|
|
34
|
+
classNames?: HeaderClassnames;
|
|
35
|
+
glassEffect?: HeaderGlassEffect;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type HeaderDropdownProps = SharedComponentProps & {};
|
|
39
|
+
|
|
40
|
+
export type UserDropdownProps = SharedComponentProps & {};
|
|
41
|
+
|
|
42
|
+
export type HeaderStylesProps = {
|
|
43
|
+
primaryColor?: string;
|
|
44
|
+
foregroundColor?: string;
|
|
45
|
+
variant?: HeaderVariant;
|
|
46
|
+
glassEffect?: HeaderGlassEffect;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type SegmentedHeaderContentProps = SharedComponentProps & {
|
|
50
|
+
glassEffect?: HeaderGlassEffect;
|
|
51
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type * from "./header";
|
|
2
|
+
export type * from "./listings";
|
|
3
|
+
export type * from "./nav-bar";
|
|
4
|
+
export type * from "./side-bar";
|
|
5
|
+
export type * from "./scaffold";
|
|
6
|
+
export type * from "./filter";
|
|
7
|
+
export type * from "./footer";
|
|
8
|
+
export type * from "./item-card";
|
|
9
|
+
export type * from "./item-details";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ComponentRadius,
|
|
3
|
+
ComponentSize,
|
|
4
|
+
SharedComponentProps,
|
|
5
|
+
} from "@types";
|
|
6
|
+
import type { ElementType } from "react";
|
|
7
|
+
|
|
8
|
+
export type NavBarClassnames = {
|
|
9
|
+
base?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type NavigationItem = {
|
|
13
|
+
id: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
href?: string;
|
|
16
|
+
subItems?: NavigationItem[];
|
|
17
|
+
onClick?: () => void;
|
|
18
|
+
Icon?: ElementType;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type NavBarHoverEffect =
|
|
22
|
+
| "default"
|
|
23
|
+
| "underline"
|
|
24
|
+
| "solid"
|
|
25
|
+
| "ghost"
|
|
26
|
+
| "bordered"
|
|
27
|
+
| "none";
|
|
28
|
+
|
|
29
|
+
export type NavBarVariant = "default" | "solid" | "bordered";
|
|
30
|
+
|
|
31
|
+
export type NavBarStylesProps = {
|
|
32
|
+
primaryColor?: string;
|
|
33
|
+
foregroundColor?: string;
|
|
34
|
+
variant?: NavBarVariant;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type NavBarMenuStylesProps = {};
|
|
38
|
+
|
|
39
|
+
export type NavBarItemStylesProps = {
|
|
40
|
+
foregroundColor?: string;
|
|
41
|
+
primaryColor?: string;
|
|
42
|
+
hoverEffect: NavBarHoverEffect;
|
|
43
|
+
isHovered?: boolean;
|
|
44
|
+
variant?: NavBarVariant;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type NavBarProps = SharedComponentProps & {
|
|
48
|
+
items: NavigationItem[];
|
|
49
|
+
classNames?: NavBarClassnames;
|
|
50
|
+
hoverEffect?: NavBarHoverEffect;
|
|
51
|
+
radius?: ComponentRadius;
|
|
52
|
+
size?: ComponentSize;
|
|
53
|
+
variant?: NavBarVariant;
|
|
54
|
+
subItemsColumns?: number;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type NavBarItemProps = {
|
|
58
|
+
item: NavigationItem;
|
|
59
|
+
variant: NavBarVariant;
|
|
60
|
+
hoverEffect: NavBarHoverEffect;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type SubItemsBoxProps = {
|
|
64
|
+
subItemsColumns?: number;
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from "./side-bar";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ButtonProps } from "@heroui/react";
|
|
2
|
+
import type { NavigationItem, SharedComponentProps } from "@types";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
export type SideBarVariant = "default" | "compact";
|
|
6
|
+
|
|
7
|
+
export type SideBarClassnames = {
|
|
8
|
+
base?: string;
|
|
9
|
+
trigger?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
menu?: string;
|
|
12
|
+
menuItem?: string;
|
|
13
|
+
actionsWrapper?: string;
|
|
14
|
+
actionItem?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type SideBarAction = ButtonProps & {
|
|
18
|
+
key: string;
|
|
19
|
+
label?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type SideBarProps = SharedComponentProps & {
|
|
23
|
+
classNames?: SideBarClassnames;
|
|
24
|
+
variant?: SideBarVariant;
|
|
25
|
+
items: NavigationItem[];
|
|
26
|
+
actions?: SideBarAction[];
|
|
27
|
+
triggerProps?: Omit<ButtonProps, "content"> & { content?: ReactNode };
|
|
28
|
+
isOpen?: boolean;
|
|
29
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
30
|
+
header?: ReactNode;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type SideBarItemStylesProps = {
|
|
34
|
+
foregroundColor?: string;
|
|
35
|
+
primaryColor?: string;
|
|
36
|
+
isHovered?: boolean;
|
|
37
|
+
variant?: SideBarVariant;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type CompactSideBarProps = SideBarProps & {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from "./landing-page";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { HeroUIProviderProps } from "@heroui/react";
|
|
3
|
+
|
|
4
|
+
export type ConfigContextState = {
|
|
5
|
+
config: EmperorUIConfig;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ConfigProviderProps = {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
config?: EmperorUIConfig;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ColorMode = "light" | "dark";
|
|
14
|
+
export type AppDirection = "ltr" | "rtl";
|
|
15
|
+
|
|
16
|
+
export type ColorsPalette = {
|
|
17
|
+
primary: string;
|
|
18
|
+
secondary: string;
|
|
19
|
+
success: string;
|
|
20
|
+
danger: string;
|
|
21
|
+
warning: string;
|
|
22
|
+
info: string;
|
|
23
|
+
background: string;
|
|
24
|
+
foreground: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type EmperorUITheme = {
|
|
28
|
+
mode: ColorMode;
|
|
29
|
+
colors: Partial<ColorsPalette>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type EmperorUILayout = {
|
|
33
|
+
withScaffold: boolean;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type EmperorUILang = "en" | "ar";
|
|
37
|
+
|
|
38
|
+
export type EmperorUILocales = Record<EmperorUILang, Record<string, string>>;
|
|
39
|
+
|
|
40
|
+
export type EmperorUIInterLocalization = {
|
|
41
|
+
lang?: EmperorUILang;
|
|
42
|
+
languages?: EmperorUILang[];
|
|
43
|
+
defaultLanguage?: EmperorUILang;
|
|
44
|
+
isMultiLingual?: boolean;
|
|
45
|
+
dir?: AppDirection;
|
|
46
|
+
locales?: EmperorUILocales;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type EmperorUIConfig = {
|
|
50
|
+
theme?: Partial<EmperorUITheme>;
|
|
51
|
+
layout?: Partial<EmperorUILayout>;
|
|
52
|
+
interLocalization?: Partial<EmperorUIInterLocalization>;
|
|
53
|
+
toast?: HeroUIProviderProps;
|
|
54
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export type * from "./
|
|
1
|
+
export type * from "./config";
|
|
2
|
+
export type * from "./navigation";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NavigationItem } from "@types";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
export type NavigationContextState = {
|
|
5
|
+
hoveredItemId: string | null;
|
|
6
|
+
subItems: NavigationItem[];
|
|
7
|
+
isSubItemsBoxOpen: boolean;
|
|
8
|
+
subItemsBoxIsHovered: boolean;
|
|
9
|
+
setHoveredItemId: (id: string | null) => void;
|
|
10
|
+
setSubItems: (items: NavigationItem[]) => void;
|
|
11
|
+
setIsSubItemsBoxOpen: (isOpen: boolean) => void;
|
|
12
|
+
setSubItemsBoxIsHovered: (isHovered: boolean) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type NavigationProviderProps = {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { FileObject } from "@types";
|
|
4
|
+
/**
|
|
5
|
+
* Compress an image to reduce its size
|
|
6
|
+
*
|
|
7
|
+
* ! NOTE: This function should ONLY run on CLIENT side
|
|
8
|
+
*/
|
|
9
|
+
import imageCompression from "browser-image-compression";
|
|
10
|
+
|
|
11
|
+
export async function compressImage(
|
|
12
|
+
fileObject: FileObject,
|
|
13
|
+
maxSizeMB?: number,
|
|
14
|
+
): Promise<FileObject | null> {
|
|
15
|
+
try {
|
|
16
|
+
if (!fileObject?.file) return null;
|
|
17
|
+
|
|
18
|
+
const blob = await imageCompression(fileObject?.file, {
|
|
19
|
+
maxSizeMB: maxSizeMB || 2,
|
|
20
|
+
useWebWorker: true, // Optimize performance
|
|
21
|
+
initialQuality: 0.8, // Adjust the compression quality (0.1 to 1)
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const compressedFile = new File([blob], fileObject?.file?.name, {
|
|
25
|
+
type: blob.type,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
...fileObject,
|
|
30
|
+
file: compressedFile,
|
|
31
|
+
};
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("Image compression failed:", error);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EmperorUIProvider } from "@providers";
|
|
2
|
+
import { defaultEmperorUIConfig } from "@constants";
|
|
3
|
+
import { EmperorUIConfig } from "@types";
|
|
4
|
+
|
|
5
|
+
export const getStorybookDecorators = ({
|
|
6
|
+
config = defaultEmperorUIConfig,
|
|
7
|
+
}: {
|
|
8
|
+
config?: EmperorUIConfig;
|
|
9
|
+
}) => [
|
|
10
|
+
(Story: any) => (
|
|
11
|
+
<EmperorUIProvider config={config}>
|
|
12
|
+
<Story />
|
|
13
|
+
</EmperorUIProvider>
|
|
14
|
+
),
|
|
15
|
+
];
|
package/tsconfig.app.json
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"strict": true,
|
|
21
21
|
"noUnusedLocals": true,
|
|
22
22
|
"noUnusedParameters": true,
|
|
23
|
-
"erasableSyntaxOnly": true,
|
|
24
23
|
"noFallthroughCasesInSwitch": true,
|
|
25
24
|
"noUncheckedSideEffectImports": true,
|
|
26
25
|
|
|
@@ -33,7 +32,9 @@
|
|
|
33
32
|
"@context": ["./src/context"],
|
|
34
33
|
"@examples": ["./src/examples"],
|
|
35
34
|
"@providers": ["./src/providers"],
|
|
36
|
-
"@types": ["./src/types"]
|
|
35
|
+
"@types": ["./src/types"],
|
|
36
|
+
"@mocks": ["./src/mocks"],
|
|
37
|
+
"@enums": ["./src/enums"]
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
40
|
"include": [
|
package/tsconfig.node.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -28,6 +28,8 @@ export default defineConfig({
|
|
|
28
28
|
"@hooks": path.resolve(__dirname, "./src/hooks"),
|
|
29
29
|
"@context": path.resolve(__dirname, "./src/context"),
|
|
30
30
|
"@examples": path.resolve(__dirname, "./src/examples"),
|
|
31
|
+
"@mocks": path.resolve(__dirname, "./src/mocks"),
|
|
32
|
+
"@enums": path.resolve(__dirname, "./src/enums"),
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
build: {
|
|
@@ -36,6 +38,7 @@ export default defineConfig({
|
|
|
36
38
|
name: "EmperorUI",
|
|
37
39
|
fileName: "emperor-ui",
|
|
38
40
|
},
|
|
41
|
+
cssCodeSplit: false,
|
|
39
42
|
rollupOptions: {
|
|
40
43
|
external: ["react", "react-dom"],
|
|
41
44
|
output: {
|
|
@@ -43,6 +46,7 @@ export default defineConfig({
|
|
|
43
46
|
react: "React",
|
|
44
47
|
"react-dom": "ReactDOM",
|
|
45
48
|
},
|
|
49
|
+
assetFileNames: "globals.css",
|
|
46
50
|
},
|
|
47
51
|
},
|
|
48
52
|
},
|