@etsoo/react 1.5.80 → 1.5.83
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/README.md +7 -2
- package/__tests__/ReactUtils.ts +6 -0
- package/lib/{mu → components}/DnDList.d.ts +1 -14
- package/lib/{mu → components}/DnDList.js +1 -24
- package/lib/components/GridMethodRef.d.ts +11 -0
- package/lib/{mu → components}/GridMethodRef.js +0 -0
- package/lib/components/ScrollerGrid.d.ts +3 -3
- package/lib/components/ScrollerList.d.ts +3 -3
- package/lib/index.d.ts +2 -74
- package/lib/index.js +2 -75
- package/lib/notifier/Notifier.d.ts +2 -3
- package/lib/states/UserState.d.ts +1 -1
- package/lib/uses/useWindowScroll.d.ts +10 -0
- package/lib/uses/useWindowScroll.js +46 -0
- package/lib/uses/useWindowSize.js +11 -5
- package/package.json +4 -16
- package/src/{mu → components}/DnDList.tsx +11 -34
- package/src/components/GridMethodRef.ts +12 -0
- package/src/components/ScrollerGrid.tsx +3 -3
- package/src/components/ScrollerList.tsx +5 -3
- package/src/index.ts +2 -78
- package/src/notifier/Notifier.ts +2 -3
- package/src/states/UserState.ts +7 -2
- package/src/uses/useWindowScroll.ts +60 -0
- package/src/uses/useWindowSize.ts +14 -5
- package/__tests__/mu/ComboBox.tsx +0 -30
- package/__tests__/mu/MUGlobalTests.tsx +0 -58
- package/__tests__/mu/NotifierMUTests.tsx +0 -213
- package/__tests__/mu/SelectEx.tsx +0 -26
- package/lib/app/CommonApp.d.ts +0 -39
- package/lib/app/CommonApp.js +0 -149
- package/lib/app/IServiceAppSettings.d.ts +0 -11
- package/lib/app/IServiceAppSettings.js +0 -1
- package/lib/app/IServicePage.d.ts +0 -6
- package/lib/app/IServicePage.js +0 -1
- package/lib/app/IServiceUser.d.ts +0 -14
- package/lib/app/IServiceUser.js +0 -1
- package/lib/app/ISmartERPUser.d.ts +0 -14
- package/lib/app/ISmartERPUser.js +0 -1
- package/lib/app/Labels.d.ts +0 -65
- package/lib/app/Labels.js +0 -62
- package/lib/app/ReactApp.d.ts +0 -194
- package/lib/app/ReactApp.js +0 -298
- package/lib/app/ServiceApp.d.ts +0 -78
- package/lib/app/ServiceApp.js +0 -244
- package/lib/components/ShowDataComparison.d.ts +0 -20
- package/lib/components/ShowDataComparison.js +0 -60
- package/lib/mu/AuditDisplay.d.ts +0 -33
- package/lib/mu/AuditDisplay.js +0 -52
- package/lib/mu/AutocompleteExtendedProps.d.ts +0 -64
- package/lib/mu/AutocompleteExtendedProps.js +0 -1
- package/lib/mu/BackButton.d.ts +0 -13
- package/lib/mu/BackButton.js +0 -33
- package/lib/mu/BridgeCloseButton.d.ts +0 -23
- package/lib/mu/BridgeCloseButton.js +0 -32
- package/lib/mu/ButtonLink.d.ts +0 -17
- package/lib/mu/ButtonLink.js +0 -19
- package/lib/mu/ComboBox.d.ts +0 -38
- package/lib/mu/ComboBox.js +0 -108
- package/lib/mu/CountdownButton.d.ts +0 -23
- package/lib/mu/CountdownButton.js +0 -81
- package/lib/mu/CustomFabProps.d.ts +0 -27
- package/lib/mu/CustomFabProps.js +0 -1
- package/lib/mu/DataGridEx.d.ts +0 -96
- package/lib/mu/DataGridEx.js +0 -331
- package/lib/mu/DataGridRenderers.d.ts +0 -22
- package/lib/mu/DataGridRenderers.js +0 -99
- package/lib/mu/DialogButton.d.ts +0 -54
- package/lib/mu/DialogButton.js +0 -45
- package/lib/mu/DraggablePaperComponent.d.ts +0 -8
- package/lib/mu/DraggablePaperComponent.js +0 -12
- package/lib/mu/EmailInput.d.ts +0 -11
- package/lib/mu/EmailInput.js +0 -15
- package/lib/mu/FabBox.d.ts +0 -21
- package/lib/mu/FabBox.js +0 -31
- package/lib/mu/FlexBox.d.ts +0 -14
- package/lib/mu/FlexBox.js +0 -18
- package/lib/mu/GridDataFormat.d.ts +0 -10
- package/lib/mu/GridDataFormat.js +0 -43
- package/lib/mu/GridMethodRef.d.ts +0 -11
- package/lib/mu/IconButtonLink.d.ts +0 -17
- package/lib/mu/IconButtonLink.js +0 -16
- package/lib/mu/InputField.d.ts +0 -21
- package/lib/mu/InputField.js +0 -39
- package/lib/mu/ItemList.d.ts +0 -56
- package/lib/mu/ItemList.js +0 -69
- package/lib/mu/ListItemRightIcon.d.ts +0 -4
- package/lib/mu/ListItemRightIcon.js +0 -8
- package/lib/mu/ListMoreDisplay.d.ts +0 -35
- package/lib/mu/ListMoreDisplay.js +0 -99
- package/lib/mu/LoadingButton.d.ts +0 -16
- package/lib/mu/LoadingButton.js +0 -41
- package/lib/mu/MUGlobal.d.ts +0 -102
- package/lib/mu/MUGlobal.js +0 -184
- package/lib/mu/MaskInput.d.ts +0 -34
- package/lib/mu/MaskInput.js +0 -43
- package/lib/mu/MobileListItemRenderer.d.ts +0 -17
- package/lib/mu/MobileListItemRenderer.js +0 -35
- package/lib/mu/MoreFab.d.ts +0 -45
- package/lib/mu/MoreFab.js +0 -95
- package/lib/mu/NotifierMU.d.ts +0 -47
- package/lib/mu/NotifierMU.js +0 -387
- package/lib/mu/NotifierPromptProps.d.ts +0 -22
- package/lib/mu/NotifierPromptProps.js +0 -1
- package/lib/mu/OptionGroup.d.ts +0 -58
- package/lib/mu/OptionGroup.js +0 -81
- package/lib/mu/PList.d.ts +0 -15
- package/lib/mu/PList.js +0 -12
- package/lib/mu/ProgressCount.d.ts +0 -44
- package/lib/mu/ProgressCount.js +0 -79
- package/lib/mu/PullToRefreshUI.d.ts +0 -9
- package/lib/mu/PullToRefreshUI.js +0 -18
- package/lib/mu/RLink.d.ts +0 -14
- package/lib/mu/RLink.js +0 -37
- package/lib/mu/ResponsibleContainer.d.ts +0 -89
- package/lib/mu/ResponsibleContainer.js +0 -159
- package/lib/mu/ScrollTopFab.d.ts +0 -7
- package/lib/mu/ScrollTopFab.js +0 -25
- package/lib/mu/ScrollerListEx.d.ts +0 -81
- package/lib/mu/ScrollerListEx.js +0 -167
- package/lib/mu/SearchBar.d.ts +0 -29
- package/lib/mu/SearchBar.js +0 -262
- package/lib/mu/SearchField.d.ts +0 -21
- package/lib/mu/SearchField.js +0 -39
- package/lib/mu/SearchOptionGroup.d.ts +0 -9
- package/lib/mu/SearchOptionGroup.js +0 -14
- package/lib/mu/SelectBool.d.ts +0 -13
- package/lib/mu/SelectBool.js +0 -22
- package/lib/mu/SelectEx.d.ts +0 -50
- package/lib/mu/SelectEx.js +0 -156
- package/lib/mu/Switch.d.ts +0 -29
- package/lib/mu/Switch.js +0 -34
- package/lib/mu/SwitchAnt.d.ts +0 -25
- package/lib/mu/SwitchAnt.js +0 -40
- package/lib/mu/TabBox.d.ts +0 -54
- package/lib/mu/TabBox.js +0 -31
- package/lib/mu/TableEx.d.ts +0 -66
- package/lib/mu/TableEx.js +0 -271
- package/lib/mu/TextFieldEx.d.ts +0 -101
- package/lib/mu/TextFieldEx.js +0 -127
- package/lib/mu/Tiplist.d.ts +0 -18
- package/lib/mu/Tiplist.js +0 -158
- package/lib/mu/TooltipClick.d.ts +0 -15
- package/lib/mu/TooltipClick.js +0 -40
- package/lib/mu/UserAvatar.d.ts +0 -24
- package/lib/mu/UserAvatar.js +0 -25
- package/lib/mu/UserAvatarEditor.d.ts +0 -53
- package/lib/mu/UserAvatarEditor.js +0 -129
- package/lib/mu/pages/CommonPage.d.ts +0 -11
- package/lib/mu/pages/CommonPage.js +0 -60
- package/lib/mu/pages/CommonPageProps.d.ts +0 -60
- package/lib/mu/pages/CommonPageProps.js +0 -1
- package/lib/mu/pages/DataGridPage.d.ts +0 -9
- package/lib/mu/pages/DataGridPage.js +0 -81
- package/lib/mu/pages/DataGridPageProps.d.ts +0 -17
- package/lib/mu/pages/DataGridPageProps.js +0 -1
- package/lib/mu/pages/EditPage.d.ts +0 -33
- package/lib/mu/pages/EditPage.js +0 -29
- package/lib/mu/pages/FixedListPage.d.ts +0 -15
- package/lib/mu/pages/FixedListPage.js +0 -72
- package/lib/mu/pages/ListPage.d.ts +0 -9
- package/lib/mu/pages/ListPage.js +0 -51
- package/lib/mu/pages/ListPageProps.d.ts +0 -7
- package/lib/mu/pages/ListPageProps.js +0 -1
- package/lib/mu/pages/ResponsivePage.d.ts +0 -9
- package/lib/mu/pages/ResponsivePage.js +0 -45
- package/lib/mu/pages/ResponsivePageProps.d.ts +0 -39
- package/lib/mu/pages/ResponsivePageProps.js +0 -1
- package/lib/mu/pages/SearchPageProps.d.ts +0 -30
- package/lib/mu/pages/SearchPageProps.js +0 -1
- package/lib/mu/pages/TablePage.d.ts +0 -9
- package/lib/mu/pages/TablePage.js +0 -71
- package/lib/mu/pages/TablePageProps.d.ts +0 -7
- package/lib/mu/pages/TablePageProps.js +0 -1
- package/lib/mu/pages/ViewPage.d.ts +0 -66
- package/lib/mu/pages/ViewPage.js +0 -105
- package/lib/mu/texts/DateText.d.ts +0 -34
- package/lib/mu/texts/DateText.js +0 -25
- package/lib/mu/texts/MoneyText.d.ts +0 -21
- package/lib/mu/texts/MoneyText.js +0 -14
- package/lib/mu/texts/NumberText.d.ts +0 -25
- package/lib/mu/texts/NumberText.js +0 -14
- package/src/app/CommonApp.ts +0 -225
- package/src/app/IServiceAppSettings.ts +0 -13
- package/src/app/IServicePage.ts +0 -6
- package/src/app/IServiceUser.ts +0 -17
- package/src/app/ISmartERPUser.ts +0 -16
- package/src/app/Labels.ts +0 -77
- package/src/app/ReactApp.ts +0 -500
- package/src/app/ServiceApp.ts +0 -353
- package/src/components/ShowDataComparison.tsx +0 -108
- package/src/mu/AuditDisplay.tsx +0 -117
- package/src/mu/AutocompleteExtendedProps.ts +0 -83
- package/src/mu/BackButton.tsx +0 -55
- package/src/mu/BridgeCloseButton.tsx +0 -69
- package/src/mu/ButtonLink.tsx +0 -32
- package/src/mu/ComboBox.tsx +0 -251
- package/src/mu/CountdownButton.tsx +0 -119
- package/src/mu/CustomFabProps.ts +0 -32
- package/src/mu/DataGridEx.tsx +0 -712
- package/src/mu/DataGridRenderers.tsx +0 -140
- package/src/mu/DialogButton.tsx +0 -163
- package/src/mu/DraggablePaperComponent.tsx +0 -19
- package/src/mu/EmailInput.tsx +0 -24
- package/src/mu/FabBox.tsx +0 -51
- package/src/mu/FlexBox.tsx +0 -20
- package/src/mu/GridDataFormat.tsx +0 -77
- package/src/mu/GridMethodRef.ts +0 -12
- package/src/mu/IconButtonLink.tsx +0 -29
- package/src/mu/InputField.tsx +0 -82
- package/src/mu/ItemList.tsx +0 -204
- package/src/mu/ListItemRightIcon.tsx +0 -9
- package/src/mu/ListMoreDisplay.tsx +0 -205
- package/src/mu/LoadingButton.tsx +0 -75
- package/src/mu/MUGlobal.ts +0 -220
- package/src/mu/MaskInput.tsx +0 -107
- package/src/mu/MobileListItemRenderer.tsx +0 -79
- package/src/mu/MoreFab.tsx +0 -211
- package/src/mu/NotifierMU.tsx +0 -654
- package/src/mu/NotifierPromptProps.ts +0 -26
- package/src/mu/OptionGroup.tsx +0 -223
- package/src/mu/PList.tsx +0 -27
- package/src/mu/ProgressCount.tsx +0 -166
- package/src/mu/PullToRefreshUI.tsx +0 -21
- package/src/mu/RLink.tsx +0 -64
- package/src/mu/ResponsibleContainer.tsx +0 -394
- package/src/mu/ScrollTopFab.tsx +0 -34
- package/src/mu/ScrollerListEx.tsx +0 -387
- package/src/mu/SearchBar.tsx +0 -398
- package/src/mu/SearchField.tsx +0 -82
- package/src/mu/SearchOptionGroup.tsx +0 -31
- package/src/mu/SelectBool.tsx +0 -33
- package/src/mu/SelectEx.tsx +0 -290
- package/src/mu/Switch.tsx +0 -94
- package/src/mu/SwitchAnt.tsx +0 -95
- package/src/mu/TabBox.tsx +0 -118
- package/src/mu/TableEx.tsx +0 -560
- package/src/mu/TextFieldEx.tsx +0 -250
- package/src/mu/Tiplist.tsx +0 -304
- package/src/mu/TooltipClick.tsx +0 -84
- package/src/mu/UserAvatar.tsx +0 -64
- package/src/mu/UserAvatarEditor.tsx +0 -287
- package/src/mu/pages/CommonPage.tsx +0 -128
- package/src/mu/pages/CommonPageProps.ts +0 -71
- package/src/mu/pages/DataGridPage.tsx +0 -137
- package/src/mu/pages/DataGridPageProps.ts +0 -24
- package/src/mu/pages/EditPage.tsx +0 -114
- package/src/mu/pages/FixedListPage.tsx +0 -135
- package/src/mu/pages/ListPage.tsx +0 -87
- package/src/mu/pages/ListPageProps.ts +0 -12
- package/src/mu/pages/ResponsivePage.tsx +0 -68
- package/src/mu/pages/ResponsivePageProps.ts +0 -57
- package/src/mu/pages/SearchPageProps.ts +0 -39
- package/src/mu/pages/TablePage.tsx +0 -120
- package/src/mu/pages/TablePageProps.ts +0 -12
- package/src/mu/pages/ViewPage.tsx +0 -285
- package/src/mu/texts/DateText.tsx +0 -74
- package/src/mu/texts/MoneyText.tsx +0 -49
- package/src/mu/texts/NumberText.tsx +0 -40
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { DateUtils } from '@etsoo/shared';
|
|
3
|
-
import { TypographyProps } from '@mui/material';
|
|
4
|
-
/**
|
|
5
|
-
* Date text props
|
|
6
|
-
*/
|
|
7
|
-
export interface DateTextProps extends TypographyProps {
|
|
8
|
-
/**
|
|
9
|
-
* Locale
|
|
10
|
-
*/
|
|
11
|
-
locale?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Near days to show in error color
|
|
14
|
-
*/
|
|
15
|
-
nearDays?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Options
|
|
18
|
-
*/
|
|
19
|
-
options?: DateUtils.FormatOptions;
|
|
20
|
-
/**
|
|
21
|
-
* Time zone
|
|
22
|
-
*/
|
|
23
|
-
timeZone?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Value to display
|
|
26
|
-
*/
|
|
27
|
-
value?: Date | string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Date text
|
|
31
|
-
* @param props Props
|
|
32
|
-
* @returns Component
|
|
33
|
-
*/
|
|
34
|
-
export declare function DateText(props: DateTextProps): JSX.Element;
|
package/lib/mu/texts/DateText.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DateUtils } from '@etsoo/shared';
|
|
2
|
-
import { Typography } from '@mui/material';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* Date text
|
|
6
|
-
* @param props Props
|
|
7
|
-
* @returns Component
|
|
8
|
-
*/
|
|
9
|
-
export function DateText(props) {
|
|
10
|
-
// Destruct
|
|
11
|
-
const { nearDays, locale = 'lookup', options, timeZone, value, ...rest } = props;
|
|
12
|
-
// Format date
|
|
13
|
-
const date = DateUtils.parse(value);
|
|
14
|
-
// Formatted value
|
|
15
|
-
const localValue = date == null
|
|
16
|
-
? undefined
|
|
17
|
-
: DateUtils.format(value, locale, options, timeZone);
|
|
18
|
-
if (nearDays != null &&
|
|
19
|
-
date != null &&
|
|
20
|
-
Math.abs(new Date().substract(date).totalDays) <= nearDays) {
|
|
21
|
-
rest.color = (theme) => theme.palette.error.main;
|
|
22
|
-
}
|
|
23
|
-
// Layout
|
|
24
|
-
return (React.createElement(Typography, { component: "span", fontSize: "inherit", ...rest }, localValue));
|
|
25
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { NumberTextProps } from './NumberText';
|
|
3
|
-
/**
|
|
4
|
-
* Money text props
|
|
5
|
-
*/
|
|
6
|
-
export interface MoneyTextProps extends NumberTextProps {
|
|
7
|
-
/**
|
|
8
|
-
* Currency, USD for US dollar
|
|
9
|
-
*/
|
|
10
|
-
currency?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Is integer number
|
|
13
|
-
*/
|
|
14
|
-
isInteger?: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Money text
|
|
18
|
-
* @param props Props
|
|
19
|
-
* @returns Component
|
|
20
|
-
*/
|
|
21
|
-
export declare function MoneyText(props: MoneyTextProps): JSX.Element;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NumberUtils } from '@etsoo/shared';
|
|
2
|
-
import { Typography } from '@mui/material';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* Money text
|
|
6
|
-
* @param props Props
|
|
7
|
-
* @returns Component
|
|
8
|
-
*/
|
|
9
|
-
export function MoneyText(props) {
|
|
10
|
-
// Destruct
|
|
11
|
-
const { currency, isInteger = false, locale, options = {}, value, ...rest } = props;
|
|
12
|
-
// Layout
|
|
13
|
-
return (React.createElement(Typography, { component: "span", fontSize: "inherit", ...rest }, NumberUtils.formatMoney(value, currency, locale, isInteger, options)));
|
|
14
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { TypographyProps } from '@mui/material';
|
|
3
|
-
/**
|
|
4
|
-
* Number text props
|
|
5
|
-
*/
|
|
6
|
-
export interface NumberTextProps extends TypographyProps {
|
|
7
|
-
/**
|
|
8
|
-
* Locale
|
|
9
|
-
*/
|
|
10
|
-
locale?: string | string[];
|
|
11
|
-
/**
|
|
12
|
-
* Options
|
|
13
|
-
*/
|
|
14
|
-
options?: Intl.NumberFormatOptions;
|
|
15
|
-
/**
|
|
16
|
-
* Value
|
|
17
|
-
*/
|
|
18
|
-
value?: number | bigint;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Number text
|
|
22
|
-
* @param props Props
|
|
23
|
-
* @returns Component
|
|
24
|
-
*/
|
|
25
|
-
export declare function NumberText(props: NumberTextProps): JSX.Element;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NumberUtils } from '@etsoo/shared';
|
|
2
|
-
import { Typography } from '@mui/material';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* Number text
|
|
6
|
-
* @param props Props
|
|
7
|
-
* @returns Component
|
|
8
|
-
*/
|
|
9
|
-
export function NumberText(props) {
|
|
10
|
-
// Destruct
|
|
11
|
-
const { locale, options = {}, value, ...rest } = props;
|
|
12
|
-
// Layout
|
|
13
|
-
return (React.createElement(Typography, { component: "span", fontSize: "inherit", ...rest }, NumberUtils.format(value, locale, options)));
|
|
14
|
-
}
|
package/src/app/CommonApp.ts
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IActionResult,
|
|
3
|
-
IApiPayload,
|
|
4
|
-
IAppSettings,
|
|
5
|
-
IUser,
|
|
6
|
-
RefreshTokenProps,
|
|
7
|
-
RefreshTokenResult
|
|
8
|
-
} from '@etsoo/appscript';
|
|
9
|
-
import { IPageData } from '../states/PageState';
|
|
10
|
-
import { CoreConstants } from './CoreConstants';
|
|
11
|
-
import { ReactApp } from './ReactApp';
|
|
12
|
-
import { RefreshTokenRQ } from './RefreshTokenRQ';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Common independent application
|
|
16
|
-
* 通用独立程序
|
|
17
|
-
*/
|
|
18
|
-
export abstract class CommonApp<
|
|
19
|
-
U extends IUser = IUser,
|
|
20
|
-
P extends IPageData = IPageData,
|
|
21
|
-
S extends IAppSettings = IAppSettings
|
|
22
|
-
> extends ReactApp<S, U, P> {
|
|
23
|
-
/**
|
|
24
|
-
* Override persistedFields
|
|
25
|
-
*/
|
|
26
|
-
protected override get persistedFields() {
|
|
27
|
-
return [...super.persistedFields, CoreConstants.FieldUserIdSaved];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Init call update fields in local storage
|
|
32
|
-
* @returns Fields
|
|
33
|
-
*/
|
|
34
|
-
protected override initCallEncryptedUpdateFields(): string[] {
|
|
35
|
-
const fields = super.initCallEncryptedUpdateFields();
|
|
36
|
-
fields.push(CoreConstants.FieldUserIdSaved);
|
|
37
|
-
return fields;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Do user login
|
|
42
|
-
* @param data User data
|
|
43
|
-
* @param refreshToken Refresh token
|
|
44
|
-
* @param keep Keep login
|
|
45
|
-
* @returns Success data
|
|
46
|
-
*/
|
|
47
|
-
protected doUserLogin(
|
|
48
|
-
data: U,
|
|
49
|
-
refreshToken: string,
|
|
50
|
-
keep: boolean
|
|
51
|
-
): string | undefined {
|
|
52
|
-
this.userLogin(data, refreshToken, keep);
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Refresh token
|
|
58
|
-
* @param props Props
|
|
59
|
-
*/
|
|
60
|
-
override async refreshToken<D extends object = RefreshTokenRQ>(
|
|
61
|
-
props?: RefreshTokenProps<D>
|
|
62
|
-
) {
|
|
63
|
-
// Destruct
|
|
64
|
-
const {
|
|
65
|
-
callback,
|
|
66
|
-
data,
|
|
67
|
-
relogin = false,
|
|
68
|
-
showLoading = false
|
|
69
|
-
} = props ?? {};
|
|
70
|
-
|
|
71
|
-
// Token
|
|
72
|
-
const token = this.getCacheToken();
|
|
73
|
-
if (token == null || token === '') {
|
|
74
|
-
if (callback) callback(false);
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Reqest data
|
|
79
|
-
const rq: RefreshTokenRQ = {
|
|
80
|
-
deviceId: this.deviceId,
|
|
81
|
-
timezone: this.getTimeZone(),
|
|
82
|
-
...data
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// Login result type
|
|
86
|
-
type LoginResult = IActionResult<U>;
|
|
87
|
-
|
|
88
|
-
// Payload
|
|
89
|
-
const payload: IApiPayload<LoginResult, any> = {
|
|
90
|
-
// No loading bar needed to avoid screen flicks
|
|
91
|
-
showLoading,
|
|
92
|
-
config: { headers: { [CoreConstants.TokenHeaderRefresh]: token } },
|
|
93
|
-
onError: (error) => {
|
|
94
|
-
if (callback) callback(error);
|
|
95
|
-
|
|
96
|
-
// Prevent further processing
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// Success callback
|
|
102
|
-
const success = (
|
|
103
|
-
result: LoginResult,
|
|
104
|
-
failCallback?: (
|
|
105
|
-
result: RefreshTokenResult,
|
|
106
|
-
serviceToken?: string
|
|
107
|
-
) => void
|
|
108
|
-
) => {
|
|
109
|
-
// Token
|
|
110
|
-
const refreshToken = this.getResponseToken(payload.response);
|
|
111
|
-
if (refreshToken == null || result.data == null) {
|
|
112
|
-
if (failCallback) failCallback(this.get('noData')!);
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Keep
|
|
117
|
-
const keep = this.storage.getData(
|
|
118
|
-
CoreConstants.FieldLoginKeep,
|
|
119
|
-
false
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
// User login
|
|
123
|
-
var successData = this.doUserLogin(result.data, refreshToken, keep);
|
|
124
|
-
|
|
125
|
-
// Callback
|
|
126
|
-
if (failCallback) failCallback(true, successData);
|
|
127
|
-
|
|
128
|
-
return true;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Call API
|
|
132
|
-
const result = await this.api.put<LoginResult>(
|
|
133
|
-
'Auth/RefreshToken',
|
|
134
|
-
rq,
|
|
135
|
-
payload
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
if (result == null) return false;
|
|
139
|
-
|
|
140
|
-
if (!result.ok) {
|
|
141
|
-
if (result.type === 'TokenExpired' && relogin) {
|
|
142
|
-
// Try login
|
|
143
|
-
// Dialog to receive password
|
|
144
|
-
var labels = this.getLabels('reloginTip', 'login');
|
|
145
|
-
this.notifier.prompt(
|
|
146
|
-
labels.reloginTip,
|
|
147
|
-
async (pwd) => {
|
|
148
|
-
if (pwd == null) {
|
|
149
|
-
this.toLoginPage();
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Set password for the action
|
|
154
|
-
rq.pwd = this.encrypt(this.hash(pwd));
|
|
155
|
-
|
|
156
|
-
// Submit again
|
|
157
|
-
const result = await this.api.put<LoginResult>(
|
|
158
|
-
'Auth/RefreshToken',
|
|
159
|
-
rq,
|
|
160
|
-
payload
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
if (result == null) return;
|
|
164
|
-
|
|
165
|
-
if (result.ok) {
|
|
166
|
-
success(
|
|
167
|
-
result,
|
|
168
|
-
(loginResult: RefreshTokenResult) => {
|
|
169
|
-
if (loginResult === true) {
|
|
170
|
-
if (callback) callback(true);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const message =
|
|
175
|
-
this.formatRefreshTokenResult(
|
|
176
|
-
loginResult
|
|
177
|
-
);
|
|
178
|
-
if (message) this.notifier.alert(message);
|
|
179
|
-
}
|
|
180
|
-
);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Popup message
|
|
185
|
-
this.alertResult(result);
|
|
186
|
-
return false;
|
|
187
|
-
},
|
|
188
|
-
labels.login,
|
|
189
|
-
{ type: 'password' }
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
// Fake truth to avoid reloading
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (callback) callback(result);
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return success(result, callback);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Try login
|
|
205
|
-
* @param data Additional data
|
|
206
|
-
* @param showLoading Show loading bar or not
|
|
207
|
-
* @returns Result
|
|
208
|
-
*/
|
|
209
|
-
override async tryLogin<D extends object = RefreshTokenRQ>(
|
|
210
|
-
data?: D,
|
|
211
|
-
showLoading?: boolean
|
|
212
|
-
) {
|
|
213
|
-
// Reset user state
|
|
214
|
-
const result = await super.tryLogin(data);
|
|
215
|
-
if (!result) return false;
|
|
216
|
-
|
|
217
|
-
// Refresh token
|
|
218
|
-
return await this.refreshToken({
|
|
219
|
-
callback: (result) => this.doRefreshTokenResult(result),
|
|
220
|
-
data,
|
|
221
|
-
showLoading,
|
|
222
|
-
relogin: true
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { IAppSettings } from '@etsoo/appscript';
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Service app settings interface
|
|
6
|
-
*/
|
|
7
|
-
export interface IServiceAppSettings<S extends DataTypes.IdType = number>
|
|
8
|
-
extends IAppSettings {
|
|
9
|
-
/**
|
|
10
|
-
* Service id
|
|
11
|
-
*/
|
|
12
|
-
readonly serviceId: S;
|
|
13
|
-
}
|
package/src/app/IServicePage.ts
DELETED
package/src/app/IServiceUser.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IActionResult, IUser } from '@etsoo/appscript';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Service user interface
|
|
5
|
-
*/
|
|
6
|
-
export interface IServiceUser extends IUser {
|
|
7
|
-
/**
|
|
8
|
-
* Service device id
|
|
9
|
-
*/
|
|
10
|
-
serviceDeviceId: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Service user login result
|
|
15
|
-
*/
|
|
16
|
-
export type ServiceLoginResult<U extends IServiceUser = IServiceUser> =
|
|
17
|
-
IActionResult<U>;
|
package/src/app/ISmartERPUser.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IActionResult, IUser } from '@etsoo/appscript';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* SmartERP user interface
|
|
5
|
-
*/
|
|
6
|
-
export interface ISmartERPUser extends IUser {
|
|
7
|
-
/**
|
|
8
|
-
* Service refresh token
|
|
9
|
-
*/
|
|
10
|
-
readonly serviceToken?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* SmartERP user login result
|
|
15
|
-
*/
|
|
16
|
-
export type SmartERPLoginResult = IActionResult<ISmartERPUser>;
|
package/src/app/Labels.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { DataTypes, Utils } from '@etsoo/shared';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Labels
|
|
5
|
-
*/
|
|
6
|
-
export namespace Labels {
|
|
7
|
-
/**
|
|
8
|
-
* Common page labels
|
|
9
|
-
*/
|
|
10
|
-
export const CommonPage = {
|
|
11
|
-
add: 'Add',
|
|
12
|
-
back: 'Back',
|
|
13
|
-
delete: 'Delete',
|
|
14
|
-
more: 'More',
|
|
15
|
-
pullToRefresh: 'Pull down to refresh',
|
|
16
|
-
refresh: 'Refresh',
|
|
17
|
-
refreshing: 'Refreshing',
|
|
18
|
-
releaseToRefresh: 'Release to refresh',
|
|
19
|
-
reset: 'Reset',
|
|
20
|
-
save: 'Save',
|
|
21
|
-
scrollTop: 'Scroll to top',
|
|
22
|
-
submit: 'Submit'
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Notification MU labels
|
|
27
|
-
*/
|
|
28
|
-
export const NotificationMU = {
|
|
29
|
-
alertTitle: 'Warning',
|
|
30
|
-
alertOK: 'OK',
|
|
31
|
-
confirmTitle: 'Confirm',
|
|
32
|
-
confirmYes: 'OK',
|
|
33
|
-
confirmNo: 'Cancel',
|
|
34
|
-
promptTitle: 'Input',
|
|
35
|
-
promptCancel: 'Cancel',
|
|
36
|
-
promptOK: 'OK',
|
|
37
|
-
loading: 'Loading',
|
|
38
|
-
success: 'Success',
|
|
39
|
-
warning: 'Warning',
|
|
40
|
-
info: 'Information'
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* UserAvatarEditor labels
|
|
45
|
-
*/
|
|
46
|
-
export const UserAvatarEditor = {
|
|
47
|
-
done: 'Done',
|
|
48
|
-
reset: 'Reset',
|
|
49
|
-
rotateLeft: 'Rotate left 90°',
|
|
50
|
-
rotateRight: 'Rotate right 90°',
|
|
51
|
-
upload: 'Upload',
|
|
52
|
-
zoom: 'Zoom'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* setLabelReference key reference
|
|
57
|
-
*/
|
|
58
|
-
export interface setLabelsReference {
|
|
59
|
-
commonPage?: DataTypes.StringDictionary;
|
|
60
|
-
notificationMU?: DataTypes.StringDictionary;
|
|
61
|
-
userAvatarEditor?: DataTypes.StringDictionary;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Set components' labels
|
|
66
|
-
* @param labels Labels
|
|
67
|
-
* @param reference Key reference
|
|
68
|
-
*/
|
|
69
|
-
export const setLabels = (
|
|
70
|
-
labels: DataTypes.StringRecord,
|
|
71
|
-
reference: setLabelsReference = {}
|
|
72
|
-
) => {
|
|
73
|
-
Utils.setLabels(CommonPage, labels, reference.commonPage);
|
|
74
|
-
Utils.setLabels(NotificationMU, labels, reference.notificationMU);
|
|
75
|
-
Utils.setLabels(UserAvatarEditor, labels, reference.userAvatarEditor);
|
|
76
|
-
};
|
|
77
|
-
}
|