@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,37 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { FieldProps } from "@/types";
|
|
4
|
-
import { Controller, type FieldValues } from "react-hook-form";
|
|
5
|
-
import { Textarea } from "@heroui/input";
|
|
6
|
-
import { useEmperorUI, useFormBuilder } from "@/hooks";
|
|
7
|
-
|
|
8
|
-
export function TextareaField<TSchema extends FieldValues>({
|
|
9
|
-
textareaProps,
|
|
10
|
-
name,
|
|
11
|
-
}: Pick<FieldProps<TSchema>, "textareaProps" | "name">) {
|
|
12
|
-
const { config } = useEmperorUI();
|
|
13
|
-
|
|
14
|
-
const theme = config?.theme?.components?.textarea;
|
|
15
|
-
|
|
16
|
-
const { control } = useFormBuilder<TSchema>();
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<Controller
|
|
20
|
-
control={control}
|
|
21
|
-
name={name}
|
|
22
|
-
render={({ field, fieldState }) => (
|
|
23
|
-
<Textarea
|
|
24
|
-
{...theme}
|
|
25
|
-
{...textareaProps}
|
|
26
|
-
value={field.value ? String(field.value) : ""}
|
|
27
|
-
onBlur={field.onBlur}
|
|
28
|
-
onValueChange={field.onChange}
|
|
29
|
-
isInvalid={textareaProps?.isInvalid ?? Boolean(fieldState.error)}
|
|
30
|
-
errorMessage={
|
|
31
|
-
textareaProps?.errorMessage ?? fieldState.error?.message
|
|
32
|
-
}
|
|
33
|
-
/>
|
|
34
|
-
)}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { cn } from "@/utils";
|
|
2
|
-
import { FilterProps, FilterType } from "@/types";
|
|
3
|
-
import { filterClasses } from "./styles";
|
|
4
|
-
import { ReactNode } from "react";
|
|
5
|
-
import {
|
|
6
|
-
SearchFilter,
|
|
7
|
-
SelectFilter,
|
|
8
|
-
AutocompleteFilter,
|
|
9
|
-
DateFilter,
|
|
10
|
-
NumericFilter,
|
|
11
|
-
CheckboxFilter,
|
|
12
|
-
CheckboxGroupFilter,
|
|
13
|
-
SwitchFilter,
|
|
14
|
-
RangeFilter,
|
|
15
|
-
} from "@/components";
|
|
16
|
-
|
|
17
|
-
export function Filter({
|
|
18
|
-
className,
|
|
19
|
-
type,
|
|
20
|
-
searchProps,
|
|
21
|
-
selectProps,
|
|
22
|
-
autocompleteProps,
|
|
23
|
-
dateProps,
|
|
24
|
-
numericProps,
|
|
25
|
-
checkboxProps,
|
|
26
|
-
checkboxGroupProps,
|
|
27
|
-
radioProps,
|
|
28
|
-
switchProps,
|
|
29
|
-
rangeProps,
|
|
30
|
-
paramKey,
|
|
31
|
-
options,
|
|
32
|
-
...props
|
|
33
|
-
}: FilterProps) {
|
|
34
|
-
const sharedProps = { paramKey };
|
|
35
|
-
|
|
36
|
-
const components: Record<FilterType, ReactNode> = {
|
|
37
|
-
search: (
|
|
38
|
-
<SearchFilter searchProps={searchProps} {...sharedProps} {...props} />
|
|
39
|
-
),
|
|
40
|
-
select: (
|
|
41
|
-
<SelectFilter
|
|
42
|
-
selectProps={selectProps}
|
|
43
|
-
options={options}
|
|
44
|
-
{...sharedProps}
|
|
45
|
-
{...props}
|
|
46
|
-
/>
|
|
47
|
-
),
|
|
48
|
-
autocomplete: (
|
|
49
|
-
<AutocompleteFilter
|
|
50
|
-
autocompleteProps={autocompleteProps}
|
|
51
|
-
options={options}
|
|
52
|
-
{...sharedProps}
|
|
53
|
-
{...props}
|
|
54
|
-
/>
|
|
55
|
-
),
|
|
56
|
-
date: <DateFilter dateProps={dateProps} {...sharedProps} {...props} />,
|
|
57
|
-
numeric: (
|
|
58
|
-
<NumericFilter numericProps={numericProps} {...sharedProps} {...props} />
|
|
59
|
-
),
|
|
60
|
-
checkbox: (
|
|
61
|
-
<CheckboxFilter
|
|
62
|
-
checkboxProps={checkboxProps}
|
|
63
|
-
{...sharedProps}
|
|
64
|
-
{...props}
|
|
65
|
-
/>
|
|
66
|
-
),
|
|
67
|
-
checkboxGroup: (
|
|
68
|
-
<CheckboxGroupFilter
|
|
69
|
-
checkboxGroupProps={checkboxGroupProps}
|
|
70
|
-
options={options}
|
|
71
|
-
{...sharedProps}
|
|
72
|
-
{...props}
|
|
73
|
-
/>
|
|
74
|
-
),
|
|
75
|
-
switch: (
|
|
76
|
-
<SwitchFilter switchProps={switchProps} {...sharedProps} {...props} />
|
|
77
|
-
),
|
|
78
|
-
range: <RangeFilter rangeProps={rangeProps} {...sharedProps} {...props} />,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<div
|
|
83
|
-
data-slot="emperor-ui-filter"
|
|
84
|
-
className={cn(
|
|
85
|
-
filterClasses({ type }),
|
|
86
|
-
className,
|
|
87
|
-
props?.classNames?.base,
|
|
88
|
-
)}
|
|
89
|
-
>
|
|
90
|
-
{components[type]}
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { Filter } from "@/components";
|
|
3
|
-
import { useFilters } from "@/hooks";
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Filter> = {
|
|
6
|
-
title: "Atoms/Filter",
|
|
7
|
-
component: Filter,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: "centered",
|
|
10
|
-
},
|
|
11
|
-
tags: ["autodocs"],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default meta;
|
|
15
|
-
|
|
16
|
-
type Story = StoryObj<typeof meta>;
|
|
17
|
-
|
|
18
|
-
const filterOptions = [
|
|
19
|
-
{ key: "option-key-1", label: "Option 1" },
|
|
20
|
-
{ key: "option-key-2", label: "Option 2" },
|
|
21
|
-
{ key: "option-key-3", label: "Option 3" },
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
export const SearchFilter: Story = {
|
|
25
|
-
render: () => {
|
|
26
|
-
const { filters } = useFilters<{
|
|
27
|
-
search: string;
|
|
28
|
-
}>();
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<section className="flex flex-col gap-2">
|
|
32
|
-
<Filter
|
|
33
|
-
type="search"
|
|
34
|
-
paramKey="search"
|
|
35
|
-
searchProps={{ label: "Search" }}
|
|
36
|
-
/>
|
|
37
|
-
|
|
38
|
-
<p className="text-gray-500 text-xs">
|
|
39
|
-
{filters?.search || "No filter applied"}
|
|
40
|
-
</p>
|
|
41
|
-
</section>
|
|
42
|
-
);
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const SelectFilter: Story = {
|
|
47
|
-
render: () => {
|
|
48
|
-
const { filters } = useFilters<{
|
|
49
|
-
select: string;
|
|
50
|
-
}>();
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<section className="flex flex-col gap-2">
|
|
54
|
-
<Filter
|
|
55
|
-
type="select"
|
|
56
|
-
paramKey="select"
|
|
57
|
-
selectProps={{ label: "Select an option" }}
|
|
58
|
-
options={[
|
|
59
|
-
{ key: "option-key-1", label: "Option 1" },
|
|
60
|
-
{ key: "option-key-2", label: "Option 2" },
|
|
61
|
-
{ key: "option-key-3", label: "Option 3" },
|
|
62
|
-
]}
|
|
63
|
-
/>
|
|
64
|
-
|
|
65
|
-
<p className="text-gray-500 text-xs">
|
|
66
|
-
{filters?.select || "No filter applied"}
|
|
67
|
-
</p>
|
|
68
|
-
</section>
|
|
69
|
-
);
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const CheckboxFilter: Story = {
|
|
74
|
-
render: () => {
|
|
75
|
-
const { filters } = useFilters<{
|
|
76
|
-
isChecked: boolean;
|
|
77
|
-
}>();
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<section className="flex flex-col gap-2">
|
|
81
|
-
<Filter
|
|
82
|
-
type="checkbox"
|
|
83
|
-
paramKey="isChecked"
|
|
84
|
-
checkboxProps={{ children: "Is Checked ?" }}
|
|
85
|
-
/>
|
|
86
|
-
|
|
87
|
-
<p className="text-gray-500 text-xs">
|
|
88
|
-
<span>Result: </span>
|
|
89
|
-
<span className="text-gray-500">
|
|
90
|
-
{filters?.isChecked ? "Yes" : "No"}
|
|
91
|
-
</span>
|
|
92
|
-
</p>
|
|
93
|
-
</section>
|
|
94
|
-
);
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const AutocompleteFilter: Story = {
|
|
99
|
-
render: () => {
|
|
100
|
-
const { filters } = useFilters<{
|
|
101
|
-
autocomplete: string;
|
|
102
|
-
}>();
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<section className="flex flex-col gap-2">
|
|
106
|
-
<Filter
|
|
107
|
-
type="autocomplete"
|
|
108
|
-
paramKey="autocomplete"
|
|
109
|
-
autocompleteProps={{ label: "Autocomplete" }}
|
|
110
|
-
options={filterOptions}
|
|
111
|
-
/>
|
|
112
|
-
|
|
113
|
-
<p className="text-gray-500 text-xs">
|
|
114
|
-
{filters?.autocomplete || "No filter applied"}
|
|
115
|
-
</p>
|
|
116
|
-
</section>
|
|
117
|
-
);
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const DateFilter: Story = {
|
|
122
|
-
render: () => {
|
|
123
|
-
const { filters } = useFilters<{
|
|
124
|
-
date: string;
|
|
125
|
-
}>();
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<section className="flex flex-col gap-2">
|
|
129
|
-
<Filter
|
|
130
|
-
type="date"
|
|
131
|
-
paramKey="date"
|
|
132
|
-
dateProps={{ label: "Select date" }}
|
|
133
|
-
/>
|
|
134
|
-
|
|
135
|
-
<p className="text-gray-500 text-xs">
|
|
136
|
-
{filters?.date || "No filter applied"}
|
|
137
|
-
</p>
|
|
138
|
-
</section>
|
|
139
|
-
);
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const NumericFilter: Story = {
|
|
144
|
-
render: () => {
|
|
145
|
-
const { filters } = useFilters<{
|
|
146
|
-
numeric: string;
|
|
147
|
-
}>();
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<section className="flex flex-col gap-2">
|
|
151
|
-
<Filter
|
|
152
|
-
type="numeric"
|
|
153
|
-
paramKey="numeric"
|
|
154
|
-
numericProps={{ label: "Enter number", placeholder: "0" }}
|
|
155
|
-
/>
|
|
156
|
-
|
|
157
|
-
<p className="text-gray-500 text-xs">
|
|
158
|
-
{filters?.numeric || "No filter applied"}
|
|
159
|
-
</p>
|
|
160
|
-
</section>
|
|
161
|
-
);
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export const CheckboxGroupFilter: Story = {
|
|
166
|
-
render: () => {
|
|
167
|
-
const { filters } = useFilters<{
|
|
168
|
-
categories: string;
|
|
169
|
-
}>();
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<section className="flex flex-col gap-2">
|
|
173
|
-
<Filter
|
|
174
|
-
type="checkboxGroup"
|
|
175
|
-
paramKey="categories"
|
|
176
|
-
checkboxGroupProps={{ label: "Categories" }}
|
|
177
|
-
options={filterOptions}
|
|
178
|
-
/>
|
|
179
|
-
|
|
180
|
-
<p className="text-gray-500 text-xs">
|
|
181
|
-
{filters?.categories || "No filter applied"}
|
|
182
|
-
</p>
|
|
183
|
-
</section>
|
|
184
|
-
);
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export const SwitchFilter: Story = {
|
|
189
|
-
render: () => {
|
|
190
|
-
const { filters } = useFilters<{
|
|
191
|
-
enabled: boolean;
|
|
192
|
-
}>();
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<section className="flex flex-col gap-2">
|
|
196
|
-
<Filter
|
|
197
|
-
type="switch"
|
|
198
|
-
paramKey="enabled"
|
|
199
|
-
switchProps={{ children: "Enabled ?" }}
|
|
200
|
-
/>
|
|
201
|
-
|
|
202
|
-
<p className="text-gray-500 text-xs">
|
|
203
|
-
<span>Result: </span>
|
|
204
|
-
<span className="text-gray-500">
|
|
205
|
-
{filters?.enabled ? "Yes" : "No"}
|
|
206
|
-
</span>
|
|
207
|
-
</p>
|
|
208
|
-
</section>
|
|
209
|
-
);
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
export const RangeFilter: Story = {
|
|
214
|
-
render: () => {
|
|
215
|
-
const { filters } = useFilters<{
|
|
216
|
-
range: string;
|
|
217
|
-
}>();
|
|
218
|
-
|
|
219
|
-
return (
|
|
220
|
-
<section className="flex flex-col gap-2">
|
|
221
|
-
<Filter
|
|
222
|
-
type="range"
|
|
223
|
-
paramKey="range"
|
|
224
|
-
rangeProps={{
|
|
225
|
-
label: "Value",
|
|
226
|
-
minValue: 0,
|
|
227
|
-
maxValue: 100,
|
|
228
|
-
step: 1,
|
|
229
|
-
}}
|
|
230
|
-
/>
|
|
231
|
-
|
|
232
|
-
<p className="text-gray-500 text-xs">
|
|
233
|
-
{filters?.range ?? "No filter applied"}
|
|
234
|
-
</p>
|
|
235
|
-
</section>
|
|
236
|
-
);
|
|
237
|
-
},
|
|
238
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { cva } from "class-variance-authority";
|
|
2
|
-
|
|
3
|
-
export const filterClasses = cva([""], {
|
|
4
|
-
variants: {
|
|
5
|
-
type: {
|
|
6
|
-
search: "",
|
|
7
|
-
select: "",
|
|
8
|
-
autocomplete: "",
|
|
9
|
-
date: "",
|
|
10
|
-
numeric: "",
|
|
11
|
-
checkbox: "",
|
|
12
|
-
checkboxGroup: "",
|
|
13
|
-
radio: "",
|
|
14
|
-
switch: "",
|
|
15
|
-
range: "",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
defaultVariants: {},
|
|
19
|
-
compoundVariants: [],
|
|
20
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./classes";
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { FilterProps } from "@/types";
|
|
4
|
-
import { filterClasses } from "@/components";
|
|
5
|
-
import { Autocomplete, AutocompleteItem } from "@heroui/autocomplete";
|
|
6
|
-
import { cn } from "@/utils";
|
|
7
|
-
import { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
8
|
-
|
|
9
|
-
export function AutocompleteFilter({
|
|
10
|
-
classNames,
|
|
11
|
-
autocompleteProps,
|
|
12
|
-
autocompleteItemProps,
|
|
13
|
-
paramKey,
|
|
14
|
-
options,
|
|
15
|
-
}: Pick<
|
|
16
|
-
FilterProps,
|
|
17
|
-
| "classNames"
|
|
18
|
-
| "autocompleteProps"
|
|
19
|
-
| "autocompleteItemProps"
|
|
20
|
-
| "paramKey"
|
|
21
|
-
| "options"
|
|
22
|
-
>) {
|
|
23
|
-
const { config } = useEmperorUI();
|
|
24
|
-
|
|
25
|
-
const theme = config?.theme?.components?.autocomplete;
|
|
26
|
-
const themeItem = config?.theme?.components?.autocompleteItem;
|
|
27
|
-
|
|
28
|
-
const { getParam, setParams } = useSearchParamsHandler();
|
|
29
|
-
const value = getParam(paramKey);
|
|
30
|
-
|
|
31
|
-
if (!options?.length)
|
|
32
|
-
throw new Error(
|
|
33
|
-
"Filter with type 'autocomplete' must have 'options' property.",
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<Autocomplete
|
|
38
|
-
{...theme}
|
|
39
|
-
{...autocompleteProps}
|
|
40
|
-
selectedKey={value || null}
|
|
41
|
-
onSelectionChange={(selectedKey) =>
|
|
42
|
-
setParams({
|
|
43
|
-
params: {
|
|
44
|
-
[paramKey]: selectedKey ? String(selectedKey) : undefined,
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
className={cn(filterClasses({ type: "autocomplete" }), classNames?.field)}
|
|
49
|
-
classNames={{
|
|
50
|
-
base: "min-w-40",
|
|
51
|
-
...theme?.classNames,
|
|
52
|
-
...autocompleteProps?.classNames,
|
|
53
|
-
}}
|
|
54
|
-
>
|
|
55
|
-
{(options || [])?.map((option) => (
|
|
56
|
-
<AutocompleteItem
|
|
57
|
-
key={option.key}
|
|
58
|
-
{...themeItem}
|
|
59
|
-
{...autocompleteItemProps}
|
|
60
|
-
>
|
|
61
|
-
{option.label}
|
|
62
|
-
</AutocompleteItem>
|
|
63
|
-
))}
|
|
64
|
-
</Autocomplete>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { FilterProps } from "@/types";
|
|
4
|
-
import { filterClasses } from "@/components";
|
|
5
|
-
import { Checkbox } from "@heroui/checkbox";
|
|
6
|
-
import { cn } from "@/utils";
|
|
7
|
-
import { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
8
|
-
import { useMemo } from "react";
|
|
9
|
-
|
|
10
|
-
export function CheckboxFilter({
|
|
11
|
-
classNames,
|
|
12
|
-
checkboxProps,
|
|
13
|
-
paramKey,
|
|
14
|
-
}: Pick<FilterProps, "classNames" | "checkboxProps" | "paramKey">) {
|
|
15
|
-
const { config } = useEmperorUI();
|
|
16
|
-
|
|
17
|
-
const theme = config?.theme?.components?.checkbox;
|
|
18
|
-
|
|
19
|
-
const { getParam, setParams } = useSearchParamsHandler();
|
|
20
|
-
|
|
21
|
-
const { isSelected } = useMemo(() => {
|
|
22
|
-
const value = getParam(paramKey);
|
|
23
|
-
const isSelected = value === "true" || value === "1" || value === "yes";
|
|
24
|
-
|
|
25
|
-
return { value, isSelected };
|
|
26
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
-
}, [paramKey]);
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Checkbox
|
|
31
|
-
{...theme}
|
|
32
|
-
{...checkboxProps}
|
|
33
|
-
isSelected={isSelected}
|
|
34
|
-
onValueChange={(selected) =>
|
|
35
|
-
setParams({
|
|
36
|
-
params: { [paramKey]: selected ? "true" : undefined },
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
className={cn(filterClasses({ type: "checkbox" }), classNames?.field)}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { FilterProps } from "@/types";
|
|
4
|
-
import { filterClasses } from "@/components";
|
|
5
|
-
import { Checkbox, CheckboxGroup } from "@heroui/checkbox";
|
|
6
|
-
import { cn } from "@/utils";
|
|
7
|
-
import { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
8
|
-
import { useMemo } from "storybook/internal/preview-api";
|
|
9
|
-
|
|
10
|
-
export function CheckboxGroupFilter({
|
|
11
|
-
classNames,
|
|
12
|
-
checkboxGroupProps,
|
|
13
|
-
paramKey,
|
|
14
|
-
options,
|
|
15
|
-
}: Pick<
|
|
16
|
-
FilterProps,
|
|
17
|
-
"classNames" | "checkboxGroupProps" | "paramKey" | "options"
|
|
18
|
-
>) {
|
|
19
|
-
const { config } = useEmperorUI();
|
|
20
|
-
|
|
21
|
-
const themeCheckboxGroup = config?.theme?.components?.checkboxGroup;
|
|
22
|
-
const themeCheckbox = config?.theme?.components?.checkbox;
|
|
23
|
-
|
|
24
|
-
const { getParam, setParams } = useSearchParamsHandler();
|
|
25
|
-
|
|
26
|
-
const { value } = useMemo(() => {
|
|
27
|
-
const valueStr = getParam(paramKey);
|
|
28
|
-
const value = valueStr ? valueStr.split(",").filter(Boolean) : [];
|
|
29
|
-
|
|
30
|
-
return { value };
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
}, [paramKey]);
|
|
33
|
-
|
|
34
|
-
if (!options?.length)
|
|
35
|
-
throw new Error(
|
|
36
|
-
"Filter with type 'checkboxGroup' must have 'options' property.",
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<CheckboxGroup
|
|
41
|
-
{...themeCheckboxGroup}
|
|
42
|
-
{...checkboxGroupProps}
|
|
43
|
-
value={value}
|
|
44
|
-
onValueChange={(values) =>
|
|
45
|
-
setParams({
|
|
46
|
-
params: {
|
|
47
|
-
[paramKey]: values.length > 0 ? values.join(",") : undefined,
|
|
48
|
-
},
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
classNames={{
|
|
52
|
-
label: "font-semibold",
|
|
53
|
-
...themeCheckboxGroup?.classNames,
|
|
54
|
-
...checkboxGroupProps?.classNames,
|
|
55
|
-
}}
|
|
56
|
-
className={cn(
|
|
57
|
-
filterClasses({ type: "checkboxGroup" }),
|
|
58
|
-
classNames?.field,
|
|
59
|
-
)}
|
|
60
|
-
>
|
|
61
|
-
{options.map((option) => (
|
|
62
|
-
<Checkbox key={option.key} {...themeCheckbox} value={option.key}>
|
|
63
|
-
{option.label}
|
|
64
|
-
</Checkbox>
|
|
65
|
-
))}
|
|
66
|
-
</CheckboxGroup>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { FilterProps } from "@/types";
|
|
4
|
-
import { filterClasses } from "@/components";
|
|
5
|
-
import { DatePicker } from "@heroui/date-picker";
|
|
6
|
-
import { cn } from "@/utils";
|
|
7
|
-
import { parseDate } from "@internationalized/date";
|
|
8
|
-
import { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
9
|
-
|
|
10
|
-
export function DateFilter({
|
|
11
|
-
classNames,
|
|
12
|
-
dateProps,
|
|
13
|
-
paramKey,
|
|
14
|
-
}: Pick<FilterProps, "classNames" | "dateProps" | "paramKey">) {
|
|
15
|
-
const { getParam, setParams } = useSearchParamsHandler();
|
|
16
|
-
const { config } = useEmperorUI();
|
|
17
|
-
|
|
18
|
-
const theme = config?.theme?.components?.datePicker;
|
|
19
|
-
|
|
20
|
-
const valueStr = getParam(paramKey);
|
|
21
|
-
const value =
|
|
22
|
-
valueStr && /^\d{4}-\d{2}-\d{2}$/.test(valueStr)
|
|
23
|
-
? parseDate(valueStr)
|
|
24
|
-
: null;
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<DatePicker
|
|
28
|
-
{...theme}
|
|
29
|
-
{...dateProps}
|
|
30
|
-
value={value}
|
|
31
|
-
onChange={(date) =>
|
|
32
|
-
setParams({
|
|
33
|
-
params: {
|
|
34
|
-
[paramKey]: date ? String(date) : undefined,
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
className={cn(filterClasses({ type: "date" }), classNames?.field)}
|
|
39
|
-
classNames={{
|
|
40
|
-
label: "font-semibold",
|
|
41
|
-
...theme?.classNames,
|
|
42
|
-
...dateProps?.classNames,
|
|
43
|
-
}}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./search-filter";
|
|
2
|
-
export * from "./select-filter";
|
|
3
|
-
export * from "./autocomplete-filter";
|
|
4
|
-
export * from "./date-filter";
|
|
5
|
-
export * from "./numeric-filter";
|
|
6
|
-
export * from "./checkbox-filter";
|
|
7
|
-
export * from "./checkbox-group-filter";
|
|
8
|
-
export * from "./switch-filter";
|
|
9
|
-
export * from "./range-filter";
|
|
@@ -1,41 +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 { useEmperorUI, useSearchParamsHandler } from "@/hooks";
|
|
8
|
-
|
|
9
|
-
export function NumericFilter({
|
|
10
|
-
classNames,
|
|
11
|
-
numericProps,
|
|
12
|
-
paramKey,
|
|
13
|
-
}: Pick<FilterProps, "classNames" | "numericProps" | "paramKey">) {
|
|
14
|
-
const { getParam, setParams } = useSearchParamsHandler();
|
|
15
|
-
const { config } = useEmperorUI();
|
|
16
|
-
|
|
17
|
-
const theme = config?.theme?.components?.input;
|
|
18
|
-
|
|
19
|
-
const value = getParam(paramKey);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<Input
|
|
23
|
-
{...theme}
|
|
24
|
-
{...numericProps}
|
|
25
|
-
type="number"
|
|
26
|
-
value={value ?? ""}
|
|
27
|
-
onValueChange={(v) =>
|
|
28
|
-
setParams({
|
|
29
|
-
params: { [paramKey]: v || undefined },
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
className={cn(filterClasses({ type: "numeric" }), classNames?.field)}
|
|
33
|
-
classNames={{
|
|
34
|
-
input: "min-w-40",
|
|
35
|
-
label: "font-semibold",
|
|
36
|
-
...theme?.classNames,
|
|
37
|
-
...numericProps?.classNames,
|
|
38
|
-
}}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
}
|