@js-empire/emperor-ui 1.0.1 → 1.2.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.
Files changed (189) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.storybook/main.ts +2 -11
  3. package/.storybook/preview.ts +1 -1
  4. package/.storybook/vitest.setup.ts +3 -3
  5. package/.vscode/extensions.json +1 -0
  6. package/README.md +47 -1
  7. package/dist/emperor-ui.js +69 -3169
  8. package/dist/emperor-ui.umd.cjs +45 -2
  9. package/dist/features-animation-D_Ss-HYx.js +1938 -0
  10. package/dist/globals.css +1 -0
  11. package/dist/icons/emperor-ui-logo.ico +0 -0
  12. package/dist/images/avatar-female.jpg +0 -0
  13. package/dist/images/avatar-male.jpg +0 -0
  14. package/dist/images/emperor-ui-logo.png +0 -0
  15. package/dist/index-C3mfrNCk.js +1630 -0
  16. package/dist/index-CZpTSGZs.js +5 -0
  17. package/dist/index-SRvFgjzo.js +26257 -0
  18. package/dist/index.d.ts +552 -46
  19. package/dist/src-UW24ZMRV-Ducut0ty.js +5 -0
  20. package/eslint.config.js +5 -14
  21. package/package.json +19 -7
  22. package/public/icons/emperor-ui-logo.ico +0 -0
  23. package/public/images/avatar-female.jpg +0 -0
  24. package/public/images/avatar-male.jpg +0 -0
  25. package/public/images/emperor-ui-logo.png +0 -0
  26. package/src/components/atoms/brand/brand.stories.tsx +27 -0
  27. package/src/components/atoms/brand/brand.tsx +56 -0
  28. package/src/components/atoms/brand/index.ts +1 -0
  29. package/src/components/atoms/brand/styles/classes.ts +9 -0
  30. package/src/components/atoms/brand/styles/index.ts +2 -0
  31. package/src/components/atoms/brand/styles/styles.ts +0 -0
  32. package/src/components/atoms/column/column.stories.tsx +37 -0
  33. package/src/components/atoms/column/column.tsx +21 -0
  34. package/src/components/atoms/column/index.ts +1 -0
  35. package/src/components/atoms/container/column.stories.tsx +37 -0
  36. package/src/components/atoms/container/container.tsx +28 -0
  37. package/src/components/atoms/container/index.ts +1 -0
  38. package/src/components/atoms/index.ts +6 -0
  39. package/src/components/atoms/portal/index.ts +1 -0
  40. package/src/components/atoms/portal/portal.stories.tsx +43 -0
  41. package/src/components/atoms/portal/portal.tsx +25 -0
  42. package/src/components/atoms/row/index.ts +1 -0
  43. package/src/components/atoms/row/row.stories.tsx +37 -0
  44. package/src/components/atoms/row/row.tsx +26 -0
  45. package/src/components/atoms/uploader/avatar-label.tsx +83 -0
  46. package/src/components/atoms/uploader/index.ts +7 -0
  47. package/src/components/atoms/uploader/stories/uploader.stories.tsx +160 -0
  48. package/src/components/atoms/uploader/upload-file-error-box.tsx +29 -0
  49. package/src/components/atoms/uploader/upload-file-input.tsx +36 -0
  50. package/src/components/atoms/uploader/upload-file-label.tsx +74 -0
  51. package/src/components/atoms/uploader/upload-file-listing.tsx +55 -0
  52. package/src/components/atoms/uploader/uploader.tsx +55 -0
  53. package/src/components/atoms/uploader/view-image-modal.tsx +40 -0
  54. package/src/components/index.ts +4 -8
  55. package/src/components/{filter → molecules/filter}/filter.tsx +2 -2
  56. package/src/components/molecules/index.ts +5 -0
  57. package/src/components/molecules/item-card/item-card.tsx +6 -0
  58. package/src/components/molecules/nav-bar/index.ts +3 -0
  59. package/src/components/molecules/nav-bar/nav-bar-item.tsx +70 -0
  60. package/src/components/molecules/nav-bar/nav-bar.tsx +65 -0
  61. package/src/components/molecules/nav-bar/stories/hover-effect/nav-bar-hover-effect.stories.tsx +52 -0
  62. package/src/components/molecules/nav-bar/stories/nav-bar.stories.tsx +50 -0
  63. package/src/components/molecules/nav-bar/styles/classes.ts +68 -0
  64. package/src/components/molecules/nav-bar/styles/index.ts +2 -0
  65. package/src/components/molecules/nav-bar/styles/styles.ts +85 -0
  66. package/src/components/molecules/nav-bar/sub-items-box.tsx +57 -0
  67. package/src/components/molecules/scaffold/scaffold.stories.tsx +21 -0
  68. package/src/components/molecules/scaffold/scaffold.tsx +36 -0
  69. package/src/components/molecules/side-bar/compact-side-bar.tsx +75 -0
  70. package/src/components/molecules/side-bar/index.ts +1 -0
  71. package/src/components/molecules/side-bar/side-bar-drawer.tsx +124 -0
  72. package/src/components/molecules/side-bar/side-bar.stories.tsx +111 -0
  73. package/src/components/molecules/side-bar/side-bar.tsx +31 -0
  74. package/src/components/molecules/side-bar/styles/classes.ts +28 -0
  75. package/src/components/molecules/side-bar/styles/index.ts +2 -0
  76. package/src/components/molecules/side-bar/styles/styles.ts +13 -0
  77. package/src/components/organisms/footer/copy-rights-box.tsx +27 -0
  78. package/src/components/organisms/footer/footer.tsx +75 -0
  79. package/src/components/organisms/footer/index.ts +5 -0
  80. package/src/components/organisms/footer/policies-box.tsx +26 -0
  81. package/src/components/organisms/footer/quick-links-box.tsx +45 -0
  82. package/src/components/organisms/footer/social-links-box.tsx +32 -0
  83. package/src/components/organisms/footer/stories/footer.stories.tsx +61 -0
  84. package/src/components/organisms/footer/styles/classes.ts +71 -0
  85. package/src/components/organisms/footer/styles/index.ts +2 -0
  86. package/src/components/organisms/footer/styles/styles.ts +6 -0
  87. package/src/components/organisms/header/header.tsx +94 -0
  88. package/src/components/organisms/header/segmented-header-content.tsx +37 -0
  89. package/src/components/organisms/header/stories/header.stories.tsx +144 -0
  90. package/src/components/organisms/header/styles/classes.ts +22 -0
  91. package/src/components/organisms/header/styles/index.ts +2 -0
  92. package/src/components/organisms/header/styles/styles.ts +39 -0
  93. package/src/components/organisms/index.ts +4 -0
  94. package/src/components/{item-details → organisms/item-details}/item-details.tsx +2 -2
  95. package/src/components/{listings → organisms/listings}/listings.tsx +2 -2
  96. package/src/components/templates/index.ts +1 -0
  97. package/src/components/templates/landing-page/index.ts +1 -0
  98. package/src/components/templates/landing-page/landing-page.stories.tsx +21 -0
  99. package/src/components/templates/landing-page/landing-page.tsx +57 -0
  100. package/src/components/templates/landing-page/styles/classes.ts +11 -0
  101. package/src/components/templates/landing-page/styles/index.ts +1 -0
  102. package/src/constants/defaults.ts +43 -8
  103. package/src/constants/fake.ts +5 -0
  104. package/src/constants/footer.tsx +157 -0
  105. package/src/constants/index.ts +3 -0
  106. package/src/constants/uploader.ts +27 -0
  107. package/src/context/emperor-ui-context.ts +4 -4
  108. package/src/context/index.ts +2 -0
  109. package/src/context/navigation-context.ts +6 -0
  110. package/src/context/uploader-context.ts +6 -0
  111. package/src/enums/index.ts +2 -0
  112. package/src/enums/placeholders.ts +4 -0
  113. package/src/enums/preserved-keys.ts +3 -0
  114. package/src/hooks/index.ts +3 -0
  115. package/src/hooks/use-emperor-ui.ts +1 -1
  116. package/src/hooks/use-navigation.ts +12 -0
  117. package/src/hooks/use-uploader-context.ts +14 -0
  118. package/src/hooks/use-uploader.tsx +151 -0
  119. package/src/index.ts +9 -5
  120. package/src/main.tsx +3 -0
  121. package/src/mocks/header.tsx +118 -0
  122. package/src/mocks/index.ts +1 -0
  123. package/src/providers/config-provider.tsx +54 -0
  124. package/src/providers/emperor-ui-provider.tsx +17 -24
  125. package/src/providers/index.ts +3 -0
  126. package/src/providers/navigation-provider.tsx +42 -0
  127. package/src/providers/uploader-provider.tsx +53 -0
  128. package/src/styles/globals.css +13 -0
  129. package/src/styles/hero.ts +2 -0
  130. package/src/types/components/atoms/brand.ts +13 -0
  131. package/src/types/components/atoms/column.ts +3 -0
  132. package/src/types/components/atoms/container.ts +3 -0
  133. package/src/types/components/atoms/index.ts +6 -0
  134. package/src/types/components/atoms/portal.ts +6 -0
  135. package/src/types/components/atoms/row.ts +3 -0
  136. package/src/types/components/atoms/uploader.ts +97 -0
  137. package/src/types/components/index.ts +3 -8
  138. package/src/types/components/{filter → molecules/filter}/filter.ts +1 -1
  139. package/src/types/components/molecules/footer/footer.ts +68 -0
  140. package/src/types/components/molecules/header/header.ts +51 -0
  141. package/src/types/components/molecules/index.ts +9 -0
  142. package/src/types/components/{item-card → molecules/item-card}/item-card.ts +1 -1
  143. package/src/types/components/{item-details → molecules/item-details}/item-details.ts +1 -1
  144. package/src/types/components/{listings → molecules/listings}/listings.ts +1 -1
  145. package/src/types/components/molecules/nav-bar/nav-bar.ts +66 -0
  146. package/src/types/components/{scaffold → molecules/scaffold}/scaffold.ts +1 -1
  147. package/src/types/components/molecules/side-bar/index.ts +1 -0
  148. package/src/types/components/molecules/side-bar/side-bar.ts +40 -0
  149. package/src/types/components/templates/index.ts +1 -0
  150. package/src/types/components/templates/landing-page.ts +10 -0
  151. package/src/types/context/config.ts +54 -0
  152. package/src/types/context/index.ts +2 -1
  153. package/src/types/context/navigation.ts +17 -0
  154. package/src/types/shared/components.ts +4 -0
  155. package/src/utils/compress-images.ts +36 -0
  156. package/src/utils/index.ts +3 -0
  157. package/src/utils/storybook.tsx +15 -0
  158. package/src/utils/uploader.ts +148 -0
  159. package/tsconfig.app.json +1 -9
  160. package/tsconfig.node.json +0 -1
  161. package/vite.config.ts +3 -8
  162. package/vitest.shims.d.ts +1 -1
  163. package/src/components/footer/footer.tsx +0 -6
  164. package/src/components/footer/index.ts +0 -1
  165. package/src/components/header/header.tsx +0 -49
  166. package/src/components/item-card/item-card.tsx +0 -6
  167. package/src/components/nav-bar/index.ts +0 -1
  168. package/src/components/nav-bar/nav-bar.tsx +0 -6
  169. package/src/components/scaffold/scaffold.tsx +0 -15
  170. package/src/index.css +0 -1
  171. package/src/types/components/footer/footer.ts +0 -9
  172. package/src/types/components/header/header.ts +0 -21
  173. package/src/types/components/nav-bar/nav-bar.ts +0 -9
  174. package/src/types/context/emperor-ui.ts +0 -37
  175. package/tailwind.config.js +0 -6
  176. /package/src/components/{filter → molecules/filter}/index.ts +0 -0
  177. /package/src/components/{item-card → molecules/item-card}/index.ts +0 -0
  178. /package/src/components/{scaffold → molecules/scaffold}/index.ts +0 -0
  179. /package/src/components/{header → organisms/header}/index.ts +0 -0
  180. /package/src/components/{item-details → organisms/item-details}/index.ts +0 -0
  181. /package/src/components/{listings → organisms/listings}/index.ts +0 -0
  182. /package/src/types/components/{filter → molecules/filter}/index.ts +0 -0
  183. /package/src/types/components/{footer → molecules/footer}/index.ts +0 -0
  184. /package/src/types/components/{header → molecules/header}/index.ts +0 -0
  185. /package/src/types/components/{item-card → molecules/item-card}/index.ts +0 -0
  186. /package/src/types/components/{item-details → molecules/item-details}/index.ts +0 -0
  187. /package/src/types/components/{listings → molecules/listings}/index.ts +0 -0
  188. /package/src/types/components/{nav-bar → molecules/nav-bar}/index.ts +0 -0
  189. /package/src/types/components/{scaffold → molecules/scaffold}/index.ts +0 -0
@@ -0,0 +1,39 @@
1
+ import { CSSProperties } from "react";
2
+ import { HeaderGlassEffect, HeaderStylesProps } from "@/types";
3
+
4
+ export const getGlassEffectStyles = ({
5
+ glassEffect,
6
+ }: {
7
+ glassEffect: HeaderGlassEffect;
8
+ }): CSSProperties => ({
9
+ backgroundColor: glassEffect?.backgroundColor
10
+ ? `${glassEffect?.backgroundColor}${glassEffect?.opacity ?? 30}`
11
+ : "transparent",
12
+ backdropFilter: `blur(${glassEffect?.blur ?? 0}px)`,
13
+ color: glassEffect?.foregroundColor,
14
+ });
15
+
16
+ export const headerStyles = ({
17
+ primaryColor,
18
+ foregroundColor,
19
+ variant,
20
+ glassEffect,
21
+ }: HeaderStylesProps): CSSProperties => {
22
+ if (glassEffect?.enabled && variant !== "segmented-floating") {
23
+ return getGlassEffectStyles({
24
+ glassEffect: {
25
+ ...glassEffect,
26
+ foregroundColor: glassEffect?.foregroundColor ?? foregroundColor,
27
+ },
28
+ });
29
+ }
30
+
31
+ if (["default", "floating"].includes(variant ?? "")) {
32
+ return {
33
+ backgroundColor: primaryColor,
34
+ color: foregroundColor,
35
+ };
36
+ }
37
+
38
+ return {};
39
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./item-details";
2
+ export * from "./listings";
3
+ export * from "./footer";
4
+ export * from "./header";
@@ -1,5 +1,5 @@
1
- import type { ItemDetailsProps } from "src";
2
- import { cn } from "@utils";
1
+ import type { ItemDetailsProps } from "@/types";
2
+ import { cn } from "@/utils";
3
3
 
4
4
  export function ItemDetails({ className }: ItemDetailsProps) {
5
5
  return <div className={cn("", className)}>ItemDetails Component</div>;
@@ -1,5 +1,5 @@
1
- import type { ListingsProps } from "src";
2
- import { cn } from "@utils";
1
+ import type { ListingsProps } from "@/types";
2
+ import { cn } from "@/utils";
3
3
 
4
4
  export function Listings({ className }: ListingsProps) {
5
5
  return <div className={cn("", className)}>Listings Component</div>;
@@ -0,0 +1 @@
1
+ export * from "./landing-page";
@@ -0,0 +1 @@
1
+ export * from "./landing-page";
@@ -0,0 +1,21 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { LandingPage } from "@/components";
3
+ import { getStorybookDecorators } from "@/utils";
4
+
5
+ const meta: Meta<typeof LandingPage> = {
6
+ title: "Templates/LandingPage",
7
+ component: LandingPage,
8
+ parameters: {
9
+ layout: "fullscreen",
10
+ },
11
+ tags: ["autodocs"],
12
+ decorators: getStorybookDecorators({}),
13
+ };
14
+
15
+ export default meta;
16
+
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ export const Default: Story = {
20
+ args: {},
21
+ };
@@ -0,0 +1,57 @@
1
+ import { forwardRef, ComponentProps } from "react";
2
+ import { VariantProps } from "class-variance-authority";
3
+ import { cn } from "@/utils";
4
+ import { LandingPageProps } from "@/types";
5
+ import { landingPageClasses } from "./styles";
6
+ import { Brand, Header, NavBar } from "@/components";
7
+ import { MOCK_HEADER_ITEMS_WITH_SUB_ITEMS } from "@/mocks";
8
+ import { FAKE_PARAGRAPH } from "@/constants";
9
+
10
+ const GLASS_EFFECT_CONFIG = {
11
+ enabled: true,
12
+ blur: 10,
13
+ backgroundColor: "#006fed",
14
+ foregroundColor: "#fff",
15
+ opacity: 40,
16
+ };
17
+
18
+ /**
19
+ * This component is not for general use nor it is reusable, it is intended to be used as a demo page.
20
+ */
21
+ export const LandingPage = forwardRef<
22
+ HTMLDivElement,
23
+ ComponentProps<"main"> &
24
+ VariantProps<typeof landingPageClasses> &
25
+ LandingPageProps
26
+ >(({ className, variant = "default", children, ...props }, ref) => {
27
+ return (
28
+ <main
29
+ ref={ref}
30
+ data-slot="emperor-landing-page"
31
+ className={cn(landingPageClasses({ className }))}
32
+ {...props}
33
+ >
34
+ <Header variant="floating" glassEffect={GLASS_EFFECT_CONFIG}>
35
+ <Brand />
36
+
37
+ <NavBar
38
+ items={MOCK_HEADER_ITEMS_WITH_SUB_ITEMS}
39
+ hoverEffect="none"
40
+ variant="default"
41
+ className="hidden md:flex"
42
+ subItemsColumns={4}
43
+ />
44
+ </Header>
45
+
46
+ <main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
47
+ <p>{FAKE_PARAGRAPH}</p>
48
+ <p>{FAKE_PARAGRAPH}</p>
49
+ <p>{FAKE_PARAGRAPH}</p>
50
+ <p>{FAKE_PARAGRAPH}</p>
51
+ <p>{FAKE_PARAGRAPH}</p>
52
+ </main>
53
+
54
+ {children}
55
+ </main>
56
+ );
57
+ });
@@ -0,0 +1,11 @@
1
+ import { cva } from "class-variance-authority";
2
+
3
+ export const landingPageClasses = cva(["flex flex-col w-full"], {
4
+ variants: {
5
+ variant: {
6
+ default: [],
7
+ },
8
+ },
9
+ defaultVariants: {},
10
+ compoundVariants: [],
11
+ });
@@ -0,0 +1 @@
1
+ export * from "./classes";
@@ -1,14 +1,14 @@
1
- import type { ColorsPalette, EmperorUIConfig } from "@types";
1
+ import type { ColorsPalette, EmperorUIConfig } from "@/types";
2
2
 
3
3
  export const defaultColorsPalette: ColorsPalette = {
4
- primary: "#1E40AF",
5
- secondary: "#F59E0B",
6
- background: "#FFFFFF",
7
- text: "#111827",
8
- danger: "#DC2626",
9
- warning: "#D97706",
4
+ primary: "#006FEE",
5
+ secondary: "#9353d3",
6
+ background: "#3f3f46",
7
+ foreground: "#ECEDEE",
8
+ success: "#17c964",
9
+ warning: "#f5a524",
10
+ danger: "#f31260",
10
11
  info: "#3B82F6",
11
- success: "#16A34A",
12
12
  };
13
13
 
14
14
  export const defaultEmperorUIConfig: EmperorUIConfig = {
@@ -19,4 +19,39 @@ export const defaultEmperorUIConfig: EmperorUIConfig = {
19
19
  layout: {
20
20
  withScaffold: true,
21
21
  },
22
+ interLocalization: {
23
+ lang: "en",
24
+ languages: ["en", "ar"],
25
+ defaultLanguage: "en",
26
+ dir: "ltr",
27
+ isMultiLingual: false,
28
+ locales: {
29
+ en: {
30
+ dropHere: "Drop file here",
31
+ selectFile: "Select a file or drag and drop here",
32
+ selectionTypes: "JPG, PNG or PDF, file size no more than 10MB",
33
+ selectBtn: "Select file",
34
+ errorUploadingFile: "No file was uploaded",
35
+ maxNumImages: "Maximum number of uploaded images exceeded: ",
36
+ errorUploadedTypes: "You can only upload files within these types: ",
37
+ maxSizeExceededError:
38
+ "You can only upload files/images with less than MAX_FILE_SIZE Mega Bytes, you're file's size is UPLOADED_FILE_SIZE Mega Bytes",
39
+ duplicatesDenied:
40
+ "You can't upload images with duplicate names, you may rename them before the upload process",
41
+ },
42
+ ar: {
43
+ dropHere: "أسقط الملف هنا",
44
+ selectFile: "حدد ملفًا أو اسحبه وأفلته هنا",
45
+ selectionTypes: "JPG, PNG أو PDF، حجم الملف لا يزيد عن 10MB",
46
+ selectBtn: "حدد ملف",
47
+ errorUploadingFile: "لم يتم تحميل أي ملف",
48
+ maxNumImages: "تم تجاوز الحد الأقصى للصور المرفوعة: ",
49
+ errorUploadedTypes: "يمكنك فقط تحميل الملفات من الأنواع التالية: ",
50
+ maxSizeExceededError:
51
+ "يمكنك فقط رفع ملفات/صور بحجم أقل من MAX_FILE_SIZE ميغابايت، بينما حجم الملف الذي رفعته هو UPLOADED_FILE_SIZE ميغابايت",
52
+ duplicatesDenied:
53
+ "لا يمكنك رفع صور تحمل نفس الاسم، يمكنك إعادة تسميتها قبل عملية الرفع",
54
+ },
55
+ },
56
+ },
22
57
  };
@@ -0,0 +1,5 @@
1
+ export const FAKE_SENTENCE =
2
+ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.";
3
+
4
+ export const FAKE_PARAGRAPH =
5
+ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,";
@@ -0,0 +1,157 @@
1
+ import {
2
+ CopyRights,
3
+ Contacts,
4
+ QuickLink,
5
+ QuickLinkCollection,
6
+ SocialLink,
7
+ } from "@/types";
8
+
9
+ import {
10
+ FacebookIcon,
11
+ InstagramIcon,
12
+ LinkedinIcon,
13
+ TwitterIcon,
14
+ YoutubeIcon,
15
+ } from "lucide-react";
16
+
17
+ export const quickLinks: QuickLinkCollection[] = [
18
+ {
19
+ title: "Products",
20
+ links: [
21
+ {
22
+ label: "Product 1",
23
+ href: "/product-1",
24
+ },
25
+ {
26
+ label: "Product 2",
27
+ href: "/product-2",
28
+ },
29
+ {
30
+ label: "Product 3",
31
+ href: "/product-3",
32
+ },
33
+ ],
34
+ },
35
+ {
36
+ title: "Services",
37
+ links: [
38
+ {
39
+ label: "Service 1",
40
+ href: "/service-1",
41
+ },
42
+ {
43
+ label: "Service 2",
44
+ href: "/service-2",
45
+ },
46
+ {
47
+ label: "Service 3",
48
+ href: "/service-3",
49
+ },
50
+ {
51
+ label: "Service 4",
52
+ href: "/service-4",
53
+ },
54
+ ],
55
+ },
56
+ {
57
+ title: "Resources",
58
+ links: [
59
+ {
60
+ label: "Resource 1",
61
+ href: "/resource-1",
62
+ },
63
+ ],
64
+ },
65
+ {
66
+ title: "Company",
67
+ links: [
68
+ {
69
+ label: "About Us",
70
+ href: "/about-us",
71
+ },
72
+ {
73
+ label: "Careers",
74
+ href: "/careers",
75
+ },
76
+ {
77
+ label: "Blog",
78
+ href: "/blog",
79
+ },
80
+ ],
81
+ },
82
+ {
83
+ title: "Support",
84
+ links: [
85
+ {
86
+ label: "Contact Us",
87
+ href: "/contact-us",
88
+ },
89
+ ],
90
+ },
91
+ ];
92
+
93
+ export const policies: QuickLink[] = [
94
+ {
95
+ label: "Privacy Policy",
96
+ href: "/privacy-policy",
97
+ },
98
+ {
99
+ label: "Terms of Service",
100
+ href: "/terms-of-service",
101
+ },
102
+ {
103
+ label: "Cookie Policy",
104
+ href: "/cookie-policy",
105
+ },
106
+ ];
107
+
108
+ export const copyRights: CopyRights = {
109
+ year: 2026,
110
+ text: "All rights reserved - Emperor UI",
111
+ };
112
+
113
+ export const contacts: Contacts = {
114
+ mobile: "+964 770 000 0000",
115
+ email: "contact@emperorui.com",
116
+ website: "https://jsempire.com",
117
+ workingHours: "Monday - Friday: 9:00 AM - 5:00 PM",
118
+ addresses: [
119
+ {
120
+ country: "Jordan",
121
+ street: "Amman, Jordan",
122
+ city: "Amman",
123
+ state: "Amman",
124
+ zip: "11111",
125
+ },
126
+ {
127
+ country: "Saudi Arabia",
128
+ street: "Riyadh, Saudi Arabia",
129
+ city: "Riyadh",
130
+ state: "Riyadh",
131
+ zip: "11111",
132
+ },
133
+ ],
134
+ };
135
+
136
+ export const socialLinks: SocialLink[] = [
137
+ {
138
+ href: "https://facebook.com",
139
+ icon: <FacebookIcon />,
140
+ },
141
+ {
142
+ href: "https://twitter.com",
143
+ icon: <TwitterIcon />,
144
+ },
145
+ {
146
+ href: "https://instagram.com",
147
+ icon: <InstagramIcon />,
148
+ },
149
+ {
150
+ href: "https://linkedin.com",
151
+ icon: <LinkedinIcon />,
152
+ },
153
+ {
154
+ href: "https://youtube.com",
155
+ icon: <YoutubeIcon />,
156
+ },
157
+ ];
@@ -1 +1,4 @@
1
1
  export * from "./defaults";
2
+ export * from "./fake";
3
+ export * from "./uploader";
4
+ export * from "./footer";
@@ -0,0 +1,27 @@
1
+ export const ALLOWED_IMAGES_TYPES = [
2
+ "image/jpeg",
3
+ "image/jpg",
4
+ "image/png",
5
+ "image/webp",
6
+ "image/gif",
7
+ "image/bmp",
8
+ "image/svg+xml",
9
+ "image/tiff",
10
+ "image/x-icon",
11
+ ];
12
+
13
+ export const ALLOWED_PDF_TYPES = ["application/pdf"];
14
+
15
+ export const ALLOWED_DOC_TYPES = [
16
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
17
+ ];
18
+
19
+ export const ONE_MEGABYTE = 1024;
20
+
21
+ export const fileTypesMapping: { [key: string]: string[] } = {
22
+ image: [".jpg", ".jpeg", ".png"],
23
+ doc: [".doc", ".docx"],
24
+ pdf: [".pdf"],
25
+ video: [".mp4"],
26
+ sheet: [".xlsx", ".xlx"],
27
+ };
@@ -1,6 +1,6 @@
1
- import type { EmperorUIContextState } from "@types";
1
+ import type { ConfigContextState } from "@/types";
2
2
  import { createContext } from "react";
3
3
 
4
- export const EmperorUIContext = createContext<
5
- EmperorUIContextState | undefined
6
- >(undefined);
4
+ export const EmperorUIContext = createContext<ConfigContextState | undefined>(
5
+ undefined,
6
+ );
@@ -1 +1,3 @@
1
1
  export * from "./emperor-ui-context";
2
+ export * from "./navigation-context";
3
+ export * from "./uploader-context";
@@ -0,0 +1,6 @@
1
+ import type { NavigationContextState } from "@/types";
2
+ import { createContext } from "react";
3
+
4
+ export const NavigationContext = createContext<
5
+ NavigationContextState | undefined
6
+ >(undefined);
@@ -0,0 +1,6 @@
1
+ import type { UploaderContextState } from "@/types";
2
+ import { createContext } from "react";
3
+
4
+ export const UploaderContext = createContext<UploaderContextState | undefined>(
5
+ undefined,
6
+ );
@@ -0,0 +1,2 @@
1
+ export * from "./preserved-keys";
2
+ export * from "./placeholders";
@@ -0,0 +1,4 @@
1
+ export enum Placeholders {
2
+ PLACEHOLDER_MALE_AVATAR = "/images/placeholder-male-avatar.png",
3
+ PLACEHOLDER_FEMALE_AVATAR = "/images/placeholder-female-avatar.png",
4
+ }
@@ -0,0 +1,3 @@
1
+ export enum PreservedKeys {
2
+ COMPACT_SIDEBAR_ID = "emperor-compact-sidebar",
3
+ }
@@ -1 +1,4 @@
1
1
  export * from "./use-emperor-ui";
2
+ export * from "./use-navigation";
3
+ export * from "./use-uploader-context";
4
+ export * from "./use-uploader";
@@ -1,4 +1,4 @@
1
- import { EmperorUIContext } from "@context";
1
+ import { EmperorUIContext } from "@/context";
2
2
  import { useContext } from "react";
3
3
 
4
4
  export function useEmperorUI() {
@@ -0,0 +1,12 @@
1
+ import { NavigationContext } from "@/context";
2
+ import { useContext } from "react";
3
+
4
+ export function useNavigation() {
5
+ const context = useContext(NavigationContext);
6
+
7
+ if (!context) {
8
+ throw new Error("useNavigation must be used within a NavigationProvider");
9
+ }
10
+
11
+ return context;
12
+ }
@@ -0,0 +1,14 @@
1
+ import { UploaderContext } from "@/context";
2
+ import { useContext } from "react";
3
+
4
+ export function useUploaderContext() {
5
+ const context = useContext(UploaderContext);
6
+
7
+ if (!context) {
8
+ throw new Error(
9
+ "useUploaderContext must be used within a UploaderProvider",
10
+ );
11
+ }
12
+
13
+ return context;
14
+ }
@@ -0,0 +1,151 @@
1
+ "use client";
2
+
3
+ import { addToast } from "@heroui/react";
4
+ import { FileObject, UseUploadFileProps, UseUploadFileReturn } from "@/types";
5
+ import { useState } from "react";
6
+ import { useEmperorUI } from "@/hooks";
7
+ import {
8
+ validateUploadedFiles,
9
+ getAllowedTypes,
10
+ refineUploadedFiles,
11
+ } from "@/utils";
12
+ import { ONE_MEGABYTE } from "@/constants";
13
+
14
+ export const useUploader = ({
15
+ labelContent,
16
+ labelId,
17
+ fileTypes,
18
+ isRequired = false,
19
+ isDraggable = true,
20
+ isMulti = false,
21
+ preventDuplicates = true,
22
+ maxCount = 10,
23
+ maxFileSize = ONE_MEGABYTE * 10,
24
+ compressFiles = false,
25
+ onChange = () => {},
26
+ }: UseUploadFileProps): UseUploadFileReturn => {
27
+ const { config } = useEmperorUI();
28
+ const [files, setFiles] = useState<FileObject[]>([]);
29
+ const [isLoading, setIsLoading] = useState(false);
30
+
31
+ const locales = config?.interLocalization?.locales;
32
+ const lang = config?.interLocalization?.lang;
33
+
34
+ const locale = locales?.[lang || "en"];
35
+
36
+ // remove a specific uploaded file
37
+ const handleClearFile = (fileName?: string) => {
38
+ setFiles((prev) => prev?.filter((file) => file?.file?.name !== fileName));
39
+
40
+ // Reset the input value to allow re-uploading the same file
41
+ if (labelId) {
42
+ const input = document.getElementById(labelId) as HTMLInputElement;
43
+ if (input) {
44
+ input.value = "";
45
+ }
46
+ }
47
+ };
48
+
49
+ // handle the uploading process including the window upload and the drag-and-drop upload
50
+ const onInputChange = async (
51
+ event: React.ChangeEvent<HTMLInputElement> &
52
+ React.DragEvent<HTMLLabelElement>,
53
+ ): Promise<void | string | null> => {
54
+ console.log("files: ", event.target.files);
55
+
56
+ if (
57
+ (!event.target.files || !event.target.files?.[0]) &&
58
+ (!event?.dataTransfer?.files || !event?.dataTransfer?.files[0])
59
+ ) {
60
+ return addToast({
61
+ title: locale?.errorUploadingFile,
62
+ });
63
+ }
64
+
65
+ // validate the file type according to the given allowed types
66
+ const allowedTypes = getAllowedTypes(fileTypes);
67
+
68
+ // verify if the files exist
69
+ if (!event.target.files && !event.dataTransfer.files) return;
70
+
71
+ // get the uploaded files
72
+ const uploadedFiles = Array.from(
73
+ event.target.files || event.dataTransfer.files,
74
+ );
75
+
76
+ // validate the files' length and prevent exceeded files only in the multiple-mode
77
+ if (
78
+ isMulti &&
79
+ (uploadedFiles?.length > maxCount ||
80
+ files?.length + uploadedFiles?.length > maxCount)
81
+ ) {
82
+ addToast({
83
+ title: `${locale?.maxNumImages} ${maxCount}`,
84
+ });
85
+ return;
86
+ }
87
+
88
+ // validate the files' types according to the given allowed types
89
+ if (
90
+ !uploadedFiles
91
+ ?.map((file) => file?.type)
92
+ ?.every((type) => allowedTypes.includes(type))
93
+ ) {
94
+ addToast({
95
+ title: `${locale?.errorUploadedTypes} ${allowedTypes.join(", ")}`,
96
+ });
97
+ return;
98
+ }
99
+
100
+ // validate the files' sizes if none of them exceeds the maximum allowed size
101
+ // validate files' names to ensure there are no duplicates if specified
102
+ const { compressedFiles, isInValid } = await validateUploadedFiles({
103
+ uploadedFiles,
104
+ maxFileSize,
105
+ compressFiles,
106
+ preventDuplicates,
107
+ files,
108
+ locale,
109
+ });
110
+
111
+ if (isInValid) return;
112
+
113
+ setIsLoading(true);
114
+
115
+ await Promise.all(
116
+ await refineUploadedFiles({
117
+ uploadedFiles: compressedFiles,
118
+ locale,
119
+ allowedTypes,
120
+ isMulti,
121
+ setFiles,
122
+ }),
123
+ ).finally(() => {
124
+ setIsLoading(false);
125
+ });
126
+
127
+ setTimeout(() => {
128
+ onChange();
129
+ }, 200);
130
+
131
+ // Reset the input value to allow re-uploading the same file
132
+ // Only reset for input change events, not drag events
133
+ if (event.target && "value" in event.target && event.target.files) {
134
+ (event.target as HTMLInputElement).value = "";
135
+ }
136
+ };
137
+
138
+ return {
139
+ files,
140
+ fileTypes,
141
+ labelId,
142
+ isRequired,
143
+ labelContent,
144
+ isDraggable,
145
+ isMulti,
146
+ handleClearFile,
147
+ onInputChange,
148
+ setFiles,
149
+ isLoading,
150
+ };
151
+ };