@sqrzro/admin 2.0.0-beta.0 → 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/.turbo/turbo-docs.log +0 -0
- package/.turbo/turbo-lint.log +112 -0
- package/.turbo/turbo-prettier.log +215 -0
- package/.turbo/turbo-test.log +6 -0
- package/dist/components/Alert/index.d.ts +4 -26
- package/dist/components/Alert/index.js +15 -54
- package/dist/components/Allow/index.d.ts +20 -20
- package/dist/components/Allow/index.js +29 -29
- package/dist/components/AppLayout/AppLayout.stories.d.ts +5 -5
- package/dist/components/AppLayout/AppLayout.stories.js +11 -11
- package/dist/components/AppLayout/index.d.ts +6 -6
- package/dist/components/AppLayout/index.js +18 -11
- package/dist/components/AutoSuggest/index.d.ts +74 -74
- package/dist/components/AutoSuggest/index.js +143 -143
- package/dist/components/Button/Button.stories.d.ts +11 -11
- package/dist/components/Button/Button.stories.js +41 -41
- package/dist/components/Button/index.d.ts +49 -50
- package/dist/components/Button/index.js +50 -50
- package/dist/components/CalendarInput/index.d.ts +24 -24
- package/dist/components/CalendarInput/index.js +54 -56
- package/dist/components/CheckboxList/index.d.ts +17 -17
- package/dist/components/CheckboxList/index.js +25 -25
- package/dist/components/CodeInput/index.d.ts +9 -9
- package/dist/components/CodeInput/index.js +51 -57
- package/dist/components/ConnectedDropdown/index.d.ts +14 -14
- package/dist/components/ConnectedDropdown/index.js +36 -36
- package/dist/components/ConnectedList/index.d.ts +5 -5
- package/dist/components/ConnectedList/index.js +7 -7
- package/dist/components/ConnectedTable/index.d.ts +5 -5
- package/dist/components/ConnectedTable/index.js +7 -7
- package/dist/components/ContentBlock/index.d.ts +16 -16
- package/dist/components/ContentBlock/index.js +13 -13
- package/dist/components/DataPanel/index.d.ts +8 -8
- package/dist/components/DataPanel/index.js +8 -8
- package/dist/components/DateInput/index.d.ts +18 -18
- package/dist/components/DateInput/index.js +81 -81
- package/dist/components/Dropdown/index.d.ts +36 -36
- package/dist/components/Dropdown/index.js +122 -122
- package/dist/components/ErrorMessage/index.d.ts +16 -16
- package/dist/components/ErrorMessage/index.js +17 -17
- package/dist/components/Fieldset/index.d.ts +18 -18
- package/dist/components/Fieldset/index.js +19 -19
- package/dist/components/FileInput/index.d.ts +10 -10
- package/dist/components/FileInput/index.js +26 -26
- package/dist/components/FilterLink/index.d.ts +14 -14
- package/dist/components/FilterLink/index.js +15 -15
- package/dist/components/Form/index.d.ts +14 -14
- package/dist/components/Form/index.js +15 -15
- package/dist/components/FormActions/index.d.ts +18 -18
- package/dist/components/FormActions/index.js +14 -14
- package/dist/components/FormField/index.d.ts +14 -14
- package/dist/components/FormField/index.js +40 -40
- package/dist/components/FormRepeater/index.d.ts +18 -18
- package/dist/components/FormRepeater/index.js +65 -65
- package/dist/components/ImageInput/index.d.ts +13 -13
- package/dist/components/ImageInput/index.js +45 -45
- package/dist/components/InfoPanel/index.d.ts +14 -14
- package/dist/components/InfoPanel/index.js +11 -11
- package/dist/components/Link/__mocks__/index.d.ts +6 -6
- package/dist/components/Link/__mocks__/index.js +12 -12
- package/dist/components/Link/index.d.ts +23 -23
- package/dist/components/Link/index.js +21 -21
- package/dist/components/List/index.d.ts +36 -36
- package/dist/components/List/index.js +46 -46
- package/dist/components/ListActions/index.d.ts +18 -18
- package/dist/components/ListActions/index.js +14 -14
- package/dist/components/LoginForm/index.d.ts +3 -3
- package/dist/components/LoginForm/index.js +47 -47
- package/dist/components/Message/index.d.ts +14 -14
- package/dist/components/Message/index.js +14 -14
- package/dist/components/Modal/index.d.ts +4 -4
- package/dist/components/Modal/index.js +18 -18
- package/dist/components/ModalActions/index.d.ts +21 -21
- package/dist/components/ModalActions/index.js +18 -18
- package/dist/components/MoneyInput/index.d.ts +10 -10
- package/dist/components/MoneyInput/index.js +13 -13
- package/dist/components/PasswordForm/index.d.ts +35 -35
- package/dist/components/PasswordForm/index.js +21 -21
- package/dist/components/PasswordInput/index.d.ts +4 -4
- package/dist/components/PasswordInput/index.js +12 -12
- package/dist/components/RadioList/index.d.ts +9 -9
- package/dist/components/RadioList/index.js +7 -7
- package/dist/components/RootLayout/index.d.ts +6 -8
- package/dist/components/RootLayout/index.js +7 -21
- package/dist/components/SummaryList/index.d.ts +18 -18
- package/dist/components/SummaryList/index.js +15 -15
- package/dist/components/Switch/index.d.ts +21 -21
- package/dist/components/Switch/index.js +31 -31
- package/dist/components/Table/index.d.ts +28 -28
- package/dist/components/Table/index.js +55 -55
- package/dist/components/Tag/index.d.ts +15 -15
- package/dist/components/Tag/index.js +13 -13
- package/dist/components/TextArea/index.d.ts +18 -18
- package/dist/components/TextArea/index.js +26 -26
- package/dist/components/TextInput/index.d.ts +14 -14
- package/dist/components/TextInput/index.js +27 -27
- package/dist/components/WebsiteInput/index.d.ts +10 -10
- package/dist/components/WebsiteInput/index.js +13 -13
- package/dist/components/WeekCalendar/index.d.ts +24 -24
- package/dist/components/WeekCalendar/index.js +48 -48
- package/dist/core/AlertComponent/index.d.ts +26 -26
- package/dist/core/AlertComponent/index.js +35 -45
- package/dist/core/AppHeader/index.d.ts +3 -3
- package/dist/core/AppHeader/index.js +17 -17
- package/dist/core/AppLogo/index.d.ts +12 -12
- package/dist/core/AppLogo/index.js +16 -17
- package/dist/core/AppLogoImage/index.d.ts +3 -3
- package/dist/core/AppLogoImage/index.js +11 -11
- package/dist/core/AppLogoPlaceholder/index.d.ts +3 -3
- package/dist/core/AppLogoPlaceholder/index.js +10 -10
- package/dist/core/Assistive/index.d.ts +12 -12
- package/dist/core/Assistive/index.js +9 -9
- package/dist/core/AuthForm/index.d.ts +10 -10
- package/dist/core/AuthForm/index.js +13 -26
- package/dist/core/Banner/index.d.ts +3 -3
- package/dist/core/Banner/index.js +14 -14
- package/dist/core/Calendar/index.d.ts +21 -21
- package/dist/core/Calendar/index.js +69 -69
- package/dist/core/CalendarDay/index.d.ts +30 -30
- package/dist/core/CalendarDay/index.js +30 -30
- package/dist/core/CalendarMonth/index.d.ts +23 -23
- package/dist/core/CalendarMonth/index.js +45 -45
- package/dist/core/CalendarNavigation/index.d.ts +17 -17
- package/dist/core/CalendarNavigation/index.js +24 -24
- package/dist/core/CalendarWeek/index.d.ts +28 -28
- package/dist/core/CalendarWeek/index.js +46 -46
- package/dist/core/ChkRad/index.d.ts +26 -26
- package/dist/core/ChkRad/index.js +33 -33
- package/dist/core/ChkRadIcon/index.d.ts +14 -14
- package/dist/core/ChkRadIcon/index.js +12 -12
- package/dist/core/ChkRadList/index.d.ts +32 -32
- package/dist/core/ChkRadList/index.js +37 -37
- package/dist/core/CloseButton/index.d.ts +17 -17
- package/dist/core/CloseButton/index.js +12 -12
- package/dist/core/ConfirmModal/index.d.ts +3 -3
- package/dist/core/ConfirmModal/index.js +38 -38
- package/dist/core/ConnectedRepeater/index.d.ts +50 -50
- package/dist/core/ConnectedRepeater/index.js +154 -154
- package/dist/core/ConnectedRepeaterComponent/index.d.ts +24 -24
- package/dist/core/ConnectedRepeaterComponent/index.js +25 -25
- package/dist/core/Container/index.d.ts +14 -14
- package/dist/core/Container/index.js +12 -12
- package/dist/core/DataPanelItem/index.d.ts +8 -8
- package/dist/core/DataPanelItem/index.js +7 -7
- package/dist/core/DropdownPanel/index.d.ts +31 -31
- package/dist/core/DropdownPanel/index.js +32 -32
- package/dist/core/EmptyMessage/index.d.ts +21 -21
- package/dist/core/EmptyMessage/index.js +21 -21
- package/dist/core/FilterItem/index.d.ts +25 -25
- package/dist/core/FilterItem/index.js +82 -84
- package/dist/core/Filters/index.d.ts +31 -31
- package/dist/core/Filters/index.js +85 -85
- package/dist/core/FixedActions/index.d.ts +24 -24
- package/dist/core/FixedActions/index.js +22 -22
- package/dist/core/FormError/index.d.ts +12 -12
- package/dist/core/FormError/index.js +9 -9
- package/dist/core/FormLabel/index.d.ts +16 -16
- package/dist/core/FormLabel/index.js +13 -13
- package/dist/core/FormLegend/index.d.ts +12 -12
- package/dist/core/FormLegend/index.js +9 -9
- package/dist/core/Header/Header.stories.d.ts +5 -5
- package/dist/core/Header/Header.stories.js +11 -11
- package/dist/core/Header/index.d.ts +14 -14
- package/dist/core/Header/index.js +12 -12
- package/dist/core/Icon/index.d.ts +14 -14
- package/dist/core/Icon/index.js +32 -32
- package/dist/core/IconButton/index.d.ts +22 -22
- package/dist/core/IconButton/index.js +20 -20
- package/dist/core/InputPanel/index.d.ts +16 -16
- package/dist/core/InputPanel/index.js +11 -11
- package/dist/core/ListItem/index.d.ts +39 -39
- package/dist/core/ListItem/index.js +44 -44
- package/dist/core/ListItemAction/index.d.ts +11 -11
- package/dist/core/ListItemAction/index.js +13 -13
- package/dist/core/ListItemActions/index.d.ts +8 -8
- package/dist/core/ListItemActions/index.js +16 -16
- package/dist/core/ListItemMetaItem/index.d.ts +19 -19
- package/dist/core/ListItemMetaItem/index.js +29 -29
- package/dist/core/ListItemTitle/index.d.ts +19 -19
- package/dist/core/ListItemTitle/index.js +44 -44
- package/dist/core/Loader/index.d.ts +15 -15
- package/dist/core/Loader/index.js +16 -16
- package/dist/core/MeActions/index.d.ts +3 -3
- package/dist/core/MeActions/index.js +48 -48
- package/dist/core/MePanel/index.d.ts +19 -19
- package/dist/core/MePanel/index.js +29 -29
- package/dist/core/ModalComponent/index.d.ts +22 -22
- package/dist/core/ModalComponent/index.js +29 -29
- package/dist/core/Navigation/index.d.ts +3 -3
- package/dist/core/Navigation/index.js +33 -33
- package/dist/core/NavigationDivider/index.d.ts +3 -3
- package/dist/core/NavigationDivider/index.js +8 -8
- package/dist/core/NavigationItem/index.d.ts +16 -16
- package/dist/core/NavigationItem/index.js +21 -21
- package/dist/core/Pagination/index.d.ts +15 -15
- package/dist/core/Pagination/index.js +64 -64
- package/dist/core/PaginationItem/index.d.ts +10 -10
- package/dist/core/PaginationItem/index.js +17 -17
- package/dist/core/Panel/index.d.ts +17 -17
- package/dist/core/Panel/index.js +13 -16
- package/dist/core/PasswordForgotForm/index.d.ts +7 -7
- package/dist/core/PasswordForgotForm/index.js +40 -40
- package/dist/core/PasswordResetForm/index.d.ts +7 -7
- package/dist/core/PasswordResetForm/index.js +34 -34
- package/dist/core/RadialProgress/index.d.ts +16 -16
- package/dist/core/RadialProgress/index.js +23 -23
- package/dist/core/SettingsForm/index.d.ts +3 -3
- package/dist/core/SettingsForm/index.js +14 -14
- package/dist/core/StaticTextInput/index.d.ts +29 -29
- package/dist/core/StaticTextInput/index.js +39 -39
- package/dist/core/Styled/index.d.ts +6 -6
- package/dist/core/Styled/index.js +39 -39
- package/dist/core/SummaryListItem/index.d.ts +23 -23
- package/dist/core/SummaryListItem/index.js +31 -31
- package/dist/core/TabItem/index.d.ts +4 -4
- package/dist/core/TabItem/index.js +13 -13
- package/dist/core/TableActionsCell/index.d.ts +8 -8
- package/dist/core/TableActionsCell/index.js +8 -8
- package/dist/core/TableCell/index.d.ts +15 -15
- package/dist/core/TableCell/index.js +20 -20
- package/dist/core/TableHead/index.d.ts +18 -18
- package/dist/core/TableHead/index.js +18 -18
- package/dist/core/TableRow/index.d.ts +13 -13
- package/dist/core/TableRow/index.js +18 -18
- package/dist/core/Tabs/index.d.ts +7 -7
- package/dist/core/Tabs/index.js +13 -13
- package/dist/core/TextInputAncillary/index.d.ts +29 -29
- package/dist/core/TextInputAncillary/index.js +31 -31
- package/dist/core/Toast/index.d.ts +3 -3
- package/dist/core/Toast/index.js +47 -47
- package/dist/core/TwoFactor/index.d.ts +13 -13
- package/dist/core/TwoFactor/index.js +49 -49
- package/dist/core/TwoFactorAuthenticator/index.d.ts +10 -10
- package/dist/core/TwoFactorAuthenticator/index.js +9 -9
- package/dist/core/TwoFactorMethodList/index.d.ts +10 -10
- package/dist/core/TwoFactorMethodList/index.js +22 -22
- package/dist/core/TwoFactorSetup/index.d.ts +12 -12
- package/dist/core/TwoFactorSetup/index.js +43 -43
- package/dist/core/TwoFactorSetupAuthenticator/index.d.ts +20 -20
- package/dist/core/TwoFactorSetupAuthenticator/index.js +42 -42
- package/dist/core/TwoFactorSetupYubikey/index.d.ts +16 -16
- package/dist/core/TwoFactorSetupYubikey/index.js +14 -14
- package/dist/core/TwoFactorYubikey/index.d.ts +9 -9
- package/dist/core/TwoFactorYubikey/index.js +14 -14
- package/dist/core/WeekCalendarDay/index.d.ts +27 -27
- package/dist/core/WeekCalendarDay/index.js +35 -35
- package/dist/core/YubikeyInput/index.d.ts +4 -4
- package/dist/core/YubikeyInput/index.js +14 -39
- package/dist/filters/BooleanFilter/index.d.ts +14 -14
- package/dist/filters/BooleanFilter/index.js +35 -35
- package/dist/filters/DateFilter/index.d.ts +5 -5
- package/dist/filters/DateFilter/index.js +24 -24
- package/dist/filters/DropdownFilter/index.d.ts +17 -17
- package/dist/filters/DropdownFilter/index.js +32 -32
- package/dist/filters/QuickDateFilter/index.d.ts +13 -13
- package/dist/filters/QuickDateFilter/index.js +40 -40
- package/dist/filters/interfaces.d.ts +35 -35
- package/dist/filters/interfaces.js +1 -1
- package/dist/hooks/useAlert.d.ts +12 -12
- package/dist/hooks/useAlert.js +18 -18
- package/dist/hooks/useAppConfig.d.ts +3 -0
- package/dist/hooks/useAppConfig.js +5 -0
- package/dist/hooks/useConnectedList.d.ts +7 -7
- package/dist/hooks/useConnectedList.js +6 -6
- package/dist/hooks/useConnectedRepeater.d.ts +7 -7
- package/dist/hooks/useConnectedRepeater.js +14 -14
- package/dist/hooks/useConnectedTable.d.ts +7 -7
- package/dist/hooks/useConnectedTable.js +6 -6
- package/dist/hooks/useFilters.d.ts +9 -9
- package/dist/hooks/useFilters.js +24 -24
- package/dist/hooks/useLayout.d.ts +7 -7
- package/dist/hooks/useLayout.js +10 -10
- package/dist/hooks/useLayout.spec.d.ts +1 -1
- package/dist/hooks/useLayout.spec.js +24 -24
- package/dist/hooks/useModal.d.ts +12 -12
- package/dist/hooks/useModal.js +39 -39
- package/dist/hooks/useModalOffset.d.ts +2 -2
- package/dist/hooks/useModalOffset.js +16 -16
- package/dist/hooks/useModalOffset.spec.d.ts +1 -1
- package/dist/hooks/useModalOffset.spec.js +19 -19
- package/dist/hooks/useNavigation.d.ts +7 -7
- package/dist/hooks/useNavigation.js +113 -113
- package/dist/hooks/useRemote.d.ts +7 -7
- package/dist/hooks/useRemote.js +29 -29
- package/dist/hooks/useVariant.d.ts +9 -9
- package/dist/hooks/useVariant.js +14 -14
- package/dist/index.d.ts +209 -208
- package/dist/index.js +213 -212
- package/dist/scenes/Error404Scene.d.ts +3 -3
- package/dist/scenes/Error404Scene.js +5 -5
- package/dist/services/AppService.d.ts +5 -5
- package/dist/services/AppService.js +11 -11
- package/dist/services/ConfigService.d.ts +42 -42
- package/dist/services/ConfigService.js +52 -55
- package/dist/services/ConfirmService.d.ts +12 -12
- package/dist/services/ConfirmService.js +10 -10
- package/dist/services/DateService.d.ts +26 -26
- package/dist/services/DateService.js +132 -132
- package/dist/services/DateService.spec.d.ts +1 -1
- package/dist/services/DateService.spec.js +83 -83
- package/dist/services/DownloadService.d.ts +7 -7
- package/dist/services/DownloadService.js +16 -16
- package/dist/services/DownloadService.spec.d.ts +1 -1
- package/dist/services/DownloadService.spec.js +18 -18
- package/dist/services/FilterComponentService.d.ts +25 -25
- package/dist/services/FilterComponentService.js +54 -54
- package/dist/services/FilterService.d.ts +34 -34
- package/dist/services/FilterService.js +58 -58
- package/dist/services/FilterService.spec.d.ts +1 -1
- package/dist/services/FilterService.spec.js +67 -67
- package/dist/services/FormatService.d.ts +11 -11
- package/dist/services/FormatService.js +45 -45
- package/dist/services/FormatService.spec.d.ts +1 -1
- package/dist/services/FormatService.spec.js +66 -66
- package/dist/services/ToastService.d.ts +7 -7
- package/dist/services/ToastService.js +17 -17
- package/dist/services/ToastService.spec.d.ts +1 -1
- package/dist/services/ToastService.spec.js +34 -34
- package/dist/styles.css +125 -67
- package/dist/utility/MockRouter/index.d.ts +2 -2
- package/dist/utility/MockRouter/index.js +37 -37
- package/dist/utility/StorybookPanel/index.d.ts +14 -14
- package/dist/utility/StorybookPanel/index.js +12 -12
- package/dist/utility/TestChangeHandler/index.d.ts +15 -15
- package/dist/utility/TestChangeHandler/index.js +30 -30
- package/dist/utility/icons.d.ts +3 -3
- package/dist/utility/icons.js +12 -12
- package/dist/utility/interfaces.d.ts +79 -80
- package/dist/utility/interfaces.js +18 -18
- package/dist/utility/middleware.d.ts +4 -4
- package/dist/utility/middleware.js +9 -4
- package/dist/utility/prop-types.d.ts +57 -57
- package/dist/utility/prop-types.js +77 -77
- package/dist/utility/register.d.ts +3 -3
- package/dist/utility/register.js +9 -7
- package/package.json +5 -5
- package/src/components/LoginForm/index.tsx +1 -1
- package/src/core/TwoFactor/TwoFactor.spec.tsx +4 -4
- package/src/core/TwoFactor/index.tsx +5 -5
- package/src/core/TwoFactorAuthenticator/index.tsx +1 -1
- package/src/core/TwoFactorSetup/index.tsx +1 -1
- package/src/core/TwoFactorYubikey/index.tsx +1 -1
- package/dist/hooks/useConfig.d.ts +0 -9
- package/dist/hooks/useConfig.js +0 -13
|
@@ -1,55 +1,52 @@
|
|
|
1
|
-
import { AuthIdentifier } from '@sqrzro/hooks';
|
|
2
|
-
export var AppLayout;
|
|
3
|
-
(function (AppLayout) {
|
|
4
|
-
AppLayout["sidebar"] = "sidebar";
|
|
5
|
-
AppLayout["topbar"] = "topbar";
|
|
6
|
-
})(AppLayout || (AppLayout = {}));
|
|
7
|
-
let appConfig = {
|
|
8
|
-
auth: {
|
|
9
|
-
identifier: AuthIdentifier.username,
|
|
10
|
-
identifierLabel: 'Username',
|
|
11
|
-
loginUrl: 'tokens',
|
|
12
|
-
meUrl: 'me',
|
|
13
|
-
passwordUrl: 'tokens/password',
|
|
14
|
-
tfa: false,
|
|
15
|
-
},
|
|
16
|
-
name: '',
|
|
17
|
-
navigation: [],
|
|
18
|
-
paths: { api: 'http://localhost:8081' },
|
|
19
|
-
style: { isDarkMode: false, layout: AppLayout.sidebar },
|
|
20
|
-
};
|
|
21
|
-
function
|
|
22
|
-
if (config) {
|
|
23
|
-
return { ...defaults, ...config };
|
|
24
|
-
}
|
|
25
|
-
return defaults;
|
|
26
|
-
}
|
|
27
|
-
export function registerConfig(userConfig) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
if (userConfig.
|
|
39
|
-
config.
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return appConfig;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
registerConfig,
|
|
54
|
-
};
|
|
55
|
-
export default ConfigService;
|
|
1
|
+
import { AuthIdentifier } from '@sqrzro/hooks';
|
|
2
|
+
export var AppLayout;
|
|
3
|
+
(function (AppLayout) {
|
|
4
|
+
AppLayout["sidebar"] = "sidebar";
|
|
5
|
+
AppLayout["topbar"] = "topbar";
|
|
6
|
+
})(AppLayout || (AppLayout = {}));
|
|
7
|
+
let appConfig = {
|
|
8
|
+
auth: {
|
|
9
|
+
identifier: AuthIdentifier.username,
|
|
10
|
+
identifierLabel: 'Username',
|
|
11
|
+
loginUrl: 'tokens',
|
|
12
|
+
meUrl: 'me',
|
|
13
|
+
passwordUrl: 'tokens/password',
|
|
14
|
+
tfa: false,
|
|
15
|
+
},
|
|
16
|
+
name: '',
|
|
17
|
+
navigation: [],
|
|
18
|
+
paths: { api: 'http://localhost:8081' },
|
|
19
|
+
style: { isDarkMode: false, layout: AppLayout.sidebar },
|
|
20
|
+
};
|
|
21
|
+
function mergeAppContext(defaults, config) {
|
|
22
|
+
if (config) {
|
|
23
|
+
return { ...defaults, ...config };
|
|
24
|
+
}
|
|
25
|
+
return defaults;
|
|
26
|
+
}
|
|
27
|
+
export function registerConfig(userConfig) {
|
|
28
|
+
const config = {
|
|
29
|
+
auth: mergeAppContext(appConfig.auth, userConfig.auth),
|
|
30
|
+
name: userConfig.name || 'Square Zero Admin',
|
|
31
|
+
navigation: userConfig.navigation || appConfig.navigation,
|
|
32
|
+
paths: userConfig.paths ? { ...appConfig.paths, ...userConfig.paths } : appConfig.paths,
|
|
33
|
+
style: userConfig.style ? { ...appConfig.style, ...userConfig.style } : appConfig.style,
|
|
34
|
+
};
|
|
35
|
+
if (userConfig.Logo) {
|
|
36
|
+
config.Logo = userConfig.Logo;
|
|
37
|
+
}
|
|
38
|
+
if (userConfig.me) {
|
|
39
|
+
config.me = { ...userConfig.me };
|
|
40
|
+
}
|
|
41
|
+
appConfig = config;
|
|
42
|
+
return appConfig;
|
|
43
|
+
}
|
|
44
|
+
function get() {
|
|
45
|
+
return appConfig;
|
|
46
|
+
}
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
48
|
+
const ConfigService = {
|
|
49
|
+
get,
|
|
50
|
+
registerConfig,
|
|
51
|
+
};
|
|
52
|
+
export default ConfigService;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
export interface ConfirmModalData {
|
|
3
|
-
description: ReactNode;
|
|
4
|
-
label?: string;
|
|
5
|
-
onConfirm?: () => void;
|
|
6
|
-
}
|
|
7
|
-
export interface ConfirmObject {
|
|
8
|
-
ask: (data: ConfirmModalData) => boolean;
|
|
9
|
-
close: () => boolean;
|
|
10
|
-
}
|
|
11
|
-
declare const ConfirmService: ConfirmObject;
|
|
12
|
-
export default ConfirmService;
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface ConfirmModalData {
|
|
3
|
+
description: ReactNode;
|
|
4
|
+
label?: string;
|
|
5
|
+
onConfirm?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface ConfirmObject {
|
|
8
|
+
ask: (data: ConfirmModalData) => boolean;
|
|
9
|
+
close: () => boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const ConfirmService: ConfirmObject;
|
|
12
|
+
export default ConfirmService;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EventService } from '@sqrzro/utility';
|
|
2
|
-
function ask(data) {
|
|
3
|
-
return EventService.publish('@confirm/send', data);
|
|
4
|
-
}
|
|
5
|
-
function close() {
|
|
6
|
-
return EventService.publish('@confirm/send', null);
|
|
7
|
-
}
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
|
-
const ConfirmService = { ask, close };
|
|
10
|
-
export default ConfirmService;
|
|
1
|
+
import { EventService } from '@sqrzro/utility';
|
|
2
|
+
function ask(data) {
|
|
3
|
+
return EventService.publish('@confirm/send', data);
|
|
4
|
+
}
|
|
5
|
+
function close() {
|
|
6
|
+
return EventService.publish('@confirm/send', null);
|
|
7
|
+
}
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
|
+
const ConfirmService = { ask, close };
|
|
10
|
+
export default ConfirmService;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { StrictSimpleObject } from '../utility/interfaces';
|
|
2
|
-
interface DateItem {
|
|
3
|
-
id: number;
|
|
4
|
-
name: string | null;
|
|
5
|
-
}
|
|
6
|
-
declare function getDays(): DateItem[];
|
|
7
|
-
declare function getMonths(): DateItem[];
|
|
8
|
-
declare function getYears(startYear?: number, endYear?: number): DateItem[];
|
|
9
|
-
declare function isToday(date: string): boolean;
|
|
10
|
-
declare function getDayOfWeek(date: string): number;
|
|
11
|
-
declare function getDaysInMonth(date: string): number;
|
|
12
|
-
declare function addMonths(date: string, amount: number): string;
|
|
13
|
-
declare function subMonths(date: string, amount: number): string;
|
|
14
|
-
declare function getQuickDates(): StrictSimpleObject[];
|
|
15
|
-
declare const DateService: {
|
|
16
|
-
addMonths: typeof addMonths;
|
|
17
|
-
getDaysInMonth: typeof getDaysInMonth;
|
|
18
|
-
getDayOfWeek: typeof getDayOfWeek;
|
|
19
|
-
getDays: typeof getDays;
|
|
20
|
-
getMonths: typeof getMonths;
|
|
21
|
-
getQuickDates: typeof getQuickDates;
|
|
22
|
-
getYears: typeof getYears;
|
|
23
|
-
isToday: typeof isToday;
|
|
24
|
-
subMonths: typeof subMonths;
|
|
25
|
-
};
|
|
26
|
-
export default DateService;
|
|
1
|
+
import type { StrictSimpleObject } from '../utility/interfaces';
|
|
2
|
+
interface DateItem {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string | null;
|
|
5
|
+
}
|
|
6
|
+
declare function getDays(): DateItem[];
|
|
7
|
+
declare function getMonths(): DateItem[];
|
|
8
|
+
declare function getYears(startYear?: number, endYear?: number): DateItem[];
|
|
9
|
+
declare function isToday(date: string): boolean;
|
|
10
|
+
declare function getDayOfWeek(date: string): number;
|
|
11
|
+
declare function getDaysInMonth(date: string): number;
|
|
12
|
+
declare function addMonths(date: string, amount: number): string;
|
|
13
|
+
declare function subMonths(date: string, amount: number): string;
|
|
14
|
+
declare function getQuickDates(): StrictSimpleObject[];
|
|
15
|
+
declare const DateService: {
|
|
16
|
+
addMonths: typeof addMonths;
|
|
17
|
+
getDaysInMonth: typeof getDaysInMonth;
|
|
18
|
+
getDayOfWeek: typeof getDayOfWeek;
|
|
19
|
+
getDays: typeof getDays;
|
|
20
|
+
getMonths: typeof getMonths;
|
|
21
|
+
getQuickDates: typeof getQuickDates;
|
|
22
|
+
getYears: typeof getYears;
|
|
23
|
+
isToday: typeof isToday;
|
|
24
|
+
subMonths: typeof subMonths;
|
|
25
|
+
};
|
|
26
|
+
export default DateService;
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
import { addMonths as fnsAddMonths, getDay as fnsGetDay, getDaysInMonth as fnsGetDaysInMonth, set as fnsSet, subDays as fnsSubDays, subMonths as fnsSubMonths, parseISO, } from 'date-fns';
|
|
2
|
-
import FormatService from './FormatService';
|
|
3
|
-
const DAYS_IN_WEEK = 7;
|
|
4
|
-
const MONTHS_IN_YEAR = 12;
|
|
5
|
-
const DAYS_IN_30_DAYS = 30;
|
|
6
|
-
const DAYS_IN_MONTH = 31;
|
|
7
|
-
const FIRST_YEAR = 1900;
|
|
8
|
-
const SUNDAY = 6;
|
|
9
|
-
function getDays() {
|
|
10
|
-
return Array(DAYS_IN_MONTH)
|
|
11
|
-
.fill(0)
|
|
12
|
-
.map((_item, index) => ({ id: index + 1, name: `${index + 1}` }));
|
|
13
|
-
}
|
|
14
|
-
function getMonths() {
|
|
15
|
-
return Array(MONTHS_IN_YEAR)
|
|
16
|
-
.fill(0)
|
|
17
|
-
.map((_item, index) => ({
|
|
18
|
-
id: index + 1,
|
|
19
|
-
name: FormatService.date(new Date(FIRST_YEAR, index, 1), 'MMMM'),
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
function getYears(startYear = FIRST_YEAR, endYear = new Date().getFullYear()) {
|
|
23
|
-
return Array(endYear - startYear + 1)
|
|
24
|
-
.fill(0)
|
|
25
|
-
.map((_item, index) => ({ id: endYear - index, name: `${endYear - index}` }));
|
|
26
|
-
}
|
|
27
|
-
function isToday(date) {
|
|
28
|
-
return FormatService.date(new Date(), 'y-MM-dd') === date;
|
|
29
|
-
}
|
|
30
|
-
// Most date libraries start the week on Sunday (US). We want to start on Monday (UK).
|
|
31
|
-
function adjustDayOfWeek(num) {
|
|
32
|
-
return num === 0 ? SUNDAY : num - 1;
|
|
33
|
-
}
|
|
34
|
-
function getDayOfWeek(date) {
|
|
35
|
-
const parsed = parseISO(date);
|
|
36
|
-
const num = adjustDayOfWeek(fnsGetDay(parsed));
|
|
37
|
-
return Number.isNaN(num) ? -1 : num;
|
|
38
|
-
}
|
|
39
|
-
function getDaysInMonth(date) {
|
|
40
|
-
const parsed = parseISO(date);
|
|
41
|
-
const num = fnsGetDaysInMonth(parsed);
|
|
42
|
-
return Number.isNaN(num) ? -1 : num;
|
|
43
|
-
}
|
|
44
|
-
function addMonths(date, amount) {
|
|
45
|
-
const parsed = parseISO(`${date}-01`);
|
|
46
|
-
return FormatService.date(fnsAddMonths(parsed, amount), 'y-MM');
|
|
47
|
-
}
|
|
48
|
-
function subMonths(date, amount) {
|
|
49
|
-
const parsed = parseISO(`${date}-01`);
|
|
50
|
-
return FormatService.date(fnsSubMonths(parsed, amount), 'y-MM');
|
|
51
|
-
}
|
|
52
|
-
// Quick Date
|
|
53
|
-
const QUICK_DATE_FORMAT = 'Y-MM-dd';
|
|
54
|
-
function getToday() {
|
|
55
|
-
return new Date();
|
|
56
|
-
}
|
|
57
|
-
function getYesterday() {
|
|
58
|
-
return fnsSubDays(new Date(), 1);
|
|
59
|
-
}
|
|
60
|
-
function getLast7Days() {
|
|
61
|
-
return [fnsSubDays(new Date(), DAYS_IN_WEEK), new Date()];
|
|
62
|
-
}
|
|
63
|
-
function getLast30Days() {
|
|
64
|
-
return [fnsSubDays(new Date(), DAYS_IN_30_DAYS), new Date()];
|
|
65
|
-
}
|
|
66
|
-
// Get the first day of this month, and today
|
|
67
|
-
function getThisMonth() {
|
|
68
|
-
return [fnsSet(new Date(), { date: 1 }), getToday()];
|
|
69
|
-
}
|
|
70
|
-
// Get the first day of last month, and the day before the first day of this month
|
|
71
|
-
function getLastMonth() {
|
|
72
|
-
return [fnsSet(fnsSubMonths(new Date(), 1), { date: 1 }), fnsSubDays(getThisMonth()[0], 1)];
|
|
73
|
-
}
|
|
74
|
-
function getQuickDateId(value) {
|
|
75
|
-
if (Array.isArray(value)) {
|
|
76
|
-
return value.map((item) => FormatService.date(item, QUICK_DATE_FORMAT)).join(',');
|
|
77
|
-
}
|
|
78
|
-
const formatted = FormatService.date(value, QUICK_DATE_FORMAT);
|
|
79
|
-
return `${formatted},${formatted}`;
|
|
80
|
-
}
|
|
81
|
-
function getQuickDates() {
|
|
82
|
-
const today = new Date();
|
|
83
|
-
const dates = [
|
|
84
|
-
{
|
|
85
|
-
id: getToday(),
|
|
86
|
-
name: 'Today',
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
id: getYesterday(),
|
|
90
|
-
name: 'Yesterday',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: getLast7Days(),
|
|
94
|
-
name: 'Last 7 Days',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: getLast30Days(),
|
|
98
|
-
name: 'Last 30 Days',
|
|
99
|
-
},
|
|
100
|
-
];
|
|
101
|
-
/*
|
|
102
|
-
* If the date is the 8th or 31st of the month, it matches up with last 7 days or last 30 days,
|
|
103
|
-
* respectively, and causes duplicate key errors. So best just leave it out in these cases.
|
|
104
|
-
*/
|
|
105
|
-
if (today.getDate() !== DAYS_IN_WEEK + 1 && today.getDate() !== DAYS_IN_MONTH) {
|
|
106
|
-
dates.push({
|
|
107
|
-
id: getThisMonth(),
|
|
108
|
-
name: 'This Month',
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
dates.push({
|
|
112
|
-
id: getLastMonth(),
|
|
113
|
-
name: 'Last Month',
|
|
114
|
-
});
|
|
115
|
-
return dates.map((item) => ({
|
|
116
|
-
id: getQuickDateId(item.id),
|
|
117
|
-
name: item.name,
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
121
|
-
const DateService = {
|
|
122
|
-
addMonths,
|
|
123
|
-
getDaysInMonth,
|
|
124
|
-
getDayOfWeek,
|
|
125
|
-
getDays,
|
|
126
|
-
getMonths,
|
|
127
|
-
getQuickDates,
|
|
128
|
-
getYears,
|
|
129
|
-
isToday,
|
|
130
|
-
subMonths,
|
|
131
|
-
};
|
|
132
|
-
export default DateService;
|
|
1
|
+
import { addMonths as fnsAddMonths, getDay as fnsGetDay, getDaysInMonth as fnsGetDaysInMonth, set as fnsSet, subDays as fnsSubDays, subMonths as fnsSubMonths, parseISO, } from 'date-fns';
|
|
2
|
+
import FormatService from './FormatService';
|
|
3
|
+
const DAYS_IN_WEEK = 7;
|
|
4
|
+
const MONTHS_IN_YEAR = 12;
|
|
5
|
+
const DAYS_IN_30_DAYS = 30;
|
|
6
|
+
const DAYS_IN_MONTH = 31;
|
|
7
|
+
const FIRST_YEAR = 1900;
|
|
8
|
+
const SUNDAY = 6;
|
|
9
|
+
function getDays() {
|
|
10
|
+
return Array(DAYS_IN_MONTH)
|
|
11
|
+
.fill(0)
|
|
12
|
+
.map((_item, index) => ({ id: index + 1, name: `${index + 1}` }));
|
|
13
|
+
}
|
|
14
|
+
function getMonths() {
|
|
15
|
+
return Array(MONTHS_IN_YEAR)
|
|
16
|
+
.fill(0)
|
|
17
|
+
.map((_item, index) => ({
|
|
18
|
+
id: index + 1,
|
|
19
|
+
name: FormatService.date(new Date(FIRST_YEAR, index, 1), 'MMMM'),
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
function getYears(startYear = FIRST_YEAR, endYear = new Date().getFullYear()) {
|
|
23
|
+
return Array(endYear - startYear + 1)
|
|
24
|
+
.fill(0)
|
|
25
|
+
.map((_item, index) => ({ id: endYear - index, name: `${endYear - index}` }));
|
|
26
|
+
}
|
|
27
|
+
function isToday(date) {
|
|
28
|
+
return FormatService.date(new Date(), 'y-MM-dd') === date;
|
|
29
|
+
}
|
|
30
|
+
// Most date libraries start the week on Sunday (US). We want to start on Monday (UK).
|
|
31
|
+
function adjustDayOfWeek(num) {
|
|
32
|
+
return num === 0 ? SUNDAY : num - 1;
|
|
33
|
+
}
|
|
34
|
+
function getDayOfWeek(date) {
|
|
35
|
+
const parsed = parseISO(date);
|
|
36
|
+
const num = adjustDayOfWeek(fnsGetDay(parsed));
|
|
37
|
+
return Number.isNaN(num) ? -1 : num;
|
|
38
|
+
}
|
|
39
|
+
function getDaysInMonth(date) {
|
|
40
|
+
const parsed = parseISO(date);
|
|
41
|
+
const num = fnsGetDaysInMonth(parsed);
|
|
42
|
+
return Number.isNaN(num) ? -1 : num;
|
|
43
|
+
}
|
|
44
|
+
function addMonths(date, amount) {
|
|
45
|
+
const parsed = parseISO(`${date}-01`);
|
|
46
|
+
return FormatService.date(fnsAddMonths(parsed, amount), 'y-MM');
|
|
47
|
+
}
|
|
48
|
+
function subMonths(date, amount) {
|
|
49
|
+
const parsed = parseISO(`${date}-01`);
|
|
50
|
+
return FormatService.date(fnsSubMonths(parsed, amount), 'y-MM');
|
|
51
|
+
}
|
|
52
|
+
// Quick Date
|
|
53
|
+
const QUICK_DATE_FORMAT = 'Y-MM-dd';
|
|
54
|
+
function getToday() {
|
|
55
|
+
return new Date();
|
|
56
|
+
}
|
|
57
|
+
function getYesterday() {
|
|
58
|
+
return fnsSubDays(new Date(), 1);
|
|
59
|
+
}
|
|
60
|
+
function getLast7Days() {
|
|
61
|
+
return [fnsSubDays(new Date(), DAYS_IN_WEEK), new Date()];
|
|
62
|
+
}
|
|
63
|
+
function getLast30Days() {
|
|
64
|
+
return [fnsSubDays(new Date(), DAYS_IN_30_DAYS), new Date()];
|
|
65
|
+
}
|
|
66
|
+
// Get the first day of this month, and today
|
|
67
|
+
function getThisMonth() {
|
|
68
|
+
return [fnsSet(new Date(), { date: 1 }), getToday()];
|
|
69
|
+
}
|
|
70
|
+
// Get the first day of last month, and the day before the first day of this month
|
|
71
|
+
function getLastMonth() {
|
|
72
|
+
return [fnsSet(fnsSubMonths(new Date(), 1), { date: 1 }), fnsSubDays(getThisMonth()[0], 1)];
|
|
73
|
+
}
|
|
74
|
+
function getQuickDateId(value) {
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
return value.map((item) => FormatService.date(item, QUICK_DATE_FORMAT)).join(',');
|
|
77
|
+
}
|
|
78
|
+
const formatted = FormatService.date(value, QUICK_DATE_FORMAT);
|
|
79
|
+
return `${formatted},${formatted}`;
|
|
80
|
+
}
|
|
81
|
+
function getQuickDates() {
|
|
82
|
+
const today = new Date();
|
|
83
|
+
const dates = [
|
|
84
|
+
{
|
|
85
|
+
id: getToday(),
|
|
86
|
+
name: 'Today',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: getYesterday(),
|
|
90
|
+
name: 'Yesterday',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: getLast7Days(),
|
|
94
|
+
name: 'Last 7 Days',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: getLast30Days(),
|
|
98
|
+
name: 'Last 30 Days',
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
/*
|
|
102
|
+
* If the date is the 8th or 31st of the month, it matches up with last 7 days or last 30 days,
|
|
103
|
+
* respectively, and causes duplicate key errors. So best just leave it out in these cases.
|
|
104
|
+
*/
|
|
105
|
+
if (today.getDate() !== DAYS_IN_WEEK + 1 && today.getDate() !== DAYS_IN_MONTH) {
|
|
106
|
+
dates.push({
|
|
107
|
+
id: getThisMonth(),
|
|
108
|
+
name: 'This Month',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
dates.push({
|
|
112
|
+
id: getLastMonth(),
|
|
113
|
+
name: 'Last Month',
|
|
114
|
+
});
|
|
115
|
+
return dates.map((item) => ({
|
|
116
|
+
id: getQuickDateId(item.id),
|
|
117
|
+
name: item.name,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
121
|
+
const DateService = {
|
|
122
|
+
addMonths,
|
|
123
|
+
getDaysInMonth,
|
|
124
|
+
getDayOfWeek,
|
|
125
|
+
getDays,
|
|
126
|
+
getMonths,
|
|
127
|
+
getQuickDates,
|
|
128
|
+
getYears,
|
|
129
|
+
isToday,
|
|
130
|
+
subMonths,
|
|
131
|
+
};
|
|
132
|
+
export default DateService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import MockDate from 'mockdate';
|
|
2
|
-
import DateService from './DateService';
|
|
3
|
-
describe('DateService', () => {
|
|
4
|
-
it('should addMonths', () => {
|
|
5
|
-
expect(DateService.addMonths('2020-01', 4)).toBe('2020-05');
|
|
6
|
-
expect(DateService.addMonths('1946-07', 12)).toBe('1947-07');
|
|
7
|
-
expect(DateService.addMonths('2050-02', 1)).toBe('2050-03');
|
|
8
|
-
expect(DateService.addMonths('2021-02', 0)).toBe('2021-02');
|
|
9
|
-
expect(DateService.addMonths('lorem', 5)).toBe('');
|
|
10
|
-
});
|
|
11
|
-
it('should getDaysInMonth', () => {
|
|
12
|
-
expect(DateService.getDaysInMonth('2020-01')).toBe(31);
|
|
13
|
-
expect(DateService.getDaysInMonth('2020-02')).toBe(29);
|
|
14
|
-
expect(DateService.getDaysInMonth('1950-09')).toBe(30);
|
|
15
|
-
expect(DateService.getDaysInMonth('lorem')).toBe(-1);
|
|
16
|
-
});
|
|
17
|
-
it('should getDayOfWeek', () => {
|
|
18
|
-
expect(DateService.getDayOfWeek('1987-04-18')).toBe(5);
|
|
19
|
-
expect(DateService.getDayOfWeek('2018-06-17')).toBe(6);
|
|
20
|
-
expect(DateService.getDayOfWeek('2028-05-18')).toBe(3);
|
|
21
|
-
expect(DateService.getDayOfWeek('2045-08-07')).toBe(0);
|
|
22
|
-
expect(DateService.getDayOfWeek('2046-01-02')).toBe(1);
|
|
23
|
-
expect(DateService.getDayOfWeek('lorem')).toBe(-1);
|
|
24
|
-
});
|
|
25
|
-
it('should getDays', () => {
|
|
26
|
-
const days = DateService.getDays();
|
|
27
|
-
expect(days[0]).toEqual({ id: 1, name: '1' });
|
|
28
|
-
expect(days[17]).toEqual({ id: 18, name: '18' });
|
|
29
|
-
expect(days[40]).toBeUndefined();
|
|
30
|
-
});
|
|
31
|
-
it('should getMonths', () => {
|
|
32
|
-
const months = DateService.getMonths();
|
|
33
|
-
expect(months[0]).toEqual({ id: 1, name: 'January' });
|
|
34
|
-
expect(months[7]).toEqual({ id: 8, name: 'August' });
|
|
35
|
-
expect(months[14]).toBeUndefined();
|
|
36
|
-
});
|
|
37
|
-
it('should getQuickDates', () => {
|
|
38
|
-
MockDate.set('2000-11-22');
|
|
39
|
-
const dates = DateService.getQuickDates();
|
|
40
|
-
expect(dates).toHaveLength(6);
|
|
41
|
-
expect(dates[0]).toEqual({ id: '2000-11-22,2000-11-22', name: 'Today' });
|
|
42
|
-
expect(dates[1]).toEqual({ id: '2000-11-21,2000-11-21', name: 'Yesterday' });
|
|
43
|
-
expect(dates[2]).toEqual({ id: '2000-11-15,2000-11-22', name: 'Last 7 Days' });
|
|
44
|
-
expect(dates[3]).toEqual({ id: '2000-10-23,2000-11-22', name: 'Last 30 Days' });
|
|
45
|
-
expect(dates[4]).toEqual({ id: '2000-11-01,2000-11-22', name: 'This Month' });
|
|
46
|
-
expect(dates[5]).toEqual({ id: '2000-10-01,2000-10-31', name: 'Last Month' });
|
|
47
|
-
});
|
|
48
|
-
it('should getQuickDates (8th of month)', () => {
|
|
49
|
-
MockDate.set('2000-11-08');
|
|
50
|
-
const dates = DateService.getQuickDates();
|
|
51
|
-
expect(dates).toHaveLength(5);
|
|
52
|
-
});
|
|
53
|
-
it('should getQuickDates (31st of month)', () => {
|
|
54
|
-
MockDate.set('2000-12-31');
|
|
55
|
-
const dates = DateService.getQuickDates();
|
|
56
|
-
expect(dates).toHaveLength(5);
|
|
57
|
-
});
|
|
58
|
-
describe('should getYears', () => {
|
|
59
|
-
it('should get default years', () => {
|
|
60
|
-
MockDate.set('2021-11-22');
|
|
61
|
-
const years = DateService.getYears();
|
|
62
|
-
expect(years[0]).toEqual({ id: 2021, name: '2021' });
|
|
63
|
-
expect(years[17]).toEqual({ id: 2004, name: '2004' });
|
|
64
|
-
expect(years[200]).toBeUndefined();
|
|
65
|
-
});
|
|
66
|
-
it('should get custom years', () => {
|
|
67
|
-
expect(DateService.getYears(2000, 2016)[3]).toEqual({ id: 2013, name: '2013' });
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe('should isToday', () => {
|
|
71
|
-
MockDate.set('2000-11-22');
|
|
72
|
-
expect(DateService.isToday('2000-11-22')).toBe(true);
|
|
73
|
-
expect(DateService.isToday('2001-11-22')).toBe(false);
|
|
74
|
-
expect(DateService.isToday('lorem')).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
describe('should subMonths', () => {
|
|
77
|
-
expect(DateService.subMonths('2020-01', 4)).toBe('2019-09');
|
|
78
|
-
expect(DateService.subMonths('1946-07', 12)).toBe('1945-07');
|
|
79
|
-
expect(DateService.subMonths('2050-02', 1)).toBe('2050-01');
|
|
80
|
-
expect(DateService.subMonths('2021-02', 0)).toBe('2021-02');
|
|
81
|
-
expect(DateService.subMonths('lorem', 5)).toBe('');
|
|
82
|
-
});
|
|
83
|
-
});
|
|
1
|
+
import MockDate from 'mockdate';
|
|
2
|
+
import DateService from './DateService';
|
|
3
|
+
describe('DateService', () => {
|
|
4
|
+
it('should addMonths', () => {
|
|
5
|
+
expect(DateService.addMonths('2020-01', 4)).toBe('2020-05');
|
|
6
|
+
expect(DateService.addMonths('1946-07', 12)).toBe('1947-07');
|
|
7
|
+
expect(DateService.addMonths('2050-02', 1)).toBe('2050-03');
|
|
8
|
+
expect(DateService.addMonths('2021-02', 0)).toBe('2021-02');
|
|
9
|
+
expect(DateService.addMonths('lorem', 5)).toBe('');
|
|
10
|
+
});
|
|
11
|
+
it('should getDaysInMonth', () => {
|
|
12
|
+
expect(DateService.getDaysInMonth('2020-01')).toBe(31);
|
|
13
|
+
expect(DateService.getDaysInMonth('2020-02')).toBe(29);
|
|
14
|
+
expect(DateService.getDaysInMonth('1950-09')).toBe(30);
|
|
15
|
+
expect(DateService.getDaysInMonth('lorem')).toBe(-1);
|
|
16
|
+
});
|
|
17
|
+
it('should getDayOfWeek', () => {
|
|
18
|
+
expect(DateService.getDayOfWeek('1987-04-18')).toBe(5);
|
|
19
|
+
expect(DateService.getDayOfWeek('2018-06-17')).toBe(6);
|
|
20
|
+
expect(DateService.getDayOfWeek('2028-05-18')).toBe(3);
|
|
21
|
+
expect(DateService.getDayOfWeek('2045-08-07')).toBe(0);
|
|
22
|
+
expect(DateService.getDayOfWeek('2046-01-02')).toBe(1);
|
|
23
|
+
expect(DateService.getDayOfWeek('lorem')).toBe(-1);
|
|
24
|
+
});
|
|
25
|
+
it('should getDays', () => {
|
|
26
|
+
const days = DateService.getDays();
|
|
27
|
+
expect(days[0]).toEqual({ id: 1, name: '1' });
|
|
28
|
+
expect(days[17]).toEqual({ id: 18, name: '18' });
|
|
29
|
+
expect(days[40]).toBeUndefined();
|
|
30
|
+
});
|
|
31
|
+
it('should getMonths', () => {
|
|
32
|
+
const months = DateService.getMonths();
|
|
33
|
+
expect(months[0]).toEqual({ id: 1, name: 'January' });
|
|
34
|
+
expect(months[7]).toEqual({ id: 8, name: 'August' });
|
|
35
|
+
expect(months[14]).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
it('should getQuickDates', () => {
|
|
38
|
+
MockDate.set('2000-11-22');
|
|
39
|
+
const dates = DateService.getQuickDates();
|
|
40
|
+
expect(dates).toHaveLength(6);
|
|
41
|
+
expect(dates[0]).toEqual({ id: '2000-11-22,2000-11-22', name: 'Today' });
|
|
42
|
+
expect(dates[1]).toEqual({ id: '2000-11-21,2000-11-21', name: 'Yesterday' });
|
|
43
|
+
expect(dates[2]).toEqual({ id: '2000-11-15,2000-11-22', name: 'Last 7 Days' });
|
|
44
|
+
expect(dates[3]).toEqual({ id: '2000-10-23,2000-11-22', name: 'Last 30 Days' });
|
|
45
|
+
expect(dates[4]).toEqual({ id: '2000-11-01,2000-11-22', name: 'This Month' });
|
|
46
|
+
expect(dates[5]).toEqual({ id: '2000-10-01,2000-10-31', name: 'Last Month' });
|
|
47
|
+
});
|
|
48
|
+
it('should getQuickDates (8th of month)', () => {
|
|
49
|
+
MockDate.set('2000-11-08');
|
|
50
|
+
const dates = DateService.getQuickDates();
|
|
51
|
+
expect(dates).toHaveLength(5);
|
|
52
|
+
});
|
|
53
|
+
it('should getQuickDates (31st of month)', () => {
|
|
54
|
+
MockDate.set('2000-12-31');
|
|
55
|
+
const dates = DateService.getQuickDates();
|
|
56
|
+
expect(dates).toHaveLength(5);
|
|
57
|
+
});
|
|
58
|
+
describe('should getYears', () => {
|
|
59
|
+
it('should get default years', () => {
|
|
60
|
+
MockDate.set('2021-11-22');
|
|
61
|
+
const years = DateService.getYears();
|
|
62
|
+
expect(years[0]).toEqual({ id: 2021, name: '2021' });
|
|
63
|
+
expect(years[17]).toEqual({ id: 2004, name: '2004' });
|
|
64
|
+
expect(years[200]).toBeUndefined();
|
|
65
|
+
});
|
|
66
|
+
it('should get custom years', () => {
|
|
67
|
+
expect(DateService.getYears(2000, 2016)[3]).toEqual({ id: 2013, name: '2013' });
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('should isToday', () => {
|
|
71
|
+
MockDate.set('2000-11-22');
|
|
72
|
+
expect(DateService.isToday('2000-11-22')).toBe(true);
|
|
73
|
+
expect(DateService.isToday('2001-11-22')).toBe(false);
|
|
74
|
+
expect(DateService.isToday('lorem')).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
describe('should subMonths', () => {
|
|
77
|
+
expect(DateService.subMonths('2020-01', 4)).toBe('2019-09');
|
|
78
|
+
expect(DateService.subMonths('1946-07', 12)).toBe('1945-07');
|
|
79
|
+
expect(DateService.subMonths('2050-02', 1)).toBe('2050-01');
|
|
80
|
+
expect(DateService.subMonths('2021-02', 0)).toBe('2021-02');
|
|
81
|
+
expect(DateService.subMonths('lorem', 5)).toBe('');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare function makeUrl(alias: string): string;
|
|
2
|
-
declare function download(alias: string): void;
|
|
3
|
-
declare const DownloadService: {
|
|
4
|
-
download: typeof download;
|
|
5
|
-
makeUrl: typeof makeUrl;
|
|
6
|
-
};
|
|
7
|
-
export default DownloadService;
|
|
1
|
+
declare function makeUrl(alias: string): string;
|
|
2
|
+
declare function download(alias: string): void;
|
|
3
|
+
declare const DownloadService: {
|
|
4
|
+
download: typeof download;
|
|
5
|
+
makeUrl: typeof makeUrl;
|
|
6
|
+
};
|
|
7
|
+
export default DownloadService;
|