@js-empire/emperor-ui 1.3.11 → 1.3.12
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/.cursor/rules/code-conventions.mdc +50 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc +10 -0
- package/.storybook/main.ts +24 -0
- package/.storybook/preview.ts +19 -0
- package/.storybook/vitest.setup.ts +7 -0
- package/.vscode/extensions.json +1 -0
- package/dist/emperor-ui.js +158 -4236
- package/dist/emperor-ui.umd.cjs +52 -1
- package/dist/icons/emperor-ui-logo.ico +0 -0
- package/dist/images/avatar-female.jpg +0 -0
- package/dist/images/avatar-male.jpg +0 -0
- package/dist/images/emperor-ui-logo.png +0 -0
- package/dist/index-4OxAyqvp.js +5 -0
- package/dist/index-CHrqdTZ9.js +290 -0
- package/dist/index-DXWNWGH3.js +57021 -0
- package/dist/index.d.ts +1357 -0
- package/dist/src-UW24ZMRV-DQtCWsbT.js +5 -0
- package/eslint.config.js +34 -0
- package/index.html +13 -0
- package/package.json +10 -57
- 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 +26 -0
- package/src/animations/floating.ts +12 -0
- package/src/animations/index.ts +2 -0
- package/src/components/atoms/brand/brand.stories.tsx +29 -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/color-picker/color-picker.tsx +12 -0
- package/src/components/atoms/color-picker/free-color-picker.tsx +58 -0
- package/src/components/atoms/color-picker/index.ts +3 -0
- package/src/components/atoms/color-picker/preset-color-picker.tsx +66 -0
- package/src/components/atoms/color-picker/stories/color-picker.stories.tsx +63 -0
- package/src/components/atoms/column/column.stories.tsx +37 -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 +37 -0
- package/src/components/atoms/container/container.tsx +28 -0
- package/src/components/atoms/container/index.ts +1 -0
- package/src/components/atoms/copy-button/copy-button.tsx +73 -0
- package/src/components/atoms/copy-button/index.ts +1 -0
- package/src/components/atoms/copy-button/stories/copy-button.stories.tsx +21 -0
- package/src/components/atoms/field/field.tsx +81 -0
- package/src/components/atoms/field/index.ts +3 -0
- package/src/components/atoms/field/styles/classes.ts +9 -0
- package/src/components/atoms/field/styles/index.ts +1 -0
- package/src/components/atoms/field/units/autocomplete-field.tsx +49 -0
- package/src/components/atoms/field/units/checkbox-field.tsx +35 -0
- package/src/components/atoms/field/units/index.ts +7 -0
- package/src/components/atoms/field/units/input-field.tsx +35 -0
- package/src/components/atoms/field/units/radio-field.tsx +43 -0
- package/src/components/atoms/field/units/select-field.tsx +50 -0
- package/src/components/atoms/field/units/switch-field.tsx +35 -0
- package/src/components/atoms/field/units/textarea-field.tsx +37 -0
- package/src/components/atoms/filter/filter.tsx +93 -0
- package/src/components/atoms/filter/index.ts +3 -0
- package/src/components/atoms/filter/stories/filter.stories.tsx +238 -0
- package/src/components/atoms/filter/styles/classes.ts +20 -0
- package/src/components/atoms/filter/styles/index.ts +1 -0
- package/src/components/atoms/filter/units/autocomplete-filter.tsx +66 -0
- package/src/components/atoms/filter/units/checkbox-filter.tsx +42 -0
- package/src/components/atoms/filter/units/checkbox-group-filter.tsx +68 -0
- package/src/components/atoms/filter/units/date-filter.tsx +46 -0
- package/src/components/atoms/filter/units/index.ts +9 -0
- package/src/components/atoms/filter/units/numeric-filter.tsx +41 -0
- package/src/components/atoms/filter/units/range-filter.tsx +65 -0
- package/src/components/atoms/filter/units/search-filter.tsx +53 -0
- package/src/components/atoms/filter/units/select-filter.tsx +57 -0
- package/src/components/atoms/filter/units/switch-filter.tsx +35 -0
- package/src/components/atoms/index.ts +11 -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 +25 -0
- package/src/components/atoms/row/index.ts +1 -0
- package/src/components/atoms/row/row.stories.tsx +37 -0
- package/src/components/atoms/row/row.tsx +26 -0
- package/src/components/atoms/theme-switch/index.ts +1 -0
- package/src/components/atoms/theme-switch/styles/classes.ts +16 -0
- package/src/components/atoms/theme-switch/styles/index.ts +1 -0
- package/src/components/atoms/theme-switch/theme-switch.stories.tsx +26 -0
- package/src/components/atoms/theme-switch/theme-switch.tsx +54 -0
- package/src/components/atoms/uploader/components/avatar-label.tsx +102 -0
- package/src/components/atoms/uploader/components/index.ts +8 -0
- package/src/components/atoms/uploader/components/upload-file-error-box.tsx +40 -0
- package/src/components/atoms/uploader/components/upload-file-input.tsx +36 -0
- package/src/components/atoms/uploader/components/upload-file-label.tsx +92 -0
- package/src/components/atoms/uploader/components/upload-file-listing.tsx +64 -0
- package/src/components/atoms/uploader/components/uploader-title.tsx +21 -0
- package/src/components/atoms/uploader/components/uploader.tsx +89 -0
- package/src/components/atoms/uploader/components/view-image-modal.tsx +41 -0
- package/src/components/atoms/uploader/index.ts +1 -0
- package/src/components/atoms/uploader/stories/uploader.stories.tsx +202 -0
- package/src/components/index.ts +4 -0
- package/src/components/molecules/index.ts +4 -0
- package/src/components/molecules/item-card/components/actions/index.ts +3 -0
- package/src/components/molecules/item-card/components/actions/item-actions-buttons.tsx +43 -0
- package/src/components/molecules/item-card/components/actions/item-actions-dropdown.tsx +57 -0
- package/src/components/molecules/item-card/components/actions/item-actions-overlay.tsx +50 -0
- package/src/components/molecules/item-card/components/additions/index.ts +2 -0
- package/src/components/molecules/item-card/components/additions/item-banner.tsx +22 -0
- package/src/components/molecules/item-card/components/additions/loading-item.tsx +88 -0
- package/src/components/molecules/item-card/components/card/index.ts +4 -0
- package/src/components/molecules/item-card/components/card/item-card-body.tsx +74 -0
- package/src/components/molecules/item-card/components/card/item-card-footer.tsx +79 -0
- package/src/components/molecules/item-card/components/card/item-card-header.tsx +69 -0
- package/src/components/molecules/item-card/components/card/item-card.tsx +123 -0
- package/src/components/molecules/item-card/components/index.ts +3 -0
- package/src/components/molecules/item-card/index.ts +2 -0
- package/src/components/molecules/item-card/stories/item-card.stories.tsx +218 -0
- package/src/components/molecules/item-card/styles/classes.ts +141 -0
- package/src/components/molecules/item-card/styles/index.ts +1 -0
- package/src/components/molecules/nav-bar/index.ts +3 -0
- package/src/components/molecules/nav-bar/nav-bar-item.tsx +64 -0
- package/src/components/molecules/nav-bar/nav-bar.tsx +57 -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 +85 -0
- package/src/components/molecules/nav-bar/sub-items-box.tsx +58 -0
- package/src/components/molecules/scaffold/index.ts +2 -0
- package/src/components/molecules/scaffold/scaffold.stories.tsx +21 -0
- package/src/components/molecules/scaffold/scaffold.tsx +23 -0
- package/src/components/molecules/scaffold/styles/index.ts +1 -0
- package/src/components/molecules/scaffold/styles/scaffold-classes.ts +10 -0
- package/src/components/molecules/side-bar/compact-side-bar.tsx +77 -0
- package/src/components/molecules/side-bar/index.ts +1 -0
- package/src/components/molecules/side-bar/side-bar-drawer.tsx +113 -0
- package/src/components/molecules/side-bar/side-bar.stories.tsx +111 -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/deletion-confirmor/deletion-confirmor.tsx +110 -0
- package/src/components/organisms/deletion-confirmor/index.ts +3 -0
- package/src/components/organisms/deletion-confirmor/stories/components.tsx +25 -0
- package/src/components/organisms/deletion-confirmor/stories/deletion-confirmor.stories.tsx +78 -0
- package/src/components/organisms/deletion-confirmor/styles/classes.ts +28 -0
- package/src/components/organisms/deletion-confirmor/styles/index.ts +2 -0
- package/src/components/organisms/deletion-confirmor/styles/styles.ts +4 -0
- package/src/components/organisms/footer/copy-rights-box.tsx +27 -0
- package/src/components/organisms/footer/footer.tsx +75 -0
- package/src/components/organisms/footer/index.ts +5 -0
- package/src/components/organisms/footer/policies-box.tsx +27 -0
- package/src/components/organisms/footer/quick-links-box.tsx +46 -0
- package/src/components/organisms/footer/social-links-box.tsx +33 -0
- package/src/components/organisms/footer/stories/footer.stories.tsx +61 -0
- package/src/components/organisms/footer/styles/classes.ts +71 -0
- package/src/components/organisms/footer/styles/index.ts +2 -0
- package/src/components/organisms/footer/styles/styles.ts +6 -0
- package/src/components/organisms/form-builder/form-builder.stories.tsx +144 -0
- package/src/components/organisms/form-builder/form-builder.tsx +75 -0
- package/src/components/organisms/form-builder/index.ts +1 -0
- package/src/components/organisms/header/header.tsx +87 -0
- package/src/components/organisms/header/index.ts +1 -0
- package/src/components/organisms/header/segmented-header-content.tsx +29 -0
- package/src/components/organisms/header/stories/header.stories.tsx +144 -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 +6 -0
- package/src/components/organisms/item-details/index.ts +1 -0
- package/src/components/organisms/item-details/item-details.tsx +6 -0
- package/src/components/organisms/listings/empty-listings.tsx +80 -0
- package/src/components/organisms/listings/index.ts +3 -0
- package/src/components/organisms/listings/listings.tsx +96 -0
- package/src/components/organisms/listings/stories/grid-listings.stories.tsx +153 -0
- package/src/components/organisms/listings/stories/list-listings.stories.tsx +171 -0
- package/src/components/organisms/listings/styles/classes.ts +49 -0
- package/src/components/organisms/listings/styles/index.ts +2 -0
- package/src/components/organisms/listings/styles/styles.ts +6 -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/animations.ts +14 -0
- package/src/constants/card.tsx +42 -0
- package/src/constants/defaults.ts +59 -0
- package/src/constants/fake.ts +5 -0
- package/src/constants/footer.tsx +157 -0
- package/src/constants/index.ts +6 -0
- package/src/constants/uploader.ts +33 -0
- package/src/context/emperor-ui-context.ts +6 -0
- package/src/context/form-builder-context.tsx +8 -0
- package/src/context/index.ts +4 -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 +5 -0
- package/src/enums/preserved-keys.ts +3 -0
- package/src/examples/index.ts +1 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/use-emperor-ui.ts +12 -0
- package/src/hooks/use-filters.ts +20 -0
- package/src/hooks/use-form-builder-context.ts +16 -0
- package/src/hooks/use-navigation.ts +12 -0
- package/src/hooks/use-search-params-handler.tsx +186 -0
- package/src/hooks/use-uploader-context.ts +14 -0
- package/src/hooks/use-uploader.tsx +164 -0
- package/src/hooks/use-window-size.tsx +53 -0
- package/src/i18n/configs/i18n.ts +7 -0
- package/src/i18n/configs/index.ts +1 -0
- package/src/i18n/constants/index.ts +1 -0
- package/src/i18n/constants/locales.ts +4 -0
- package/src/i18n/index.ts +5 -0
- package/src/i18n/locales/ar.ts +15 -0
- package/src/i18n/locales/atoms/ar.ts +18 -0
- package/src/i18n/locales/atoms/en.ts +18 -0
- package/src/i18n/locales/atoms/index.ts +2 -0
- package/src/i18n/locales/common/ar.ts +1 -0
- package/src/i18n/locales/common/en.ts +1 -0
- package/src/i18n/locales/common/index.ts +2 -0
- package/src/i18n/locales/en.ts +15 -0
- package/src/i18n/locales/index.ts +4 -0
- package/src/i18n/locales/molecules/ar.ts +1 -0
- package/src/i18n/locales/molecules/en.ts +1 -0
- package/src/i18n/locales/molecules/index.ts +2 -0
- package/src/i18n/locales/organisms/ar.ts +11 -0
- package/src/i18n/locales/organisms/en.ts +11 -0
- package/src/i18n/locales/organisms/index.ts +2 -0
- package/src/i18n/locales/templates/ar.ts +1 -0
- package/src/i18n/locales/templates/en.ts +1 -0
- package/src/i18n/locales/templates/index.ts +2 -0
- package/src/i18n/locales/toasts/ar.ts +1 -0
- package/src/i18n/locales/toasts/en.ts +1 -0
- package/src/i18n/locales/toasts/index.ts +2 -0
- package/src/i18n/types/index.ts +2 -0
- package/{dist/src/i18n/types/locale.d.ts → src/i18n/types/locale.ts} +3 -1
- package/{dist/src/i18n/types/toasts.d.ts → src/i18n/types/toasts.ts} +2 -1
- package/src/i18n/utils/get-locales.ts +4 -0
- package/src/i18n/utils/index.ts +2 -0
- package/src/i18n/utils/localize.ts +15 -0
- package/src/index.ts +14 -0
- package/src/mocks/constants.ts +103 -0
- package/src/mocks/deletion-confirmor.ts +16 -0
- package/src/mocks/header.tsx +118 -0
- package/src/mocks/index.ts +6 -0
- package/src/mocks/listings.tsx +154 -0
- package/src/mocks/locales/index.ts +1 -0
- package/src/mocks/locales/uploader.ts +33 -0
- package/src/mocks/types.ts +64 -0
- package/src/providers/config-provider.tsx +72 -0
- package/src/providers/emperor-ui-provider.tsx +35 -0
- package/src/providers/form-builder-provider-context.tsx +18 -0
- package/src/providers/index.ts +6 -0
- package/src/providers/navigation-provider.tsx +42 -0
- package/src/providers/theme-provider.tsx +16 -0
- package/src/providers/uploader-provider.tsx +53 -0
- package/src/styles/globals.css +38 -0
- package/src/styles/hero.ts +3 -0
- package/src/styles/index.css +18 -0
- package/src/types/components/atoms/brand.ts +13 -0
- package/src/types/components/atoms/color-picker/color-picker.ts +21 -0
- package/src/types/components/atoms/color-picker/index.ts +1 -0
- package/src/types/components/atoms/column.ts +3 -0
- package/{dist/src/types/components/atoms/container.d.ts → src/types/components/atoms/container.ts} +2 -1
- package/src/types/components/atoms/field/field.ts +61 -0
- package/src/types/components/atoms/field/index.ts +1 -0
- package/src/types/components/atoms/filter/filter.ts +52 -0
- package/src/types/components/atoms/filter/index.ts +2 -0
- package/{dist/src/types/components/atoms/filter/select-filter.d.ts → src/types/components/atoms/filter/select-filter.ts} +4 -3
- package/src/types/components/atoms/index.ts +9 -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 +103 -0
- package/src/types/components/index.ts +4 -0
- package/src/types/components/molecules/footer/footer.ts +68 -0
- package/src/types/components/molecules/footer/index.ts +1 -0
- package/src/types/components/molecules/header/header.ts +51 -0
- package/src/types/components/molecules/header/index.ts +1 -0
- package/src/types/components/molecules/index.ts +9 -0
- package/src/types/components/molecules/item-card/index.ts +1 -0
- package/src/types/components/molecules/item-card/item-card.ts +69 -0
- package/src/types/components/molecules/item-details/index.ts +1 -0
- package/src/types/components/molecules/item-details/item-details.ts +9 -0
- package/src/types/components/molecules/listings/index.ts +1 -0
- package/src/types/components/molecules/listings/listings.ts +29 -0
- package/src/types/components/molecules/nav-bar/index.ts +1 -0
- package/src/types/components/molecules/nav-bar/nav-bar.ts +66 -0
- package/src/types/components/molecules/scaffold/index.ts +1 -0
- package/src/types/components/molecules/scaffold/scaffold.ts +9 -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/molecules/theme-switch/index.ts +1 -0
- package/src/types/components/molecules/theme-switch/theme-switch.ts +9 -0
- package/src/types/components/organisms/deletion-confirmor/deletion-confirmor.ts +22 -0
- package/src/types/components/organisms/deletion-confirmor/index.ts +1 -0
- package/src/types/components/organisms/filters/filters.ts +11 -0
- package/src/types/components/organisms/filters/index.ts +1 -0
- package/src/types/components/organisms/form-builder/context.ts +6 -0
- package/src/types/components/organisms/form-builder/form-builder.ts +39 -0
- package/src/types/components/organisms/form-builder/index.ts +2 -0
- package/src/types/components/organisms/index.ts +3 -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 +24 -0
- package/src/types/context/index.ts +4 -0
- package/src/types/context/localization.ts +24 -0
- package/src/types/context/navigation.ts +17 -0
- package/src/types/context/theme.ts +33 -0
- package/src/types/index.ts +3 -0
- package/{dist/src/types/shared/components.d.ts → src/types/shared/components.ts} +9 -6
- package/src/types/shared/index.ts +1 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/compress-images.ts +36 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/locales.ts +54 -0
- package/src/utils/storybook.tsx +15 -0
- package/src/utils/uploader.ts +170 -0
- package/tsconfig.app.json +37 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +25 -0
- package/vite.config.ts +44 -0
- package/vitest.shims.d.ts +1 -0
- package/dist/src/animations/blink.d.ts +0 -7
- package/dist/src/animations/floating.d.ts +0 -2
- package/dist/src/animations/index.d.ts +0 -2
- package/dist/src/components/atoms/brand/brand.d.ts +0 -14
- package/dist/src/components/atoms/brand/index.d.ts +0 -1
- package/dist/src/components/atoms/brand/styles/classes.d.ts +0 -3
- package/dist/src/components/atoms/brand/styles/index.d.ts +0 -2
- package/dist/src/components/atoms/brand/styles/styles.d.ts +0 -1
- package/dist/src/components/atoms/color-picker/color-picker.d.ts +0 -2
- package/dist/src/components/atoms/color-picker/free-color-picker.d.ts +0 -2
- package/dist/src/components/atoms/color-picker/index.d.ts +0 -3
- package/dist/src/components/atoms/color-picker/preset-color-picker.d.ts +0 -2
- package/dist/src/components/atoms/column/column.d.ts +0 -2
- package/dist/src/components/atoms/column/index.d.ts +0 -1
- package/dist/src/components/atoms/container/container.d.ts +0 -2
- package/dist/src/components/atoms/container/index.d.ts +0 -1
- package/dist/src/components/atoms/copy-button/copy-button.d.ts +0 -3
- package/dist/src/components/atoms/copy-button/index.d.ts +0 -1
- package/dist/src/components/atoms/field/field.d.ts +0 -3
- package/dist/src/components/atoms/field/index.d.ts +0 -3
- package/dist/src/components/atoms/field/styles/classes.d.ts +0 -3
- package/dist/src/components/atoms/field/styles/index.d.ts +0 -1
- package/dist/src/components/atoms/field/units/autocomplete-field.d.ts +0 -3
- package/dist/src/components/atoms/field/units/checkbox-field.d.ts +0 -3
- package/dist/src/components/atoms/field/units/index.d.ts +0 -7
- package/dist/src/components/atoms/field/units/input-field.d.ts +0 -3
- package/dist/src/components/atoms/field/units/radio-field.d.ts +0 -3
- package/dist/src/components/atoms/field/units/select-field.d.ts +0 -3
- package/dist/src/components/atoms/field/units/switch-field.d.ts +0 -3
- package/dist/src/components/atoms/field/units/textarea-field.d.ts +0 -3
- package/dist/src/components/atoms/filter/filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/index.d.ts +0 -3
- package/dist/src/components/atoms/filter/styles/classes.d.ts +0 -3
- package/dist/src/components/atoms/filter/styles/index.d.ts +0 -1
- package/dist/src/components/atoms/filter/units/autocomplete-filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/units/checkbox-filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/units/checkbox-group-filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/units/date-filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/units/index.d.ts +0 -9
- package/dist/src/components/atoms/filter/units/numeric-filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/units/range-filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/units/search-filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/units/select-filter.d.ts +0 -2
- package/dist/src/components/atoms/filter/units/switch-filter.d.ts +0 -2
- package/dist/src/components/atoms/index.d.ts +0 -11
- package/dist/src/components/atoms/portal/index.d.ts +0 -1
- package/dist/src/components/atoms/portal/portal.d.ts +0 -2
- package/dist/src/components/atoms/row/index.d.ts +0 -1
- package/dist/src/components/atoms/row/row.d.ts +0 -2
- package/dist/src/components/atoms/theme-switch/index.d.ts +0 -1
- package/dist/src/components/atoms/theme-switch/styles/classes.d.ts +0 -3
- package/dist/src/components/atoms/theme-switch/styles/index.d.ts +0 -1
- package/dist/src/components/atoms/theme-switch/theme-switch.d.ts +0 -2
- package/dist/src/components/atoms/uploader/components/avatar-label.d.ts +0 -1
- package/dist/src/components/atoms/uploader/components/index.d.ts +0 -8
- package/dist/src/components/atoms/uploader/components/upload-file-error-box.d.ts +0 -1
- package/dist/src/components/atoms/uploader/components/upload-file-input.d.ts +0 -1
- package/dist/src/components/atoms/uploader/components/upload-file-label.d.ts +0 -1
- package/dist/src/components/atoms/uploader/components/upload-file-listing.d.ts +0 -1
- package/dist/src/components/atoms/uploader/components/uploader-title.d.ts +0 -2
- package/dist/src/components/atoms/uploader/components/uploader.d.ts +0 -19
- package/dist/src/components/atoms/uploader/components/view-image-modal.d.ts +0 -1
- package/dist/src/components/atoms/uploader/index.d.ts +0 -1
- package/dist/src/components/index.d.ts +0 -4
- package/dist/src/components/molecules/index.d.ts +0 -4
- package/dist/src/components/molecules/item-card/components/actions/index.d.ts +0 -3
- package/dist/src/components/molecules/item-card/components/actions/item-actions-buttons.d.ts +0 -6
- package/dist/src/components/molecules/item-card/components/actions/item-actions-dropdown.d.ts +0 -2
- package/dist/src/components/molecules/item-card/components/actions/item-actions-overlay.d.ts +0 -4
- package/dist/src/components/molecules/item-card/components/additions/index.d.ts +0 -2
- package/dist/src/components/molecules/item-card/components/additions/item-banner.d.ts +0 -2
- package/dist/src/components/molecules/item-card/components/additions/loading-item.d.ts +0 -2
- package/dist/src/components/molecules/item-card/components/card/index.d.ts +0 -4
- package/dist/src/components/molecules/item-card/components/card/item-card-body.d.ts +0 -2
- package/dist/src/components/molecules/item-card/components/card/item-card-footer.d.ts +0 -2
- package/dist/src/components/molecules/item-card/components/card/item-card-header.d.ts +0 -2
- package/dist/src/components/molecules/item-card/components/card/item-card.d.ts +0 -2
- package/dist/src/components/molecules/item-card/components/index.d.ts +0 -3
- package/dist/src/components/molecules/item-card/index.d.ts +0 -2
- package/dist/src/components/molecules/item-card/styles/classes.d.ts +0 -33
- package/dist/src/components/molecules/item-card/styles/index.d.ts +0 -1
- package/dist/src/components/molecules/nav-bar/index.d.ts +0 -3
- package/dist/src/components/molecules/nav-bar/nav-bar-item.d.ts +0 -6
- package/dist/src/components/molecules/nav-bar/nav-bar.d.ts +0 -13
- package/dist/src/components/molecules/nav-bar/styles/classes.d.ts +0 -11
- package/dist/src/components/molecules/nav-bar/styles/index.d.ts +0 -2
- package/dist/src/components/molecules/nav-bar/styles/styles.d.ts +0 -5
- package/dist/src/components/molecules/nav-bar/sub-items-box.d.ts +0 -2
- package/dist/src/components/molecules/scaffold/index.d.ts +0 -2
- package/dist/src/components/molecules/scaffold/scaffold.d.ts +0 -3
- package/dist/src/components/molecules/scaffold/styles/index.d.ts +0 -1
- package/dist/src/components/molecules/scaffold/styles/scaffold-classes.d.ts +0 -1
- package/dist/src/components/molecules/side-bar/compact-side-bar.d.ts +0 -2
- package/dist/src/components/molecules/side-bar/index.d.ts +0 -1
- package/dist/src/components/molecules/side-bar/side-bar-drawer.d.ts +0 -2
- package/dist/src/components/molecules/side-bar/side-bar.d.ts +0 -15
- package/dist/src/components/molecules/side-bar/styles/classes.d.ts +0 -6
- package/dist/src/components/molecules/side-bar/styles/index.d.ts +0 -2
- package/dist/src/components/molecules/side-bar/styles/styles.d.ts +0 -3
- package/dist/src/components/organisms/deletion-confirmor/deletion-confirmor.d.ts +0 -2
- package/dist/src/components/organisms/deletion-confirmor/index.d.ts +0 -3
- package/dist/src/components/organisms/deletion-confirmor/stories/components.d.ts +0 -2
- package/dist/src/components/organisms/deletion-confirmor/styles/classes.d.ts +0 -4
- package/dist/src/components/organisms/deletion-confirmor/styles/index.d.ts +0 -2
- package/dist/src/components/organisms/deletion-confirmor/styles/styles.d.ts +0 -2
- package/dist/src/components/organisms/footer/copy-rights-box.d.ts +0 -2
- package/dist/src/components/organisms/footer/footer.d.ts +0 -11
- package/dist/src/components/organisms/footer/index.d.ts +0 -5
- package/dist/src/components/organisms/footer/policies-box.d.ts +0 -2
- package/dist/src/components/organisms/footer/quick-links-box.d.ts +0 -2
- package/dist/src/components/organisms/footer/social-links-box.d.ts +0 -2
- package/dist/src/components/organisms/footer/styles/classes.d.ts +0 -9
- package/dist/src/components/organisms/footer/styles/index.d.ts +0 -2
- package/dist/src/components/organisms/footer/styles/styles.d.ts +0 -2
- package/dist/src/components/organisms/form-builder/form-builder.d.ts +0 -3
- package/dist/src/components/organisms/form-builder/index.d.ts +0 -1
- package/dist/src/components/organisms/header/header.d.ts +0 -8
- package/dist/src/components/organisms/header/index.d.ts +0 -1
- package/dist/src/components/organisms/header/segmented-header-content.d.ts +0 -2
- package/dist/src/components/organisms/header/styles/classes.d.ts +0 -3
- package/dist/src/components/organisms/header/styles/index.d.ts +0 -2
- package/dist/src/components/organisms/header/styles/styles.d.ts +0 -6
- package/dist/src/components/organisms/index.d.ts +0 -6
- package/dist/src/components/organisms/item-details/index.d.ts +0 -1
- package/dist/src/components/organisms/item-details/item-details.d.ts +0 -2
- package/dist/src/components/organisms/listings/empty-listings.d.ts +0 -9
- package/dist/src/components/organisms/listings/index.d.ts +0 -3
- package/dist/src/components/organisms/listings/listings.d.ts +0 -2
- package/dist/src/components/organisms/listings/styles/classes.d.ts +0 -10
- package/dist/src/components/organisms/listings/styles/index.d.ts +0 -2
- package/dist/src/components/organisms/listings/styles/styles.d.ts +0 -2
- package/dist/src/components/templates/index.d.ts +0 -1
- package/dist/src/components/templates/landing-page/index.d.ts +0 -1
- package/dist/src/components/templates/landing-page/landing-page.d.ts +0 -10
- package/dist/src/components/templates/landing-page/styles/classes.d.ts +0 -3
- package/dist/src/components/templates/landing-page/styles/index.d.ts +0 -1
- package/dist/src/constants/animations.d.ts +0 -5
- package/dist/src/constants/card.d.ts +0 -3
- package/dist/src/constants/defaults.d.ts +0 -2
- package/dist/src/constants/fake.d.ts +0 -2
- package/dist/src/constants/footer.d.ts +0 -6
- package/dist/src/constants/index.d.ts +0 -6
- package/dist/src/constants/uploader.d.ts +0 -8
- package/dist/src/context/emperor-ui-context.d.ts +0 -2
- package/dist/src/context/form-builder-context.d.ts +0 -3
- package/dist/src/context/index.d.ts +0 -4
- package/dist/src/context/navigation-context.d.ts +0 -2
- package/dist/src/context/uploader-context.d.ts +0 -2
- package/dist/src/enums/index.d.ts +0 -2
- package/dist/src/enums/placeholders.d.ts +0 -5
- package/dist/src/enums/preserved-keys.d.ts +0 -3
- package/dist/src/examples/index.d.ts +0 -1
- package/dist/src/hooks/index.d.ts +0 -8
- package/dist/src/hooks/use-emperor-ui.d.ts +0 -1
- package/dist/src/hooks/use-filters.d.ts +0 -4
- package/dist/src/hooks/use-form-builder-context.d.ts +0 -3
- package/dist/src/hooks/use-navigation.d.ts +0 -1
- package/dist/src/hooks/use-search-params-handler.d.ts +0 -17
- package/dist/src/hooks/use-uploader-context.d.ts +0 -1
- package/dist/src/hooks/use-uploader.d.ts +0 -2
- package/dist/src/hooks/use-window-size.d.ts +0 -7
- package/dist/src/i18n/configs/i18n.d.ts +0 -6
- package/dist/src/i18n/configs/index.d.ts +0 -1
- package/dist/src/i18n/constants/index.d.ts +0 -1
- package/dist/src/i18n/constants/locales.d.ts +0 -4
- package/dist/src/i18n/index.d.ts +0 -5
- package/dist/src/i18n/locales/ar.d.ts +0 -32
- package/dist/src/i18n/locales/atoms/ar.d.ts +0 -16
- package/dist/src/i18n/locales/atoms/en.d.ts +0 -16
- package/dist/src/i18n/locales/atoms/index.d.ts +0 -2
- package/dist/src/i18n/locales/common/ar.d.ts +0 -1
- package/dist/src/i18n/locales/common/en.d.ts +0 -1
- package/dist/src/i18n/locales/common/index.d.ts +0 -2
- package/dist/src/i18n/locales/en.d.ts +0 -32
- package/dist/src/i18n/locales/index.d.ts +0 -4
- package/dist/src/i18n/locales/molecules/ar.d.ts +0 -1
- package/dist/src/i18n/locales/molecules/en.d.ts +0 -1
- package/dist/src/i18n/locales/molecules/index.d.ts +0 -2
- package/dist/src/i18n/locales/organisms/ar.d.ts +0 -10
- package/dist/src/i18n/locales/organisms/en.d.ts +0 -10
- package/dist/src/i18n/locales/organisms/index.d.ts +0 -2
- package/dist/src/i18n/locales/templates/ar.d.ts +0 -1
- package/dist/src/i18n/locales/templates/en.d.ts +0 -1
- package/dist/src/i18n/locales/templates/index.d.ts +0 -2
- package/dist/src/i18n/locales/toasts/ar.d.ts +0 -1
- package/dist/src/i18n/locales/toasts/en.d.ts +0 -1
- package/dist/src/i18n/locales/toasts/index.d.ts +0 -2
- package/dist/src/i18n/types/index.d.ts +0 -2
- package/dist/src/i18n/utils/get-locales.d.ts +0 -2
- package/dist/src/i18n/utils/index.d.ts +0 -2
- package/dist/src/i18n/utils/localize.d.ts +0 -6
- package/dist/src/index.d.ts +0 -10
- package/dist/src/mocks/constants.d.ts +0 -10
- package/dist/src/mocks/deletion-confirmor.d.ts +0 -7
- package/dist/src/mocks/header.d.ts +0 -5
- package/dist/src/mocks/index.d.ts +0 -6
- package/dist/src/mocks/listings.d.ts +0 -14
- package/dist/src/mocks/locales/index.d.ts +0 -1
- package/dist/src/mocks/locales/uploader.d.ts +0 -2
- package/dist/src/mocks/types.d.ts +0 -28
- package/dist/src/providers/config-provider.d.ts +0 -2
- package/dist/src/providers/emperor-ui-provider.d.ts +0 -4
- package/dist/src/providers/form-builder-provider-context.d.ts +0 -7
- package/dist/src/providers/index.d.ts +0 -6
- package/dist/src/providers/navigation-provider.d.ts +0 -2
- package/dist/src/providers/theme-provider.d.ts +0 -5
- package/dist/src/providers/uploader-provider.d.ts +0 -2
- package/dist/src/styles/hero.d.ts +0 -2
- package/dist/src/types/components/atoms/brand.d.ts +0 -12
- package/dist/src/types/components/atoms/color-picker/color-picker.d.ts +0 -10
- package/dist/src/types/components/atoms/color-picker/index.d.ts +0 -1
- package/dist/src/types/components/atoms/column.d.ts +0 -2
- package/dist/src/types/components/atoms/field/field.d.ts +0 -36
- package/dist/src/types/components/atoms/field/index.d.ts +0 -1
- package/dist/src/types/components/atoms/filter/filter.d.ts +0 -35
- package/dist/src/types/components/atoms/filter/index.d.ts +0 -2
- package/dist/src/types/components/atoms/index.d.ts +0 -9
- package/dist/src/types/components/atoms/portal.d.ts +0 -5
- package/dist/src/types/components/atoms/row.d.ts +0 -2
- package/dist/src/types/components/atoms/uploader.d.ts +0 -84
- package/dist/src/types/components/index.d.ts +0 -4
- package/dist/src/types/components/molecules/footer/footer.d.ts +0 -60
- package/dist/src/types/components/molecules/footer/index.d.ts +0 -1
- package/dist/src/types/components/molecules/header/header.d.ts +0 -38
- package/dist/src/types/components/molecules/header/index.d.ts +0 -1
- package/dist/src/types/components/molecules/index.d.ts +0 -9
- package/dist/src/types/components/molecules/item-card/index.d.ts +0 -1
- package/dist/src/types/components/molecules/item-card/item-card.d.ts +0 -57
- package/dist/src/types/components/molecules/item-details/index.d.ts +0 -1
- package/dist/src/types/components/molecules/item-details/item-details.d.ts +0 -7
- package/dist/src/types/components/molecules/listings/index.d.ts +0 -1
- package/dist/src/types/components/molecules/listings/listings.d.ts +0 -22
- package/dist/src/types/components/molecules/nav-bar/index.d.ts +0 -1
- package/dist/src/types/components/molecules/nav-bar/nav-bar.d.ts +0 -45
- package/dist/src/types/components/molecules/scaffold/index.d.ts +0 -1
- package/dist/src/types/components/molecules/scaffold/scaffold.d.ts +0 -7
- package/dist/src/types/components/molecules/side-bar/index.d.ts +0 -1
- package/dist/src/types/components/molecules/side-bar/side-bar.d.ts +0 -36
- package/dist/src/types/components/molecules/theme-switch/index.d.ts +0 -1
- package/dist/src/types/components/molecules/theme-switch/theme-switch.d.ts +0 -7
- package/dist/src/types/components/organisms/deletion-confirmor/deletion-confirmor.d.ts +0 -20
- package/dist/src/types/components/organisms/deletion-confirmor/index.d.ts +0 -1
- package/dist/src/types/components/organisms/filters/filters.d.ts +0 -9
- package/dist/src/types/components/organisms/filters/index.d.ts +0 -1
- package/dist/src/types/components/organisms/form-builder/context.d.ts +0 -5
- package/dist/src/types/components/organisms/form-builder/form-builder.d.ts +0 -26
- package/dist/src/types/components/organisms/form-builder/index.d.ts +0 -2
- package/dist/src/types/components/organisms/index.d.ts +0 -3
- package/dist/src/types/components/templates/index.d.ts +0 -1
- package/dist/src/types/components/templates/landing-page.d.ts +0 -8
- package/dist/src/types/context/config.d.ts +0 -19
- package/dist/src/types/context/index.d.ts +0 -4
- package/dist/src/types/context/localization.d.ts +0 -17
- package/dist/src/types/context/navigation.d.ts +0 -15
- package/dist/src/types/context/theme.d.ts +0 -32
- package/dist/src/types/index.d.ts +0 -3
- package/dist/src/types/shared/index.d.ts +0 -1
- package/dist/src/utils/cn.d.ts +0 -2
- package/dist/src/utils/compress-images.d.ts +0 -2
- package/dist/src/utils/index.d.ts +0 -5
- package/dist/src/utils/locales.d.ts +0 -10
- package/dist/src/utils/storybook.d.ts +0 -4
- package/dist/src/utils/uploader.d.ts +0 -40
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Stable external URLs so the published package does not ship image assets. */
|
|
2
|
+
export enum Placeholders {
|
|
3
|
+
PLACEHOLDER_MALE_AVATAR = "https://api.dicebear.com/7.x/avataaars/svg?seed=male",
|
|
4
|
+
PLACEHOLDER_FEMALE_AVATAR = "https://api.dicebear.com/7.x/avataaars/svg?seed=female",
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./use-emperor-ui";
|
|
2
|
+
export * from "./use-navigation";
|
|
3
|
+
export * from "./use-search-params-handler";
|
|
4
|
+
export * from "./use-uploader-context";
|
|
5
|
+
export * from "./use-uploader";
|
|
6
|
+
export * from "./use-window-size";
|
|
7
|
+
export * from "./use-filters";
|
|
8
|
+
export * from "./use-form-builder-context";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EmperorUIContext } from "@/context";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
|
|
4
|
+
export function useEmperorUI() {
|
|
5
|
+
const context = useContext(EmperorUIContext);
|
|
6
|
+
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error("useEmperorUI must be used within a EmperorUIProvider");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useSearchParamsHandler } from "@/hooks";
|
|
5
|
+
|
|
6
|
+
export function useFilters<
|
|
7
|
+
FiltersType extends Record<string, string | number | boolean>,
|
|
8
|
+
>() {
|
|
9
|
+
const { allParams, clearParams } = useSearchParamsHandler();
|
|
10
|
+
|
|
11
|
+
const filters = useMemo(() => {
|
|
12
|
+
if (!Object.keys(allParams).length) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return allParams as unknown as FiltersType;
|
|
17
|
+
}, [allParams]);
|
|
18
|
+
|
|
19
|
+
return { filters, clearFilters: clearParams };
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormBuilderContext } from "@/context";
|
|
2
|
+
import { FormBuilderValue } from "@/types";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { FieldValues } from "react-hook-form";
|
|
5
|
+
|
|
6
|
+
export function useFormBuilder<TSchema extends FieldValues>() {
|
|
7
|
+
const context = useContext(FormBuilderContext) as FormBuilderValue<TSchema>;
|
|
8
|
+
|
|
9
|
+
if (!context) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
"'useFormBuilder' must be used within a 'FormBuilderProvider', make sure to wrap 'Field' components with 'FormBuilder' as well.",
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
@@ -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,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
const URL_SEARCH_PARAMS_CHANGE_EVENT = "URLSearchParamsChange";
|
|
6
|
+
|
|
7
|
+
export function useSearchParamsHandler() {
|
|
8
|
+
const getAllParams = useCallback((): Record<string, string> => {
|
|
9
|
+
if (typeof window === "undefined") {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const currentSearchParams = new URLSearchParams(window.location.search);
|
|
14
|
+
|
|
15
|
+
return Array.from(currentSearchParams.entries()).reduce<
|
|
16
|
+
Record<string, string>
|
|
17
|
+
>((paramsRecord, [key, value]) => {
|
|
18
|
+
paramsRecord[key] = value;
|
|
19
|
+
return paramsRecord;
|
|
20
|
+
}, {});
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
const [allParams, setAllParams] = useState<Record<string, string>>(() =>
|
|
24
|
+
getAllParams(),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const updateUrlSearchParams = useCallback(
|
|
28
|
+
({ searchParams }: { searchParams: URLSearchParams }) => {
|
|
29
|
+
if (typeof window === "undefined") return;
|
|
30
|
+
|
|
31
|
+
const searchParamsString = searchParams.toString();
|
|
32
|
+
const searchPath = searchParamsString ? `?${searchParamsString}` : "";
|
|
33
|
+
const newPath = `${window.location.pathname}${searchPath}${window.location.hash}`;
|
|
34
|
+
const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
35
|
+
|
|
36
|
+
if (newPath === currentPath) return;
|
|
37
|
+
|
|
38
|
+
window.history.replaceState(window.history.state, "", newPath);
|
|
39
|
+
window.dispatchEvent(new Event(URL_SEARCH_PARAMS_CHANGE_EVENT));
|
|
40
|
+
},
|
|
41
|
+
[],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const setParams = useCallback(
|
|
45
|
+
({
|
|
46
|
+
params,
|
|
47
|
+
options = { replace: true },
|
|
48
|
+
}: {
|
|
49
|
+
params: Record<string, string | number | boolean | undefined | null>;
|
|
50
|
+
options?: { replace?: boolean };
|
|
51
|
+
}) => {
|
|
52
|
+
if (typeof window === "undefined") return;
|
|
53
|
+
|
|
54
|
+
const nextSearchParams = new URLSearchParams(window.location.search);
|
|
55
|
+
let hasChanges = false;
|
|
56
|
+
|
|
57
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
58
|
+
if (value === undefined || value === null || value === "") {
|
|
59
|
+
const hasKey = nextSearchParams.has(key);
|
|
60
|
+
nextSearchParams.delete(key);
|
|
61
|
+
if (hasKey) {
|
|
62
|
+
hasChanges = true;
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const serializedValue = String(value);
|
|
68
|
+
|
|
69
|
+
if (options.replace) {
|
|
70
|
+
const existingValues = nextSearchParams.getAll(key);
|
|
71
|
+
const isAlreadyReplaced =
|
|
72
|
+
existingValues.length === 1 &&
|
|
73
|
+
existingValues[0] === serializedValue;
|
|
74
|
+
|
|
75
|
+
if (isAlreadyReplaced) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
nextSearchParams.delete(key);
|
|
80
|
+
nextSearchParams.append(key, serializedValue);
|
|
81
|
+
hasChanges = true;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const existingValues = nextSearchParams.getAll(key);
|
|
86
|
+
const hasMatchingValue = existingValues.some(
|
|
87
|
+
(existingValue) => existingValue === serializedValue,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (!hasMatchingValue) {
|
|
91
|
+
nextSearchParams.append(key, serializedValue);
|
|
92
|
+
hasChanges = true;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (!hasChanges) return;
|
|
97
|
+
|
|
98
|
+
updateUrlSearchParams({ searchParams: nextSearchParams });
|
|
99
|
+
},
|
|
100
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
+
[],
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const deleteParam = useCallback(
|
|
105
|
+
({ key }: { key: string }) => {
|
|
106
|
+
if (typeof window === "undefined") {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const nextSearchParams = new URLSearchParams(window.location.search);
|
|
111
|
+
nextSearchParams.delete(key);
|
|
112
|
+
updateUrlSearchParams({ searchParams: nextSearchParams });
|
|
113
|
+
},
|
|
114
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
115
|
+
[],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const deleteParams = useCallback(
|
|
119
|
+
({ keys }: { keys: string[] }) => {
|
|
120
|
+
if (typeof window === "undefined") return;
|
|
121
|
+
|
|
122
|
+
const nextSearchParams = new URLSearchParams(window.location.search);
|
|
123
|
+
let hasChanges = false;
|
|
124
|
+
keys.forEach((key) => {
|
|
125
|
+
const hasKey = nextSearchParams.has(key);
|
|
126
|
+
nextSearchParams.delete(key);
|
|
127
|
+
if (hasKey) {
|
|
128
|
+
hasChanges = true;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (!hasChanges) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
updateUrlSearchParams({ searchParams: nextSearchParams });
|
|
137
|
+
},
|
|
138
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
139
|
+
[],
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const clearParams = useCallback(() => {
|
|
143
|
+
if (typeof window === "undefined") return;
|
|
144
|
+
|
|
145
|
+
if (!window.location.search) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
updateUrlSearchParams({ searchParams: new URLSearchParams() });
|
|
150
|
+
}, [updateUrlSearchParams]);
|
|
151
|
+
|
|
152
|
+
const getParam = useCallback((name: string) => {
|
|
153
|
+
if (typeof window === "undefined") return null;
|
|
154
|
+
|
|
155
|
+
const currentSearchParams = new URLSearchParams(window.location.search);
|
|
156
|
+
return currentSearchParams.get(name);
|
|
157
|
+
}, []);
|
|
158
|
+
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (typeof window === "undefined") {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const syncAllParams = () => {
|
|
165
|
+
setAllParams(getAllParams());
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
syncAllParams();
|
|
169
|
+
window.addEventListener("popstate", syncAllParams);
|
|
170
|
+
window.addEventListener(URL_SEARCH_PARAMS_CHANGE_EVENT, syncAllParams);
|
|
171
|
+
|
|
172
|
+
return () => {
|
|
173
|
+
window.removeEventListener("popstate", syncAllParams);
|
|
174
|
+
window.removeEventListener(URL_SEARCH_PARAMS_CHANGE_EVENT, syncAllParams);
|
|
175
|
+
};
|
|
176
|
+
}, [getAllParams]);
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
getParam,
|
|
180
|
+
allParams,
|
|
181
|
+
setParams,
|
|
182
|
+
deleteParam,
|
|
183
|
+
deleteParams,
|
|
184
|
+
clearParams,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
@@ -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,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { addToast } from "@heroui/toast";
|
|
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
|
+
mergeUploaderLocale,
|
|
12
|
+
} from "@/utils";
|
|
13
|
+
import { ONE_MEGABYTE } from "@/constants";
|
|
14
|
+
import { Locale, getLocales } from "@/i18n";
|
|
15
|
+
|
|
16
|
+
export const useUploader = ({
|
|
17
|
+
labelContent,
|
|
18
|
+
labelId,
|
|
19
|
+
fileTypes,
|
|
20
|
+
isRequired = false,
|
|
21
|
+
isDraggable = true,
|
|
22
|
+
isMulti = false,
|
|
23
|
+
preventDuplicates = true,
|
|
24
|
+
maxCount = 10,
|
|
25
|
+
maxFileSize = ONE_MEGABYTE * 10,
|
|
26
|
+
compressFiles = false,
|
|
27
|
+
onChange = () => {},
|
|
28
|
+
locales,
|
|
29
|
+
}: UseUploadFileProps): UseUploadFileReturn => {
|
|
30
|
+
const { config } = useEmperorUI();
|
|
31
|
+
const [files, setFiles] = useState<FileObject[]>([]);
|
|
32
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
33
|
+
|
|
34
|
+
const configLocales = config?.interLocalization?.locales;
|
|
35
|
+
const lang =
|
|
36
|
+
config?.interLocalization?.lang ||
|
|
37
|
+
config?.interLocalization?.defaultLanguage ||
|
|
38
|
+
"en";
|
|
39
|
+
|
|
40
|
+
const defaultLocale = getLocales(lang);
|
|
41
|
+
const uploaderLocale = mergeUploaderLocale({
|
|
42
|
+
defaultUploaderLocale: defaultLocale.atoms.uploader,
|
|
43
|
+
configUploaderLocale: (configLocales?.[lang] as Locale | undefined)?.atoms
|
|
44
|
+
?.uploader,
|
|
45
|
+
contextUploaderLocale: locales,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// remove a specific uploaded file
|
|
49
|
+
const handleClearFile = (fileName?: string) => {
|
|
50
|
+
setFiles((prev) => prev?.filter((file) => file?.file?.name !== fileName));
|
|
51
|
+
|
|
52
|
+
// Reset the input value to allow re-uploading the same file
|
|
53
|
+
if (labelId) {
|
|
54
|
+
const input = document.getElementById(labelId) as HTMLInputElement;
|
|
55
|
+
if (input) {
|
|
56
|
+
input.value = "";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// handle the uploading process including the window upload and the drag-and-drop upload
|
|
62
|
+
const onInputChange = async (
|
|
63
|
+
event: React.ChangeEvent<HTMLInputElement> &
|
|
64
|
+
React.DragEvent<HTMLLabelElement>,
|
|
65
|
+
): Promise<void | string | null> => {
|
|
66
|
+
console.log("files: ", event.target.files);
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
(!event.target.files || !event.target.files?.[0]) &&
|
|
70
|
+
(!event?.dataTransfer?.files || !event?.dataTransfer?.files[0])
|
|
71
|
+
) {
|
|
72
|
+
return addToast({
|
|
73
|
+
title: uploaderLocale.errorUploadingFile,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// validate the file type according to the given allowed types
|
|
78
|
+
const allowedTypes = getAllowedTypes(fileTypes);
|
|
79
|
+
|
|
80
|
+
// verify if the files exist
|
|
81
|
+
if (!event.target.files && !event.dataTransfer.files) return;
|
|
82
|
+
|
|
83
|
+
// get the uploaded files
|
|
84
|
+
const uploadedFiles = Array.from(
|
|
85
|
+
event.target.files || event.dataTransfer.files,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// validate the files' length and prevent exceeded files only in the multiple-mode
|
|
89
|
+
if (
|
|
90
|
+
isMulti &&
|
|
91
|
+
(uploadedFiles?.length > maxCount ||
|
|
92
|
+
files?.length + uploadedFiles?.length > maxCount)
|
|
93
|
+
) {
|
|
94
|
+
addToast({
|
|
95
|
+
title: `${uploaderLocale.maxNumImages} ${maxCount}`,
|
|
96
|
+
});
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// validate the files' types according to the given allowed types
|
|
101
|
+
if (
|
|
102
|
+
!uploadedFiles
|
|
103
|
+
?.map((file) => file?.type)
|
|
104
|
+
?.every((type) => allowedTypes.includes(type))
|
|
105
|
+
) {
|
|
106
|
+
addToast({
|
|
107
|
+
title: uploaderLocale.errorUploadedTypes,
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// validate the files' sizes if none of them exceeds the maximum allowed size
|
|
113
|
+
// validate files' names to ensure there are no duplicates if specified
|
|
114
|
+
const { compressedFiles, isInValid } = await validateUploadedFiles({
|
|
115
|
+
uploadedFiles,
|
|
116
|
+
maxFileSize,
|
|
117
|
+
compressFiles,
|
|
118
|
+
preventDuplicates,
|
|
119
|
+
files,
|
|
120
|
+
uploaderLocale,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
if (isInValid) return;
|
|
124
|
+
|
|
125
|
+
setIsLoading(true);
|
|
126
|
+
|
|
127
|
+
await Promise.all(
|
|
128
|
+
await refineUploadedFiles({
|
|
129
|
+
uploadedFiles: compressedFiles,
|
|
130
|
+
uploaderLocale,
|
|
131
|
+
allowedTypes,
|
|
132
|
+
isMulti,
|
|
133
|
+
setFiles,
|
|
134
|
+
}),
|
|
135
|
+
).finally(() => {
|
|
136
|
+
setIsLoading(false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
onChange();
|
|
141
|
+
}, 200);
|
|
142
|
+
|
|
143
|
+
// Reset the input value to allow re-uploading the same file
|
|
144
|
+
// Only reset for input change events, not drag events
|
|
145
|
+
if (event.target && "value" in event.target && event.target.files) {
|
|
146
|
+
(event.target as HTMLInputElement).value = "";
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
files,
|
|
152
|
+
fileTypes,
|
|
153
|
+
labelId,
|
|
154
|
+
isRequired,
|
|
155
|
+
labelContent,
|
|
156
|
+
isDraggable,
|
|
157
|
+
isMulti,
|
|
158
|
+
handleClearFile,
|
|
159
|
+
onInputChange,
|
|
160
|
+
setFiles,
|
|
161
|
+
isLoading,
|
|
162
|
+
locales,
|
|
163
|
+
};
|
|
164
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useMemo, useState } from "react";
|
|
4
|
+
|
|
5
|
+
const SCREENS = {
|
|
6
|
+
sm: 640,
|
|
7
|
+
md: 768,
|
|
8
|
+
lg: 1024,
|
|
9
|
+
xl: 1280,
|
|
10
|
+
"2xl": 1536,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const useWindowSize = () => {
|
|
14
|
+
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
function updateSize() {
|
|
18
|
+
setSize({ width: window.innerWidth, height: window.innerHeight });
|
|
19
|
+
}
|
|
20
|
+
window.addEventListener("resize", updateSize);
|
|
21
|
+
updateSize();
|
|
22
|
+
|
|
23
|
+
return () => window.removeEventListener("resize", updateSize);
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
const currentScreen: "base" | "sm" | "md" | "lg" | "xl" | "2xl" =
|
|
27
|
+
useMemo(() => {
|
|
28
|
+
if (size?.width > SCREENS?.["2xl"]) return "2xl";
|
|
29
|
+
else if (size?.width > SCREENS?.xl) return "xl";
|
|
30
|
+
else if (size?.width > SCREENS?.lg) return "lg";
|
|
31
|
+
else if (size?.width > SCREENS?.md) return "md";
|
|
32
|
+
else if (size?.width > SCREENS?.sm) return "sm";
|
|
33
|
+
else return "base";
|
|
34
|
+
}, [size]);
|
|
35
|
+
|
|
36
|
+
const isSmallDevice = useMemo(
|
|
37
|
+
() => ["base", "sm", "md"].includes(currentScreen),
|
|
38
|
+
[currentScreen],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const isExtraSmallDevice = useMemo(
|
|
42
|
+
() => ["base"].includes(currentScreen),
|
|
43
|
+
[currentScreen],
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
viewportWidth: size.width,
|
|
48
|
+
viewportHeight: size.height,
|
|
49
|
+
currentScreen,
|
|
50
|
+
isSmallDevice,
|
|
51
|
+
isExtraSmallDevice,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./i18n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./locales";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { commonAr } from "./common";
|
|
2
|
+
import { toastsAr } from "./toasts";
|
|
3
|
+
import { atomsAr } from "./atoms";
|
|
4
|
+
import { moleculesAr } from "./molecules";
|
|
5
|
+
import { organismsAr } from "./organisms";
|
|
6
|
+
import { templatesAr } from "./templates";
|
|
7
|
+
|
|
8
|
+
export const ar = {
|
|
9
|
+
common: commonAr,
|
|
10
|
+
toasts: toastsAr,
|
|
11
|
+
atoms: atomsAr,
|
|
12
|
+
molecules: moleculesAr,
|
|
13
|
+
organisms: organismsAr,
|
|
14
|
+
templates: templatesAr,
|
|
15
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const atomsAr = {
|
|
2
|
+
colorPicker: {
|
|
3
|
+
invalidColorFormat: "يرجى إدخال لون صالح (مثال: #000000 أو #fff)",
|
|
4
|
+
},
|
|
5
|
+
uploader: {
|
|
6
|
+
dropHere: "أسقط الملف هنا",
|
|
7
|
+
selectFile: "حدد ملفًا أو اسحبه وأفلته هنا",
|
|
8
|
+
selectionTypes: "JPG, PNG أو PDF، حجم الملف لا يزيد عن 10MB",
|
|
9
|
+
selectBtn: "حدد ملف",
|
|
10
|
+
errorUploadingFile: "لم يتم تحميل أي ملف",
|
|
11
|
+
maxNumImages: "تم تجاوز الحد الأقصى للصور المرفوعة: ",
|
|
12
|
+
errorUploadedTypes: "نوع الملف المرفوع غير مسموح به",
|
|
13
|
+
maxSizeExceededError:
|
|
14
|
+
"يمكنك فقط رفع ملفات/صور بحجم أقل من MAX_FILE_SIZE ميغابايت، بينما حجم الملف الذي رفعته هو UPLOADED_FILE_SIZE ميغابايت",
|
|
15
|
+
duplicatesDenied:
|
|
16
|
+
"لا يمكنك رفع صور تحمل نفس الاسم، يمكنك إعادة تسميتها قبل عملية الرفع",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const atomsEn = {
|
|
2
|
+
colorPicker: {
|
|
3
|
+
invalidColorFormat: "Please enter a valid color (e.g., #000000 or #fff)",
|
|
4
|
+
},
|
|
5
|
+
uploader: {
|
|
6
|
+
dropHere: "Drop file here",
|
|
7
|
+
selectFile: "Select a file or drag and drop here",
|
|
8
|
+
selectionTypes: "JPG, PNG or PDF, file size no more than 10MB",
|
|
9
|
+
selectBtn: "Select file",
|
|
10
|
+
errorUploadingFile: "No file was uploaded",
|
|
11
|
+
maxNumImages: "Maximum number of uploaded images exceeded: ",
|
|
12
|
+
errorUploadedTypes: "The uploaded file type is not allowed.",
|
|
13
|
+
maxSizeExceededError:
|
|
14
|
+
"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",
|
|
15
|
+
duplicatesDenied:
|
|
16
|
+
"You can't upload images with duplicate names, you may rename them before the upload process",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const commonAr = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const commonEn = {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { commonEn } from "./common";
|
|
2
|
+
import { toastsEn } from "./toasts";
|
|
3
|
+
import { atomsEn } from "./atoms";
|
|
4
|
+
import { moleculesEn } from "./molecules";
|
|
5
|
+
import { organismsEn } from "./organisms";
|
|
6
|
+
import { templatesEn } from "./templates";
|
|
7
|
+
|
|
8
|
+
export const en = {
|
|
9
|
+
common: commonEn,
|
|
10
|
+
toasts: toastsEn,
|
|
11
|
+
atoms: atomsEn,
|
|
12
|
+
molecules: moleculesEn,
|
|
13
|
+
organisms: organismsEn,
|
|
14
|
+
templates: templatesEn,
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const moleculesAr = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const moleculesEn = {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const organismsEn = {
|
|
2
|
+
deletionConfirmor: {
|
|
3
|
+
confirm: "Confirm",
|
|
4
|
+
decline: "Decline",
|
|
5
|
+
},
|
|
6
|
+
listings: {
|
|
7
|
+
emptyTitle: "No listings found",
|
|
8
|
+
emptyDescription:
|
|
9
|
+
"We couldn't find any listings matching your search. Try adjusting your filters or check back later.",
|
|
10
|
+
},
|
|
11
|
+
};
|