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,484 @@
|
|
|
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 { type ComponentProps, useEffect, useRef, useState } from 'react'
|
|
7
|
+
|
|
8
|
+
import { Actions, Checkbox, Pagination, Popover } from '@/components/atoms'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
IColumnItem,
|
|
12
|
+
IFilterQuery,
|
|
13
|
+
IPaginationOptions,
|
|
14
|
+
ISortItem,
|
|
15
|
+
SortType
|
|
16
|
+
} from '@/types'
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
cellStyles,
|
|
20
|
+
filterStyles,
|
|
21
|
+
footerStyles,
|
|
22
|
+
headStyles,
|
|
23
|
+
headStylesWrapper,
|
|
24
|
+
rowStyles,
|
|
25
|
+
sortFilterStyles,
|
|
26
|
+
sortStyles,
|
|
27
|
+
tableStyles,
|
|
28
|
+
tableWrapperStyles,
|
|
29
|
+
theadStyles
|
|
30
|
+
} from './Table.styles'
|
|
31
|
+
|
|
32
|
+
import { Typography } from '../Typography'
|
|
33
|
+
|
|
34
|
+
import { FilterContent } from './FilterContent'
|
|
35
|
+
import { FilterIcon } from './FilterIcon'
|
|
36
|
+
import { SortIcon } from './SortIcon'
|
|
37
|
+
import { getNotFoundData } from './Table.utils'
|
|
38
|
+
import { useStickyHeader } from '@/hooks'
|
|
39
|
+
import { addParam, getParam, getRangePagination, removeParam } from '@/utils'
|
|
40
|
+
|
|
41
|
+
const { Text } = Typography
|
|
42
|
+
|
|
43
|
+
type TableProps = ComponentProps<'div'> & {
|
|
44
|
+
columns: IColumnItem[]
|
|
45
|
+
dataSource: any[]
|
|
46
|
+
defaultSelection?: number[] | string[]
|
|
47
|
+
onRowSelection?: (ids: string[]) => void
|
|
48
|
+
pagination?: IPaginationOptions & { name?: string }
|
|
49
|
+
getData?: (data: Record<string, any>) => void
|
|
50
|
+
filterQuery?: IFilterQuery
|
|
51
|
+
actions?: boolean
|
|
52
|
+
inModal?: boolean
|
|
53
|
+
isAllChecked?: boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function Table({
|
|
57
|
+
columns,
|
|
58
|
+
dataSource,
|
|
59
|
+
defaultSelection,
|
|
60
|
+
onRowSelection,
|
|
61
|
+
pagination,
|
|
62
|
+
getData,
|
|
63
|
+
filterQuery,
|
|
64
|
+
actions = false,
|
|
65
|
+
inModal = false,
|
|
66
|
+
isAllChecked = false,
|
|
67
|
+
className
|
|
68
|
+
}: TableProps) {
|
|
69
|
+
const tg = useTranslations()
|
|
70
|
+
const t = useTranslations(pagination?.name)
|
|
71
|
+
//
|
|
72
|
+
const scrollRef = useRef<HTMLDivElement>(null)
|
|
73
|
+
const headerRef = useRef<HTMLTableSectionElement>(null)
|
|
74
|
+
//
|
|
75
|
+
useStickyHeader(scrollRef, headerRef)
|
|
76
|
+
//
|
|
77
|
+
const router = useRouter()
|
|
78
|
+
//
|
|
79
|
+
const rangePagination = pagination ? getRangePagination(pagination) : null
|
|
80
|
+
//
|
|
81
|
+
const [sortState, setSortState] = useState<Record<string, SortType>>({})
|
|
82
|
+
const [filterState, setFilterState] = useState<Record<string, boolean>>({})
|
|
83
|
+
const [checkedState, setCheckedState] = useState<Record<string, boolean>>(
|
|
84
|
+
defaultSelection
|
|
85
|
+
? defaultSelection.reduce(
|
|
86
|
+
(acc, id) => {
|
|
87
|
+
acc[id] = true
|
|
88
|
+
|
|
89
|
+
return acc
|
|
90
|
+
},
|
|
91
|
+
{} as Record<string, boolean>
|
|
92
|
+
)
|
|
93
|
+
: {}
|
|
94
|
+
)
|
|
95
|
+
//
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const sort = getParam('sort')
|
|
98
|
+
|
|
99
|
+
if (columns?.length) {
|
|
100
|
+
const sorts = sort
|
|
101
|
+
? Object.fromEntries(
|
|
102
|
+
JSON.parse(sort).map(({ column, order }: ISortItem) => {
|
|
103
|
+
return [column, order]
|
|
104
|
+
})
|
|
105
|
+
)
|
|
106
|
+
: {}
|
|
107
|
+
//
|
|
108
|
+
setSortState(
|
|
109
|
+
Object.fromEntries(
|
|
110
|
+
columns.map((d: any) => [d.key, sorts[d.key] || false])
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const filter = getParam('filter')
|
|
116
|
+
|
|
117
|
+
if (filter) {
|
|
118
|
+
const filters = Object.entries(JSON.parse(filter)).map(
|
|
119
|
+
([key, value]) => {
|
|
120
|
+
return [key, Boolean(value)]
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
//
|
|
124
|
+
setFilterState(Object.fromEntries(filters))
|
|
125
|
+
}
|
|
126
|
+
}, [])
|
|
127
|
+
//
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (dataSource?.[0]?.id) {
|
|
130
|
+
setCheckedState(prev => {
|
|
131
|
+
const newState: Record<string, boolean> = {}
|
|
132
|
+
|
|
133
|
+
dataSource.forEach((d: any) => {
|
|
134
|
+
newState[d.id] = prev.hasOwnProperty(d.id)
|
|
135
|
+
? prev[d.id]
|
|
136
|
+
: isAllChecked
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
const prevKeys = Object.keys(prev).sort()
|
|
140
|
+
const newKeys = Object.keys(newState).sort()
|
|
141
|
+
|
|
142
|
+
if (
|
|
143
|
+
prevKeys.length === newKeys.length &&
|
|
144
|
+
prevKeys.every((key, i) => key === newKeys[i]) &&
|
|
145
|
+
prevKeys.every(key => prev[key] === newState[key])
|
|
146
|
+
) {
|
|
147
|
+
return prev
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return newState
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
}, [dataSource])
|
|
154
|
+
//
|
|
155
|
+
const allChecked =
|
|
156
|
+
Object.values(checkedState).length &&
|
|
157
|
+
Object.values(checkedState).every(Boolean)
|
|
158
|
+
const someChecked = Object.values(checkedState).some(Boolean)
|
|
159
|
+
const isIndeterminate = someChecked && !allChecked
|
|
160
|
+
//
|
|
161
|
+
const onAllCheckedChange = (checked: boolean) => {
|
|
162
|
+
setCheckedState(prev => {
|
|
163
|
+
const newState = Object.keys(prev).reduce(
|
|
164
|
+
(acc, key) => {
|
|
165
|
+
acc[key] = checked
|
|
166
|
+
return acc
|
|
167
|
+
},
|
|
168
|
+
{} as Record<string, boolean>
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
if (onRowSelection) {
|
|
172
|
+
const selectedKeys = Object.keys(newState).filter(
|
|
173
|
+
key => newState[key]
|
|
174
|
+
)
|
|
175
|
+
onRowSelection(selectedKeys)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return newState
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
//
|
|
182
|
+
const onCheckedChange = (id: string, checked: CheckedState) => {
|
|
183
|
+
setCheckedState(prev => {
|
|
184
|
+
const newState = {
|
|
185
|
+
...prev,
|
|
186
|
+
[id]: checked as boolean
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (onRowSelection) {
|
|
190
|
+
const selectedKeys = Object.keys(newState).filter(
|
|
191
|
+
key => newState[key]
|
|
192
|
+
)
|
|
193
|
+
onRowSelection(selectedKeys)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return newState
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
//
|
|
200
|
+
const onSortChange = (column: any) => {
|
|
201
|
+
const { key } = column
|
|
202
|
+
let order: SortType = false
|
|
203
|
+
//
|
|
204
|
+
const newState = Object.keys(sortState).reduce(
|
|
205
|
+
(acc, i) => {
|
|
206
|
+
if (i === key) {
|
|
207
|
+
if (sortState[i] === false) {
|
|
208
|
+
order = 'asc'
|
|
209
|
+
} else if (sortState[i] === 'asc') {
|
|
210
|
+
order = 'desc'
|
|
211
|
+
} else if (sortState[i] === 'desc') {
|
|
212
|
+
order = false
|
|
213
|
+
}
|
|
214
|
+
acc[i] = order
|
|
215
|
+
} else {
|
|
216
|
+
acc[i] = false
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return acc
|
|
220
|
+
},
|
|
221
|
+
{} as Record<string, SortType>
|
|
222
|
+
)
|
|
223
|
+
//
|
|
224
|
+
setSortState(newState)
|
|
225
|
+
//
|
|
226
|
+
const sort = order ? [{ column: key, order }] : []
|
|
227
|
+
//
|
|
228
|
+
if (order) {
|
|
229
|
+
addParam(router, 'sort', JSON.stringify(sort))
|
|
230
|
+
} else {
|
|
231
|
+
removeParam(router, 'sort')
|
|
232
|
+
}
|
|
233
|
+
//
|
|
234
|
+
setTimeout(() => removeParam(router, 'page'), 350)
|
|
235
|
+
//
|
|
236
|
+
getData?.({
|
|
237
|
+
sort,
|
|
238
|
+
page: 0
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
//
|
|
242
|
+
return (
|
|
243
|
+
<div className={className} {...(inModal && { ref: scrollRef })}>
|
|
244
|
+
<div className={tableWrapperStyles}>
|
|
245
|
+
<table className={tableStyles}>
|
|
246
|
+
<colgroup>
|
|
247
|
+
{onRowSelection && <col style={{ width: 42 }} />}
|
|
248
|
+
{/* {columns.map((column: any) => {
|
|
249
|
+
return (
|
|
250
|
+
<col
|
|
251
|
+
key={column.key}
|
|
252
|
+
{...(column.width && {
|
|
253
|
+
style: {
|
|
254
|
+
width: column.width
|
|
255
|
+
}
|
|
256
|
+
})}
|
|
257
|
+
/>
|
|
258
|
+
)
|
|
259
|
+
})} */}
|
|
260
|
+
{actions && <col style={{ width: 80 }} />}
|
|
261
|
+
</colgroup>
|
|
262
|
+
<thead
|
|
263
|
+
className={theadStyles}
|
|
264
|
+
{...(inModal && { ref: headerRef })}
|
|
265
|
+
>
|
|
266
|
+
<tr>
|
|
267
|
+
{onRowSelection && (
|
|
268
|
+
<th className={headStylesWrapper()} scope='col'>
|
|
269
|
+
<div
|
|
270
|
+
className={headStyles({
|
|
271
|
+
type: 'selection'
|
|
272
|
+
})}
|
|
273
|
+
data-type='selection'
|
|
274
|
+
>
|
|
275
|
+
<Checkbox
|
|
276
|
+
checked={allChecked || someChecked}
|
|
277
|
+
onCheckedChange={onAllCheckedChange}
|
|
278
|
+
indeterminate={isIndeterminate}
|
|
279
|
+
/>
|
|
280
|
+
</div>
|
|
281
|
+
</th>
|
|
282
|
+
)}
|
|
283
|
+
{columns.map((column: any, idx: number) => {
|
|
284
|
+
const isLast = idx === columns.length - 1
|
|
285
|
+
//
|
|
286
|
+
return (
|
|
287
|
+
<th
|
|
288
|
+
key={column.key}
|
|
289
|
+
className={headStylesWrapper({
|
|
290
|
+
isLast: isLast && !actions
|
|
291
|
+
})}
|
|
292
|
+
scope='col'
|
|
293
|
+
>
|
|
294
|
+
{column.sort && filterQuery ? (
|
|
295
|
+
<Popover
|
|
296
|
+
trigger={
|
|
297
|
+
<div
|
|
298
|
+
className={headStyles()}
|
|
299
|
+
data-type='default'
|
|
300
|
+
>
|
|
301
|
+
<Text
|
|
302
|
+
strong
|
|
303
|
+
accent
|
|
304
|
+
size={'sm'}
|
|
305
|
+
>
|
|
306
|
+
{column.title}
|
|
307
|
+
</Text>
|
|
308
|
+
<div
|
|
309
|
+
className={
|
|
310
|
+
sortFilterStyles
|
|
311
|
+
}
|
|
312
|
+
>
|
|
313
|
+
<span
|
|
314
|
+
data-type='filter'
|
|
315
|
+
className={filterStyles(
|
|
316
|
+
{
|
|
317
|
+
isActive:
|
|
318
|
+
filterState[
|
|
319
|
+
column
|
|
320
|
+
.key
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
)}
|
|
324
|
+
>
|
|
325
|
+
<FilterIcon
|
|
326
|
+
type={
|
|
327
|
+
column.sort
|
|
328
|
+
}
|
|
329
|
+
/>
|
|
330
|
+
</span>
|
|
331
|
+
<button
|
|
332
|
+
onClick={e => {
|
|
333
|
+
e.preventDefault()
|
|
334
|
+
onSortChange(
|
|
335
|
+
column
|
|
336
|
+
)
|
|
337
|
+
}}
|
|
338
|
+
data-type='sort'
|
|
339
|
+
className={
|
|
340
|
+
sortStyles
|
|
341
|
+
}
|
|
342
|
+
>
|
|
343
|
+
<SortIcon
|
|
344
|
+
state={
|
|
345
|
+
sortState[
|
|
346
|
+
column
|
|
347
|
+
.key
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
/>
|
|
351
|
+
</button>
|
|
352
|
+
</div>
|
|
353
|
+
</div>
|
|
354
|
+
}
|
|
355
|
+
arrow={false}
|
|
356
|
+
sideOffset={1}
|
|
357
|
+
align='start'
|
|
358
|
+
className='p-4'
|
|
359
|
+
>
|
|
360
|
+
<FilterContent
|
|
361
|
+
column={column}
|
|
362
|
+
getData={getData}
|
|
363
|
+
filterQuery={filterQuery}
|
|
364
|
+
setFilterState={
|
|
365
|
+
setFilterState
|
|
366
|
+
}
|
|
367
|
+
/>
|
|
368
|
+
</Popover>
|
|
369
|
+
) : (
|
|
370
|
+
<div
|
|
371
|
+
className={headStyles()}
|
|
372
|
+
data-type='not-sort'
|
|
373
|
+
>
|
|
374
|
+
<Text strong accent size={'sm'}>
|
|
375
|
+
{column.title}
|
|
376
|
+
</Text>
|
|
377
|
+
</div>
|
|
378
|
+
)}
|
|
379
|
+
</th>
|
|
380
|
+
)
|
|
381
|
+
})}
|
|
382
|
+
{actions && (
|
|
383
|
+
<th
|
|
384
|
+
className={headStylesWrapper()}
|
|
385
|
+
scope='col'
|
|
386
|
+
></th>
|
|
387
|
+
)}
|
|
388
|
+
</tr>
|
|
389
|
+
</thead>
|
|
390
|
+
<tbody>
|
|
391
|
+
{dataSource?.length
|
|
392
|
+
? dataSource.map((dataItem: any, idx: number) => {
|
|
393
|
+
return (
|
|
394
|
+
<tr
|
|
395
|
+
key={dataItem.id || idx}
|
|
396
|
+
className={rowStyles}
|
|
397
|
+
>
|
|
398
|
+
{onRowSelection && (
|
|
399
|
+
<td
|
|
400
|
+
className={cellStyles({
|
|
401
|
+
type: 'selection'
|
|
402
|
+
})}
|
|
403
|
+
>
|
|
404
|
+
<div className='flex items-center'>
|
|
405
|
+
<Checkbox
|
|
406
|
+
checked={
|
|
407
|
+
checkedState[
|
|
408
|
+
dataItem.id
|
|
409
|
+
]
|
|
410
|
+
}
|
|
411
|
+
onCheckedChange={checked =>
|
|
412
|
+
onCheckedChange(
|
|
413
|
+
dataItem.id,
|
|
414
|
+
checked
|
|
415
|
+
)
|
|
416
|
+
}
|
|
417
|
+
/>
|
|
418
|
+
</div>
|
|
419
|
+
</td>
|
|
420
|
+
)}
|
|
421
|
+
{Object.entries(dataItem).map(
|
|
422
|
+
([key, value]) => {
|
|
423
|
+
if (key === 'id') return
|
|
424
|
+
//
|
|
425
|
+
return (
|
|
426
|
+
<td
|
|
427
|
+
key={key}
|
|
428
|
+
className={cellStyles()}
|
|
429
|
+
>
|
|
430
|
+
{value as any}
|
|
431
|
+
</td>
|
|
432
|
+
)
|
|
433
|
+
}
|
|
434
|
+
)}
|
|
435
|
+
{actions && (
|
|
436
|
+
<td
|
|
437
|
+
className={cellStyles({
|
|
438
|
+
type: 'actions'
|
|
439
|
+
})}
|
|
440
|
+
>
|
|
441
|
+
<Actions className='ml-auto' />
|
|
442
|
+
</td>
|
|
443
|
+
)}
|
|
444
|
+
</tr>
|
|
445
|
+
)
|
|
446
|
+
})
|
|
447
|
+
: getNotFoundData(
|
|
448
|
+
columns.length + 2,
|
|
449
|
+
tg('no-data')
|
|
450
|
+
)}
|
|
451
|
+
</tbody>
|
|
452
|
+
</table>
|
|
453
|
+
</div>
|
|
454
|
+
|
|
455
|
+
{!inModal && (
|
|
456
|
+
<div className={footerStyles}>
|
|
457
|
+
{pagination && pagination.total > pagination.limit && (
|
|
458
|
+
<>
|
|
459
|
+
<Text muted size={'xs'}>
|
|
460
|
+
{pagination.name
|
|
461
|
+
? t('items', {
|
|
462
|
+
from: rangePagination!.from,
|
|
463
|
+
to: rangePagination!.to,
|
|
464
|
+
total: pagination.total
|
|
465
|
+
})
|
|
466
|
+
: tg('pagination.items', {
|
|
467
|
+
from: rangePagination!.from,
|
|
468
|
+
to: rangePagination!.to,
|
|
469
|
+
total: pagination.total
|
|
470
|
+
})}
|
|
471
|
+
</Text>
|
|
472
|
+
<Pagination
|
|
473
|
+
pagination={pagination}
|
|
474
|
+
getData={getData}
|
|
475
|
+
/>
|
|
476
|
+
</>
|
|
477
|
+
)}
|
|
478
|
+
</div>
|
|
479
|
+
)}
|
|
480
|
+
</div>
|
|
481
|
+
)
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export { Table }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { notFoundStyles } from './Table.styles'
|
|
2
|
+
|
|
3
|
+
import { EmptyIcon } from '../icons'
|
|
4
|
+
import { Typography } from '../Typography'
|
|
5
|
+
|
|
6
|
+
const { Title } = Typography
|
|
7
|
+
|
|
8
|
+
export const getNotFoundData = (colCount = 1, title: string) => {
|
|
9
|
+
return (
|
|
10
|
+
<tr data-type='not-found'>
|
|
11
|
+
<td colSpan={colCount}>
|
|
12
|
+
<div className={notFoundStyles}>
|
|
13
|
+
<EmptyIcon size={100} />
|
|
14
|
+
<Title level={5}>{title}</Title>
|
|
15
|
+
</div>
|
|
16
|
+
</td>
|
|
17
|
+
</tr>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Table } from './Table'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Tabs as RadixTabs } from 'radix-ui'
|
|
4
|
+
|
|
5
|
+
type TabsProps = ComponentProps<typeof RadixTabs.Root>
|
|
6
|
+
|
|
7
|
+
function Tabs({ children, ...props }: TabsProps) {
|
|
8
|
+
return <RadixTabs.Root {...props}>{children}</RadixTabs.Root>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Tabs.List = RadixTabs.List
|
|
12
|
+
Tabs.Trigger = RadixTabs.Trigger
|
|
13
|
+
Tabs.Content = RadixTabs.Content
|
|
14
|
+
|
|
15
|
+
export { Tabs }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tabs } from './Tabs'
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type VariantProps, cva } from 'class-variance-authority'
|
|
2
|
+
|
|
3
|
+
import { twJoin } from '@/utils'
|
|
4
|
+
|
|
5
|
+
export const rootStyles = cva(
|
|
6
|
+
twJoin({
|
|
7
|
+
tw: [
|
|
8
|
+
'group-has-[[data-state="open"]]/input:border-primary',
|
|
9
|
+
'group-has-[[data-state="open"]]/input:shadow-primary-sm',
|
|
10
|
+
'hover:group-has-[[data-state="open"]]/input:border-primary'
|
|
11
|
+
],
|
|
12
|
+
display: 'flex w-full min-w-0 ',
|
|
13
|
+
text: 'text-base text-gray-800',
|
|
14
|
+
visual: 'border-divider border bg-white outline-none',
|
|
15
|
+
animation: 'transition-all',
|
|
16
|
+
placeholder: 'placeholder:text-gray-400',
|
|
17
|
+
hover: 'hover:border-gray hover:focus-visible:border-primary',
|
|
18
|
+
focus: 'focus-visible:border-primary focus-visible:shadow-primary-sm',
|
|
19
|
+
attrs: 'aria-[invalid=true]:border-danger',
|
|
20
|
+
//
|
|
21
|
+
dark: {
|
|
22
|
+
text: 'dark:text-dark-gray-300',
|
|
23
|
+
visual: 'dark:border-dark-divider dark:bg-dark-gray-900',
|
|
24
|
+
placeholder: 'dark:placeholder:text-dark-gray-700',
|
|
25
|
+
hover: 'dark:hover:border-dark-gray',
|
|
26
|
+
focus: 'dark:focus-visible:shadow-dark-sm'
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
{
|
|
30
|
+
variants: {
|
|
31
|
+
sizes: {
|
|
32
|
+
sm: twJoin({
|
|
33
|
+
display: 'h-7 py-2 px-2.5',
|
|
34
|
+
text: 'text-sm',
|
|
35
|
+
visual: 'rounded-sm',
|
|
36
|
+
focus: {
|
|
37
|
+
display: 'focus-visible:pl-3.5'
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
md: twJoin({
|
|
41
|
+
display: 'min-h-12 py-2 px-3.5',
|
|
42
|
+
text: 'text-base',
|
|
43
|
+
visual: 'rounded-md',
|
|
44
|
+
focus: {
|
|
45
|
+
display: 'focus-visible:pl-4.5'
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
lg: twJoin({
|
|
49
|
+
display: 'h-12 py-3 px-4',
|
|
50
|
+
text: 'text-lg',
|
|
51
|
+
visual: 'rounded-lg',
|
|
52
|
+
focus: {
|
|
53
|
+
display: 'focus-visible:pl-5.5'
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
defaultVariants: {
|
|
59
|
+
sizes: 'md'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
export type RootStylesProps = VariantProps<typeof rootStyles>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react'
|
|
2
|
+
|
|
3
|
+
import { type RootStylesProps, rootStyles } from './Textarea.styles'
|
|
4
|
+
|
|
5
|
+
type TextareaProps = ComponentProps<'textarea'> & RootStylesProps
|
|
6
|
+
|
|
7
|
+
function Textarea({ sizes, className, children, ...props }: TextareaProps) {
|
|
8
|
+
return (
|
|
9
|
+
<textarea className={rootStyles({ sizes, className })} {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</textarea>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { Textarea }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Textarea } from './Textarea'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { VariantProps, cva } from 'class-variance-authority'
|
|
2
|
+
|
|
3
|
+
import { twJoin } from '@/utils'
|
|
4
|
+
|
|
5
|
+
export const rootStyles = cva(
|
|
6
|
+
twJoin({
|
|
7
|
+
display: 'flex gap-x-2.5 w-full py-3 px-4',
|
|
8
|
+
visual: 'rounded-md shadow-lg border'
|
|
9
|
+
}),
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
type: {
|
|
13
|
+
default: '',
|
|
14
|
+
success: 'bg-success-100 border-success',
|
|
15
|
+
info: 'bg-info-100 border-info',
|
|
16
|
+
warning: 'bg-warning-100 border-warning',
|
|
17
|
+
error: 'bg-danger-100 border-danger',
|
|
18
|
+
loading: 'bg-secondary-100 border-secondary'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
type: 'default'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
export type RootStylesProps = VariantProps<typeof rootStyles>
|
|
28
|
+
|
|
29
|
+
// /////////////////////////
|
|
30
|
+
|
|
31
|
+
export const iconStyles = twJoin({
|
|
32
|
+
display: 'size-6.5 p-1',
|
|
33
|
+
visual: 'bg-white rounded-md',
|
|
34
|
+
childs: '[&_svg]:size-4.5'
|
|
35
|
+
})
|