bmdl-sdk 1.5.9 → 2.0.1
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/.prettierrc +37 -0
- package/bin/dev.js +10 -8
- package/bin/init.js +2 -1
- package/bmdl-sdk-2.0.1.tgz +0 -0
- package/global.d.ts +9 -0
- package/next.config.ts +35 -0
- package/package.json +35 -8
- package/postcss.config.mjs +5 -0
- package/public/favicon.ico +0 -0
- package/public/images/bg/404.bg.dark.png +0 -0
- package/public/images/bg/404.bg.png +0 -0
- package/public/images/bg/maintenance.bg.dark.png +0 -0
- package/public/images/bg/maintenance.bg.png +0 -0
- package/public/images/bg/not-authorized.bg.dark.png +0 -0
- package/public/images/bg/not-authorized.bg.png +0 -0
- package/public/images/bg/redirect.bg.dark.png +0 -0
- package/public/images/bg/redirect.bg.png +0 -0
- package/public/images/cover/email-verify.cover.dark.png +0 -0
- package/public/images/cover/email-verify.cover.png +0 -0
- package/public/images/cover/login.cover.dark.png +0 -0
- package/public/images/cover/login.cover.png +0 -0
- package/public/images/cover/password-forgot.cover.dark.png +0 -0
- package/public/images/cover/password-forgot.cover.png +0 -0
- package/public/images/cover/password-reset.cover.dark.png +0 -0
- package/public/images/cover/password-reset.cover.png +0 -0
- package/public/images/cover/register.cover.dark.png +0 -0
- package/public/images/cover/register.cover.png +0 -0
- package/public/images/cover/two-factor-verify.cover.dark.png +0 -0
- package/public/images/cover/two-factor-verify.cover.png +0 -0
- package/public/images/lang/en.png +0 -0
- package/public/images/lang/ru.png +0 -0
- package/public/locales/en/datasets.json +92 -0
- package/public/locales/en/errors.json +402 -0
- package/public/locales/en/general.json +139 -0
- package/public/locales/ru/datasets.json +92 -0
- package/public/locales/ru/errors.json +406 -0
- package/public/locales/ru/general.json +139 -0
- package/src/app/datasets/page.tsx +25 -0
- package/src/app/layout.tsx +45 -0
- package/src/app/not-found.tsx +34 -0
- package/src/app/page.tsx +24 -0
- package/src/components/atoms/Actions/Actions.styles.ts +31 -0
- package/src/components/atoms/Actions/Actions.tsx +45 -0
- package/src/components/atoms/Actions/index.ts +1 -0
- package/src/components/atoms/Avatar/Avatar.styles.ts +95 -0
- package/src/components/atoms/Avatar/Avatar.tsx +46 -0
- package/src/components/atoms/Avatar/index.ts +1 -0
- package/src/components/atoms/Badge/Badge.styles.ts +93 -0
- package/src/components/atoms/Badge/Badge.tsx +31 -0
- package/src/components/atoms/Badge/index.ts +1 -0
- package/src/components/atoms/Button/Button.styles.ts +189 -0
- package/src/components/atoms/Button/Button.tsx +29 -0
- package/src/components/atoms/Button/index.ts +1 -0
- package/src/components/atoms/Calendar/Calendar.styles.ts +227 -0
- package/src/components/atoms/Calendar/Calendar.tsx +96 -0
- package/src/components/atoms/Calendar/index.ts +1 -0
- package/src/components/atoms/Checkbox/Checkbox.styles.ts +37 -0
- package/src/components/atoms/Checkbox/Checkbox.tsx +26 -0
- package/src/components/atoms/Checkbox/index.ts +1 -0
- package/src/components/atoms/Date/Date.styles.ts +6 -0
- package/src/components/atoms/Date/Date.tsx +27 -0
- package/src/components/atoms/Date/index.ts +1 -0
- package/src/components/atoms/DatePicker/DatePicker.styles.ts +53 -0
- package/src/components/atoms/DatePicker/DatePicker.tsx +114 -0
- package/src/components/atoms/DatePicker/DatePicker.utils.tsx +49 -0
- package/src/components/atoms/DatePicker/index.ts +1 -0
- package/src/components/atoms/Dialog/Dialog.styles.ts +71 -0
- package/src/components/atoms/Dialog/Dialog.tsx +55 -0
- package/src/components/atoms/Dialog/index.ts +1 -0
- package/src/components/atoms/Dropdown/Divider/Divider.styles.ts +8 -0
- package/src/components/atoms/Dropdown/Divider/Divider.tsx +14 -0
- package/src/components/atoms/Dropdown/Divider/index.ts +1 -0
- package/src/components/atoms/Dropdown/Dropdown.styles.ts +31 -0
- package/src/components/atoms/Dropdown/Dropdown.tsx +48 -0
- package/src/components/atoms/Dropdown/Item/Item.styles.ts +12 -0
- package/src/components/atoms/Dropdown/Item/Item.tsx +18 -0
- package/src/components/atoms/Dropdown/Item/index.ts +1 -0
- package/src/components/atoms/Dropdown/index.ts +1 -0
- package/src/components/atoms/Form/Form.styles.ts +23 -0
- package/src/components/atoms/Form/Form.tsx +21 -0
- package/src/components/atoms/Form/Item/Item.styles.ts +23 -0
- package/src/components/atoms/Form/Item/Item.tsx +11 -0
- package/src/components/atoms/Form/Item/index.ts +1 -0
- package/src/components/atoms/Form/Label/Label.tsx +11 -0
- package/src/components/atoms/Form/Label/index.ts +1 -0
- package/src/components/atoms/Form/Message/Message.tsx +29 -0
- package/src/components/atoms/Form/Message/index.ts +1 -0
- package/src/components/atoms/Form/index.ts +1 -0
- package/src/components/atoms/Input/Email/Email.tsx +11 -0
- package/src/components/atoms/Input/Email/index.ts +1 -0
- package/src/components/atoms/Input/Input.styles.ts +77 -0
- package/src/components/atoms/Input/Input.tsx +29 -0
- package/src/components/atoms/Input/Number/Number.tsx +12 -0
- package/src/components/atoms/Input/Number/index.ts +1 -0
- package/src/components/atoms/Input/OTP/OTP.styles.ts +30 -0
- package/src/components/atoms/Input/OTP/OTP.tsx +23 -0
- package/src/components/atoms/Input/OTP/index.ts +1 -0
- package/src/components/atoms/Input/Password/Password.tsx +11 -0
- package/src/components/atoms/Input/Password/index.ts +1 -0
- package/src/components/atoms/Input/Search/Search.tsx +12 -0
- package/src/components/atoms/Input/Search/index.ts +1 -0
- package/src/components/atoms/Input/index.ts +1 -0
- package/src/components/atoms/Label/Label.styles.ts +29 -0
- package/src/components/atoms/Label/Label.tsx +18 -0
- package/src/components/atoms/Label/index.ts +1 -0
- package/src/components/atoms/Logo/Logo.styles.ts +16 -0
- package/src/components/atoms/Logo/Logo.tsx +20 -0
- package/src/components/atoms/Logo/index.ts +1 -0
- package/src/components/atoms/Pagination/Pagination.styles.ts +77 -0
- package/src/components/atoms/Pagination/Pagination.tsx +131 -0
- package/src/components/atoms/Pagination/index.ts +1 -0
- package/src/components/atoms/Popover/Popover.styles.ts +28 -0
- package/src/components/atoms/Popover/Popover.tsx +46 -0
- package/src/components/atoms/Popover/index.ts +1 -0
- package/src/components/atoms/Radio/Item/Item.styles.ts +35 -0
- package/src/components/atoms/Radio/Item/Item.tsx +18 -0
- package/src/components/atoms/Radio/Item/index.ts +1 -0
- package/src/components/atoms/Radio/Radio.styles.ts +25 -0
- package/src/components/atoms/Radio/Radio.tsx +21 -0
- package/src/components/atoms/Radio/index.ts +1 -0
- package/src/components/atoms/RangeNumber/RangeNumber.tsx +33 -0
- package/src/components/atoms/RangeNumber/index.ts +1 -0
- package/src/components/atoms/Select/Item/Item.styles.ts +22 -0
- package/src/components/atoms/Select/Item/Item.tsx +17 -0
- package/src/components/atoms/Select/Item/index.ts +1 -0
- package/src/components/atoms/Select/Select.styles.ts +149 -0
- package/src/components/atoms/Select/Select.tsx +68 -0
- package/src/components/atoms/Select/index.ts +1 -0
- package/src/components/atoms/Separator/Separator.styles.ts +13 -0
- package/src/components/atoms/Separator/Separator.tsx +20 -0
- package/src/components/atoms/Separator/index.ts +1 -0
- package/src/components/atoms/Sheet/Sheet.styles.ts +100 -0
- package/src/components/atoms/Sheet/Sheet.tsx +53 -0
- package/src/components/atoms/Sheet/index.ts +1 -0
- package/src/components/atoms/Skeleton/Skeleton.styles.ts +30 -0
- package/src/components/atoms/Skeleton/Skeleton.tsx +11 -0
- package/src/components/atoms/Skeleton/index.ts +1 -0
- package/src/components/atoms/Spin/Spin.styles.ts +17 -0
- package/src/components/atoms/Spin/Spin.tsx +19 -0
- package/src/components/atoms/Spin/index.ts +1 -0
- package/src/components/atoms/Switch/Switch.styles.ts +34 -0
- package/src/components/atoms/Switch/Switch.tsx +20 -0
- package/src/components/atoms/Switch/index.ts +1 -0
- package/src/components/atoms/Table/FilterContent/FilterContent.styles.ts +33 -0
- package/src/components/atoms/Table/FilterContent/FilterContent.tsx +300 -0
- package/src/components/atoms/Table/FilterContent/index.ts +1 -0
- package/src/components/atoms/Table/FilterIcon/FilterIcon.tsx +16 -0
- package/src/components/atoms/Table/FilterIcon/index.ts +1 -0
- package/src/components/atoms/Table/SortIcon/SortIcon.tsx +32 -0
- package/src/components/atoms/Table/SortIcon/index.ts +1 -0
- package/src/components/atoms/Table/Table.styles.ts +178 -0
- package/src/components/atoms/Table/Table.tsx +484 -0
- package/src/components/atoms/Table/Table.utils.tsx +19 -0
- package/src/components/atoms/Table/index.ts +1 -0
- package/src/components/atoms/Tabs/Tabs.tsx +15 -0
- package/src/components/atoms/Tabs/index.ts +1 -0
- package/src/components/atoms/Textarea/Textarea.styles.ts +64 -0
- package/src/components/atoms/Textarea/Textarea.tsx +15 -0
- package/src/components/atoms/Textarea/index.ts +1 -0
- package/src/components/atoms/Toast/Toast.styles.ts +35 -0
- package/src/components/atoms/Toast/Toast.tsx +85 -0
- package/src/components/atoms/Toast/Toast.utils.tsx +43 -0
- package/src/components/atoms/Toast/index.ts +1 -0
- package/src/components/atoms/Tooltip/Tooltip.styles.ts +33 -0
- package/src/components/atoms/Tooltip/Tooltip.tsx +32 -0
- package/src/components/atoms/Tooltip/index.ts +1 -0
- package/src/components/atoms/Typography/Display/Display.styles.ts +26 -0
- package/src/components/atoms/Typography/Display/Display.tsx +11 -0
- package/src/components/atoms/Typography/Display/index.ts +1 -0
- package/src/components/atoms/Typography/Link/Link.styles.ts +32 -0
- package/src/components/atoms/Typography/Link/Link.tsx +25 -0
- package/src/components/atoms/Typography/Link/index.ts +1 -0
- package/src/components/atoms/Typography/Paragraph/Paragraph.styles.ts +32 -0
- package/src/components/atoms/Typography/Paragraph/Paragraph.tsx +11 -0
- package/src/components/atoms/Typography/Paragraph/index.ts +1 -0
- package/src/components/atoms/Typography/Text/Text.styles.ts +39 -0
- package/src/components/atoms/Typography/Text/Text.tsx +25 -0
- package/src/components/atoms/Typography/Text/index.ts +1 -0
- package/src/components/atoms/Typography/Title/Title.styles.ts +28 -0
- package/src/components/atoms/Typography/Title/Title.tsx +15 -0
- package/src/components/atoms/Typography/Title/index.ts +1 -0
- package/src/components/atoms/Typography/Typography.tsx +21 -0
- package/src/components/atoms/Typography/index.ts +1 -0
- package/src/components/atoms/icons/AvanpostIcon.tsx +31 -0
- package/src/components/atoms/icons/CheckIcon.tsx +22 -0
- package/src/components/atoms/icons/EmptyIcon.tsx +56 -0
- package/src/components/atoms/icons/LogoIcon.tsx +141 -0
- package/src/components/atoms/icons/NumberTypeIcon.tsx +25 -0
- package/src/components/atoms/icons/SidebarCloseIcon.tsx +75 -0
- package/src/components/atoms/icons/index.ts +6 -0
- package/src/components/atoms/index.ts +31 -0
- package/src/components/molecules/DataTable/CreationModal/CreationModal.tsx +31 -0
- package/src/components/molecules/DataTable/CreationModal/index.ts +1 -0
- package/src/components/molecules/DataTable/DataTable.styles.ts +23 -0
- package/src/components/molecules/DataTable/DataTable.tsx +167 -0
- package/src/components/molecules/DataTable/Name/Name.tsx +20 -0
- package/src/components/molecules/DataTable/Name/index.ts +1 -0
- package/src/components/molecules/DataTable/Skeleton/Skeleton.tsx +27 -0
- package/src/components/molecules/DataTable/Skeleton/index.ts +6 -0
- package/src/components/molecules/DataTable/index.ts +8 -0
- package/src/components/molecules/Header/Button/Button.styles.ts +24 -0
- package/src/components/molecules/Header/Button/Button.tsx +20 -0
- package/src/components/molecules/Header/Button/index.ts +1 -0
- package/src/components/molecules/Header/Header.styles.ts +16 -0
- package/src/components/molecules/Header/Header.tsx +20 -0
- package/src/components/molecules/Header/Navigate/Navigate.tsx +40 -0
- package/src/components/molecules/Header/Navigate/index.ts +1 -0
- package/src/components/molecules/Header/SelectLang/SelectLang.tsx +47 -0
- package/src/components/molecules/Header/SelectLang/index.ts +2 -0
- package/src/components/molecules/Header/SelectTheme/SelectTheme.tsx +43 -0
- package/src/components/molecules/Header/SelectTheme/index.ts +1 -0
- package/src/components/molecules/Header/index.ts +2 -0
- package/src/components/molecules/ProjectIcon/ProjectIcon.styles.ts +23 -0
- package/src/components/molecules/ProjectIcon/ProjectIcon.tsx +37 -0
- package/src/components/molecules/ProjectIcon/index.ts +1 -0
- package/src/components/molecules/Sidebar/Item/Item.styles.ts +52 -0
- package/src/components/molecules/Sidebar/Item/Item.tsx +30 -0
- package/src/components/molecules/Sidebar/Item/index.ts +1 -0
- package/src/components/molecules/Sidebar/Sidebar.styles.ts +97 -0
- package/src/components/molecules/Sidebar/Sidebar.tsx +122 -0
- package/src/components/molecules/Sidebar/Sidebar.utils.tsx +36 -0
- package/src/components/molecules/Sidebar/Trigger/Trigger.tsx +23 -0
- package/src/components/molecules/Sidebar/Trigger/index.ts +1 -0
- package/src/components/molecules/Sidebar/index.ts +1 -0
- package/src/components/molecules/Widget/Content/Content.tsx +80 -0
- package/src/components/molecules/Widget/Content/index.ts +1 -0
- package/src/components/molecules/Widget/Toolbox/Toolbox.tsx +0 -0
- package/src/components/molecules/Widget/Toolbox/index.ts +0 -0
- package/src/components/molecules/Widget/Widget.tsx +26 -0
- package/src/components/molecules/Widget/Widget.utils.tsx +31 -0
- package/src/components/molecules/Widget/index.ts +2 -0
- package/src/components/molecules/index.ts +6 -0
- package/src/components/organisms/ComponentWidget/ComponentWidget.tsx +9 -0
- package/src/components/organisms/ComponentWidget/index.ts +2 -0
- package/src/components/organisms/DatasetsTable/Creation/Creation.tsx +105 -0
- package/src/components/organisms/DatasetsTable/Creation/Navigate/Navigate.tsx +59 -0
- package/src/components/organisms/DatasetsTable/Creation/Navigate/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Creation/Step/Step.styles.ts +12 -0
- package/src/components/organisms/DatasetsTable/Creation/Step/Step.tsx +43 -0
- package/src/components/organisms/DatasetsTable/Creation/Step/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step1/Step1.styles.ts +41 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step1/Step1.tsx +67 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step1/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step2/SelectSource/SelectSource.tsx +252 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step2/SelectSource/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step2/Step2.tsx +11 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step2/UploadFile/UploadFile.tsx +112 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step2/UploadFile/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step2/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step3/Step3.tsx +145 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step3/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step4/Step4.tsx +120 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/Step4/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Creation/Steps/index.ts +4 -0
- package/src/components/organisms/DatasetsTable/Creation/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/DatasetsTable.tsx +81 -0
- package/src/components/organisms/DatasetsTable/DatasetsTable.utils.tsx +125 -0
- package/src/components/organisms/DatasetsTable/Source/Source.styles.ts +7 -0
- package/src/components/organisms/DatasetsTable/Source/Source.tsx +39 -0
- package/src/components/organisms/DatasetsTable/Source/Source.utils.tsx +45 -0
- package/src/components/organisms/DatasetsTable/Source/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Status/Status.styles.ts +25 -0
- package/src/components/organisms/DatasetsTable/Status/Status.tsx +29 -0
- package/src/components/organisms/DatasetsTable/Status/Status.utils.tsx +29 -0
- package/src/components/organisms/DatasetsTable/Status/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/Type/Type.styles.ts +7 -0
- package/src/components/organisms/DatasetsTable/Type/Type.tsx +32 -0
- package/src/components/organisms/DatasetsTable/Type/Type.utils.tsx +14 -0
- package/src/components/organisms/DatasetsTable/Type/index.ts +1 -0
- package/src/components/organisms/DatasetsTable/index.ts +1 -0
- package/src/components/organisms/index.ts +3 -0
- package/src/components/templates/DefaultLayout/DefaultLayout.styles.ts +26 -0
- package/src/components/templates/DefaultLayout/DefaultLayout.tsx +41 -0
- package/src/components/templates/DefaultLayout/index.ts +1 -0
- package/src/components/templates/PageLayout/PageLayout.styles.ts +25 -0
- package/src/components/templates/PageLayout/PageLayout.tsx +28 -0
- package/src/components/templates/PageLayout/index.ts +1 -0
- package/src/components/templates/index.ts +3 -0
- package/src/config/i18n.config.ts +46 -0
- package/src/constants/index.ts +10 -0
- package/src/contexts/CreateComponentContext/CreateComponentContext.tsx +17 -0
- package/src/contexts/CreateComponentContext/index.ts +4 -0
- package/src/contexts/CreateDatasetContext/CreateDatasetContext.tsx +25 -0
- package/src/contexts/CreateDatasetContext/index.ts +4 -0
- package/src/contexts/ProjectContext/ProjectContext.tsx +32 -0
- package/src/contexts/ProjectContext/index.ts +1 -0
- package/src/contexts/SidebarContext/SidebarContext.tsx +10 -0
- package/src/contexts/SidebarContext/index.ts +1 -0
- package/src/contexts/index.ts +10 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useCreateComponent.ts +15 -0
- package/src/hooks/useCreateDataset.ts +15 -0
- package/src/hooks/useDebounce.ts +17 -0
- package/src/hooks/useDebounced.ts +31 -0
- package/src/hooks/useIsMobile.ts +27 -0
- package/src/hooks/useSidebar.ts +15 -0
- package/src/hooks/useStickyHeader.ts +35 -0
- package/src/hooks/useWindowSize.ts +27 -0
- package/src/providers/CreateComponentProvider/CreateComponentProvider.tsx +53 -0
- package/src/providers/CreateComponentProvider/index.ts +1 -0
- package/src/providers/CreateDatasetProvider/CreateDatasetProvider.tsx +73 -0
- package/src/providers/CreateDatasetProvider/index.ts +1 -0
- package/src/providers/LangProvider/LangProvider.tsx +15 -0
- package/src/providers/LangProvider/index.ts +1 -0
- package/src/providers/ProjectProvider/ProjectProvider.tsx +110 -0
- package/src/providers/ProjectProvider/index.ts +1 -0
- package/src/providers/SidebarProvider/SidebarProvider.tsx +51 -0
- package/src/providers/SidebarProvider/index.ts +1 -0
- package/src/providers/ThemeProvider/ThemeProvider.tsx +20 -0
- package/src/providers/ThemeProvider/index.ts +1 -0
- package/src/providers/index.ts +6 -0
- package/src/store/index.ts +2 -0
- package/src/store/sidebar/sidebar.store.ts +17 -0
- package/src/store/sidebar/sidebar.type.ts +4 -0
- package/src/styles/globals.css +202 -0
- package/src/types/component.type.ts +13 -0
- package/src/types/dataset.type.ts +25 -0
- package/src/types/file.type.ts +13 -0
- package/src/types/general.type.ts +86 -0
- package/src/types/index.ts +9 -0
- package/src/types/layer.type.ts +7 -0
- package/src/types/project.type.ts +15 -0
- package/src/types/user.type.ts +6 -0
- package/src/types/widget.type.ts +12 -0
- package/src/utils/bm.util.ts +150 -0
- package/src/utils/bytes.util.ts +110 -0
- package/src/utils/date.util.ts +49 -0
- package/src/utils/dynamicMessage.util.ts +9 -0
- package/src/utils/getInitials.util.ts +10 -0
- package/src/utils/hideEmail.util.ts +14 -0
- package/src/utils/index.ts +12 -0
- package/src/utils/pagination.util.ts +144 -0
- package/src/utils/twJoin.util.ts +49 -0
- package/src/utils/twMerge.util.ts +6 -0
- package/src/utils/upload.util.ts +26 -0
- package/src/utils/url.util.ts +29 -0
- package/tsconfig.json +40 -6
- package/bmdl-sdk-1.5.9.tgz +0 -0
- package/index.html +0 -12
- package/src/App.tsx +0 -187
- package/src/main.tsx +0 -15
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { CheckedState } from '@radix-ui/react-checkbox'
|
|
4
|
+
import { useTranslations } from 'next-intl'
|
|
5
|
+
import { useRouter } from 'next/navigation'
|
|
6
|
+
import {
|
|
7
|
+
ChangeEvent,
|
|
8
|
+
Dispatch,
|
|
9
|
+
SetStateAction,
|
|
10
|
+
useEffect,
|
|
11
|
+
useState
|
|
12
|
+
} from 'react'
|
|
13
|
+
import { DateRange } from 'react-day-picker'
|
|
14
|
+
|
|
15
|
+
import { Checkbox, Input, Label, Spin } from '@/components/atoms'
|
|
16
|
+
|
|
17
|
+
import { IFilterQuery } from '@/types'
|
|
18
|
+
|
|
19
|
+
import { DatePicker } from '../../DatePicker'
|
|
20
|
+
import { RangeNumber } from '../../RangeNumber'
|
|
21
|
+
import { Typography } from '../../Typography'
|
|
22
|
+
|
|
23
|
+
import { useDebounce } from '@/hooks'
|
|
24
|
+
import { _, addParam, getParam, removeParam } from '@/utils'
|
|
25
|
+
|
|
26
|
+
const { Link } = Typography
|
|
27
|
+
|
|
28
|
+
type FilterContentProps = {
|
|
29
|
+
column: any
|
|
30
|
+
getData: any
|
|
31
|
+
filterQuery: IFilterQuery
|
|
32
|
+
setFilterState: Dispatch<SetStateAction<Record<string, boolean>>>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function FilterContent({
|
|
36
|
+
column,
|
|
37
|
+
getData,
|
|
38
|
+
filterQuery,
|
|
39
|
+
setFilterState
|
|
40
|
+
}: FilterContentProps) {
|
|
41
|
+
const t = useTranslations()
|
|
42
|
+
//
|
|
43
|
+
const router = useRouter()
|
|
44
|
+
//
|
|
45
|
+
const { querykey, queryFn } = filterQuery
|
|
46
|
+
//
|
|
47
|
+
const [q, setQ] = useState<string>()
|
|
48
|
+
const [checkedState, setCheckedState] = useState<Record<string, boolean>>(
|
|
49
|
+
{}
|
|
50
|
+
)
|
|
51
|
+
const [rangeState, setRangeState] = useState<DateRange>()
|
|
52
|
+
const debouncedQ = useDebounce(q, 300)
|
|
53
|
+
//
|
|
54
|
+
const { data, loading, refetch } = queryFn({
|
|
55
|
+
variables: {
|
|
56
|
+
data: {
|
|
57
|
+
column: column.key
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
//
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const filter = getParam('filter')
|
|
64
|
+
const filterValues = filter ? JSON.parse(filter)[column.key] : []
|
|
65
|
+
const isAll = filterValues?.includes('ALL')
|
|
66
|
+
|
|
67
|
+
if (data?.[querykey].data.length) {
|
|
68
|
+
if (
|
|
69
|
+
filterValues?.length === 2 &&
|
|
70
|
+
_.isNumber(filterValues?.[0]) &&
|
|
71
|
+
_.isNumber(filterValues?.[1])
|
|
72
|
+
) {
|
|
73
|
+
setRangeState({
|
|
74
|
+
from: new Date(filterValues[0]),
|
|
75
|
+
to: new Date(filterValues[1])
|
|
76
|
+
})
|
|
77
|
+
} else {
|
|
78
|
+
setCheckedState(
|
|
79
|
+
Object.fromEntries(
|
|
80
|
+
data?.[querykey].data.map((item: any) => [
|
|
81
|
+
item.id,
|
|
82
|
+
isAll || filterValues?.includes(item.id)
|
|
83
|
+
])
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, [data])
|
|
89
|
+
//
|
|
90
|
+
const allChecked =
|
|
91
|
+
Object.values(checkedState).length &&
|
|
92
|
+
Object.values(checkedState).every(Boolean)
|
|
93
|
+
const someChecked = Object.values(checkedState).some(Boolean)
|
|
94
|
+
//
|
|
95
|
+
const onAllCheckedChange = (checked: boolean) => {
|
|
96
|
+
setCheckedState(prev => {
|
|
97
|
+
const newState = Object.keys(prev).reduce(
|
|
98
|
+
(acc, key) => {
|
|
99
|
+
acc[key] = checked
|
|
100
|
+
return acc
|
|
101
|
+
},
|
|
102
|
+
{} as Record<string, boolean>
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
return newState
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const oldFilter = getParam('filter')
|
|
109
|
+
|
|
110
|
+
const newFilter: Record<string, string[]> = {
|
|
111
|
+
...(oldFilter ? JSON.parse(oldFilter) : {})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (checked) {
|
|
115
|
+
newFilter[column.key] = ['ALL']
|
|
116
|
+
} else {
|
|
117
|
+
delete newFilter[column.key]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (Object.values(newFilter).some(f => f.length)) {
|
|
121
|
+
addParam(router, 'filter', JSON.stringify(newFilter))
|
|
122
|
+
} else {
|
|
123
|
+
removeParam(router, 'filter')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setFilterState(prev => {
|
|
127
|
+
prev[column.key] = checked
|
|
128
|
+
|
|
129
|
+
return prev
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
getData({
|
|
133
|
+
filter: newFilter
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
//
|
|
137
|
+
const onCheckedChange = (id: string, checked: CheckedState) => {
|
|
138
|
+
let filterValue: string[] = []
|
|
139
|
+
//
|
|
140
|
+
setCheckedState(prev => {
|
|
141
|
+
const newState = {
|
|
142
|
+
...prev,
|
|
143
|
+
[id]: checked as boolean
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const checkedIds = Object.entries(newState)
|
|
147
|
+
.filter(d => d[1])
|
|
148
|
+
.map(d => d[0])
|
|
149
|
+
|
|
150
|
+
filterValue =
|
|
151
|
+
data?.[querykey].data
|
|
152
|
+
.map((item: any) => item.id)
|
|
153
|
+
.filter((id: string) => checkedIds.includes(id)) || []
|
|
154
|
+
|
|
155
|
+
return newState
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
const oldFilter = getParam('filter')
|
|
159
|
+
|
|
160
|
+
const newFilter: Record<string, string[]> = {
|
|
161
|
+
...(oldFilter ? JSON.parse(oldFilter) : {})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (filterValue.length) {
|
|
165
|
+
newFilter[column.key] = filterValue
|
|
166
|
+
} else {
|
|
167
|
+
delete newFilter[column.key]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (Object.values(newFilter).some(f => f.length)) {
|
|
171
|
+
addParam(router, 'filter', JSON.stringify(newFilter))
|
|
172
|
+
} else {
|
|
173
|
+
removeParam(router, 'filter')
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
setFilterState(prev => {
|
|
177
|
+
prev[column.key] = Boolean(filterValue.length)
|
|
178
|
+
|
|
179
|
+
return prev
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
getData({
|
|
183
|
+
filter: newFilter
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
//
|
|
187
|
+
const { sort: type } = column
|
|
188
|
+
//
|
|
189
|
+
const onChangeValue = (value: DateRange) => {
|
|
190
|
+
const oldFilter = getParam('filter')
|
|
191
|
+
|
|
192
|
+
const newFilter: Record<string, any> = {
|
|
193
|
+
...(oldFilter ? JSON.parse(oldFilter) : {})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (value) {
|
|
197
|
+
newFilter[column.key] = [value.from!.getTime(), value.to!.getTime()]
|
|
198
|
+
} else {
|
|
199
|
+
delete newFilter[column.key]
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (Object.values(newFilter).some(f => f.length || f.from)) {
|
|
203
|
+
addParam(router, 'filter', JSON.stringify(newFilter))
|
|
204
|
+
} else {
|
|
205
|
+
removeParam(router, 'filter')
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
setFilterState(prev => {
|
|
209
|
+
prev[column.key] = Boolean(value)
|
|
210
|
+
|
|
211
|
+
return prev
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
getData({
|
|
215
|
+
filter: newFilter
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
//
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
if (!_.isUndefined(debouncedQ)) {
|
|
221
|
+
refetch({
|
|
222
|
+
data: { column: column.key, q: debouncedQ }
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
}, [debouncedQ])
|
|
226
|
+
//
|
|
227
|
+
return (
|
|
228
|
+
<>
|
|
229
|
+
{type === 'number' ? <RangeNumber size={'sm'} /> : null}
|
|
230
|
+
{type === 'date' ? (
|
|
231
|
+
<DatePicker
|
|
232
|
+
size={'sm'}
|
|
233
|
+
mode={'range'}
|
|
234
|
+
onSelect={value => onChangeValue(value!)}
|
|
235
|
+
defaultOpen={{ isOpen: true, delay: 100 }}
|
|
236
|
+
defaultSelected={rangeState}
|
|
237
|
+
/>
|
|
238
|
+
) : null}
|
|
239
|
+
{type === 'string' ? (
|
|
240
|
+
<Input.Search
|
|
241
|
+
value={q || ''}
|
|
242
|
+
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
|
243
|
+
setQ(e.target.value)
|
|
244
|
+
}
|
|
245
|
+
placeholder={t('search')}
|
|
246
|
+
sizes={'sm'}
|
|
247
|
+
/>
|
|
248
|
+
) : null}
|
|
249
|
+
{type === 'string' ? (
|
|
250
|
+
<>
|
|
251
|
+
<div className='my-3 flex justify-between'>
|
|
252
|
+
<Link
|
|
253
|
+
asChild
|
|
254
|
+
href='#'
|
|
255
|
+
size={'sm'}
|
|
256
|
+
onClick={() => onAllCheckedChange(true)}
|
|
257
|
+
disabled={!!allChecked}
|
|
258
|
+
>
|
|
259
|
+
<button>{t('select-all')}</button>
|
|
260
|
+
</Link>
|
|
261
|
+
<Link
|
|
262
|
+
asChild
|
|
263
|
+
href='#'
|
|
264
|
+
size={'sm'}
|
|
265
|
+
onClick={() => onAllCheckedChange(false)}
|
|
266
|
+
disabled={!someChecked}
|
|
267
|
+
>
|
|
268
|
+
<button>{t('reset')}</button>
|
|
269
|
+
</Link>
|
|
270
|
+
</div>
|
|
271
|
+
<div className='flex flex-col gap-2'>
|
|
272
|
+
{loading ? (
|
|
273
|
+
<Spin />
|
|
274
|
+
) : (
|
|
275
|
+
data?.[querykey].data.map((item: any) => {
|
|
276
|
+
return (
|
|
277
|
+
<Label htmlFor={item.id} key={item.id}>
|
|
278
|
+
<Checkbox
|
|
279
|
+
id={item.id}
|
|
280
|
+
checked={checkedState[item.id]}
|
|
281
|
+
onCheckedChange={checked =>
|
|
282
|
+
onCheckedChange(
|
|
283
|
+
item.id,
|
|
284
|
+
checked
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
/>
|
|
288
|
+
{item.value}
|
|
289
|
+
</Label>
|
|
290
|
+
)
|
|
291
|
+
})
|
|
292
|
+
)}
|
|
293
|
+
</div>
|
|
294
|
+
</>
|
|
295
|
+
) : null}
|
|
296
|
+
</>
|
|
297
|
+
)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export { FilterContent }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilterContent } from './FilterContent'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TbFilter, TbFilterCheck } from 'react-icons/tb'
|
|
2
|
+
|
|
3
|
+
type FilterIconProps = {
|
|
4
|
+
type?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function FilterIcon({ type }: FilterIconProps) {
|
|
8
|
+
switch (type) {
|
|
9
|
+
case 'string':
|
|
10
|
+
return <TbFilterCheck />
|
|
11
|
+
default:
|
|
12
|
+
return <TbFilter />
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { FilterIcon }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilterIcon } from './FilterIcon'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
|
|
3
|
+
import { TbChevronDown, TbChevronUp } from 'react-icons/tb'
|
|
4
|
+
|
|
5
|
+
import { SortType } from '@/types'
|
|
6
|
+
|
|
7
|
+
type SortIconProps = {
|
|
8
|
+
state: SortType
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function SortIcon({ state }: SortIconProps) {
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<span
|
|
15
|
+
className={clsx('-mb-0.5', {
|
|
16
|
+
'dark:text-dark-gray-300 text-gray-800': state === 'asc'
|
|
17
|
+
})}
|
|
18
|
+
>
|
|
19
|
+
<TbChevronUp size={18} />
|
|
20
|
+
</span>
|
|
21
|
+
<span
|
|
22
|
+
className={clsx('-mt-0.5', {
|
|
23
|
+
'dark:text-dark-gray-300 text-gray-800': state === 'desc'
|
|
24
|
+
})}
|
|
25
|
+
>
|
|
26
|
+
<TbChevronDown size={18} />
|
|
27
|
+
</span>
|
|
28
|
+
</>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { SortIcon }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SortIcon } from './SortIcon'
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority'
|
|
2
|
+
|
|
3
|
+
import { twJoin } from '@/utils'
|
|
4
|
+
|
|
5
|
+
export const tableWrapperStyles = twJoin({
|
|
6
|
+
position: 'relative',
|
|
7
|
+
display: 'max-h-[calc(100vh-328px)] overflow-y-auto'
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
// /////////////////////////
|
|
11
|
+
|
|
12
|
+
export const tableStyles = twJoin({
|
|
13
|
+
display: 'table-auto w-full',
|
|
14
|
+
visual: 'border-separate border-spacing-0',
|
|
15
|
+
//
|
|
16
|
+
dark: {
|
|
17
|
+
visual: 'dark:border-dark-divider'
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
// /////////////////////////
|
|
22
|
+
|
|
23
|
+
export const theadStyles = twJoin({
|
|
24
|
+
position: 'sticky top-0 z-10',
|
|
25
|
+
visual: 'bg-white',
|
|
26
|
+
//
|
|
27
|
+
dark: 'dark:bg-dark-gray-900'
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// /////////////////////////
|
|
31
|
+
|
|
32
|
+
export const headStylesWrapper = cva(
|
|
33
|
+
twJoin({
|
|
34
|
+
tw: 'group',
|
|
35
|
+
mouse: 'hover:cursor-pointer',
|
|
36
|
+
position: 'relative',
|
|
37
|
+
text: 'text-start uppercase',
|
|
38
|
+
visual: 'border-y border-divider',
|
|
39
|
+
hover: 'hover:[&_[data-type="default"]]:bg-[#F4F2FE]',
|
|
40
|
+
attrs: 'has-[[data-state="open"]]:[&_[data-type="default"]]:bg-[#F4F2FE]',
|
|
41
|
+
after: {
|
|
42
|
+
position:
|
|
43
|
+
'after:content-[""] after:absolute after:top-3 after:-right-px after:-z-1',
|
|
44
|
+
display:
|
|
45
|
+
'after:h-4 has-[[data-type*="sort"]]:after:w-px after:-mr-px after:inline-block',
|
|
46
|
+
visual: 'after:bg-divider dark:after:bg-dark-divider',
|
|
47
|
+
hover: 'has-[[data-type="sort"]]:hover:after:opacity-0',
|
|
48
|
+
attrs: 'has-[[data-state="open"]]:after:opacity-0'
|
|
49
|
+
},
|
|
50
|
+
//
|
|
51
|
+
dark: {
|
|
52
|
+
visual: 'dark:border-dark-divider',
|
|
53
|
+
hover: 'dark:hover:[&_[data-type="default"]]:bg-[#353757]',
|
|
54
|
+
attrs: 'dark:has-[[data-state="open"]]:[&_[data-type="default"]]:bg-[#353757]'
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
{
|
|
58
|
+
variants: {
|
|
59
|
+
isLast: {
|
|
60
|
+
true: 'after:hidden!'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
defaultVariants: {
|
|
64
|
+
isLast: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
// /////////////////////////
|
|
70
|
+
|
|
71
|
+
export const headStyles = cva('flex py-3', {
|
|
72
|
+
variants: {
|
|
73
|
+
type: {
|
|
74
|
+
selection: 'pl-5 pr-1',
|
|
75
|
+
default: 'pl-5 pr-20',
|
|
76
|
+
'not-sort': 'px-5',
|
|
77
|
+
actions: 'pl-1 pr-5'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
defaultVariants: {
|
|
81
|
+
type: 'default'
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// /////////////////////////
|
|
86
|
+
|
|
87
|
+
export const sortFilterStyles = twJoin({
|
|
88
|
+
position: 'absolute top-0 right-0 bottom-0',
|
|
89
|
+
display: 'flex'
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// /////////////////////////
|
|
93
|
+
|
|
94
|
+
export const filterStyles = cva(
|
|
95
|
+
twJoin({
|
|
96
|
+
position: 'relative top-0 bottom-0',
|
|
97
|
+
display: 'w-6 inline-flex items-center justify-center',
|
|
98
|
+
text: 'text-gray-800',
|
|
99
|
+
animation: 'transition-opacity',
|
|
100
|
+
dark: 'dark:text-dark-gray-300'
|
|
101
|
+
}),
|
|
102
|
+
{
|
|
103
|
+
variants: {
|
|
104
|
+
isActive: {
|
|
105
|
+
true: 'opacity-100',
|
|
106
|
+
false: 'opacity-0'
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
defaultVariants: {
|
|
110
|
+
isActive: false
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
// /////////////////////////
|
|
116
|
+
|
|
117
|
+
export const sortStyles = twJoin({
|
|
118
|
+
position: 'relative top-0 bottom-0',
|
|
119
|
+
display: 'flex w-10 flex-col items-center justify-center',
|
|
120
|
+
text: 'text-gray',
|
|
121
|
+
animation: 'transition-color',
|
|
122
|
+
dark: 'dark:text-dark-gray-600'
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
// /////////////////////////
|
|
126
|
+
|
|
127
|
+
export const rowStyles = twJoin({
|
|
128
|
+
hover: 'hover:bg-primary/5',
|
|
129
|
+
childs: [
|
|
130
|
+
'has-[[data-state="open"]]:bg-primary/5',
|
|
131
|
+
'has-[[data-state="checked"]]:bg-primary/10',
|
|
132
|
+
'hover:[&_[data-type="name"]_span]:text-primary'
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
// /////////////////////////
|
|
137
|
+
|
|
138
|
+
export const cellStyles = cva(
|
|
139
|
+
twJoin({
|
|
140
|
+
display: 'py-2.5',
|
|
141
|
+
visual: 'border-b border-divider',
|
|
142
|
+
//
|
|
143
|
+
dark: {
|
|
144
|
+
visual: 'dark:border-dark-divider'
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
{
|
|
148
|
+
variants: {
|
|
149
|
+
type: {
|
|
150
|
+
selection: 'pl-5 pr-1 align-middle',
|
|
151
|
+
default: 'px-5',
|
|
152
|
+
actions: 'pl-1 pr-5 align-right'
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
defaultVariants: {
|
|
156
|
+
type: 'default'
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
// /////////////////////////
|
|
162
|
+
|
|
163
|
+
export const footerStyles = twJoin({
|
|
164
|
+
display: 'flex items-center justify-between px-6 py-4'
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
// /////////////////////////
|
|
168
|
+
|
|
169
|
+
export const notFoundStyles = twJoin({
|
|
170
|
+
display: 'flex flex-col justify-center items-center size-full p-8',
|
|
171
|
+
childs: {
|
|
172
|
+
text: '[&_svg]:text-gray'
|
|
173
|
+
},
|
|
174
|
+
//
|
|
175
|
+
dark: {
|
|
176
|
+
childs: 'dark:[&_svg]:text-dark-gray-800'
|
|
177
|
+
}
|
|
178
|
+
})
|