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,202 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
2
|
+
@import 'tw-animate-css';
|
|
3
|
+
|
|
4
|
+
@theme {
|
|
5
|
+
--color-primary: #7367f0;
|
|
6
|
+
--color-primary-100: #e3e1fc;
|
|
7
|
+
--color-primary-200: #c7c2f9;
|
|
8
|
+
--color-primary-300: #aba4f6;
|
|
9
|
+
--color-primary-400: #8f85f3;
|
|
10
|
+
--color-primary-500: #7367f0;
|
|
11
|
+
--color-primary-600: #685dd8;
|
|
12
|
+
--color-primary-700: #6258cc;
|
|
13
|
+
--color-primary-800: #5c52c0;
|
|
14
|
+
--color-primary-900: #564db4;
|
|
15
|
+
/* */
|
|
16
|
+
--color-secondary: #a8aaae;
|
|
17
|
+
--color-secondary-100: #eeeeef;
|
|
18
|
+
--color-secondary-200: #dcdddf;
|
|
19
|
+
--color-secondary-300: #cbccce;
|
|
20
|
+
--color-secondary-400: #b9bbbe;
|
|
21
|
+
--color-secondary-500: #a8aaae;
|
|
22
|
+
--color-secondary-600: #98999d;
|
|
23
|
+
--color-secondary-700: #8f9194;
|
|
24
|
+
--color-secondary-800: #86888b;
|
|
25
|
+
--color-secondary-900: #7e7f82;
|
|
26
|
+
/* */
|
|
27
|
+
--color-gray: #a5a3ae;
|
|
28
|
+
--color-gray-100: #f6f6f7;
|
|
29
|
+
--color-gray-200: #dbdade;
|
|
30
|
+
--color-gray-300: #c9c7ce;
|
|
31
|
+
--color-gray-400: #b7b5be;
|
|
32
|
+
--color-gray-500: #a5a3ae;
|
|
33
|
+
--color-gray-600: #93909d;
|
|
34
|
+
--color-gray-700: #817d8d;
|
|
35
|
+
--color-gray-800: #6f6b7d;
|
|
36
|
+
--color-gray-900: #5d586c;
|
|
37
|
+
/* */
|
|
38
|
+
--color-success: #28c76f;
|
|
39
|
+
--color-success-100: #d4f4e2;
|
|
40
|
+
--color-success-200: #a9e9c5;
|
|
41
|
+
--color-success-300: #7edda9;
|
|
42
|
+
--color-success-400: #53d28c;
|
|
43
|
+
--color-success-500: #28c76f;
|
|
44
|
+
--color-success-600: #24b364;
|
|
45
|
+
--color-success-700: #22a95e;
|
|
46
|
+
--color-success-800: #209f59;
|
|
47
|
+
--color-success-900: #1e9553;
|
|
48
|
+
/* */
|
|
49
|
+
--color-danger: #ea5455;
|
|
50
|
+
--color-danger-100: #fbdddd;
|
|
51
|
+
--color-danger-200: #f7bbbb;
|
|
52
|
+
--color-danger-300: #f29899;
|
|
53
|
+
--color-danger-400: #ee7677;
|
|
54
|
+
--color-danger-500: #ea5455;
|
|
55
|
+
--color-danger-600: #d34c4d;
|
|
56
|
+
--color-danger-700: #c74748;
|
|
57
|
+
--color-danger-800: #bb4344;
|
|
58
|
+
--color-danger-900: #af3f40;
|
|
59
|
+
/* */
|
|
60
|
+
--color-warning: #ff9f43;
|
|
61
|
+
--color-warning-100: #ffecd9;
|
|
62
|
+
--color-warning-200: #ffd9b4;
|
|
63
|
+
--color-warning-300: #ffc58e;
|
|
64
|
+
--color-warning-400: #ffb269;
|
|
65
|
+
--color-warning-500: #ff9f43;
|
|
66
|
+
--color-warning-600: #e68f3c;
|
|
67
|
+
--color-warning-700: #d98739;
|
|
68
|
+
--color-warning-800: #cc7f36;
|
|
69
|
+
--color-warning-900: #bf7732;
|
|
70
|
+
/* */
|
|
71
|
+
--color-info: #00cfe8;
|
|
72
|
+
--color-info-100: #ccf5fa;
|
|
73
|
+
--color-info-200: #99ecf6;
|
|
74
|
+
--color-info-300: #66e2f1;
|
|
75
|
+
--color-info-400: #33d9ed;
|
|
76
|
+
--color-info-500: #00cfe8;
|
|
77
|
+
--color-info-600: #00bbd1;
|
|
78
|
+
--color-info-700: #00b0c5;
|
|
79
|
+
--color-info-800: #00a6ba;
|
|
80
|
+
--color-info-900: #009bae;
|
|
81
|
+
/* */
|
|
82
|
+
--color-blue: #007bff;
|
|
83
|
+
--color-indigo: #6610f2;
|
|
84
|
+
--color-purple: #7367f0;
|
|
85
|
+
--color-pink: #e83e8c;
|
|
86
|
+
--color-red: #ea5455;
|
|
87
|
+
--color-orange: #fd7e14;
|
|
88
|
+
--color-yellow: #ff9f43;
|
|
89
|
+
--color-green: #28c76f;
|
|
90
|
+
--color-teal: #20c997;
|
|
91
|
+
--color-cyan: #00cfe8;
|
|
92
|
+
/* */
|
|
93
|
+
--color-tooltip: #2f3349;
|
|
94
|
+
--color-divider: #dbdade;
|
|
95
|
+
/* */
|
|
96
|
+
--color-background: #f8f7fa;
|
|
97
|
+
/* */
|
|
98
|
+
/* */
|
|
99
|
+
/* */
|
|
100
|
+
--gradient-primary: 133deg, #7367f0 0%, rgba(115, 103, 240, 0.7) 100%;
|
|
101
|
+
/* */
|
|
102
|
+
/* */
|
|
103
|
+
/* */
|
|
104
|
+
--shadow-primary-sm: 0 2px 3px 0 rgba(115, 103, 240, 0.3);
|
|
105
|
+
--shadow-primary: 0 4px 16px 0 rgba(115, 103, 240, 0.45);
|
|
106
|
+
--shadow-primary-lg: 0 10px 20px 0 rgba(115, 103, 240, 0.4);
|
|
107
|
+
/* */
|
|
108
|
+
--shadow-sm: 0 2px 4px 0 rgba(165, 163, 174, 0.3);
|
|
109
|
+
--shadow-md: 0 4px 16px 0 rgba(165, 163, 174, 0.45);
|
|
110
|
+
--shadow-lg: 0 10px 20px 5px rgba(165, 163, 174, 0.4);
|
|
111
|
+
/* */
|
|
112
|
+
--shadow-extra: 0 4px 18px 0 rgba(75, 70, 92, 0.1);
|
|
113
|
+
/* */
|
|
114
|
+
/* */
|
|
115
|
+
/* */
|
|
116
|
+
--text-2xs: 9px;
|
|
117
|
+
--text-xs: 11px;
|
|
118
|
+
--text-sm: 13px;
|
|
119
|
+
--text-base: 15px;
|
|
120
|
+
--text-lg: 17px;
|
|
121
|
+
--text-xl: 19px;
|
|
122
|
+
--text-2xl: 22px;
|
|
123
|
+
--text-3xl: 32px;
|
|
124
|
+
--text-4xl: 38px;
|
|
125
|
+
/* */
|
|
126
|
+
/* */
|
|
127
|
+
/* */
|
|
128
|
+
--default-transition-duration: 250ms;
|
|
129
|
+
/* */
|
|
130
|
+
/* */
|
|
131
|
+
/* */
|
|
132
|
+
--breakpoint-sm: 576px;
|
|
133
|
+
--breakpoint-md: 768px;
|
|
134
|
+
--breakpoint-lg: 992px;
|
|
135
|
+
--breakpoint-xl: 1200px;
|
|
136
|
+
--breakpoint-2xl: 1440px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
140
|
+
|
|
141
|
+
@media (prefers-color-scheme: dark) {
|
|
142
|
+
@theme {
|
|
143
|
+
/* */
|
|
144
|
+
--color-dark-gray: #8692d0;
|
|
145
|
+
--color-dark-gray-100: #e7e9f6;
|
|
146
|
+
--color-dark-gray-200: #cfd3ec;
|
|
147
|
+
--color-dark-gray-300: #b6bee3;
|
|
148
|
+
--color-dark-gray-400: #aab2de;
|
|
149
|
+
--color-dark-gray-500: #8692d0;
|
|
150
|
+
--color-dark-gray-600: #7984bc;
|
|
151
|
+
--color-dark-gray-700: #5e6692;
|
|
152
|
+
--color-dark-gray-800: #4a5072;
|
|
153
|
+
--color-dark-gray-900: #2f3349;
|
|
154
|
+
/* */
|
|
155
|
+
--color-dark-tooltip: #5d586c;
|
|
156
|
+
--color-dark-divider: #434968;
|
|
157
|
+
/* */
|
|
158
|
+
--color-dark-background: #25293c;
|
|
159
|
+
/* */
|
|
160
|
+
/* */
|
|
161
|
+
/* */
|
|
162
|
+
--shadow-dark-sm: 0 2px 4px 0 rgba(15, 20, 34, 0.4);
|
|
163
|
+
--shadow-dark-sm: 0 4px 16px 0 rgba(15, 20, 34, 0.45);
|
|
164
|
+
--shadow-dark-lg: 0 10px 20px 0 rgba(15, 20, 34, 0.5);
|
|
165
|
+
/* */
|
|
166
|
+
--shadow-dark-extra: 0 4px 20px 0 rgba(15, 20, 34, 0.4);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
html,
|
|
171
|
+
body {
|
|
172
|
+
overflow-x: hidden;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
a:hover,
|
|
176
|
+
button:hover {
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
a,
|
|
181
|
+
button {
|
|
182
|
+
outline: none;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* */
|
|
186
|
+
|
|
187
|
+
.is-grid {
|
|
188
|
+
background:
|
|
189
|
+
linear-gradient(#bbb, transparent 1px),
|
|
190
|
+
linear-gradient(90deg, #bbb, transparent 1px);
|
|
191
|
+
background-size: 15px 15px;
|
|
192
|
+
background-position: 0 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.is-edit .react-grid-item .echarts-for-react {
|
|
196
|
+
pointer-events: none;
|
|
197
|
+
opacity: 0.5;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.react-grid-item.react-draggable {
|
|
201
|
+
cursor: move;
|
|
202
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export type DatasetsTableDataItem = Record<
|
|
4
|
+
| 'type'
|
|
5
|
+
| 'name'
|
|
6
|
+
| 'items'
|
|
7
|
+
| 'connects'
|
|
8
|
+
| 'source'
|
|
9
|
+
| 'author'
|
|
10
|
+
| 'createdAt'
|
|
11
|
+
| 'editedAt'
|
|
12
|
+
| 'updatedAt'
|
|
13
|
+
| 'status',
|
|
14
|
+
ReactNode
|
|
15
|
+
>
|
|
16
|
+
|
|
17
|
+
export type DatasetType =
|
|
18
|
+
| 'api'
|
|
19
|
+
| 'txt'
|
|
20
|
+
| 'csv'
|
|
21
|
+
| 'xml'
|
|
22
|
+
| 'xls'
|
|
23
|
+
| 'xlsx'
|
|
24
|
+
| 'json'
|
|
25
|
+
| 'db'
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export interface IWindowSize {
|
|
2
|
+
width?: number
|
|
3
|
+
height?: number
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/////
|
|
7
|
+
|
|
8
|
+
export interface IColumnItem {
|
|
9
|
+
key: string
|
|
10
|
+
title: string
|
|
11
|
+
sort?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/////
|
|
15
|
+
|
|
16
|
+
export type SortType = 'asc' | 'desc' | false
|
|
17
|
+
|
|
18
|
+
export interface ISortItem {
|
|
19
|
+
column: string
|
|
20
|
+
order: SortType
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/////
|
|
24
|
+
|
|
25
|
+
export interface IDataQuery {
|
|
26
|
+
q?: string
|
|
27
|
+
sort?: string
|
|
28
|
+
filter?: string
|
|
29
|
+
page?: string
|
|
30
|
+
limit?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface IGetDataOptions {
|
|
34
|
+
q?: string
|
|
35
|
+
sort?: ISortItem[]
|
|
36
|
+
filter?: Record<string, any>
|
|
37
|
+
page?: number
|
|
38
|
+
limit?: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/////
|
|
42
|
+
|
|
43
|
+
export interface IPaginationOptions {
|
|
44
|
+
page: number
|
|
45
|
+
limit: number
|
|
46
|
+
pages: number
|
|
47
|
+
total: number
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IPagination extends IPaginationOptions {
|
|
51
|
+
hasPrevPage: boolean
|
|
52
|
+
hasNextPage: boolean
|
|
53
|
+
pageNumbers: (number | 'ellipsis')[]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/////
|
|
57
|
+
|
|
58
|
+
export interface IFilterQuery {
|
|
59
|
+
querykey: string
|
|
60
|
+
queryFn: (params: any) => any
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/////
|
|
64
|
+
|
|
65
|
+
export type TranslateFn = (
|
|
66
|
+
key: string,
|
|
67
|
+
values?: Record<string, string | number | Date>
|
|
68
|
+
) => string
|
|
69
|
+
|
|
70
|
+
/////
|
|
71
|
+
|
|
72
|
+
export enum AccessType {
|
|
73
|
+
VIEW = 'view',
|
|
74
|
+
EDIT = 'edit',
|
|
75
|
+
ALL = 'all'
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface IGuardItem {
|
|
79
|
+
id: number
|
|
80
|
+
type: AccessType
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface IGuard {
|
|
84
|
+
users: IGuardItem[]
|
|
85
|
+
groups: IGuardItem[]
|
|
86
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './general.type'
|
|
2
|
+
//
|
|
3
|
+
export type { ComponentsTableDataItem } from './component.type'
|
|
4
|
+
export type { DatasetsTableDataItem, DatasetType } from './dataset.type'
|
|
5
|
+
export type { IDatasetFileInfo, IFileInfo } from './file.type'
|
|
6
|
+
export type { BreakpointType, GridSizeType, LayoutsType } from './layer.type'
|
|
7
|
+
export type { ProjectData, ProjectsTableDataItem } from './project.type'
|
|
8
|
+
export type { UsersTableDataItem } from './user.type'
|
|
9
|
+
export type { WidgetsTableDataItem } from './widget.type'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { ProjectModel, ThemeModel } from '@/graphql'
|
|
4
|
+
|
|
5
|
+
export type ProjectData = Pick<
|
|
6
|
+
ProjectModel,
|
|
7
|
+
'id' | 'name' | 'previewPath' | 'icon' | 'layers'
|
|
8
|
+
> & {
|
|
9
|
+
theme: Pick<ThemeModel, 'options'>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type ProjectsTableDataItem = Record<
|
|
13
|
+
'icon' | 'name' | 'description' | 'author' | 'createdAt' | 'editedAt',
|
|
14
|
+
ReactNode
|
|
15
|
+
>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export const _ = {
|
|
2
|
+
/**
|
|
3
|
+
* Проверяет является ли значение булевым
|
|
4
|
+
* @param {unknown} value
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
isBoolean(value: unknown): value is boolean {
|
|
8
|
+
return typeof value === 'boolean'
|
|
9
|
+
},
|
|
10
|
+
/**
|
|
11
|
+
* Проверяет является ли значение null
|
|
12
|
+
* @param {unknown} value
|
|
13
|
+
* @returns {boolean}
|
|
14
|
+
*/
|
|
15
|
+
isNull(value: unknown): value is null {
|
|
16
|
+
return value === null
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Проверяет является ли значение undefined
|
|
20
|
+
* @param {unknown} value
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
isUndefined(value: unknown): value is undefined {
|
|
24
|
+
return value === undefined
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Проверяет является ли значение строкой
|
|
28
|
+
* @param {unknown} value
|
|
29
|
+
* @returns {boolean}
|
|
30
|
+
*/
|
|
31
|
+
isString(value: unknown): value is string {
|
|
32
|
+
return typeof value === 'string'
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Проверяет является ли значение числом
|
|
36
|
+
* @param {unknown} value
|
|
37
|
+
* @returns {boolean}
|
|
38
|
+
*/
|
|
39
|
+
isNumber(value: unknown): value is number {
|
|
40
|
+
return typeof value === 'number'
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Проверяет является ли значение датой
|
|
44
|
+
* @param {unknown} value
|
|
45
|
+
* @returns {boolean}
|
|
46
|
+
*/
|
|
47
|
+
isDate(value: unknown): value is Date {
|
|
48
|
+
return value instanceof Date
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Проверяет является ли значение массивом
|
|
52
|
+
* @param {unknown} value
|
|
53
|
+
* @returns {boolean}
|
|
54
|
+
*/
|
|
55
|
+
isArray(value: unknown): value is Array<unknown> {
|
|
56
|
+
return Array.isArray(value)
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Проверяет является ли значение объектом
|
|
60
|
+
* @param {unknown} value
|
|
61
|
+
* @returns {boolean}
|
|
62
|
+
*/
|
|
63
|
+
isObject(value: unknown): value is Record<string, unknown> {
|
|
64
|
+
return (
|
|
65
|
+
typeof value === 'object' &&
|
|
66
|
+
!this.isNull(value) &&
|
|
67
|
+
!this.isArray(value) &&
|
|
68
|
+
!this.isDate(value) &&
|
|
69
|
+
!(value instanceof RegExp) &&
|
|
70
|
+
!(value instanceof Map) &&
|
|
71
|
+
!(value instanceof Set)
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
//////////////////////////////
|
|
75
|
+
/**
|
|
76
|
+
* Проверка на пустое значение (null, undefined, '', [], {})
|
|
77
|
+
* @param {unknown} value
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
isEmpty(value: unknown) {
|
|
81
|
+
if (this.isNull(value) || this.isUndefined(value)) return true
|
|
82
|
+
if (this.isString(value) || this.isArray(value)) {
|
|
83
|
+
return value.length === 0
|
|
84
|
+
}
|
|
85
|
+
if (this.isObject(value)) {
|
|
86
|
+
return Object.keys(value).length === 0
|
|
87
|
+
}
|
|
88
|
+
return false
|
|
89
|
+
},
|
|
90
|
+
//////////////////////////////
|
|
91
|
+
/**
|
|
92
|
+
* Приведение значения к булевому значению
|
|
93
|
+
* @param {unknown} value
|
|
94
|
+
* @returns {boolean}
|
|
95
|
+
*/
|
|
96
|
+
toBoolean(value: unknown): boolean {
|
|
97
|
+
if (this.isString(value)) {
|
|
98
|
+
const lowerValue = value.trim().toLowerCase()
|
|
99
|
+
if (lowerValue === 'true') {
|
|
100
|
+
return true
|
|
101
|
+
}
|
|
102
|
+
if (lowerValue === 'false') {
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return Boolean(value)
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* Приведение значения к числу
|
|
111
|
+
* @param {unknown} value
|
|
112
|
+
* @returns {number}
|
|
113
|
+
*/
|
|
114
|
+
toNumber(value: unknown): number {
|
|
115
|
+
if (this.isString(value)) {
|
|
116
|
+
const trimmedValue = value.trim()
|
|
117
|
+
|
|
118
|
+
if (trimmedValue === '') {
|
|
119
|
+
return 0
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const num = Number(trimmedValue)
|
|
123
|
+
|
|
124
|
+
if (!isNaN(num) && isFinite(num)) {
|
|
125
|
+
return num
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const lowerValue = trimmedValue.toLowerCase()
|
|
129
|
+
if (lowerValue === 'true') {
|
|
130
|
+
return 1
|
|
131
|
+
}
|
|
132
|
+
if (lowerValue === 'false') {
|
|
133
|
+
return 0
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return 0
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this.isNull(value) || this.isUndefined(value) || value === false) {
|
|
140
|
+
return 0
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (value === true) {
|
|
144
|
+
return 1
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const num = Number(value)
|
|
148
|
+
return isNaN(num) || !isFinite(num) ? 0 : num
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const b = 1
|
|
2
|
+
const kb = b * 1024
|
|
3
|
+
const mb = kb * 1024
|
|
4
|
+
const gb = mb * 1024
|
|
5
|
+
const tb = gb * 1024
|
|
6
|
+
const pb = tb * 1024
|
|
7
|
+
|
|
8
|
+
type SizeUnit =
|
|
9
|
+
| 'Bytes'
|
|
10
|
+
| 'Byte'
|
|
11
|
+
| 'B'
|
|
12
|
+
| 'Kilobytes'
|
|
13
|
+
| 'Kilobyte'
|
|
14
|
+
| 'Kb'
|
|
15
|
+
| 'KB'
|
|
16
|
+
| 'K'
|
|
17
|
+
| 'Megabytes'
|
|
18
|
+
| 'Megabyte'
|
|
19
|
+
| 'Mb'
|
|
20
|
+
| 'MB'
|
|
21
|
+
| 'M'
|
|
22
|
+
| 'Gigabytes'
|
|
23
|
+
| 'Gigabyte'
|
|
24
|
+
| 'Gb'
|
|
25
|
+
| 'GB'
|
|
26
|
+
| 'G'
|
|
27
|
+
| 'Terabytes'
|
|
28
|
+
| 'Terabyte'
|
|
29
|
+
| 'Tb'
|
|
30
|
+
| 'TB'
|
|
31
|
+
| 'T'
|
|
32
|
+
| 'Petabytes'
|
|
33
|
+
| 'Petabyte'
|
|
34
|
+
| 'Pb'
|
|
35
|
+
| 'PB'
|
|
36
|
+
| 'P'
|
|
37
|
+
|
|
38
|
+
type SizeUnitAnyCase = SizeUnit | Uppercase<SizeUnit> | Lowercase<SizeUnit>
|
|
39
|
+
|
|
40
|
+
export type SizeStringValue =
|
|
41
|
+
| `${number}`
|
|
42
|
+
| `${number}${SizeUnitAnyCase}`
|
|
43
|
+
| `${number} ${SizeUnitAnyCase}`
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Парсит строку с размером файла и возвращает размер в байтах
|
|
47
|
+
* @param str - строка с размером, например '2GB', '1.5 MB', '512kb', '1024'
|
|
48
|
+
* @returns размер в байтах
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* bytes('2GB') // вернет 2147483648
|
|
52
|
+
* bytes('1.5 MB') // вернет 1572864
|
|
53
|
+
* bytes('512kb') // вернет 524288
|
|
54
|
+
* bytes('1024') // вернет 1024 (байты по умолчанию)
|
|
55
|
+
*/
|
|
56
|
+
export const bytes = (str: SizeStringValue): number => {
|
|
57
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 100) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
'Value provided to bytes() must be a string with length between 1 and 99.'
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const match =
|
|
64
|
+
/^(?<value>-?(?:\d+)?\.?\d+) *(?<type>bytes?|b|kilobytes?|kb|k|megabytes?|mb|m|gigabytes?|gb|g|terabytes?|tb|t|petabytes?|pb|p)?$/i.exec(
|
|
65
|
+
str
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
const groups = match?.groups as { value: string; type?: string } | undefined
|
|
69
|
+
if (!groups) {
|
|
70
|
+
return NaN
|
|
71
|
+
}
|
|
72
|
+
const n = parseFloat(groups.value)
|
|
73
|
+
const type = (groups.type || 'b').toLowerCase() as Lowercase<SizeUnit>
|
|
74
|
+
|
|
75
|
+
switch (type) {
|
|
76
|
+
case 'petabytes':
|
|
77
|
+
case 'petabyte':
|
|
78
|
+
case 'pb':
|
|
79
|
+
case 'p':
|
|
80
|
+
return n * pb
|
|
81
|
+
case 'terabytes':
|
|
82
|
+
case 'terabyte':
|
|
83
|
+
case 'tb':
|
|
84
|
+
case 't':
|
|
85
|
+
return n * tb
|
|
86
|
+
case 'gigabytes':
|
|
87
|
+
case 'gigabyte':
|
|
88
|
+
case 'gb':
|
|
89
|
+
case 'g':
|
|
90
|
+
return n * gb
|
|
91
|
+
case 'megabytes':
|
|
92
|
+
case 'megabyte':
|
|
93
|
+
case 'mb':
|
|
94
|
+
case 'm':
|
|
95
|
+
return n * mb
|
|
96
|
+
case 'kilobytes':
|
|
97
|
+
case 'kilobyte':
|
|
98
|
+
case 'kb':
|
|
99
|
+
case 'k':
|
|
100
|
+
return n * kb
|
|
101
|
+
case 'bytes':
|
|
102
|
+
case 'byte':
|
|
103
|
+
case 'b':
|
|
104
|
+
return n
|
|
105
|
+
default:
|
|
106
|
+
throw new Error(
|
|
107
|
+
`Error: size unit ${type} was recognized but does not have a corresponding case. Please check the input.`
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import dayjs from 'dayjs'
|
|
2
|
+
import 'dayjs/locale/ru'
|
|
3
|
+
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
4
|
+
import updateLocale from 'dayjs/plugin/updateLocale'
|
|
5
|
+
|
|
6
|
+
dayjs.extend(relativeTime)
|
|
7
|
+
dayjs.extend(updateLocale)
|
|
8
|
+
|
|
9
|
+
dayjs.locale('ru')
|
|
10
|
+
|
|
11
|
+
dayjs.updateLocale('ru', {
|
|
12
|
+
relativeTime: {
|
|
13
|
+
past: '%s назад',
|
|
14
|
+
s: 'несколько секунд',
|
|
15
|
+
m: '1 минута',
|
|
16
|
+
mm: '%d минут',
|
|
17
|
+
h: '1 час',
|
|
18
|
+
hh: '%d часов',
|
|
19
|
+
d: '1 день',
|
|
20
|
+
dd: '%d дней'
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export function isWeekPassed(fromDate: string | number | Date): boolean {
|
|
25
|
+
const startDate = dayjs(fromDate)
|
|
26
|
+
const dateAfter7Days = startDate.add(7, 'day')
|
|
27
|
+
return dayjs().isAfter(dateAfter7Days)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function fromNow(fromDate: string | number | Date): string {
|
|
31
|
+
return dayjs(fromDate).fromNow()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getFormatDate(
|
|
35
|
+
date: string | number | Date,
|
|
36
|
+
locale: string
|
|
37
|
+
): string {
|
|
38
|
+
const getDateFormat = (locale: string) => {
|
|
39
|
+
switch (locale) {
|
|
40
|
+
case 'en':
|
|
41
|
+
return 'MM/DD/YYYY, hh:mm A'
|
|
42
|
+
case 'ru':
|
|
43
|
+
default:
|
|
44
|
+
return 'DD.MM.YYYY, HH:mm'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return dayjs(date).format(getDateFormat(locale))
|
|
49
|
+
}
|