@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,65 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { FilterProps } from "@/types";
|
|
4
|
-
import { filterClasses } from "@/components";
|
|
5
|
-
import { Slider } from "@heroui/slider";
|
|
6
|
-
import { cn } from "@/utils";
|
|
7
|
-
import { useMemo } from "react";
|
|
8
|
-
import { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
9
|
-
|
|
10
|
-
export function RangeFilter({
|
|
11
|
-
classNames,
|
|
12
|
-
rangeProps,
|
|
13
|
-
paramKey,
|
|
14
|
-
}: Pick<FilterProps, "classNames" | "rangeProps" | "paramKey">) {
|
|
15
|
-
const { getParam, setParams, allParams } = useSearchParamsHandler();
|
|
16
|
-
const { config } = useEmperorUI();
|
|
17
|
-
|
|
18
|
-
const theme = config?.theme?.components?.slider;
|
|
19
|
-
|
|
20
|
-
const minVal = rangeProps?.minValue ?? 0;
|
|
21
|
-
const maxVal = rangeProps?.maxValue ?? 100;
|
|
22
|
-
|
|
23
|
-
const value = useMemo(() => {
|
|
24
|
-
const valueStr = getParam(paramKey);
|
|
25
|
-
const defaultRange: [number, number] = [minVal, maxVal];
|
|
26
|
-
|
|
27
|
-
if (valueStr == null) return defaultRange;
|
|
28
|
-
|
|
29
|
-
const [a, b] = valueStr.split(",").map(Number);
|
|
30
|
-
if (!Number.isNaN(a) && !Number.isNaN(b) && a <= b) {
|
|
31
|
-
return [a, b];
|
|
32
|
-
}
|
|
33
|
-
return defaultRange;
|
|
34
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
-
}, [paramKey, minVal, maxVal, allParams]);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Slider
|
|
39
|
-
{...theme}
|
|
40
|
-
{...rangeProps}
|
|
41
|
-
value={value}
|
|
42
|
-
onChange={(value) => {
|
|
43
|
-
const range = Array.isArray(value) ? value : [value];
|
|
44
|
-
const isFullRange =
|
|
45
|
-
range.length === 2 && range[0] === minVal && range[1] === maxVal;
|
|
46
|
-
|
|
47
|
-
setParams({
|
|
48
|
-
params: {
|
|
49
|
-
[paramKey]:
|
|
50
|
-
range.length === 2 && !isFullRange
|
|
51
|
-
? `${range[0]},${range[1]}`
|
|
52
|
-
: undefined,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
}}
|
|
56
|
-
classNames={{
|
|
57
|
-
base: "min-w-40",
|
|
58
|
-
label: "font-semibold",
|
|
59
|
-
...theme?.classNames,
|
|
60
|
-
...rangeProps?.classNames,
|
|
61
|
-
}}
|
|
62
|
-
className={cn(filterClasses({ type: "range" }), classNames?.field)}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { FilterProps } from "@/types";
|
|
4
|
-
import { filterClasses } from "@/components";
|
|
5
|
-
import { Input } from "@heroui/input";
|
|
6
|
-
import { cn } from "@/utils";
|
|
7
|
-
import { useEffect, useState } from "react";
|
|
8
|
-
import { useDebounce } from "use-debounce";
|
|
9
|
-
import { Search } from "lucide-react";
|
|
10
|
-
import { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
11
|
-
|
|
12
|
-
export function SearchFilter({
|
|
13
|
-
classNames,
|
|
14
|
-
searchProps,
|
|
15
|
-
paramKey,
|
|
16
|
-
}: Pick<FilterProps, "classNames" | "searchProps" | "paramKey">) {
|
|
17
|
-
const { config } = useEmperorUI();
|
|
18
|
-
|
|
19
|
-
const theme = config?.theme?.components?.input;
|
|
20
|
-
|
|
21
|
-
const [searchValue, setSearchValue] = useState(
|
|
22
|
-
searchProps?.defaultValue || "",
|
|
23
|
-
);
|
|
24
|
-
const { setParams } = useSearchParamsHandler();
|
|
25
|
-
|
|
26
|
-
const [debouncedSearchValue] = useDebounce(searchValue, 700);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setParams({
|
|
30
|
-
params: {
|
|
31
|
-
[paramKey]: debouncedSearchValue,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
-
}, [debouncedSearchValue]);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Input
|
|
39
|
-
{...theme}
|
|
40
|
-
{...searchProps}
|
|
41
|
-
endContent={<Search className="size-4" />}
|
|
42
|
-
value={searchValue}
|
|
43
|
-
onValueChange={setSearchValue}
|
|
44
|
-
className={cn(filterClasses({ type: "search" }), classNames?.field)}
|
|
45
|
-
classNames={{
|
|
46
|
-
input: "min-w-40",
|
|
47
|
-
label: "font-semibold",
|
|
48
|
-
...theme?.classNames,
|
|
49
|
-
...searchProps?.classNames,
|
|
50
|
-
}}
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { FilterProps } from "@/types";
|
|
4
|
-
import { filterClasses } from "@/components";
|
|
5
|
-
import { Select, SelectItem } from "@heroui/select";
|
|
6
|
-
import { cn } from "@/utils";
|
|
7
|
-
import { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
8
|
-
|
|
9
|
-
export function SelectFilter({
|
|
10
|
-
classNames,
|
|
11
|
-
selectProps,
|
|
12
|
-
selectItemProps,
|
|
13
|
-
paramKey,
|
|
14
|
-
options,
|
|
15
|
-
}: Pick<
|
|
16
|
-
FilterProps,
|
|
17
|
-
"classNames" | "selectProps" | "selectItemProps" | "paramKey" | "options"
|
|
18
|
-
>) {
|
|
19
|
-
const { getParam, setParams } = useSearchParamsHandler();
|
|
20
|
-
const { config } = useEmperorUI();
|
|
21
|
-
|
|
22
|
-
const theme = config?.theme?.components?.select;
|
|
23
|
-
const themeItem = config?.theme?.components?.selectItem;
|
|
24
|
-
|
|
25
|
-
const key = paramKey ?? "select";
|
|
26
|
-
const value = getParam(key);
|
|
27
|
-
|
|
28
|
-
if (!options?.length)
|
|
29
|
-
throw new Error("Filter with type 'select' must have 'options' property.");
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Select
|
|
33
|
-
{...theme}
|
|
34
|
-
{...selectProps}
|
|
35
|
-
selectedKeys={value ? [value] : []}
|
|
36
|
-
onSelectionChange={(keys) => {
|
|
37
|
-
const selectedKey = Array.from(keys)[0];
|
|
38
|
-
setParams({
|
|
39
|
-
params: { [key]: selectedKey ? String(selectedKey) : undefined },
|
|
40
|
-
});
|
|
41
|
-
}}
|
|
42
|
-
className={cn(filterClasses({ type: "select" }), classNames?.field)}
|
|
43
|
-
classNames={{
|
|
44
|
-
trigger: "min-w-40",
|
|
45
|
-
label: "font-semibold",
|
|
46
|
-
...theme?.classNames,
|
|
47
|
-
...selectProps?.classNames,
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
{options.map((option) => (
|
|
51
|
-
<SelectItem key={option.key} {...themeItem} {...selectItemProps}>
|
|
52
|
-
{option.label}
|
|
53
|
-
</SelectItem>
|
|
54
|
-
))}
|
|
55
|
-
</Select>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { FilterProps } from "@/types";
|
|
4
|
-
import { filterClasses } from "@/components";
|
|
5
|
-
import { Switch } from "@heroui/switch";
|
|
6
|
-
import { cn } from "@/utils";
|
|
7
|
-
import { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
8
|
-
|
|
9
|
-
export function SwitchFilter({
|
|
10
|
-
classNames,
|
|
11
|
-
switchProps,
|
|
12
|
-
paramKey,
|
|
13
|
-
}: Pick<FilterProps, "classNames" | "switchProps" | "paramKey">) {
|
|
14
|
-
const { getParam, setParams } = useSearchParamsHandler();
|
|
15
|
-
const { config } = useEmperorUI();
|
|
16
|
-
|
|
17
|
-
const theme = config?.theme?.components?.switch;
|
|
18
|
-
|
|
19
|
-
const value = getParam(paramKey);
|
|
20
|
-
const isSelected = value === "true" || value === "1" || value === "yes";
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Switch
|
|
24
|
-
{...theme}
|
|
25
|
-
{...switchProps}
|
|
26
|
-
isSelected={isSelected}
|
|
27
|
-
onValueChange={(selected) =>
|
|
28
|
-
setParams({
|
|
29
|
-
params: { [paramKey]: selected ? "true" : undefined },
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
className={cn(filterClasses({ type: "switch" }), classNames?.field)}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./brand";
|
|
2
|
-
export * from "./column";
|
|
3
|
-
export * from "./container";
|
|
4
|
-
export * from "./row";
|
|
5
|
-
export * from "./portal";
|
|
6
|
-
export * from "./uploader";
|
|
7
|
-
export * from "./filter";
|
|
8
|
-
export * from "./field";
|
|
9
|
-
export * from "./theme-switch";
|
|
10
|
-
export * from "./color-picker";
|
|
11
|
-
export * from "./copy-button";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./portal";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { Portal } from "@/components";
|
|
3
|
-
import { getStorybookDecorators } from "@/utils";
|
|
4
|
-
import { FAKE_PARAGRAPH } from "@/constants";
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Portal> = {
|
|
7
|
-
title: "Atoms/Portal",
|
|
8
|
-
component: Portal,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: "fullscreen",
|
|
11
|
-
},
|
|
12
|
-
tags: ["autodocs"],
|
|
13
|
-
decorators: getStorybookDecorators({
|
|
14
|
-
config: {
|
|
15
|
-
layout: {
|
|
16
|
-
withScaffold: false,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default meta;
|
|
23
|
-
|
|
24
|
-
type Story = StoryObj<typeof meta>;
|
|
25
|
-
|
|
26
|
-
export const Default: Story = {
|
|
27
|
-
args: {},
|
|
28
|
-
render: () => (
|
|
29
|
-
<main className="h-screen w-full flex flex-col gap-10 p-5">
|
|
30
|
-
<div id="portal-container" />
|
|
31
|
-
|
|
32
|
-
<p>{FAKE_PARAGRAPH}</p>
|
|
33
|
-
<p>{FAKE_PARAGRAPH}</p>
|
|
34
|
-
<p>{FAKE_PARAGRAPH}</p>
|
|
35
|
-
|
|
36
|
-
<Portal containerId="portal-container">
|
|
37
|
-
<div className="bg-blue-300 p-2 rounded-md absolute top-5 left-1/2 -translate-x-1/2">
|
|
38
|
-
<h2>Portal Content</h2>
|
|
39
|
-
</div>
|
|
40
|
-
</Portal>
|
|
41
|
-
</main>
|
|
42
|
-
),
|
|
43
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { PortalProps } from "@/types";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { createPortal } from "react-dom";
|
|
4
|
-
|
|
5
|
-
export function Portal({
|
|
6
|
-
children,
|
|
7
|
-
containerId,
|
|
8
|
-
isVisible = true,
|
|
9
|
-
}: PortalProps) {
|
|
10
|
-
const [container, setContainer] = useState<HTMLElement | null>(null);
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const element = document.getElementById(containerId);
|
|
14
|
-
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
setContainer(element);
|
|
17
|
-
}, 100);
|
|
18
|
-
}, [containerId]);
|
|
19
|
-
|
|
20
|
-
if (!container || !isVisible) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return createPortal(children, container);
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./row";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { Row } from "@/components";
|
|
3
|
-
import { getStorybookDecorators } from "@/utils";
|
|
4
|
-
import type { RowProps } from "@/types";
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Row> = {
|
|
7
|
-
title: "Atoms/Row",
|
|
8
|
-
component: Row,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: "centered",
|
|
11
|
-
},
|
|
12
|
-
tags: ["autodocs"],
|
|
13
|
-
decorators: getStorybookDecorators({
|
|
14
|
-
config: {
|
|
15
|
-
layout: {
|
|
16
|
-
withScaffold: false,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default meta;
|
|
23
|
-
|
|
24
|
-
type Story = StoryObj<typeof meta>;
|
|
25
|
-
|
|
26
|
-
export const Default: Story = {
|
|
27
|
-
args: {},
|
|
28
|
-
render: (args: RowProps) => (
|
|
29
|
-
<Row {...args}>
|
|
30
|
-
{Array.from({ length: 5 }).map((_, index) => (
|
|
31
|
-
<div key={index} className="bg-blue-300 p-2 rounded-md">
|
|
32
|
-
Item {index + 1}
|
|
33
|
-
</div>
|
|
34
|
-
))}
|
|
35
|
-
</Row>
|
|
36
|
-
),
|
|
37
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { RowProps } from "@/types";
|
|
2
|
-
import { cn } from "@/utils";
|
|
3
|
-
import { cva, VariantProps } from "class-variance-authority";
|
|
4
|
-
import { forwardRef, ComponentProps } from "react";
|
|
5
|
-
|
|
6
|
-
const rowStyles = cva(["flex items-center gap-3"], {
|
|
7
|
-
variants: {},
|
|
8
|
-
defaultVariants: {},
|
|
9
|
-
compoundVariants: [],
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export const Row = forwardRef<
|
|
13
|
-
HTMLElement,
|
|
14
|
-
ComponentProps<"section"> & VariantProps<typeof rowStyles> & RowProps
|
|
15
|
-
>(({ className, children, ...props }, ref) => {
|
|
16
|
-
return (
|
|
17
|
-
<section
|
|
18
|
-
ref={ref}
|
|
19
|
-
data-slot="row"
|
|
20
|
-
className={cn(rowStyles({ className }))}
|
|
21
|
-
{...props}
|
|
22
|
-
>
|
|
23
|
-
{children}
|
|
24
|
-
</section>
|
|
25
|
-
);
|
|
26
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./theme-switch";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { cva } from "class-variance-authority";
|
|
2
|
-
|
|
3
|
-
export const themeSwitcherClasses = cva(
|
|
4
|
-
[
|
|
5
|
-
"flex items-center justify-center size-9 rounded-lg transition-all duration-300 text-foreground/80 cursor-pointer",
|
|
6
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 ",
|
|
7
|
-
"hover:bg-default-100 hover:text-foreground",
|
|
8
|
-
],
|
|
9
|
-
{
|
|
10
|
-
variants: {
|
|
11
|
-
variant: {},
|
|
12
|
-
},
|
|
13
|
-
defaultVariants: {},
|
|
14
|
-
compoundVariants: [],
|
|
15
|
-
},
|
|
16
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./classes";
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { ThemeSwitch } from "@/components";
|
|
3
|
-
import { getStorybookDecorators } from "@/utils";
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof ThemeSwitch> = {
|
|
6
|
-
title: "Atoms/ThemeSwitch",
|
|
7
|
-
component: ThemeSwitch,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: "fullscreen",
|
|
10
|
-
},
|
|
11
|
-
tags: ["autodocs"],
|
|
12
|
-
decorators: getStorybookDecorators({}),
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default meta;
|
|
16
|
-
|
|
17
|
-
type Story = StoryObj<typeof meta>;
|
|
18
|
-
|
|
19
|
-
export const Default: Story = {
|
|
20
|
-
args: {},
|
|
21
|
-
render: () => (
|
|
22
|
-
<div className="flex justify-center items-center w-screen h-screen">
|
|
23
|
-
<ThemeSwitch className="m-auto" />
|
|
24
|
-
</div>
|
|
25
|
-
),
|
|
26
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { cn } from "@/utils";
|
|
2
|
-
import { themeSwitcherClasses } from "./styles";
|
|
3
|
-
import { ThemeSwitchProps } from "@/types";
|
|
4
|
-
import { useTheme } from "next-themes";
|
|
5
|
-
import { MoonIcon, SunIcon } from "lucide-react";
|
|
6
|
-
import { motion, AnimatePresence } from "motion/react";
|
|
7
|
-
|
|
8
|
-
export function ThemeSwitch({
|
|
9
|
-
className,
|
|
10
|
-
classNames,
|
|
11
|
-
...props
|
|
12
|
-
}: ThemeSwitchProps) {
|
|
13
|
-
const { setTheme, resolvedTheme } = useTheme();
|
|
14
|
-
|
|
15
|
-
const handleThemeToggle = () => {
|
|
16
|
-
setTheme(resolvedTheme === "dark" ? "light" : "dark");
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<motion.button
|
|
21
|
-
data-slot="emperor-ui-theme-knob"
|
|
22
|
-
className={cn(themeSwitcherClasses(), className, classNames?.base)}
|
|
23
|
-
onClick={handleThemeToggle}
|
|
24
|
-
initial={false}
|
|
25
|
-
whileHover={{ scale: 1.08 }}
|
|
26
|
-
whileTap={{ scale: 0.92 }}
|
|
27
|
-
transition={{
|
|
28
|
-
type: "spring" as const,
|
|
29
|
-
stiffness: 500,
|
|
30
|
-
damping: 28,
|
|
31
|
-
}}
|
|
32
|
-
{...props}
|
|
33
|
-
>
|
|
34
|
-
<span className="relative flex size-5 items-center justify-center">
|
|
35
|
-
<AnimatePresence mode="wait">
|
|
36
|
-
<motion.span
|
|
37
|
-
key={resolvedTheme ?? "loading"}
|
|
38
|
-
initial={{ opacity: 0 }}
|
|
39
|
-
animate={{ opacity: 1 }}
|
|
40
|
-
exit={{ opacity: 0 }}
|
|
41
|
-
transition={{ duration: 0.2 }}
|
|
42
|
-
className="absolute inset-0 flex items-center justify-center"
|
|
43
|
-
>
|
|
44
|
-
{resolvedTheme === "dark" ? (
|
|
45
|
-
<SunIcon className="size-5" />
|
|
46
|
-
) : (
|
|
47
|
-
<MoonIcon className="size-5" />
|
|
48
|
-
)}
|
|
49
|
-
</motion.span>
|
|
50
|
-
</AnimatePresence>
|
|
51
|
-
</span>
|
|
52
|
-
</motion.button>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Placeholders } from "@/enums";
|
|
4
|
-
import { Avatar } from "@heroui/avatar";
|
|
5
|
-
import { Spinner } from "@heroui/spinner";
|
|
6
|
-
import { cn, mergeUploaderLocale } from "@/utils";
|
|
7
|
-
import { useEmperorUI, useUploaderContext } from "@/hooks";
|
|
8
|
-
import { useState } from "react";
|
|
9
|
-
import { getLocales, Locale } from "@/i18n";
|
|
10
|
-
|
|
11
|
-
export function AvatarLabel() {
|
|
12
|
-
const { config } = useEmperorUI();
|
|
13
|
-
const [draggableMessage, setDraggableMessage] = useState<string | null>(null);
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
labelId,
|
|
17
|
-
classNames,
|
|
18
|
-
labelContent,
|
|
19
|
-
isDraggable,
|
|
20
|
-
onInputChange,
|
|
21
|
-
avatarLabelContent,
|
|
22
|
-
placeholderImage,
|
|
23
|
-
files,
|
|
24
|
-
isLoading,
|
|
25
|
-
isMulti,
|
|
26
|
-
locales,
|
|
27
|
-
} = useUploaderContext();
|
|
28
|
-
|
|
29
|
-
const configLocales = config?.interLocalization?.locales;
|
|
30
|
-
const lang =
|
|
31
|
-
config?.interLocalization?.lang ||
|
|
32
|
-
config?.interLocalization?.defaultLanguage ||
|
|
33
|
-
"en";
|
|
34
|
-
|
|
35
|
-
const defaultLocale = getLocales(lang);
|
|
36
|
-
const uploaderLocale = mergeUploaderLocale({
|
|
37
|
-
defaultUploaderLocale: defaultLocale.atoms.uploader,
|
|
38
|
-
configUploaderLocale: (configLocales?.[lang] as Locale | undefined)?.atoms
|
|
39
|
-
?.uploader,
|
|
40
|
-
contextUploaderLocale: locales,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const handleDrop = (
|
|
44
|
-
event: React.ChangeEvent<HTMLInputElement> &
|
|
45
|
-
React.DragEvent<HTMLLabelElement>,
|
|
46
|
-
) => {
|
|
47
|
-
event.preventDefault();
|
|
48
|
-
if (onInputChange) onInputChange(event);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const handleDragOver = (
|
|
52
|
-
event: React.ChangeEvent<HTMLInputElement> &
|
|
53
|
-
React.DragEvent<HTMLLabelElement>,
|
|
54
|
-
) => {
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
setDraggableMessage(uploaderLocale.dropHere);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const handleDragLeave = () => {
|
|
60
|
-
setDraggableMessage("");
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
if (!isMulti && files?.length > 0) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (isLoading)
|
|
68
|
-
return (
|
|
69
|
-
<div className={cn("mx-auto", classNames?.label)}>
|
|
70
|
-
<Spinner className="mx-auto" size="lg" />;
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<label
|
|
76
|
-
className={cn(
|
|
77
|
-
"w-full cursor-pointer mx-auto transition-opacity flex flex-col gap-5",
|
|
78
|
-
draggableMessage && "opacity-60",
|
|
79
|
-
classNames?.label,
|
|
80
|
-
)}
|
|
81
|
-
htmlFor={labelId}
|
|
82
|
-
onDrop={isDraggable ? handleDrop : () => {}}
|
|
83
|
-
onDragOver={isDraggable ? handleDragOver : () => {}}
|
|
84
|
-
onDragLeave={isDraggable ? handleDragLeave : () => {}}
|
|
85
|
-
>
|
|
86
|
-
{avatarLabelContent}
|
|
87
|
-
|
|
88
|
-
{labelContent || (
|
|
89
|
-
<Avatar
|
|
90
|
-
src={
|
|
91
|
-
files?.[0]?.view ||
|
|
92
|
-
placeholderImage ||
|
|
93
|
-
Placeholders.PLACEHOLDER_MALE_AVATAR
|
|
94
|
-
}
|
|
95
|
-
alt="avatar"
|
|
96
|
-
size="lg"
|
|
97
|
-
className={cn("size-24", classNames?.avatar)}
|
|
98
|
-
/>
|
|
99
|
-
)}
|
|
100
|
-
</label>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./uploader";
|
|
2
|
-
export * from "./avatar-label";
|
|
3
|
-
export * from "./upload-file-label";
|
|
4
|
-
export * from "./view-image-modal";
|
|
5
|
-
export * from "./upload-file-listing";
|
|
6
|
-
export * from "./upload-file-error-box";
|
|
7
|
-
export * from "./upload-file-input";
|
|
8
|
-
export * from "./uploader-title";
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn, mergeUploaderLocale } from "@/utils";
|
|
4
|
-
import { useEmperorUI, useUploaderContext } from "@/hooks";
|
|
5
|
-
import { useMemo } from "react";
|
|
6
|
-
import { getLocales, Locale } from "@/i18n";
|
|
7
|
-
|
|
8
|
-
export function UploadFileErrorBox() {
|
|
9
|
-
const { config } = useEmperorUI();
|
|
10
|
-
const { files, isRequired, classNames, errorMessage, locales } =
|
|
11
|
-
useUploaderContext();
|
|
12
|
-
|
|
13
|
-
const configLocales = config?.interLocalization?.locales;
|
|
14
|
-
const lang =
|
|
15
|
-
config?.interLocalization?.lang ||
|
|
16
|
-
config?.interLocalization?.defaultLanguage ||
|
|
17
|
-
"en";
|
|
18
|
-
|
|
19
|
-
const defaultLocale = getLocales(lang);
|
|
20
|
-
const uploaderLocale = mergeUploaderLocale({
|
|
21
|
-
defaultUploaderLocale: defaultLocale.atoms.uploader,
|
|
22
|
-
configUploaderLocale: (configLocales?.[lang] as Locale | undefined)?.atoms
|
|
23
|
-
?.uploader,
|
|
24
|
-
contextUploaderLocale: locales,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const isError = useMemo(
|
|
28
|
-
() => files?.length === 0 && isRequired,
|
|
29
|
-
[files, isRequired],
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
if (isError)
|
|
33
|
-
return (
|
|
34
|
-
<p className={cn("text-[14px] text-danger", classNames?.error)}>
|
|
35
|
-
{errorMessage ?? uploaderLocale.errorUploadingFile}
|
|
36
|
-
</p>
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@/utils";
|
|
4
|
-
import { useUploaderContext } from "@/hooks";
|
|
5
|
-
import { fileTypesMapping } from "@/constants";
|
|
6
|
-
|
|
7
|
-
export function UploadFileInput() {
|
|
8
|
-
const {
|
|
9
|
-
fileTypes = [],
|
|
10
|
-
isMulti,
|
|
11
|
-
labelId,
|
|
12
|
-
onInputChange,
|
|
13
|
-
classNames,
|
|
14
|
-
} = useUploaderContext();
|
|
15
|
-
|
|
16
|
-
const getFileAccepts = (): string => {
|
|
17
|
-
const acceptedTypes: string[] = [];
|
|
18
|
-
|
|
19
|
-
fileTypes?.forEach((fileType) => {
|
|
20
|
-
acceptedTypes.push(...(fileTypesMapping?.[fileType] || []));
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
return acceptedTypes.join(", ");
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<input
|
|
28
|
-
id={labelId}
|
|
29
|
-
type="file"
|
|
30
|
-
accept={getFileAccepts()}
|
|
31
|
-
className={cn("hidden", classNames?.input)}
|
|
32
|
-
onChange={onInputChange}
|
|
33
|
-
multiple={isMulti}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
}
|