bmdl-sdk 1.5.8 → 2.0.0
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 +5 -4
- package/bin/init.js +2 -1
- package/bmdl-sdk-2.0.0.tgz +0 -0
- package/global.d.ts +9 -0
- package/next.config.ts +27 -0
- package/package.json +36 -15
- 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 +107 -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/templates/App.tsx +1 -1
- package/templates/config.ts +1 -1
- package/templates/dataOptions.ts +1 -1
- package/templates/viewOptions.ts +1 -1
- package/tsconfig.json +40 -6
- package/bmdl-sdk-1.5.8.tgz +0 -0
- package/index.html +0 -12
- package/src/App.tsx +0 -187
- package/src/main.tsx +0 -15
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createContext, Dispatch, SetStateAction } from 'react'
|
|
2
|
+
|
|
3
|
+
import { ColumnInput } from '@/graphql'
|
|
4
|
+
|
|
5
|
+
import { IDatasetFileInfo, IFileInfo } from '@/types'
|
|
6
|
+
|
|
7
|
+
export type CreateDatasetContextProps = {
|
|
8
|
+
name: string
|
|
9
|
+
setName: Dispatch<SetStateAction<string>>
|
|
10
|
+
//
|
|
11
|
+
sourceType: string
|
|
12
|
+
setSourceType: Dispatch<SetStateAction<string>>
|
|
13
|
+
//
|
|
14
|
+
fileInfo: IFileInfo | null
|
|
15
|
+
setFileInfo: Dispatch<SetStateAction<IFileInfo | null>>
|
|
16
|
+
//
|
|
17
|
+
datasetFileInfo: IDatasetFileInfo
|
|
18
|
+
setDatasetFileInfo: Dispatch<SetStateAction<IDatasetFileInfo>>
|
|
19
|
+
//
|
|
20
|
+
columns: ColumnInput[]
|
|
21
|
+
setColumns: Dispatch<SetStateAction<ColumnInput[]>>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const CreateDatasetContext =
|
|
25
|
+
createContext<CreateDatasetContextProps | null>(null)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createContext, Dispatch, RefObject, SetStateAction } from 'react'
|
|
2
|
+
|
|
3
|
+
import { LayerModel } from '@/graphql'
|
|
4
|
+
|
|
5
|
+
import { GridSizeType, LayoutsType, ProjectData } from '@/types'
|
|
6
|
+
|
|
7
|
+
export type ProjectContextProps = {
|
|
8
|
+
project: ProjectData
|
|
9
|
+
//
|
|
10
|
+
layer: LayerModel | undefined
|
|
11
|
+
setLayer: Dispatch<SetStateAction<LayerModel | undefined>>
|
|
12
|
+
//
|
|
13
|
+
layouts: LayoutsType
|
|
14
|
+
setLayouts: Dispatch<SetStateAction<LayoutsType>>
|
|
15
|
+
//
|
|
16
|
+
tempLayouts: LayoutsType
|
|
17
|
+
setTempLayouts: Dispatch<SetStateAction<LayoutsType>>
|
|
18
|
+
//
|
|
19
|
+
isEdit: boolean
|
|
20
|
+
setIsEdit: Dispatch<SetStateAction<boolean>>
|
|
21
|
+
//
|
|
22
|
+
gridKey: number
|
|
23
|
+
setGridKey: Dispatch<SetStateAction<number>>
|
|
24
|
+
//
|
|
25
|
+
gridSize: GridSizeType
|
|
26
|
+
setGridSize: Dispatch<SetStateAction<GridSizeType>>
|
|
27
|
+
//
|
|
28
|
+
saveHandler: () => void
|
|
29
|
+
cancelHandler: () => void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const ProjectContext = createContext<ProjectContextProps | null>(null)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProjectContext, type ProjectContextProps } from './ProjectContext'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
|
|
3
|
+
export type SidebarContextProps = {
|
|
4
|
+
isMobile: boolean
|
|
5
|
+
isOpen: boolean
|
|
6
|
+
setIsOpen: (value: boolean) => void
|
|
7
|
+
toggleSidebar: () => void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const SidebarContext = createContext<SidebarContextProps | null>(null)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SidebarContext, type SidebarContextProps } from './SidebarContext'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export {
|
|
2
|
+
CreateComponentContext,
|
|
3
|
+
type CreateComponentContextProps
|
|
4
|
+
} from './CreateComponentContext'
|
|
5
|
+
export {
|
|
6
|
+
CreateDatasetContext,
|
|
7
|
+
type CreateDatasetContextProps
|
|
8
|
+
} from './CreateDatasetContext'
|
|
9
|
+
export { ProjectContext, type ProjectContextProps } from './ProjectContext'
|
|
10
|
+
export { SidebarContext, type SidebarContextProps } from './SidebarContext'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { useCreateComponent } from './useCreateComponent'
|
|
2
|
+
export { useCreateDataset } from './useCreateDataset'
|
|
3
|
+
export { useDebounce } from './useDebounce'
|
|
4
|
+
export { useDebounced } from './useDebounced'
|
|
5
|
+
export { useIsMobile } from './useIsMobile'
|
|
6
|
+
export { useSidebar } from './useSidebar'
|
|
7
|
+
export { useStickyHeader } from './useStickyHeader'
|
|
8
|
+
export { useWindowSize } from './useWindowSize'
|
|
9
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useContext } from 'react'
|
|
4
|
+
|
|
5
|
+
import { CreateComponentContext } from '@/contexts'
|
|
6
|
+
|
|
7
|
+
export function useCreateComponent() {
|
|
8
|
+
const context = useContext(CreateComponentContext)
|
|
9
|
+
//
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error('useCreateComponent')
|
|
12
|
+
}
|
|
13
|
+
//
|
|
14
|
+
return context
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useContext } from 'react'
|
|
4
|
+
|
|
5
|
+
import { CreateDatasetContext } from '@/contexts'
|
|
6
|
+
|
|
7
|
+
export function useCreateDataset() {
|
|
8
|
+
const context = useContext(CreateDatasetContext)
|
|
9
|
+
//
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error('useCreateDataset')
|
|
12
|
+
}
|
|
13
|
+
//
|
|
14
|
+
return context
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
export function useDebounce(value?: string, delay = 500) {
|
|
4
|
+
const [debouncedValue, setDebouncedValue] = useState(value)
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handler = setTimeout(() => {
|
|
8
|
+
setDebouncedValue(value)
|
|
9
|
+
}, delay)
|
|
10
|
+
|
|
11
|
+
return () => {
|
|
12
|
+
clearTimeout(handler)
|
|
13
|
+
}
|
|
14
|
+
}, [value, delay])
|
|
15
|
+
|
|
16
|
+
return debouncedValue
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
export function useDebounced<T extends (...args: any[]) => any>(
|
|
4
|
+
callback: T,
|
|
5
|
+
delay: number
|
|
6
|
+
): T {
|
|
7
|
+
const timeoutRef = useRef<NodeJS.Timeout>(null)
|
|
8
|
+
|
|
9
|
+
const debouncedCallback = useCallback(
|
|
10
|
+
(...args: Parameters<T>) => {
|
|
11
|
+
if (timeoutRef.current) {
|
|
12
|
+
clearTimeout(timeoutRef.current)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
timeoutRef.current = setTimeout(() => {
|
|
16
|
+
callback(...args)
|
|
17
|
+
}, delay)
|
|
18
|
+
},
|
|
19
|
+
[callback, delay]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
return () => {
|
|
24
|
+
if (timeoutRef.current) {
|
|
25
|
+
clearTimeout(timeoutRef.current)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, [])
|
|
29
|
+
|
|
30
|
+
return debouncedCallback as T
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
export function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = useState(false)
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (typeof window === 'undefined') return
|
|
10
|
+
|
|
11
|
+
const mediaQuery = window.matchMedia('(max-width: 992px)')
|
|
12
|
+
|
|
13
|
+
const checkIsMobile = () => {
|
|
14
|
+
setIsMobile(mediaQuery.matches)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
mediaQuery.addEventListener('change', checkIsMobile)
|
|
18
|
+
window.addEventListener('resize', checkIsMobile)
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
mediaQuery.removeEventListener('change', checkIsMobile)
|
|
22
|
+
window.removeEventListener('resize', checkIsMobile)
|
|
23
|
+
}
|
|
24
|
+
}, [])
|
|
25
|
+
|
|
26
|
+
return isMobile
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useContext } from 'react'
|
|
4
|
+
|
|
5
|
+
import { SidebarContext } from '@/contexts'
|
|
6
|
+
|
|
7
|
+
export function useSidebar() {
|
|
8
|
+
const context = useContext(SidebarContext)
|
|
9
|
+
//
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error('useSidebar')
|
|
12
|
+
}
|
|
13
|
+
//
|
|
14
|
+
return context
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RefObject, useCallback, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
export function useStickyHeader(
|
|
4
|
+
scrollContainerRef: RefObject<HTMLDivElement | null>,
|
|
5
|
+
headerRef: RefObject<HTMLTableSectionElement | null>
|
|
6
|
+
) {
|
|
7
|
+
const handleScroll = useCallback(() => {
|
|
8
|
+
const container = scrollContainerRef.current
|
|
9
|
+
const header = headerRef.current
|
|
10
|
+
|
|
11
|
+
if (!container || !header) return
|
|
12
|
+
|
|
13
|
+
const scrollTop = container.scrollTop
|
|
14
|
+
header.style.transform = `translateY(${scrollTop ? scrollTop - 1 : scrollTop}px)`
|
|
15
|
+
header.style.position = 'relative'
|
|
16
|
+
header.style.zIndex = '10'
|
|
17
|
+
}, [scrollContainerRef, headerRef])
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const container = scrollContainerRef.current
|
|
21
|
+
if (!container) return
|
|
22
|
+
|
|
23
|
+
container.addEventListener('scroll', handleScroll, { passive: true })
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
container.removeEventListener('scroll', handleScroll)
|
|
27
|
+
const header = headerRef.current
|
|
28
|
+
if (header) {
|
|
29
|
+
header.style.transform = ''
|
|
30
|
+
header.style.position = ''
|
|
31
|
+
header.style.zIndex = ''
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, [handleScroll, headerRef])
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { IWindowSize } from '@/types'
|
|
4
|
+
|
|
5
|
+
export function useWindowSize() {
|
|
6
|
+
const [windowSize, setWindowSize] = useState<IWindowSize>({
|
|
7
|
+
width: undefined,
|
|
8
|
+
height: undefined
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
function handleResize() {
|
|
13
|
+
setWindowSize({
|
|
14
|
+
width: window.innerWidth,
|
|
15
|
+
height: window.innerHeight
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
handleResize()
|
|
20
|
+
|
|
21
|
+
window.addEventListener('resize', handleResize)
|
|
22
|
+
|
|
23
|
+
return () => window.removeEventListener('resize', handleResize)
|
|
24
|
+
}, [])
|
|
25
|
+
|
|
26
|
+
return windowSize
|
|
27
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { type ReactNode, useMemo, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
import { IFileInfo } from '@/types'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
CreateComponentContext,
|
|
9
|
+
type CreateComponentContextProps
|
|
10
|
+
} from '@/contexts'
|
|
11
|
+
|
|
12
|
+
type CreateComponentProviderProps = {
|
|
13
|
+
children: ReactNode
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function CreateComponentProvider({
|
|
17
|
+
children
|
|
18
|
+
}: CreateComponentProviderProps) {
|
|
19
|
+
const [name, setName] = useState<string>('')
|
|
20
|
+
//
|
|
21
|
+
const [fileInfo, setFileInfo] = useState<IFileInfo | null>(null)
|
|
22
|
+
//
|
|
23
|
+
const [componentPath, setComponentPath] = useState('')
|
|
24
|
+
|
|
25
|
+
const contextValue = useMemo<CreateComponentContextProps>(
|
|
26
|
+
() => ({
|
|
27
|
+
name,
|
|
28
|
+
setName,
|
|
29
|
+
//
|
|
30
|
+
fileInfo,
|
|
31
|
+
setFileInfo,
|
|
32
|
+
//
|
|
33
|
+
componentPath,
|
|
34
|
+
setComponentPath
|
|
35
|
+
}),
|
|
36
|
+
[
|
|
37
|
+
name,
|
|
38
|
+
setName,
|
|
39
|
+
//
|
|
40
|
+
fileInfo,
|
|
41
|
+
setFileInfo,
|
|
42
|
+
//
|
|
43
|
+
componentPath,
|
|
44
|
+
setComponentPath
|
|
45
|
+
]
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<CreateComponentContext.Provider value={contextValue}>
|
|
50
|
+
{children}
|
|
51
|
+
</CreateComponentContext.Provider>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CreateComponentProvider } from './CreateComponentProvider'
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { type ReactNode, useMemo, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
import { IDatasetFileInfo, IFileInfo } from '@/types'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
CreateDatasetContext,
|
|
9
|
+
type CreateDatasetContextProps
|
|
10
|
+
} from '@/contexts'
|
|
11
|
+
|
|
12
|
+
type CreateDatasetProviderProps = {
|
|
13
|
+
children: ReactNode
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function CreateDatasetProvider({
|
|
17
|
+
children
|
|
18
|
+
}: CreateDatasetProviderProps) {
|
|
19
|
+
const [name, setName] = useState<string>('')
|
|
20
|
+
//
|
|
21
|
+
const [sourceType, setSourceType] = useState<string>('source')
|
|
22
|
+
//
|
|
23
|
+
const [fileInfo, setFileInfo] = useState<IFileInfo | null>(null)
|
|
24
|
+
//
|
|
25
|
+
const [datasetFileInfo, setDatasetFileInfo] = useState<IDatasetFileInfo>({
|
|
26
|
+
path: '',
|
|
27
|
+
separator: ';',
|
|
28
|
+
encoding: 'utf-8'
|
|
29
|
+
})
|
|
30
|
+
//
|
|
31
|
+
const [columns, setColumns] = useState<any[]>([])
|
|
32
|
+
|
|
33
|
+
const contextValue = useMemo<CreateDatasetContextProps>(
|
|
34
|
+
() => ({
|
|
35
|
+
name,
|
|
36
|
+
setName,
|
|
37
|
+
//
|
|
38
|
+
sourceType,
|
|
39
|
+
setSourceType,
|
|
40
|
+
//
|
|
41
|
+
fileInfo,
|
|
42
|
+
setFileInfo,
|
|
43
|
+
//
|
|
44
|
+
datasetFileInfo,
|
|
45
|
+
setDatasetFileInfo,
|
|
46
|
+
//
|
|
47
|
+
columns,
|
|
48
|
+
setColumns
|
|
49
|
+
}),
|
|
50
|
+
[
|
|
51
|
+
name,
|
|
52
|
+
setName,
|
|
53
|
+
//
|
|
54
|
+
sourceType,
|
|
55
|
+
setSourceType,
|
|
56
|
+
//
|
|
57
|
+
fileInfo,
|
|
58
|
+
setFileInfo,
|
|
59
|
+
//
|
|
60
|
+
datasetFileInfo,
|
|
61
|
+
setDatasetFileInfo,
|
|
62
|
+
//
|
|
63
|
+
columns,
|
|
64
|
+
setColumns
|
|
65
|
+
]
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<CreateDatasetContext.Provider value={contextValue}>
|
|
70
|
+
{children}
|
|
71
|
+
</CreateDatasetContext.Provider>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CreateDatasetProvider } from './CreateDatasetProvider'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NextIntlClientProvider } from 'next-intl'
|
|
2
|
+
import { getMessages } from 'next-intl/server'
|
|
3
|
+
import { type ComponentProps } from 'react'
|
|
4
|
+
|
|
5
|
+
type LangProviderProps = ComponentProps<typeof NextIntlClientProvider>
|
|
6
|
+
|
|
7
|
+
export async function LangProvider({ children, ...props }: LangProviderProps) {
|
|
8
|
+
const messages = await getMessages()
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<NextIntlClientProvider messages={messages} {...props}>
|
|
12
|
+
{children}
|
|
13
|
+
</NextIntlClientProvider>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LangProvider } from './LangProvider'
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { type ReactNode, useMemo, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
import { LayerModel, useUpdateLayerMutation } from '@/graphql'
|
|
6
|
+
|
|
7
|
+
import { GridSizeType, LayoutsType, ProjectData } from '@/types'
|
|
8
|
+
|
|
9
|
+
import { ProjectContext, type ProjectContextProps } from '@/contexts'
|
|
10
|
+
|
|
11
|
+
type ProjectProviderProps = {
|
|
12
|
+
project: ProjectData
|
|
13
|
+
children: ReactNode
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function ProjectProvider({ project, children }: ProjectProviderProps) {
|
|
17
|
+
const [layer, setLayer] = useState<LayerModel>()
|
|
18
|
+
const [layouts, setLayouts] = useState<LayoutsType>({})
|
|
19
|
+
const [tempLayouts, setTempLayouts] = useState<LayoutsType>({})
|
|
20
|
+
//
|
|
21
|
+
const [isEdit, setIsEdit] = useState(false)
|
|
22
|
+
const [gridKey, setGridKey] = useState(0)
|
|
23
|
+
const [gridSize, setGridSize] = useState<GridSizeType>('full')
|
|
24
|
+
|
|
25
|
+
const [updateLayer] = useUpdateLayerMutation({
|
|
26
|
+
onCompleted() {
|
|
27
|
+
setLayouts(tempLayouts)
|
|
28
|
+
//
|
|
29
|
+
setIsEdit(false)
|
|
30
|
+
setGridSize('full')
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const saveHandler = () => {
|
|
35
|
+
updateLayer({
|
|
36
|
+
variables: {
|
|
37
|
+
data: {
|
|
38
|
+
projectId: project.id,
|
|
39
|
+
layerId: layer!.id,
|
|
40
|
+
layouts: tempLayouts
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const cancelHandler = () => {
|
|
47
|
+
setTempLayouts(layouts)
|
|
48
|
+
//
|
|
49
|
+
setIsEdit(false)
|
|
50
|
+
setGridKey(Math.random())
|
|
51
|
+
setGridSize('full')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const contextValue = useMemo<ProjectContextProps>(
|
|
55
|
+
() => ({
|
|
56
|
+
project,
|
|
57
|
+
//
|
|
58
|
+
layer,
|
|
59
|
+
setLayer,
|
|
60
|
+
//
|
|
61
|
+
layouts,
|
|
62
|
+
setLayouts,
|
|
63
|
+
//
|
|
64
|
+
tempLayouts,
|
|
65
|
+
setTempLayouts,
|
|
66
|
+
//
|
|
67
|
+
isEdit,
|
|
68
|
+
setIsEdit,
|
|
69
|
+
//
|
|
70
|
+
gridKey,
|
|
71
|
+
setGridKey,
|
|
72
|
+
//
|
|
73
|
+
gridSize,
|
|
74
|
+
setGridSize,
|
|
75
|
+
//
|
|
76
|
+
saveHandler,
|
|
77
|
+
cancelHandler
|
|
78
|
+
}),
|
|
79
|
+
[
|
|
80
|
+
project,
|
|
81
|
+
//
|
|
82
|
+
layer,
|
|
83
|
+
setLayer,
|
|
84
|
+
//
|
|
85
|
+
layouts,
|
|
86
|
+
setLayouts,
|
|
87
|
+
//
|
|
88
|
+
tempLayouts,
|
|
89
|
+
setTempLayouts,
|
|
90
|
+
//
|
|
91
|
+
isEdit,
|
|
92
|
+
setIsEdit,
|
|
93
|
+
//
|
|
94
|
+
gridKey,
|
|
95
|
+
setGridKey,
|
|
96
|
+
//
|
|
97
|
+
gridSize,
|
|
98
|
+
setGridSize,
|
|
99
|
+
//
|
|
100
|
+
saveHandler,
|
|
101
|
+
cancelHandler
|
|
102
|
+
]
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<ProjectContext.Provider value={contextValue}>
|
|
107
|
+
{children}
|
|
108
|
+
</ProjectContext.Provider>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProjectProvider } from './ProjectProvider'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { type ReactNode, useEffect, useMemo } from 'react'
|
|
4
|
+
|
|
5
|
+
import { sidebarStore } from '@/store'
|
|
6
|
+
|
|
7
|
+
import { SidebarContext, type SidebarContextProps } from '@/contexts'
|
|
8
|
+
import { useIsMobile } from '@/hooks'
|
|
9
|
+
|
|
10
|
+
type SidebarProviderProps = {
|
|
11
|
+
children: ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function SidebarProvider({ children }: SidebarProviderProps) {
|
|
15
|
+
const isMobile = useIsMobile()
|
|
16
|
+
const isOpen = sidebarStore(state => state.isOpen)
|
|
17
|
+
const setIsOpen = sidebarStore(state => state.setIsOpen)
|
|
18
|
+
|
|
19
|
+
const toggleSidebar = () => {
|
|
20
|
+
setIsOpen(!isOpen)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
24
|
+
if (e.code === 'KeyB' && (e.metaKey || e.ctrlKey)) {
|
|
25
|
+
e.preventDefault()
|
|
26
|
+
toggleSidebar()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
window.addEventListener('keydown', handleKeyDown)
|
|
32
|
+
//
|
|
33
|
+
return () => window.removeEventListener('keydown', handleKeyDown)
|
|
34
|
+
}, [])
|
|
35
|
+
|
|
36
|
+
const contextValue = useMemo<SidebarContextProps>(
|
|
37
|
+
() => ({
|
|
38
|
+
isOpen,
|
|
39
|
+
isMobile,
|
|
40
|
+
setIsOpen,
|
|
41
|
+
toggleSidebar
|
|
42
|
+
}),
|
|
43
|
+
[isOpen, isMobile, setIsOpen, toggleSidebar]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<SidebarContext.Provider value={contextValue}>
|
|
48
|
+
{children}
|
|
49
|
+
</SidebarContext.Provider>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SidebarProvider } from './SidebarProvider'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
|
4
|
+
import { type ComponentProps } from 'react'
|
|
5
|
+
|
|
6
|
+
type ThemeProviderProps = ComponentProps<typeof NextThemesProvider>
|
|
7
|
+
|
|
8
|
+
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
|
9
|
+
return (
|
|
10
|
+
<NextThemesProvider
|
|
11
|
+
attribute='class'
|
|
12
|
+
defaultTheme='system'
|
|
13
|
+
enableSystem
|
|
14
|
+
disableTransitionOnChange
|
|
15
|
+
{...props}
|
|
16
|
+
>
|
|
17
|
+
{children}
|
|
18
|
+
</NextThemesProvider>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ThemeProvider } from './ThemeProvider'
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CreateComponentProvider } from './CreateComponentProvider'
|
|
2
|
+
export { CreateDatasetProvider } from './CreateDatasetProvider'
|
|
3
|
+
export { LangProvider } from './LangProvider'
|
|
4
|
+
export { SidebarProvider } from './SidebarProvider'
|
|
5
|
+
export { ThemeProvider } from './ThemeProvider'
|
|
6
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { create } from 'zustand'
|
|
2
|
+
import { createJSONStorage, persist } from 'zustand/middleware'
|
|
3
|
+
|
|
4
|
+
import type { SidebarStore } from './sidebar.type'
|
|
5
|
+
|
|
6
|
+
export const sidebarStore = create(
|
|
7
|
+
persist<SidebarStore>(
|
|
8
|
+
set => ({
|
|
9
|
+
isOpen: false,
|
|
10
|
+
setIsOpen: (value: boolean) => set({ isOpen: value })
|
|
11
|
+
}),
|
|
12
|
+
{
|
|
13
|
+
name: 'sidebar',
|
|
14
|
+
storage: createJSONStorage(() => localStorage)
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
)
|