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,227 @@
|
|
|
1
|
+
import { type VariantProps, cva } from 'class-variance-authority'
|
|
2
|
+
|
|
3
|
+
import { twJoin } from '@/utils'
|
|
4
|
+
|
|
5
|
+
export const mainStyles = cva(
|
|
6
|
+
twJoin({
|
|
7
|
+
tw: 'group/calendar',
|
|
8
|
+
visual: 'bg-white shadow-md',
|
|
9
|
+
//
|
|
10
|
+
dark: 'dark:bg-dark-gray-900'
|
|
11
|
+
}),
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
size: {
|
|
15
|
+
sm: 'px-2 pb-2 rounded-sm',
|
|
16
|
+
md: 'px-3.5 pb-3 rounded-md',
|
|
17
|
+
lg: ''
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: 'md'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
export type MainStylesProps = VariantProps<typeof mainStyles>
|
|
27
|
+
|
|
28
|
+
// /////////////////////////
|
|
29
|
+
|
|
30
|
+
export const allStyles = ({ size }: { size?: 'sm' | 'md' | 'lg' | null }) => {
|
|
31
|
+
const generalStyles = {
|
|
32
|
+
root: twJoin({
|
|
33
|
+
position: 'relative',
|
|
34
|
+
display: 'w-fit'
|
|
35
|
+
}),
|
|
36
|
+
month_caption: twJoin({
|
|
37
|
+
display: 'flex items-center',
|
|
38
|
+
text: 'font-semibold text-gray-900 capitalize',
|
|
39
|
+
visual: 'border-b border-divider',
|
|
40
|
+
//
|
|
41
|
+
dark: {
|
|
42
|
+
text: 'dark:text-dark-gray-200',
|
|
43
|
+
visual: 'dark:border-dark-divider'
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
nav: twJoin({
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
display: 'flex -mt-px'
|
|
49
|
+
}),
|
|
50
|
+
button_previous: twJoin({
|
|
51
|
+
display: 'flex items-center justify-center',
|
|
52
|
+
text: 'text-gray-800',
|
|
53
|
+
visual: 'bg-secondary/16 rounded-full',
|
|
54
|
+
hover: 'hover:bg-secondary/32',
|
|
55
|
+
//
|
|
56
|
+
dark: {
|
|
57
|
+
text: 'dark:text-dark-gray-300',
|
|
58
|
+
visual: 'dark:bg-dark-gray-700/16',
|
|
59
|
+
hover: 'dark:hover:bg-dark-gray-700/32'
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
button_next: twJoin({
|
|
63
|
+
display: 'flex items-center justify-center',
|
|
64
|
+
text: 'text-gray-800',
|
|
65
|
+
visual: 'bg-secondary/16 rounded-full',
|
|
66
|
+
hover: 'hover:bg-secondary/32',
|
|
67
|
+
//
|
|
68
|
+
dark: {
|
|
69
|
+
text: 'dark:text-dark-gray-300',
|
|
70
|
+
visual: 'dark:bg-dark-gray-700/16',
|
|
71
|
+
hover: 'dark:hover:bg-dark-gray-700/32'
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
weekday: twJoin({
|
|
75
|
+
display: 'flex items-center justify-center',
|
|
76
|
+
text: 'font-semibold text-gray-900 capitalize'
|
|
77
|
+
}),
|
|
78
|
+
day_button: twJoin({
|
|
79
|
+
display: 'flex items-center justify-center',
|
|
80
|
+
text: 'text-gray-800',
|
|
81
|
+
visual: 'rounded-full',
|
|
82
|
+
hover: {
|
|
83
|
+
visual: 'hover:bg-secondary/16',
|
|
84
|
+
attrs: {
|
|
85
|
+
visual: 'hover:group-data-[selected=true]/day:bg-primary'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
attrs: {
|
|
89
|
+
text: [
|
|
90
|
+
'group-data-[selected=true]/day:text-white!',
|
|
91
|
+
'group-data-[outside=true]/day:text-gray',
|
|
92
|
+
'group-data-[today=true]/day:text-primary'
|
|
93
|
+
],
|
|
94
|
+
visual: [
|
|
95
|
+
'group-data-[selected=true]/day:bg-primary',
|
|
96
|
+
'group-data-[today=true]/day:border group-data-[today=true]/day:border-primary',
|
|
97
|
+
'data-[selected-single=true]:rounded-full!'
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
//
|
|
101
|
+
dark: {
|
|
102
|
+
text: 'dark:text-dark-gray-300',
|
|
103
|
+
hover: {
|
|
104
|
+
visual: 'hover:bg-secondary/32'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}),
|
|
108
|
+
range_start: twJoin({
|
|
109
|
+
attrs: {
|
|
110
|
+
visual: ['[&_button]:rounded-e-none']
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
range_middle: twJoin({
|
|
114
|
+
attrs: {
|
|
115
|
+
text: 'data-[selected=true]:[&_button]:text-primary!',
|
|
116
|
+
visual: [
|
|
117
|
+
'[&_button]:bg-primary/16! [&_button]:rounded-none',
|
|
118
|
+
'data-[today=true]:[&_button]:bg-primary/32! data-[today=true]:[&_button]:border-none!'
|
|
119
|
+
],
|
|
120
|
+
hover: {
|
|
121
|
+
text: 'hover:[&_button]:text-gray!',
|
|
122
|
+
visual: [
|
|
123
|
+
'hover:[&_button]:bg-secondary/8!',
|
|
124
|
+
'hover:data-[today=true]:[&_button]:text-primary!'
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}),
|
|
129
|
+
range_end: twJoin({
|
|
130
|
+
attrs: {
|
|
131
|
+
visual: '[&_button]:rounded-s-none'
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const sizeStyles = {
|
|
137
|
+
sm: {
|
|
138
|
+
...generalStyles,
|
|
139
|
+
month_caption:
|
|
140
|
+
generalStyles.month_caption +
|
|
141
|
+
' ' +
|
|
142
|
+
twJoin({
|
|
143
|
+
display: 'h-10 -mx-2 px-2',
|
|
144
|
+
text: 'text-sm'
|
|
145
|
+
}),
|
|
146
|
+
nav:
|
|
147
|
+
generalStyles.nav +
|
|
148
|
+
' ' +
|
|
149
|
+
twJoin({
|
|
150
|
+
position: 'top-2 right-2',
|
|
151
|
+
display: 'gap-2'
|
|
152
|
+
}),
|
|
153
|
+
button_previous:
|
|
154
|
+
generalStyles.button_previous +
|
|
155
|
+
' ' +
|
|
156
|
+
twJoin({
|
|
157
|
+
display: 'size-6'
|
|
158
|
+
}),
|
|
159
|
+
button_next:
|
|
160
|
+
generalStyles.button_next +
|
|
161
|
+
' ' +
|
|
162
|
+
twJoin({
|
|
163
|
+
display: 'size-6'
|
|
164
|
+
}),
|
|
165
|
+
weekday:
|
|
166
|
+
generalStyles.weekday +
|
|
167
|
+
' ' +
|
|
168
|
+
twJoin({
|
|
169
|
+
display: 'h-10 w-7',
|
|
170
|
+
text: 'text-xs'
|
|
171
|
+
}),
|
|
172
|
+
day_button:
|
|
173
|
+
generalStyles.day_button +
|
|
174
|
+
' ' +
|
|
175
|
+
twJoin({
|
|
176
|
+
display: 'size-7',
|
|
177
|
+
text: 'text-sm'
|
|
178
|
+
})
|
|
179
|
+
},
|
|
180
|
+
md: {
|
|
181
|
+
...generalStyles,
|
|
182
|
+
month_caption:
|
|
183
|
+
generalStyles.month_caption +
|
|
184
|
+
' ' +
|
|
185
|
+
twJoin({
|
|
186
|
+
display: 'h-14.5 -mx-3.5 px-3.5',
|
|
187
|
+
text: 'text-base'
|
|
188
|
+
}),
|
|
189
|
+
nav:
|
|
190
|
+
generalStyles.nav +
|
|
191
|
+
' ' +
|
|
192
|
+
twJoin({
|
|
193
|
+
position: 'top-4 right-4',
|
|
194
|
+
display: 'gap-4'
|
|
195
|
+
}),
|
|
196
|
+
button_previous:
|
|
197
|
+
generalStyles.button_previous +
|
|
198
|
+
' ' +
|
|
199
|
+
twJoin({
|
|
200
|
+
display: 'size-7'
|
|
201
|
+
}),
|
|
202
|
+
button_next:
|
|
203
|
+
generalStyles.button_next +
|
|
204
|
+
' ' +
|
|
205
|
+
twJoin({
|
|
206
|
+
display: 'size-7'
|
|
207
|
+
}),
|
|
208
|
+
weekday:
|
|
209
|
+
generalStyles.weekday +
|
|
210
|
+
' ' +
|
|
211
|
+
twJoin({
|
|
212
|
+
display: 'h-14.5 w-8.5',
|
|
213
|
+
text: 'text-sm'
|
|
214
|
+
}),
|
|
215
|
+
day_button:
|
|
216
|
+
generalStyles.day_button +
|
|
217
|
+
' ' +
|
|
218
|
+
twJoin({
|
|
219
|
+
display: 'size-8.5',
|
|
220
|
+
text: 'text-base'
|
|
221
|
+
})
|
|
222
|
+
},
|
|
223
|
+
lg: {}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return size ? sizeStyles[size] : generalStyles
|
|
227
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx'
|
|
4
|
+
import { useLocale } from 'next-intl'
|
|
5
|
+
import { type ComponentProps, useState } from 'react'
|
|
6
|
+
import { DateRange, DayPicker, type Locale } from 'react-day-picker'
|
|
7
|
+
import { ru } from 'react-day-picker/locale'
|
|
8
|
+
|
|
9
|
+
import { TbChevronDown, TbChevronLeft, TbChevronRight } from 'react-icons/tb'
|
|
10
|
+
|
|
11
|
+
import { allStyles, mainStyles, type MainStylesProps } from './Calendar.styles'
|
|
12
|
+
|
|
13
|
+
type CalendarProps = {
|
|
14
|
+
onSelect?: (value: any) => void
|
|
15
|
+
defaultSelected?: DateRange
|
|
16
|
+
} & ComponentProps<typeof DayPicker> &
|
|
17
|
+
MainStylesProps
|
|
18
|
+
|
|
19
|
+
function Calendar({
|
|
20
|
+
mode = 'single',
|
|
21
|
+
size,
|
|
22
|
+
onSelect,
|
|
23
|
+
className,
|
|
24
|
+
defaultSelected
|
|
25
|
+
}: CalendarProps) {
|
|
26
|
+
const [selectedDate, setSelectedDate] = useState(defaultSelected)
|
|
27
|
+
//
|
|
28
|
+
const locale = useLocale()
|
|
29
|
+
//
|
|
30
|
+
const localeObj: Record<string, Locale> = { ru }
|
|
31
|
+
//
|
|
32
|
+
const onChangeHandler = (value: any) => {
|
|
33
|
+
setSelectedDate(value)
|
|
34
|
+
if (onSelect) onSelect(value)
|
|
35
|
+
}
|
|
36
|
+
//
|
|
37
|
+
return (
|
|
38
|
+
<DayPicker
|
|
39
|
+
{...(locale !== 'en' && { locale: localeObj[locale] })}
|
|
40
|
+
selected={selectedDate}
|
|
41
|
+
onSelect={onChangeHandler}
|
|
42
|
+
mode={mode as any}
|
|
43
|
+
showOutsideDays
|
|
44
|
+
navLayout='after'
|
|
45
|
+
className={mainStyles({ size, className })}
|
|
46
|
+
classNames={allStyles({ size })}
|
|
47
|
+
components={{
|
|
48
|
+
Root: ({ className, rootRef, ...props }) => {
|
|
49
|
+
return (
|
|
50
|
+
<div ref={rootRef} className={className} {...props} />
|
|
51
|
+
)
|
|
52
|
+
},
|
|
53
|
+
Weekday: ({ children, className, ...props }) => {
|
|
54
|
+
return (
|
|
55
|
+
<th {...props}>
|
|
56
|
+
<button className={className}>{children}</button>
|
|
57
|
+
</th>
|
|
58
|
+
)
|
|
59
|
+
},
|
|
60
|
+
Day: ({ day, modifiers, className, ...props }) => {
|
|
61
|
+
return (
|
|
62
|
+
<td
|
|
63
|
+
className={clsx('group/day', className)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
67
|
+
},
|
|
68
|
+
DayButton: ({ day, modifiers, className, ...props }) => {
|
|
69
|
+
return (
|
|
70
|
+
<button
|
|
71
|
+
data-selected-single={
|
|
72
|
+
modifiers.selected &&
|
|
73
|
+
modifiers.range_start &&
|
|
74
|
+
modifiers.range_end
|
|
75
|
+
}
|
|
76
|
+
className={className}
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
},
|
|
81
|
+
Chevron: ({ className, orientation, ...props }) => {
|
|
82
|
+
switch (orientation) {
|
|
83
|
+
case 'left':
|
|
84
|
+
return <TbChevronLeft {...props} />
|
|
85
|
+
case 'right':
|
|
86
|
+
return <TbChevronRight {...props} />
|
|
87
|
+
default:
|
|
88
|
+
return <TbChevronDown {...props} />
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { Calendar }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Calendar } from './Calendar'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { twJoin } from '@/utils'
|
|
2
|
+
|
|
3
|
+
export const rootStyles = twJoin({
|
|
4
|
+
tw: 'peer group-has-[input]/label:mr-0.5',
|
|
5
|
+
display: 'size-4.5 shrink-0',
|
|
6
|
+
visual: 'border-divider rounded-sm border outline-none',
|
|
7
|
+
animation: 'transition-all',
|
|
8
|
+
hover: [
|
|
9
|
+
'hover:cursor-pointer',
|
|
10
|
+
'group-hover/label:border-gray',
|
|
11
|
+
'group-hover/label:data-[state=checked]:border-transparent'
|
|
12
|
+
],
|
|
13
|
+
attrs: [
|
|
14
|
+
'data-[state=checked]:text-white',
|
|
15
|
+
'data-[state=checked]:bg-primary',
|
|
16
|
+
'data-[state=checked]:border-primary',
|
|
17
|
+
'data-[state=checked]:shadow-primary-sm',
|
|
18
|
+
'data-[state=checked]:hover:shadow-primary',
|
|
19
|
+
'aria-[invalid=true]:border-danger'
|
|
20
|
+
],
|
|
21
|
+
//
|
|
22
|
+
dark: [
|
|
23
|
+
'dark:border-dark-gray-200',
|
|
24
|
+
'dark:data-[state=checked]:shadow-dark-sm',
|
|
25
|
+
'dark:data-[state=checked]:hover:shadow-dark-md',
|
|
26
|
+
'dark:group-hover/label:border-dark-gray-400'
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// /////////////////////////
|
|
31
|
+
|
|
32
|
+
export const indicatorStyles = twJoin({
|
|
33
|
+
display: 'flex items-center justify-center',
|
|
34
|
+
text: 'text-current',
|
|
35
|
+
animation: 'transition-none',
|
|
36
|
+
childs: '[&_svg]:size-3.5'
|
|
37
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import { type ComponentProps } from 'react'
|
|
3
|
+
|
|
4
|
+
import { Checkbox as RadixCheckbox } from 'radix-ui'
|
|
5
|
+
|
|
6
|
+
import { TbMinus } from 'react-icons/tb'
|
|
7
|
+
|
|
8
|
+
import { indicatorStyles, rootStyles } from './Checkbox.styles'
|
|
9
|
+
|
|
10
|
+
import { CheckIcon } from '../icons'
|
|
11
|
+
|
|
12
|
+
type CheckboxProps = ComponentProps<typeof RadixCheckbox.Root> & {
|
|
13
|
+
indeterminate?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Checkbox({ className, indeterminate, ...props }: CheckboxProps) {
|
|
17
|
+
return (
|
|
18
|
+
<RadixCheckbox.Root className={clsx(rootStyles, className)} {...props}>
|
|
19
|
+
<RadixCheckbox.Indicator className={indicatorStyles}>
|
|
20
|
+
{indeterminate ? <TbMinus /> : <CheckIcon />}
|
|
21
|
+
</RadixCheckbox.Indicator>
|
|
22
|
+
</RadixCheckbox.Root>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { Checkbox }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox } from './Checkbox'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import { useLocale } from 'next-intl'
|
|
3
|
+
import { type ComponentProps } from 'react'
|
|
4
|
+
|
|
5
|
+
import { type RootStylesProps } from '..//Typography/Text/Text.styles'
|
|
6
|
+
import { Typography } from '../Typography'
|
|
7
|
+
|
|
8
|
+
import { getFormatDate } from '@/utils'
|
|
9
|
+
|
|
10
|
+
const { Text } = Typography
|
|
11
|
+
|
|
12
|
+
type DateProps = ComponentProps<'span'> &
|
|
13
|
+
RootStylesProps & {
|
|
14
|
+
date: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function Date({ date, className, ...props }: DateProps) {
|
|
18
|
+
const locale = useLocale()
|
|
19
|
+
//
|
|
20
|
+
return (
|
|
21
|
+
<Text className={clsx('text-nowrap', className)} {...props}>
|
|
22
|
+
{getFormatDate(date, locale)}
|
|
23
|
+
</Text>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { Date }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Date } from './Date'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { VariantProps, cva } from 'class-variance-authority'
|
|
2
|
+
|
|
3
|
+
import { twJoin } from '@/utils'
|
|
4
|
+
|
|
5
|
+
export const rootStyles = twJoin({
|
|
6
|
+
tw: 'group/input',
|
|
7
|
+
position: 'relative'
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
// /////////////////////////
|
|
11
|
+
|
|
12
|
+
export const inputStyles = cva('', {
|
|
13
|
+
variants: {
|
|
14
|
+
size: {
|
|
15
|
+
sm: '!w-53',
|
|
16
|
+
md: '!w-66.5',
|
|
17
|
+
lg: ''
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: 'md'
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export type InputStylesProps = VariantProps<typeof inputStyles>
|
|
26
|
+
|
|
27
|
+
// /////////////////////////
|
|
28
|
+
|
|
29
|
+
export const iconStyles = cva(
|
|
30
|
+
twJoin({
|
|
31
|
+
mouse: 'cursor-pointer',
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
text: 'text-gray',
|
|
34
|
+
hover: {
|
|
35
|
+
text: 'hover:text-primary-300'
|
|
36
|
+
},
|
|
37
|
+
attrs: {
|
|
38
|
+
text: 'data-[state=open]:text-primary'
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
{
|
|
42
|
+
variants: {
|
|
43
|
+
size: {
|
|
44
|
+
sm: 'top-1.5 right-2.5 size-4',
|
|
45
|
+
md: 'top-2 right-3 size-5.5',
|
|
46
|
+
lg: 'top-2.5 right-3.5 size-7'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
size: 'md'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useMask } from '@react-input/mask'
|
|
4
|
+
import dayjs from 'dayjs'
|
|
5
|
+
import { ChangeEvent, type ComponentProps, useEffect, useState } from 'react'
|
|
6
|
+
import { DateRange, DayPicker } from 'react-day-picker'
|
|
7
|
+
|
|
8
|
+
import { TbCalendarMonth } from 'react-icons/tb'
|
|
9
|
+
|
|
10
|
+
import { Calendar, Input, Popover } from '@/components/atoms'
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
iconStyles,
|
|
14
|
+
inputStyles,
|
|
15
|
+
type InputStylesProps,
|
|
16
|
+
rootStyles
|
|
17
|
+
} from './DatePicker.styles'
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
getAlignOffset,
|
|
21
|
+
getMask,
|
|
22
|
+
getPlaceholder,
|
|
23
|
+
getSideOffset
|
|
24
|
+
} from './DatePicker.utils'
|
|
25
|
+
import { _ } from '@/utils'
|
|
26
|
+
|
|
27
|
+
type DatePickerProps = {
|
|
28
|
+
onSelect?: (value: DateRange) => void
|
|
29
|
+
defaultSelected?: DateRange
|
|
30
|
+
defaultOpen?: boolean | { isOpen: boolean; delay: number }
|
|
31
|
+
} & ComponentProps<typeof DayPicker> &
|
|
32
|
+
InputStylesProps
|
|
33
|
+
|
|
34
|
+
export function DatePicker({
|
|
35
|
+
defaultOpen,
|
|
36
|
+
mode = 'single',
|
|
37
|
+
size = 'md',
|
|
38
|
+
onSelect,
|
|
39
|
+
defaultSelected
|
|
40
|
+
}: DatePickerProps) {
|
|
41
|
+
const [open, setOpen] = useState(
|
|
42
|
+
_.isObject(defaultOpen) ? false : defaultOpen
|
|
43
|
+
)
|
|
44
|
+
const [date, setDate] = useState('')
|
|
45
|
+
//
|
|
46
|
+
const inputRef = useMask({
|
|
47
|
+
mask: getMask(mode),
|
|
48
|
+
replacement: { _: /\d/ },
|
|
49
|
+
showMask: false,
|
|
50
|
+
modify: data => {
|
|
51
|
+
return { showMask: !!data.data }
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
//
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (_.isObject(defaultOpen) && defaultOpen?.delay) {
|
|
57
|
+
const timer = setTimeout(() => {
|
|
58
|
+
setOpen(true)
|
|
59
|
+
}, defaultOpen.delay)
|
|
60
|
+
|
|
61
|
+
return () => clearTimeout(timer)
|
|
62
|
+
}
|
|
63
|
+
}, [])
|
|
64
|
+
//
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (defaultSelected) {
|
|
67
|
+
const from = defaultSelected.from
|
|
68
|
+
? dayjs(defaultSelected.from).format('DD/MM/YYYY')
|
|
69
|
+
: ''
|
|
70
|
+
const to = defaultSelected.to
|
|
71
|
+
? dayjs(defaultSelected.to).format('DD/MM/YYYY')
|
|
72
|
+
: ''
|
|
73
|
+
setDate(from && to ? `${from} — ${to}` : '')
|
|
74
|
+
}
|
|
75
|
+
}, [defaultSelected])
|
|
76
|
+
//
|
|
77
|
+
const onSelectHandler = (value: DateRange) => {
|
|
78
|
+
const from = value.from ? dayjs(value.from).format('DD/MM/YYYY') : ''
|
|
79
|
+
const to = value.to ? dayjs(value.to).format('DD/MM/YYYY') : ''
|
|
80
|
+
setDate(from && to ? `${from} — ${to}` : '')
|
|
81
|
+
onSelect?.(value)
|
|
82
|
+
}
|
|
83
|
+
//
|
|
84
|
+
return (
|
|
85
|
+
<div className={rootStyles}>
|
|
86
|
+
<Input
|
|
87
|
+
value={date}
|
|
88
|
+
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
|
89
|
+
setDate(e.target.value)
|
|
90
|
+
}
|
|
91
|
+
sizes={size}
|
|
92
|
+
ref={inputRef}
|
|
93
|
+
className={inputStyles({ size })}
|
|
94
|
+
placeholder={getPlaceholder(mode)}
|
|
95
|
+
/>
|
|
96
|
+
<Popover
|
|
97
|
+
open={open}
|
|
98
|
+
onOpenChange={setOpen}
|
|
99
|
+
trigger={<TbCalendarMonth className={iconStyles({ size })} />}
|
|
100
|
+
align='end'
|
|
101
|
+
sideOffset={getSideOffset(size!)}
|
|
102
|
+
alignOffset={getAlignOffset(size!)}
|
|
103
|
+
arrow={false}
|
|
104
|
+
>
|
|
105
|
+
<Calendar
|
|
106
|
+
mode={mode as any}
|
|
107
|
+
size={size}
|
|
108
|
+
onSelect={onSelectHandler}
|
|
109
|
+
defaultSelected={defaultSelected}
|
|
110
|
+
/>
|
|
111
|
+
</Popover>
|
|
112
|
+
</div>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useTranslations } from 'next-intl'
|
|
2
|
+
|
|
3
|
+
export type Mode = 'single' | 'multiple' | 'range'
|
|
4
|
+
|
|
5
|
+
export const getMask = (mode: Mode) => {
|
|
6
|
+
switch (mode) {
|
|
7
|
+
case 'single':
|
|
8
|
+
return '__/__/____'
|
|
9
|
+
case 'multiple':
|
|
10
|
+
return '__/__/____ — __/__/____'
|
|
11
|
+
case 'range':
|
|
12
|
+
return '__/__/____ — __/__/____'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const getPlaceholder = (mode: Mode) => {
|
|
17
|
+
const t = useTranslations('calendar.placeholder')
|
|
18
|
+
|
|
19
|
+
switch (mode) {
|
|
20
|
+
case 'single':
|
|
21
|
+
return t('single')
|
|
22
|
+
case 'multiple':
|
|
23
|
+
return t('multiple')
|
|
24
|
+
case 'range':
|
|
25
|
+
return t('range')
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const getSideOffset = (size: 'sm' | 'md' | 'lg') => {
|
|
30
|
+
switch (size) {
|
|
31
|
+
case 'sm':
|
|
32
|
+
return 9
|
|
33
|
+
case 'md':
|
|
34
|
+
return 13
|
|
35
|
+
case 'lg':
|
|
36
|
+
return 18
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const getAlignOffset = (size: 'sm' | 'md' | 'lg') => {
|
|
41
|
+
switch (size) {
|
|
42
|
+
case 'sm':
|
|
43
|
+
return -12
|
|
44
|
+
case 'md':
|
|
45
|
+
return -14
|
|
46
|
+
case 'lg':
|
|
47
|
+
return -16
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DatePicker } from './DatePicker'
|