@js-empire/emperor-ui 1.3.6 → 1.3.7
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 +60623 -158
- package/package.json +7 -3
- package/.cursor/rules/code-conventions.mdc +0 -50
- package/.husky/pre-commit +0 -4
- package/.prettierrc +0 -10
- package/.storybook/main.ts +0 -24
- package/.storybook/preview.ts +0 -19
- package/.storybook/vitest.setup.ts +0 -7
- package/.vscode/extensions.json +0 -1
- package/dist/index-ABKcY4tX.js +0 -60607
- package/dist/index-CWu5fG3N.js +0 -6
- package/dist/index-DpemL3iQ.js +0 -291
- package/dist/src-UW24ZMRV-I8bMqcTI.js +0 -6
- package/eslint.config.js +0 -34
- package/index.html +0 -13
- 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/animations/blink.ts +0 -26
- package/src/animations/floating.ts +0 -12
- package/src/animations/index.ts +0 -2
- package/src/components/atoms/brand/brand.stories.tsx +0 -27
- package/src/components/atoms/brand/brand.tsx +0 -56
- package/src/components/atoms/brand/index.ts +0 -1
- package/src/components/atoms/brand/styles/classes.ts +0 -9
- package/src/components/atoms/brand/styles/index.ts +0 -2
- package/src/components/atoms/brand/styles/styles.ts +0 -0
- package/src/components/atoms/color-picker/color-picker.tsx +0 -12
- package/src/components/atoms/color-picker/free-color-picker.tsx +0 -58
- package/src/components/atoms/color-picker/index.ts +0 -3
- package/src/components/atoms/color-picker/preset-color-picker.tsx +0 -66
- package/src/components/atoms/color-picker/stories/color-picker.stories.tsx +0 -63
- package/src/components/atoms/column/column.stories.tsx +0 -37
- package/src/components/atoms/column/column.tsx +0 -21
- package/src/components/atoms/column/index.ts +0 -1
- package/src/components/atoms/container/column.stories.tsx +0 -37
- package/src/components/atoms/container/container.tsx +0 -28
- package/src/components/atoms/container/index.ts +0 -1
- package/src/components/atoms/copy-button/copy-button.tsx +0 -73
- package/src/components/atoms/copy-button/index.ts +0 -1
- package/src/components/atoms/copy-button/stories/copy-button.stories.tsx +0 -21
- package/src/components/atoms/field/field.tsx +0 -81
- package/src/components/atoms/field/index.ts +0 -3
- package/src/components/atoms/field/styles/classes.ts +0 -9
- package/src/components/atoms/field/styles/index.ts +0 -1
- package/src/components/atoms/field/units/autocomplete-field.tsx +0 -49
- package/src/components/atoms/field/units/checkbox-field.tsx +0 -35
- package/src/components/atoms/field/units/index.ts +0 -7
- package/src/components/atoms/field/units/input-field.tsx +0 -35
- package/src/components/atoms/field/units/radio-field.tsx +0 -43
- package/src/components/atoms/field/units/select-field.tsx +0 -50
- package/src/components/atoms/field/units/switch-field.tsx +0 -35
- package/src/components/atoms/field/units/textarea-field.tsx +0 -37
- package/src/components/atoms/filter/filter.tsx +0 -93
- package/src/components/atoms/filter/index.ts +0 -3
- package/src/components/atoms/filter/stories/filter.stories.tsx +0 -238
- package/src/components/atoms/filter/styles/classes.ts +0 -20
- package/src/components/atoms/filter/styles/index.ts +0 -1
- package/src/components/atoms/filter/units/autocomplete-filter.tsx +0 -66
- package/src/components/atoms/filter/units/checkbox-filter.tsx +0 -42
- package/src/components/atoms/filter/units/checkbox-group-filter.tsx +0 -68
- package/src/components/atoms/filter/units/date-filter.tsx +0 -46
- package/src/components/atoms/filter/units/index.ts +0 -9
- package/src/components/atoms/filter/units/numeric-filter.tsx +0 -41
- package/src/components/atoms/filter/units/range-filter.tsx +0 -65
- package/src/components/atoms/filter/units/search-filter.tsx +0 -53
- package/src/components/atoms/filter/units/select-filter.tsx +0 -57
- package/src/components/atoms/filter/units/switch-filter.tsx +0 -35
- package/src/components/atoms/index.ts +0 -11
- package/src/components/atoms/portal/index.ts +0 -1
- package/src/components/atoms/portal/portal.stories.tsx +0 -43
- package/src/components/atoms/portal/portal.tsx +0 -25
- package/src/components/atoms/row/index.ts +0 -1
- package/src/components/atoms/row/row.stories.tsx +0 -37
- package/src/components/atoms/row/row.tsx +0 -26
- package/src/components/atoms/theme-switch/index.ts +0 -1
- package/src/components/atoms/theme-switch/styles/classes.ts +0 -16
- package/src/components/atoms/theme-switch/styles/index.ts +0 -1
- package/src/components/atoms/theme-switch/theme-switch.stories.tsx +0 -26
- package/src/components/atoms/theme-switch/theme-switch.tsx +0 -54
- package/src/components/atoms/uploader/components/avatar-label.tsx +0 -102
- package/src/components/atoms/uploader/components/index.ts +0 -8
- package/src/components/atoms/uploader/components/upload-file-error-box.tsx +0 -40
- package/src/components/atoms/uploader/components/upload-file-input.tsx +0 -36
- package/src/components/atoms/uploader/components/upload-file-label.tsx +0 -92
- package/src/components/atoms/uploader/components/upload-file-listing.tsx +0 -64
- package/src/components/atoms/uploader/components/uploader-title.tsx +0 -21
- package/src/components/atoms/uploader/components/uploader.tsx +0 -89
- package/src/components/atoms/uploader/components/view-image-modal.tsx +0 -41
- package/src/components/atoms/uploader/index.ts +0 -1
- package/src/components/atoms/uploader/stories/uploader.stories.tsx +0 -202
- package/src/components/index.ts +0 -4
- package/src/components/molecules/index.ts +0 -4
- package/src/components/molecules/item-card/components/actions/index.ts +0 -3
- package/src/components/molecules/item-card/components/actions/item-actions-buttons.tsx +0 -43
- package/src/components/molecules/item-card/components/actions/item-actions-dropdown.tsx +0 -57
- package/src/components/molecules/item-card/components/actions/item-actions-overlay.tsx +0 -50
- package/src/components/molecules/item-card/components/additions/index.ts +0 -2
- package/src/components/molecules/item-card/components/additions/item-banner.tsx +0 -22
- package/src/components/molecules/item-card/components/additions/loading-item.tsx +0 -88
- package/src/components/molecules/item-card/components/card/index.ts +0 -4
- package/src/components/molecules/item-card/components/card/item-card-body.tsx +0 -74
- package/src/components/molecules/item-card/components/card/item-card-footer.tsx +0 -79
- package/src/components/molecules/item-card/components/card/item-card-header.tsx +0 -69
- package/src/components/molecules/item-card/components/card/item-card.tsx +0 -123
- package/src/components/molecules/item-card/components/index.ts +0 -3
- package/src/components/molecules/item-card/index.ts +0 -2
- package/src/components/molecules/item-card/stories/item-card.stories.tsx +0 -218
- package/src/components/molecules/item-card/styles/classes.ts +0 -141
- package/src/components/molecules/item-card/styles/index.ts +0 -1
- package/src/components/molecules/nav-bar/index.ts +0 -3
- package/src/components/molecules/nav-bar/nav-bar-item.tsx +0 -64
- package/src/components/molecules/nav-bar/nav-bar.tsx +0 -57
- package/src/components/molecules/nav-bar/stories/hover-effect/nav-bar-hover-effect.stories.tsx +0 -52
- package/src/components/molecules/nav-bar/stories/nav-bar.stories.tsx +0 -50
- package/src/components/molecules/nav-bar/styles/classes.ts +0 -68
- package/src/components/molecules/nav-bar/styles/index.ts +0 -2
- package/src/components/molecules/nav-bar/styles/styles.ts +0 -85
- package/src/components/molecules/nav-bar/sub-items-box.tsx +0 -58
- package/src/components/molecules/scaffold/index.ts +0 -2
- package/src/components/molecules/scaffold/scaffold.stories.tsx +0 -21
- package/src/components/molecules/scaffold/scaffold.tsx +0 -23
- package/src/components/molecules/scaffold/styles/index.ts +0 -1
- package/src/components/molecules/scaffold/styles/scaffold-classes.ts +0 -10
- package/src/components/molecules/side-bar/compact-side-bar.tsx +0 -77
- package/src/components/molecules/side-bar/index.ts +0 -1
- package/src/components/molecules/side-bar/side-bar-drawer.tsx +0 -113
- package/src/components/molecules/side-bar/side-bar.stories.tsx +0 -111
- package/src/components/molecules/side-bar/side-bar.tsx +0 -31
- package/src/components/molecules/side-bar/styles/classes.ts +0 -28
- package/src/components/molecules/side-bar/styles/index.ts +0 -2
- package/src/components/molecules/side-bar/styles/styles.ts +0 -13
- package/src/components/organisms/deletion-confirmor/deletion-confirmor.tsx +0 -110
- package/src/components/organisms/deletion-confirmor/index.ts +0 -3
- package/src/components/organisms/deletion-confirmor/stories/components.tsx +0 -25
- package/src/components/organisms/deletion-confirmor/stories/deletion-confirmor.stories.tsx +0 -78
- package/src/components/organisms/deletion-confirmor/styles/classes.ts +0 -28
- package/src/components/organisms/deletion-confirmor/styles/index.ts +0 -2
- package/src/components/organisms/deletion-confirmor/styles/styles.ts +0 -4
- package/src/components/organisms/footer/copy-rights-box.tsx +0 -27
- package/src/components/organisms/footer/footer.tsx +0 -75
- package/src/components/organisms/footer/index.ts +0 -5
- package/src/components/organisms/footer/policies-box.tsx +0 -27
- package/src/components/organisms/footer/quick-links-box.tsx +0 -46
- package/src/components/organisms/footer/social-links-box.tsx +0 -33
- package/src/components/organisms/footer/stories/footer.stories.tsx +0 -61
- package/src/components/organisms/footer/styles/classes.ts +0 -71
- package/src/components/organisms/footer/styles/index.ts +0 -2
- package/src/components/organisms/footer/styles/styles.ts +0 -6
- package/src/components/organisms/form-builder/form-builder.stories.tsx +0 -144
- package/src/components/organisms/form-builder/form-builder.tsx +0 -75
- package/src/components/organisms/form-builder/index.ts +0 -1
- package/src/components/organisms/header/header.tsx +0 -87
- package/src/components/organisms/header/index.ts +0 -1
- package/src/components/organisms/header/segmented-header-content.tsx +0 -29
- package/src/components/organisms/header/stories/header.stories.tsx +0 -144
- package/src/components/organisms/header/styles/classes.ts +0 -22
- package/src/components/organisms/header/styles/index.ts +0 -2
- package/src/components/organisms/header/styles/styles.ts +0 -39
- package/src/components/organisms/index.ts +0 -6
- package/src/components/organisms/item-details/index.ts +0 -1
- package/src/components/organisms/item-details/item-details.tsx +0 -6
- package/src/components/organisms/listings/empty-listings.tsx +0 -80
- package/src/components/organisms/listings/index.ts +0 -3
- package/src/components/organisms/listings/listings.tsx +0 -96
- package/src/components/organisms/listings/stories/grid-listings.stories.tsx +0 -153
- package/src/components/organisms/listings/stories/list-listings.stories.tsx +0 -171
- package/src/components/organisms/listings/styles/classes.ts +0 -49
- package/src/components/organisms/listings/styles/index.ts +0 -2
- package/src/components/organisms/listings/styles/styles.ts +0 -6
- package/src/components/templates/index.ts +0 -1
- package/src/components/templates/landing-page/index.ts +0 -1
- package/src/components/templates/landing-page/landing-page.stories.tsx +0 -21
- package/src/components/templates/landing-page/landing-page.tsx +0 -57
- package/src/components/templates/landing-page/styles/classes.ts +0 -11
- package/src/components/templates/landing-page/styles/index.ts +0 -1
- package/src/constants/animations.ts +0 -14
- package/src/constants/card.tsx +0 -42
- package/src/constants/defaults.ts +0 -59
- package/src/constants/fake.ts +0 -5
- package/src/constants/footer.tsx +0 -157
- package/src/constants/index.ts +0 -6
- package/src/constants/uploader.ts +0 -33
- package/src/context/emperor-ui-context.ts +0 -6
- package/src/context/form-builder-context.tsx +0 -8
- package/src/context/index.ts +0 -4
- package/src/context/navigation-context.ts +0 -6
- package/src/context/uploader-context.ts +0 -6
- package/src/enums/index.ts +0 -2
- package/src/enums/placeholders.ts +0 -4
- package/src/enums/preserved-keys.ts +0 -3
- package/src/examples/index.ts +0 -1
- package/src/hooks/index.ts +0 -8
- package/src/hooks/use-emperor-ui.ts +0 -12
- package/src/hooks/use-filters.ts +0 -20
- package/src/hooks/use-form-builder-context.ts +0 -16
- package/src/hooks/use-navigation.ts +0 -12
- package/src/hooks/use-search-params-handler.tsx +0 -186
- package/src/hooks/use-uploader-context.ts +0 -14
- package/src/hooks/use-uploader.tsx +0 -164
- package/src/hooks/use-window-size.tsx +0 -53
- package/src/i18n/configs/i18n.ts +0 -7
- package/src/i18n/configs/index.ts +0 -1
- package/src/i18n/constants/index.ts +0 -1
- package/src/i18n/constants/locales.ts +0 -4
- package/src/i18n/index.ts +0 -5
- package/src/i18n/locales/ar.ts +0 -15
- package/src/i18n/locales/atoms/ar.ts +0 -18
- package/src/i18n/locales/atoms/en.ts +0 -18
- package/src/i18n/locales/atoms/index.ts +0 -2
- package/src/i18n/locales/common/ar.ts +0 -1
- package/src/i18n/locales/common/en.ts +0 -1
- package/src/i18n/locales/common/index.ts +0 -2
- package/src/i18n/locales/en.ts +0 -15
- package/src/i18n/locales/index.ts +0 -4
- package/src/i18n/locales/molecules/ar.ts +0 -1
- package/src/i18n/locales/molecules/en.ts +0 -1
- package/src/i18n/locales/molecules/index.ts +0 -2
- package/src/i18n/locales/organisms/ar.ts +0 -11
- package/src/i18n/locales/organisms/en.ts +0 -11
- package/src/i18n/locales/organisms/index.ts +0 -2
- package/src/i18n/locales/templates/ar.ts +0 -1
- package/src/i18n/locales/templates/en.ts +0 -1
- package/src/i18n/locales/templates/index.ts +0 -2
- package/src/i18n/locales/toasts/ar.ts +0 -1
- package/src/i18n/locales/toasts/en.ts +0 -1
- package/src/i18n/locales/toasts/index.ts +0 -2
- package/src/i18n/types/index.ts +0 -2
- package/src/i18n/types/locale.ts +0 -5
- package/src/i18n/types/toasts.ts +0 -3
- package/src/i18n/utils/get-locales.ts +0 -4
- package/src/i18n/utils/index.ts +0 -2
- package/src/i18n/utils/localize.ts +0 -15
- package/src/index.ts +0 -14
- package/src/mocks/constants.ts +0 -103
- package/src/mocks/deletion-confirmor.ts +0 -16
- package/src/mocks/header.tsx +0 -118
- package/src/mocks/index.ts +0 -6
- package/src/mocks/listings.tsx +0 -154
- package/src/mocks/locales/index.ts +0 -1
- package/src/mocks/locales/uploader.ts +0 -33
- package/src/mocks/types.ts +0 -64
- package/src/providers/config-provider.tsx +0 -72
- package/src/providers/emperor-ui-provider.tsx +0 -35
- package/src/providers/form-builder-provider-context.tsx +0 -18
- package/src/providers/index.ts +0 -6
- package/src/providers/navigation-provider.tsx +0 -42
- package/src/providers/theme-provider.tsx +0 -16
- package/src/providers/uploader-provider.tsx +0 -53
- package/src/styles/globals.css +0 -38
- package/src/styles/hero.ts +0 -3
- package/src/styles/index.css +0 -18
- package/src/types/components/atoms/brand.ts +0 -13
- package/src/types/components/atoms/color-picker/color-picker.ts +0 -21
- package/src/types/components/atoms/color-picker/index.ts +0 -1
- package/src/types/components/atoms/column.ts +0 -3
- package/src/types/components/atoms/container.ts +0 -3
- package/src/types/components/atoms/field/field.ts +0 -61
- package/src/types/components/atoms/field/index.ts +0 -1
- package/src/types/components/atoms/filter/filter.ts +0 -52
- package/src/types/components/atoms/filter/index.ts +0 -2
- package/src/types/components/atoms/filter/select-filter.ts +0 -8
- package/src/types/components/atoms/index.ts +0 -9
- package/src/types/components/atoms/portal.ts +0 -6
- package/src/types/components/atoms/row.ts +0 -3
- package/src/types/components/atoms/uploader.ts +0 -103
- package/src/types/components/index.ts +0 -4
- package/src/types/components/molecules/footer/footer.ts +0 -68
- package/src/types/components/molecules/footer/index.ts +0 -1
- package/src/types/components/molecules/header/header.ts +0 -51
- package/src/types/components/molecules/header/index.ts +0 -1
- package/src/types/components/molecules/index.ts +0 -9
- package/src/types/components/molecules/item-card/index.ts +0 -1
- package/src/types/components/molecules/item-card/item-card.ts +0 -69
- package/src/types/components/molecules/item-details/index.ts +0 -1
- package/src/types/components/molecules/item-details/item-details.ts +0 -9
- package/src/types/components/molecules/listings/index.ts +0 -1
- package/src/types/components/molecules/listings/listings.ts +0 -29
- package/src/types/components/molecules/nav-bar/index.ts +0 -1
- package/src/types/components/molecules/nav-bar/nav-bar.ts +0 -66
- package/src/types/components/molecules/scaffold/index.ts +0 -1
- package/src/types/components/molecules/scaffold/scaffold.ts +0 -9
- package/src/types/components/molecules/side-bar/index.ts +0 -1
- package/src/types/components/molecules/side-bar/side-bar.ts +0 -40
- package/src/types/components/molecules/theme-switch/index.ts +0 -1
- package/src/types/components/molecules/theme-switch/theme-switch.ts +0 -9
- package/src/types/components/organisms/deletion-confirmor/deletion-confirmor.ts +0 -22
- package/src/types/components/organisms/deletion-confirmor/index.ts +0 -1
- package/src/types/components/organisms/filters/filters.ts +0 -11
- package/src/types/components/organisms/filters/index.ts +0 -1
- package/src/types/components/organisms/form-builder/context.ts +0 -6
- package/src/types/components/organisms/form-builder/form-builder.ts +0 -39
- package/src/types/components/organisms/form-builder/index.ts +0 -2
- package/src/types/components/organisms/index.ts +0 -3
- package/src/types/components/templates/index.ts +0 -1
- package/src/types/components/templates/landing-page.ts +0 -10
- package/src/types/context/config.ts +0 -24
- package/src/types/context/index.ts +0 -4
- package/src/types/context/localization.ts +0 -24
- package/src/types/context/navigation.ts +0 -17
- package/src/types/context/theme.ts +0 -33
- package/src/types/index.ts +0 -3
- package/src/types/shared/components.ts +0 -13
- package/src/types/shared/index.ts +0 -1
- package/src/utils/cn.ts +0 -6
- package/src/utils/compress-images.ts +0 -36
- package/src/utils/index.ts +0 -5
- package/src/utils/locales.ts +0 -54
- package/src/utils/storybook.tsx +0 -15
- package/src/utils/uploader.ts +0 -170
- package/tsconfig.app.json +0 -37
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -25
- package/vite.config.ts +0 -47
- package/vitest.shims.d.ts +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const templatesAr = {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const templatesEn = {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const toastsAr = {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const toastsEn = {};
|
package/src/i18n/types/index.ts
DELETED
package/src/i18n/types/locale.ts
DELETED
package/src/i18n/types/toasts.ts
DELETED
package/src/i18n/utils/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Lang } from "@/i18n";
|
|
2
|
-
|
|
3
|
-
export const localize = ({
|
|
4
|
-
object,
|
|
5
|
-
lang,
|
|
6
|
-
key,
|
|
7
|
-
}: {
|
|
8
|
-
lang: Lang;
|
|
9
|
-
key: string;
|
|
10
|
-
object?: Record<string, string> | undefined;
|
|
11
|
-
}): string | null | undefined =>
|
|
12
|
-
({
|
|
13
|
-
ar: object?.[key],
|
|
14
|
-
en: object?.[key],
|
|
15
|
-
})[lang] || null;
|
package/src/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import "./styles/globals.css";
|
|
4
|
-
|
|
5
|
-
export * from "./components";
|
|
6
|
-
export * from "./constants";
|
|
7
|
-
export * from "./context";
|
|
8
|
-
export * from "./examples";
|
|
9
|
-
export * from "./hooks";
|
|
10
|
-
export * from "./providers";
|
|
11
|
-
export type * from "./types";
|
|
12
|
-
export * from "./utils";
|
|
13
|
-
export * from "./mocks";
|
|
14
|
-
export * from "./enums";
|
package/src/mocks/constants.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { MockItemCategory, MockItemBrand, MockColor } from "@/mocks/types";
|
|
2
|
-
|
|
3
|
-
export const MOCK_ITEM_CATEGORIES: MockItemCategory[] = [
|
|
4
|
-
"laptops",
|
|
5
|
-
"desktops",
|
|
6
|
-
"monitors",
|
|
7
|
-
"keyboards",
|
|
8
|
-
"mice",
|
|
9
|
-
"headsets",
|
|
10
|
-
"printers",
|
|
11
|
-
"storage",
|
|
12
|
-
"components",
|
|
13
|
-
"networking",
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
export const MOCK_ITEM_BRANDS: MockItemBrand[] = [
|
|
17
|
-
"Apple",
|
|
18
|
-
"Dell",
|
|
19
|
-
"HP",
|
|
20
|
-
"Lenovo",
|
|
21
|
-
"Asus",
|
|
22
|
-
"Acer",
|
|
23
|
-
"MSI",
|
|
24
|
-
"Razer",
|
|
25
|
-
"Samsung",
|
|
26
|
-
"Microsoft",
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
export const MOCK_COLORS: MockColor[] = [
|
|
30
|
-
"black",
|
|
31
|
-
"gray",
|
|
32
|
-
"white",
|
|
33
|
-
"silver" as MockColor,
|
|
34
|
-
"blue",
|
|
35
|
-
"red",
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
export const MOCK_BASE_DATE = new Date("2026-02-04T00:00:00.000Z");
|
|
39
|
-
|
|
40
|
-
export const MOCK_REVIEW_COMMENTS: readonly string[] = [
|
|
41
|
-
"Excellent performance for the price.",
|
|
42
|
-
"Very quiet and fast machine.",
|
|
43
|
-
"Solid build quality and screen.",
|
|
44
|
-
"Battery life could be better.",
|
|
45
|
-
"Perfect for gaming and streaming.",
|
|
46
|
-
"Great value, highly recommended.",
|
|
47
|
-
"Runs cool even under heavy load.",
|
|
48
|
-
"Keyboard and trackpad feel premium.",
|
|
49
|
-
"Display is bright and color-accurate.",
|
|
50
|
-
"Setup was easy and straightforward.",
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
export const MOCK_REVIEW_AUTHORS: string[] = [
|
|
54
|
-
"Ahmed K.",
|
|
55
|
-
"Sara M.",
|
|
56
|
-
"Omar A.",
|
|
57
|
-
"Lina H.",
|
|
58
|
-
"Mohammed S.",
|
|
59
|
-
"Nour E.",
|
|
60
|
-
"Youssef R.",
|
|
61
|
-
"Fatima D.",
|
|
62
|
-
"Hassan T.",
|
|
63
|
-
"Mona L.",
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
export const MOCK_LISTING_TITLES: string[] = [
|
|
67
|
-
'Ultrabook Pro 14" Laptop',
|
|
68
|
-
"Gaming Beast RTX Desktop",
|
|
69
|
-
"Office Essential Mini PC",
|
|
70
|
-
'Curved 27" 2K Monitor',
|
|
71
|
-
"Mechanical RGB Gaming Keyboard",
|
|
72
|
-
"Wireless Silent Mouse",
|
|
73
|
-
"Studio USB-C Headset",
|
|
74
|
-
"All-in-One Color Printer",
|
|
75
|
-
"1TB NVMe PCIe 4.0 SSD",
|
|
76
|
-
"High-Airflow ATX Case",
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
export const MOCK_LISTING_DESCRIPTIONS: string[] = [
|
|
80
|
-
"Powerful and lightweight device ideal for productivity, study, and everyday use.",
|
|
81
|
-
"High-end desktop designed for 1440p and 4K gaming with excellent cooling.",
|
|
82
|
-
"Compact form factor PC optimized for office applications and web browsing.",
|
|
83
|
-
"High refresh rate display with vivid colors and thin bezels for immersive work.",
|
|
84
|
-
"Durable keyboard with customizable RGB lighting and fast mechanical switches.",
|
|
85
|
-
"Ergonomic wireless mouse with precise sensor and long battery life.",
|
|
86
|
-
"Comfortable over-ear headset with crystal-clear microphone and rich sound.",
|
|
87
|
-
"Fast wireless printer with automatic duplex printing and mobile support.",
|
|
88
|
-
"Next-generation SSD with blazing read and write speeds for fast boot times.",
|
|
89
|
-
"Spacious case with optimized airflow, cable management, and tempered glass.",
|
|
90
|
-
];
|
|
91
|
-
|
|
92
|
-
export const MOCK_LISTING_IMAGES: string[] = [
|
|
93
|
-
"https://images.pexels.com/photos/18105/pexels-photo.jpg",
|
|
94
|
-
"https://images.pexels.com/photos/1714208/pexels-photo-1714208.jpeg",
|
|
95
|
-
"https://images.pexels.com/photos/1714341/pexels-photo-1714341.jpeg",
|
|
96
|
-
"https://images.pexels.com/photos/2047905/pexels-photo-2047905.jpeg",
|
|
97
|
-
"https://images.pexels.com/photos/163117/keyboard-black-notebook-input-163117.jpeg",
|
|
98
|
-
"https://images.pexels.com/photos/3829246/pexels-photo-3829246.jpeg",
|
|
99
|
-
"https://images.pexels.com/photos/3394664/pexels-photo-3394664.jpeg",
|
|
100
|
-
"https://images.pexels.com/photos/3996439/pexels-photo-3996439.jpeg",
|
|
101
|
-
"https://images.pexels.com/photos/97077/pexels-photo-97077.jpeg",
|
|
102
|
-
"https://images.pexels.com/photos/3945650/pexels-photo-3945650.jpeg",
|
|
103
|
-
];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/** Default delay in ms for mock awaiting delete (e.g. in Storybook). */
|
|
2
|
-
export const MOCK_AWAITING_DELETE_MS = 2000;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Mocks an async delete: returns a function that resolves after a delay then calls onClose.
|
|
6
|
-
* Used for Storybook to simulate confirm-button loading state.
|
|
7
|
-
*/
|
|
8
|
-
export const mockAwaitingDelete =
|
|
9
|
-
(onClose: () => void, delayMs = MOCK_AWAITING_DELETE_MS) =>
|
|
10
|
-
(): Promise<void> =>
|
|
11
|
-
new Promise((resolve) => {
|
|
12
|
-
setTimeout(() => {
|
|
13
|
-
onClose();
|
|
14
|
-
resolve();
|
|
15
|
-
}, delayMs);
|
|
16
|
-
});
|
package/src/mocks/header.tsx
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { SideBarAction, NavigationItem } from "@/types";
|
|
2
|
-
import {
|
|
3
|
-
HelpCircleIcon,
|
|
4
|
-
HomeIcon,
|
|
5
|
-
InfoIcon,
|
|
6
|
-
LifeBuoyIcon,
|
|
7
|
-
LogOutIcon,
|
|
8
|
-
MailIcon,
|
|
9
|
-
ServerIcon,
|
|
10
|
-
SettingsIcon,
|
|
11
|
-
} from "lucide-react";
|
|
12
|
-
|
|
13
|
-
export const MOCK_HEADER_SUB_ITEMS: NavigationItem[] = [
|
|
14
|
-
{
|
|
15
|
-
id: "info",
|
|
16
|
-
label: "Info",
|
|
17
|
-
href: "#info",
|
|
18
|
-
Icon: InfoIcon,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: "contact",
|
|
22
|
-
label: "Contact",
|
|
23
|
-
href: "#contact",
|
|
24
|
-
Icon: MailIcon,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: "services",
|
|
28
|
-
label: "Services",
|
|
29
|
-
href: "#services",
|
|
30
|
-
Icon: ServerIcon,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
id: "settings",
|
|
34
|
-
label: "Settings",
|
|
35
|
-
href: "#settings",
|
|
36
|
-
Icon: SettingsIcon,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: "help",
|
|
40
|
-
label: "Help",
|
|
41
|
-
href: "#help",
|
|
42
|
-
Icon: HelpCircleIcon,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: "support",
|
|
46
|
-
label: "Support",
|
|
47
|
-
href: "#support",
|
|
48
|
-
Icon: LifeBuoyIcon,
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
export const MOCK_HEADER_ITEMS: NavigationItem[] = [
|
|
53
|
-
{
|
|
54
|
-
id: "home",
|
|
55
|
-
label: "Home",
|
|
56
|
-
href: "#home",
|
|
57
|
-
Icon: HomeIcon,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: "about",
|
|
61
|
-
label: "About",
|
|
62
|
-
href: "#about",
|
|
63
|
-
Icon: InfoIcon,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
id: "contact",
|
|
67
|
-
label: "Contact",
|
|
68
|
-
href: "#contact",
|
|
69
|
-
Icon: MailIcon,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: "services",
|
|
73
|
-
label: "Services",
|
|
74
|
-
href: "#services",
|
|
75
|
-
Icon: ServerIcon,
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
export const MOCK_HEADER_ITEMS_WITH_SUB_ITEMS: NavigationItem[] = [
|
|
80
|
-
{
|
|
81
|
-
id: "home",
|
|
82
|
-
label: "Home",
|
|
83
|
-
href: "#home",
|
|
84
|
-
Icon: HomeIcon,
|
|
85
|
-
subItems: MOCK_HEADER_SUB_ITEMS,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
id: "about",
|
|
89
|
-
label: "About",
|
|
90
|
-
href: "#about",
|
|
91
|
-
Icon: InfoIcon,
|
|
92
|
-
subItems: MOCK_HEADER_SUB_ITEMS,
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
id: "contact",
|
|
96
|
-
label: "Contact",
|
|
97
|
-
href: "#contact",
|
|
98
|
-
Icon: MailIcon,
|
|
99
|
-
subItems: MOCK_HEADER_SUB_ITEMS,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: "services",
|
|
103
|
-
label: "Services",
|
|
104
|
-
href: "#services",
|
|
105
|
-
Icon: ServerIcon,
|
|
106
|
-
subItems: MOCK_HEADER_SUB_ITEMS,
|
|
107
|
-
},
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
export const MOCK_HEADER_ACTIONS: SideBarAction[] = [
|
|
111
|
-
{
|
|
112
|
-
key: "logout",
|
|
113
|
-
label: "Logout",
|
|
114
|
-
color: "danger",
|
|
115
|
-
onPress: () => console.log("logout"),
|
|
116
|
-
startContent: <LogOutIcon />,
|
|
117
|
-
},
|
|
118
|
-
];
|
package/src/mocks/index.ts
DELETED
package/src/mocks/listings.tsx
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
-
import { type MockReview, type MockItemType } from "@/mocks/types";
|
|
3
|
-
import {
|
|
4
|
-
MOCK_REVIEW_COMMENTS,
|
|
5
|
-
MOCK_REVIEW_AUTHORS,
|
|
6
|
-
MOCK_BASE_DATE,
|
|
7
|
-
MOCK_ITEM_CATEGORIES,
|
|
8
|
-
MOCK_ITEM_BRANDS,
|
|
9
|
-
MOCK_COLORS,
|
|
10
|
-
MOCK_LISTING_TITLES,
|
|
11
|
-
MOCK_LISTING_DESCRIPTIONS,
|
|
12
|
-
MOCK_LISTING_IMAGES,
|
|
13
|
-
} from "@/mocks/constants";
|
|
14
|
-
import { ItemChipProps } from "@/types";
|
|
15
|
-
import { Star } from "lucide-react";
|
|
16
|
-
|
|
17
|
-
const createReviewList = (count: number, offset: number): MockReview[] => {
|
|
18
|
-
return Array.from({ length: count }, (_, index) => {
|
|
19
|
-
const id = offset + index + 1;
|
|
20
|
-
const ratingBase = (index % 5) + 1 + (index % 3) * 0.1;
|
|
21
|
-
const rating = Number(Math.min(5, ratingBase).toFixed(1));
|
|
22
|
-
const comment = MOCK_REVIEW_COMMENTS[index % MOCK_REVIEW_COMMENTS?.length];
|
|
23
|
-
const author = MOCK_REVIEW_AUTHORS[index % MOCK_REVIEW_AUTHORS.length];
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
id,
|
|
27
|
-
rating,
|
|
28
|
-
comment,
|
|
29
|
-
author,
|
|
30
|
-
createdAt: MOCK_BASE_DATE,
|
|
31
|
-
updatedAt: MOCK_BASE_DATE,
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// 10 reviews
|
|
37
|
-
export const MOCK_ITEM_REVIEWS_1: MockReview[] = createReviewList(10, 0);
|
|
38
|
-
|
|
39
|
-
// 50 reviews
|
|
40
|
-
export const MOCK_ITEM_REVIEWS_2: MockReview[] = createReviewList(50, 10);
|
|
41
|
-
|
|
42
|
-
// 100 reviews
|
|
43
|
-
export const MOCK_ITEM_REVIEWS_3: MockReview[] = createReviewList(100, 60);
|
|
44
|
-
|
|
45
|
-
const getListingCategories = (index: number): ItemChipProps[] => {
|
|
46
|
-
const count = (index % 5) + 1; // from 1 to 5 categories
|
|
47
|
-
const categories: ItemChipProps[] = [];
|
|
48
|
-
|
|
49
|
-
for (let i = 0; i < count; i += 1) {
|
|
50
|
-
const category: ItemChipProps = {
|
|
51
|
-
label: MOCK_ITEM_CATEGORIES[(index + i) % MOCK_ITEM_CATEGORIES.length],
|
|
52
|
-
startContent: <Star className="size-3 fill-current" />,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
if (!categories.includes(category)) {
|
|
56
|
-
categories.push(category);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return categories;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const getListingReviews = (index: number): MockReview[] => {
|
|
64
|
-
if (index < 10) return MOCK_ITEM_REVIEWS_1;
|
|
65
|
-
if (index < 30) return MOCK_ITEM_REVIEWS_2;
|
|
66
|
-
|
|
67
|
-
const maxReviews = 100;
|
|
68
|
-
const count = index % (maxReviews + 1); // from 0 to 100
|
|
69
|
-
|
|
70
|
-
return MOCK_ITEM_REVIEWS_3.slice(0, count);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const getAverageRating = (reviews: MockReview[]): number => {
|
|
74
|
-
if (!reviews.length) return 0;
|
|
75
|
-
|
|
76
|
-
const total = reviews.reduce((sum, review) => sum + review.rating, 0);
|
|
77
|
-
const average = total / reviews.length;
|
|
78
|
-
|
|
79
|
-
return Number(average.toFixed(1));
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// 50 listings
|
|
83
|
-
export const MOCK_LISTINGS: MockItemType[] = Array.from(
|
|
84
|
-
{ length: 50 },
|
|
85
|
-
(_, index) => {
|
|
86
|
-
const id = index + 1;
|
|
87
|
-
const brand = MOCK_ITEM_BRANDS[index % MOCK_ITEM_BRANDS.length];
|
|
88
|
-
const color = MOCK_COLORS[index % MOCK_COLORS.length];
|
|
89
|
-
const title = MOCK_LISTING_TITLES[index % MOCK_LISTING_TITLES.length];
|
|
90
|
-
const description =
|
|
91
|
-
MOCK_LISTING_DESCRIPTIONS[index % MOCK_LISTING_DESCRIPTIONS.length];
|
|
92
|
-
const image = MOCK_LISTING_IMAGES[index % MOCK_LISTING_IMAGES.length];
|
|
93
|
-
const priceBase = 300 + (index % 10) * 75;
|
|
94
|
-
const priceBrandModifier = (index % 3) * 50;
|
|
95
|
-
const price = priceBase + priceBrandModifier; // always less than 10000
|
|
96
|
-
const isAvailable = index % 7 !== 0;
|
|
97
|
-
const isBestSeller = index % 6 === 0;
|
|
98
|
-
const isTopRated = index % 5 === 0;
|
|
99
|
-
const reviews = getListingReviews(index);
|
|
100
|
-
const averageRating = getAverageRating(reviews);
|
|
101
|
-
const createdAt = new Date(
|
|
102
|
-
MOCK_BASE_DATE.getTime() - index * 24 * 60 * 60 * 1000,
|
|
103
|
-
);
|
|
104
|
-
const updatedAt = createdAt;
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
id,
|
|
108
|
-
title,
|
|
109
|
-
description,
|
|
110
|
-
image,
|
|
111
|
-
price,
|
|
112
|
-
categories: getListingCategories(index),
|
|
113
|
-
isAvailable,
|
|
114
|
-
isBestSeller,
|
|
115
|
-
isTopRated,
|
|
116
|
-
averageRating,
|
|
117
|
-
reviews,
|
|
118
|
-
brand,
|
|
119
|
-
color,
|
|
120
|
-
createdAt,
|
|
121
|
-
updatedAt,
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
export const getListings = async ({
|
|
127
|
-
page = 1,
|
|
128
|
-
pageSize = 12,
|
|
129
|
-
}: {
|
|
130
|
-
page?: number;
|
|
131
|
-
pageSize?: number;
|
|
132
|
-
}): Promise<{ items: MockItemType[] }> => {
|
|
133
|
-
const items = MOCK_LISTINGS.slice((page - 1) * pageSize, page * pageSize);
|
|
134
|
-
|
|
135
|
-
await new Promise((resolve) => {
|
|
136
|
-
setTimeout(resolve, 2000);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
items,
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const getListing = async (): Promise<{
|
|
145
|
-
item?: MockItemType | null | undefined;
|
|
146
|
-
}> => {
|
|
147
|
-
await new Promise((resolve) => {
|
|
148
|
-
setTimeout(resolve, 2000);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
item: MOCK_LISTINGS[0],
|
|
153
|
-
};
|
|
154
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./uploader";
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
};
|
package/src/mocks/types.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { ItemChipProps } from "@/types";
|
|
2
|
-
|
|
3
|
-
export type MockItemCategory =
|
|
4
|
-
| "laptops"
|
|
5
|
-
| "desktops"
|
|
6
|
-
| "monitors"
|
|
7
|
-
| "keyboards"
|
|
8
|
-
| "mice"
|
|
9
|
-
| "headsets"
|
|
10
|
-
| "printers"
|
|
11
|
-
| "storage"
|
|
12
|
-
| "components"
|
|
13
|
-
| "networking";
|
|
14
|
-
|
|
15
|
-
export type MockColor =
|
|
16
|
-
| "red"
|
|
17
|
-
| "blue"
|
|
18
|
-
| "green"
|
|
19
|
-
| "yellow"
|
|
20
|
-
| "purple"
|
|
21
|
-
| "orange"
|
|
22
|
-
| "pink"
|
|
23
|
-
| "brown"
|
|
24
|
-
| "gray"
|
|
25
|
-
| "black"
|
|
26
|
-
| "white";
|
|
27
|
-
|
|
28
|
-
export type MockItemBrand =
|
|
29
|
-
| "Apple"
|
|
30
|
-
| "Dell"
|
|
31
|
-
| "HP"
|
|
32
|
-
| "Lenovo"
|
|
33
|
-
| "Asus"
|
|
34
|
-
| "Acer"
|
|
35
|
-
| "MSI"
|
|
36
|
-
| "Razer"
|
|
37
|
-
| "Samsung"
|
|
38
|
-
| "Microsoft";
|
|
39
|
-
|
|
40
|
-
export type MockReview = {
|
|
41
|
-
id: number; // unique and random UUID
|
|
42
|
-
rating: number; // from 1 to 5 (float) rounded to 1 decimal place
|
|
43
|
-
comment: string; // less than 50 characters
|
|
44
|
-
author: string; // less than 100 characters
|
|
45
|
-
createdAt: Date; // current date
|
|
46
|
-
updatedAt: Date; // current date
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type MockItemType = {
|
|
50
|
-
id: number; // unique and random UUID
|
|
51
|
-
title: string; // less than 100 characters
|
|
52
|
-
description: string; // less than 1000 characters
|
|
53
|
-
image: string; // url (actual image url)
|
|
54
|
-
price: number; // less than 10000
|
|
55
|
-
categories: ItemChipProps[]; // from 1 to 5 categories
|
|
56
|
-
isAvailable: boolean;
|
|
57
|
-
isBestSeller: boolean;
|
|
58
|
-
averageRating: number; // from 1 to 5 (float) rounded to 1 decimal place
|
|
59
|
-
reviews: MockReview[]; // from 0 to 100
|
|
60
|
-
brand: MockItemBrand;
|
|
61
|
-
color: MockColor;
|
|
62
|
-
createdAt: Date; // current date
|
|
63
|
-
updatedAt: Date; // current date
|
|
64
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Scaffold } from "@/components";
|
|
2
|
-
import { defaultEmperorUIConfig } from "@/constants";
|
|
3
|
-
import { EmperorUIContext } from "@/context";
|
|
4
|
-
import { LangKey, Locale } from "@/i18n";
|
|
5
|
-
import type {
|
|
6
|
-
ConfigContextState,
|
|
7
|
-
ConfigProviderProps,
|
|
8
|
-
EmperorUIConfig,
|
|
9
|
-
} from "@/types";
|
|
10
|
-
import { mergeLocales } from "@/utils";
|
|
11
|
-
import { useMemo } from "react";
|
|
12
|
-
|
|
13
|
-
export function ConfigProvider({
|
|
14
|
-
children,
|
|
15
|
-
config = defaultEmperorUIConfig,
|
|
16
|
-
}: ConfigProviderProps) {
|
|
17
|
-
const emperorUIProviderValue: ConfigContextState = useMemo(() => {
|
|
18
|
-
const mergedConfig: EmperorUIConfig = {
|
|
19
|
-
layout: {
|
|
20
|
-
...defaultEmperorUIConfig?.layout,
|
|
21
|
-
...config?.layout,
|
|
22
|
-
},
|
|
23
|
-
interLocalization: {
|
|
24
|
-
...defaultEmperorUIConfig?.interLocalization,
|
|
25
|
-
...config?.interLocalization,
|
|
26
|
-
locales: {
|
|
27
|
-
[LangKey.ENGLISH]: mergeLocales({
|
|
28
|
-
defaultLocales: defaultEmperorUIConfig?.interLocalization
|
|
29
|
-
?.locales?.[LangKey.ENGLISH] as Locale,
|
|
30
|
-
configLocales: config?.interLocalization?.locales?.[
|
|
31
|
-
LangKey.ENGLISH
|
|
32
|
-
] as Locale,
|
|
33
|
-
}),
|
|
34
|
-
[LangKey.ARABIC]: mergeLocales({
|
|
35
|
-
defaultLocales: defaultEmperorUIConfig?.interLocalization
|
|
36
|
-
?.locales?.[LangKey.ARABIC] as Locale,
|
|
37
|
-
configLocales: config?.interLocalization?.locales?.[
|
|
38
|
-
LangKey.ARABIC
|
|
39
|
-
] as Locale,
|
|
40
|
-
}),
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
theme: {
|
|
44
|
-
...defaultEmperorUIConfig?.theme,
|
|
45
|
-
...config?.theme,
|
|
46
|
-
components: {
|
|
47
|
-
...defaultEmperorUIConfig?.theme?.components,
|
|
48
|
-
...config?.theme?.components,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
config: mergedConfig,
|
|
55
|
-
};
|
|
56
|
-
}, [config]);
|
|
57
|
-
|
|
58
|
-
const withScaffold = config.layout?.withScaffold ?? true;
|
|
59
|
-
|
|
60
|
-
if (withScaffold)
|
|
61
|
-
return (
|
|
62
|
-
<EmperorUIContext.Provider value={emperorUIProviderValue}>
|
|
63
|
-
<Scaffold>{children}</Scaffold>
|
|
64
|
-
</EmperorUIContext.Provider>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<EmperorUIContext.Provider value={emperorUIProviderValue}>
|
|
69
|
-
{children}
|
|
70
|
-
</EmperorUIContext.Provider>
|
|
71
|
-
);
|
|
72
|
-
}
|