@etsoo/react 1.5.80 → 1.5.81
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/uses/useWindowScroll.d.ts +10 -0
- package/lib/uses/useWindowScroll.js +46 -0
- package/lib/uses/useWindowSize.js +11 -5
- package/package.json +3 -15
- 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/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
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
ListProps,
|
|
9
9
|
VariableSizeList
|
|
10
10
|
} from 'react-window';
|
|
11
|
-
import { GridMethodRef } from '../mu/GridMethodRef';
|
|
12
11
|
import useCombinedRefs from '../uses/useCombinedRefs';
|
|
13
12
|
import {
|
|
14
13
|
GridLoadDataProps,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
GridLoaderStates,
|
|
17
16
|
GridSizeGet
|
|
18
17
|
} from './GridLoader';
|
|
18
|
+
import { GridMethodRef } from './GridMethodRef';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Scroller vertical list props
|
|
@@ -34,7 +34,7 @@ export interface ScrollerListProps<T extends object>
|
|
|
34
34
|
/**
|
|
35
35
|
* Methods ref
|
|
36
36
|
*/
|
|
37
|
-
mRef?: React.Ref<ScrollerListForwardRef
|
|
37
|
+
mRef?: React.Ref<ScrollerListForwardRef<T>>;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Outer div ref
|
|
@@ -77,7 +77,9 @@ interface ScrollerListRef {
|
|
|
77
77
|
/**
|
|
78
78
|
* Scroller list forward ref
|
|
79
79
|
*/
|
|
80
|
-
export interface ScrollerListForwardRef
|
|
80
|
+
export interface ScrollerListForwardRef<T>
|
|
81
|
+
extends GridMethodRef<T>,
|
|
82
|
+
ScrollerListRef {
|
|
81
83
|
/**
|
|
82
84
|
* Refresh latest page data
|
|
83
85
|
*/
|
package/src/index.ts
CHANGED
|
@@ -1,94 +1,17 @@
|
|
|
1
1
|
// app
|
|
2
|
-
export * from './app/CommonApp';
|
|
3
2
|
export * from './app/CoreConstants';
|
|
4
3
|
export * from './app/InputDialogProps';
|
|
5
|
-
export * from './app/IServiceAppSettings';
|
|
6
|
-
export * from './app/IServicePage';
|
|
7
|
-
export * from './app/IServiceUser';
|
|
8
|
-
export * from './app/ISmartERPUser';
|
|
9
|
-
export * from './app/Labels';
|
|
10
|
-
export * from './app/ReactApp';
|
|
11
4
|
export * from './app/ReactUtils';
|
|
12
5
|
export * from './app/RefreshTokenRQ';
|
|
13
|
-
export * from './app/ServiceApp';
|
|
14
6
|
|
|
15
7
|
// components
|
|
8
|
+
export * from './components/DnDList';
|
|
16
9
|
export * from './components/GridColumn';
|
|
17
10
|
export * from './components/GridLoader';
|
|
18
11
|
export * from './components/HRouter';
|
|
19
12
|
export * from './components/ListItemReact';
|
|
20
13
|
export * from './components/ScrollerGrid';
|
|
21
14
|
export * from './components/ScrollerList';
|
|
22
|
-
export * from './components/ShowDataComparison';
|
|
23
|
-
|
|
24
|
-
// mu
|
|
25
|
-
export * from './mu/pages/CommonPage';
|
|
26
|
-
export * from './mu/pages/CommonPageProps';
|
|
27
|
-
export * from './mu/pages/DataGridPage';
|
|
28
|
-
export * from './mu/pages/DataGridPageProps';
|
|
29
|
-
export * from './mu/pages/EditPage';
|
|
30
|
-
export * from './mu/pages/FixedListPage';
|
|
31
|
-
export * from './mu/pages/ListPage';
|
|
32
|
-
export * from './mu/pages/ListPageProps';
|
|
33
|
-
export * from './mu/pages/ResponsivePage';
|
|
34
|
-
export * from './mu/pages/ResponsivePageProps';
|
|
35
|
-
export * from './mu/pages/SearchPageProps';
|
|
36
|
-
export * from './mu/pages/TablePage';
|
|
37
|
-
export * from './mu/pages/ViewPage';
|
|
38
|
-
|
|
39
|
-
export * from './mu/texts/DateText';
|
|
40
|
-
export * from './mu/texts/MoneyText';
|
|
41
|
-
export * from './mu/texts/NumberText';
|
|
42
|
-
|
|
43
|
-
export * from './mu/AuditDisplay';
|
|
44
|
-
export * from './mu/BackButton';
|
|
45
|
-
export * from './mu/BridgeCloseButton';
|
|
46
|
-
export * from './mu/ButtonLink';
|
|
47
|
-
export * from './mu/ComboBox';
|
|
48
|
-
export * from './mu/CountdownButton';
|
|
49
|
-
export * from './mu/CustomFabProps';
|
|
50
|
-
export * from './mu/DataGridEx';
|
|
51
|
-
export * from './mu/DataGridRenderers';
|
|
52
|
-
export * from './mu/DialogButton';
|
|
53
|
-
export * from './mu/DnDList';
|
|
54
|
-
export * from './mu/DraggablePaperComponent';
|
|
55
|
-
export * from './mu/EmailInput';
|
|
56
|
-
export * from './mu/FabBox';
|
|
57
|
-
export * from './mu/FlexBox';
|
|
58
|
-
export * from './mu/GridDataFormat';
|
|
59
|
-
export * from './mu/IconButtonLink';
|
|
60
|
-
export * from './mu/InputField';
|
|
61
|
-
export * from './mu/ItemList';
|
|
62
|
-
export * from './mu/ListItemRightIcon';
|
|
63
|
-
export * from './mu/ListMoreDisplay';
|
|
64
|
-
export * from './mu/LoadingButton';
|
|
65
|
-
export * from './mu/MaskInput';
|
|
66
|
-
export * from './mu/MobileListItemRenderer';
|
|
67
|
-
export * from './mu/MoreFab';
|
|
68
|
-
export * from './mu/MUGlobal';
|
|
69
|
-
export * from './mu/NotifierMU';
|
|
70
|
-
export * from './mu/OptionGroup';
|
|
71
|
-
export * from './mu/PList';
|
|
72
|
-
export * from './mu/ProgressCount';
|
|
73
|
-
export * from './mu/PullToRefreshUI';
|
|
74
|
-
export * from './mu/ResponsibleContainer';
|
|
75
|
-
export * from './mu/RLink';
|
|
76
|
-
export * from './mu/ScrollerListEx';
|
|
77
|
-
export * from './mu/ScrollTopFab';
|
|
78
|
-
export * from './mu/SearchBar';
|
|
79
|
-
export * from './mu/SearchField';
|
|
80
|
-
export * from './mu/SearchOptionGroup';
|
|
81
|
-
export * from './mu/SelectBool';
|
|
82
|
-
export * from './mu/SelectEx';
|
|
83
|
-
export * from './mu/Switch';
|
|
84
|
-
export * from './mu/SwitchAnt';
|
|
85
|
-
export * from './mu/TabBox';
|
|
86
|
-
export * from './mu/TableEx';
|
|
87
|
-
export * from './mu/TextFieldEx';
|
|
88
|
-
export * from './mu/Tiplist';
|
|
89
|
-
export * from './mu/TooltipClick';
|
|
90
|
-
export * from './mu/UserAvatar';
|
|
91
|
-
export * from './mu/UserAvatarEditor';
|
|
92
15
|
|
|
93
16
|
// notifier
|
|
94
17
|
export * from './notifier/Notifier';
|
|
@@ -107,4 +30,5 @@ export * from './uses/useDelayedExecutor';
|
|
|
107
30
|
export * from './uses/useDimensions';
|
|
108
31
|
export * from './uses/useParamsEx';
|
|
109
32
|
export * from './uses/useTimeout';
|
|
33
|
+
export * from './uses/useWindowScroll';
|
|
110
34
|
export * from './uses/useWindowSize';
|
package/src/notifier/Notifier.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import { IAction } from '@etsoo/appscript';
|
|
14
14
|
import { State } from '../states/State';
|
|
15
15
|
import { IProviderProps, IUpdate } from '../states/IState';
|
|
16
|
-
import { Breakpoint, ButtonProps } from '@mui/material';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* React notification call props
|
|
@@ -37,7 +36,7 @@ export interface NotificationReactCallProps extends NotificationCallProps {
|
|
|
37
36
|
/**
|
|
38
37
|
* Max width
|
|
39
38
|
*/
|
|
40
|
-
maxWidth?:
|
|
39
|
+
maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false;
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* OK label
|
|
@@ -62,7 +61,7 @@ export interface NotificationReactCallProps extends NotificationCallProps {
|
|
|
62
61
|
/**
|
|
63
62
|
* Primary button props
|
|
64
63
|
*/
|
|
65
|
-
primaryButton?:
|
|
64
|
+
primaryButton?: {};
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
/**
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface IScrollPos {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Detect window scroll
|
|
10
|
+
* @returns Scroll location
|
|
11
|
+
*/
|
|
12
|
+
export const useWindowScroll = () => {
|
|
13
|
+
// State
|
|
14
|
+
const [pos, setPos] = React.useState<IScrollPos>({
|
|
15
|
+
x: window.pageXOffset,
|
|
16
|
+
y: window.pageYOffset
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
let ticking = false;
|
|
21
|
+
let lastPos: IScrollPos;
|
|
22
|
+
let requestAnimationFrameSeed = 0;
|
|
23
|
+
|
|
24
|
+
const scrollHandler = () => {
|
|
25
|
+
lastPos = {
|
|
26
|
+
x: window.pageXOffset,
|
|
27
|
+
y: window.pageYOffset
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
if (!ticking) {
|
|
31
|
+
requestAnimationFrameSeed = window.requestAnimationFrame(() => {
|
|
32
|
+
ticking = false;
|
|
33
|
+
requestAnimationFrameSeed = 0;
|
|
34
|
+
|
|
35
|
+
if (lastPos.x != lastPos.x || lastPos.y != lastPos.y) {
|
|
36
|
+
setPos(lastPos);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
ticking = true;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
window.addEventListener('scroll', scrollHandler, {
|
|
44
|
+
passive: true,
|
|
45
|
+
capture: false
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
// Cancel animation frame
|
|
50
|
+
if (requestAnimationFrameSeed > 0)
|
|
51
|
+
window.cancelAnimationFrame(requestAnimationFrameSeed);
|
|
52
|
+
|
|
53
|
+
// Remove scroll event
|
|
54
|
+
window.removeEventListener('scroll', scrollHandler);
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
// Return
|
|
59
|
+
return pos;
|
|
60
|
+
};
|
|
@@ -18,33 +18,42 @@ export const useWindowSize = () => {
|
|
|
18
18
|
|
|
19
19
|
React.useEffect(() => {
|
|
20
20
|
let ticking = false;
|
|
21
|
-
let
|
|
21
|
+
let lastSize: ISize;
|
|
22
22
|
let requestAnimationFrameSeed = 0;
|
|
23
23
|
|
|
24
24
|
const resizeHandler = () => {
|
|
25
|
-
|
|
25
|
+
lastSize = {
|
|
26
26
|
width: document.documentElement.clientWidth,
|
|
27
27
|
height: document.documentElement.clientHeight
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
if (!ticking) {
|
|
31
31
|
requestAnimationFrameSeed = window.requestAnimationFrame(() => {
|
|
32
|
-
setSize(lastKnownSize);
|
|
33
32
|
ticking = false;
|
|
34
33
|
requestAnimationFrameSeed = 0;
|
|
34
|
+
|
|
35
|
+
if (
|
|
36
|
+
lastSize.width != size.width ||
|
|
37
|
+
lastSize.height != size.height
|
|
38
|
+
) {
|
|
39
|
+
setSize(lastSize);
|
|
40
|
+
}
|
|
35
41
|
});
|
|
36
42
|
ticking = true;
|
|
37
43
|
}
|
|
38
44
|
};
|
|
39
45
|
|
|
40
|
-
window.addEventListener('resize', resizeHandler
|
|
46
|
+
window.addEventListener('resize', resizeHandler, {
|
|
47
|
+
passive: true,
|
|
48
|
+
capture: false
|
|
49
|
+
});
|
|
41
50
|
|
|
42
51
|
return () => {
|
|
43
52
|
// Cancel animation frame
|
|
44
53
|
if (requestAnimationFrameSeed > 0)
|
|
45
54
|
window.cancelAnimationFrame(requestAnimationFrameSeed);
|
|
46
55
|
|
|
47
|
-
// Remove
|
|
56
|
+
// Remove resize event
|
|
48
57
|
window.removeEventListener('resize', resizeHandler);
|
|
49
58
|
};
|
|
50
59
|
}, []);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ComboBox } from '../../src';
|
|
3
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
-
|
|
6
|
-
it('Render ComboBox', async () => {
|
|
7
|
-
// Arrange
|
|
8
|
-
type T = { id: number; name: string };
|
|
9
|
-
const options: T[] = [
|
|
10
|
-
{ id: 1, name: 'Name 1' },
|
|
11
|
-
{ id: 2, name: 'Name 2' }
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
render(
|
|
15
|
-
<ComboBox<T>
|
|
16
|
-
name="Test"
|
|
17
|
-
options={options}
|
|
18
|
-
labelField="name"
|
|
19
|
-
label="Test"
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
// Act, click the list
|
|
24
|
-
const clicked = fireEvent.click(screen.getByRole('button'));
|
|
25
|
-
expect(clicked).toBeTruthy();
|
|
26
|
-
|
|
27
|
-
// Get list item
|
|
28
|
-
const item = screen.getByText('Name 1');
|
|
29
|
-
expect(item.nodeName).toBe('LI');
|
|
30
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { MUGlobal } from '../../src/mu/MUGlobal';
|
|
2
|
-
|
|
3
|
-
// Theme update function
|
|
4
|
-
const updateFunc = (value: number) => `${value * 8}px`;
|
|
5
|
-
|
|
6
|
-
// Arrange
|
|
7
|
-
const paddings = { sx: 2, sm: 3, key: 'a' };
|
|
8
|
-
|
|
9
|
-
test('getMenuItem tests', () => {
|
|
10
|
-
// Assert
|
|
11
|
-
expect(
|
|
12
|
-
MUGlobal.getMenuItem('/user/add', '/user/all').selected
|
|
13
|
-
).toBeTruthy();
|
|
14
|
-
expect(MUGlobal.getMenuItem('/user/add', '/user/*').selected).toBeTruthy();
|
|
15
|
-
expect(
|
|
16
|
-
MUGlobal.getMenuItem('/user/add', '/user/edit').selected
|
|
17
|
-
).toBeFalsy();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('half tests', () => {
|
|
21
|
-
// Act
|
|
22
|
-
const result = MUGlobal.half(paddings);
|
|
23
|
-
|
|
24
|
-
// Assert
|
|
25
|
-
expect(paddings).toHaveProperty('sx', 2);
|
|
26
|
-
expect(result).toHaveProperty('sx', 1);
|
|
27
|
-
expect(result).toHaveProperty('sm', 1.5);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('increase tests', () => {
|
|
31
|
-
// Act
|
|
32
|
-
const result = MUGlobal.increase(paddings, 2);
|
|
33
|
-
|
|
34
|
-
// Assert
|
|
35
|
-
expect(paddings).toHaveProperty('sx', 2);
|
|
36
|
-
expect(result).toHaveProperty('sx', 4);
|
|
37
|
-
expect(result).toHaveProperty('sm', 5);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('adjustWithTheme tests', () => {
|
|
41
|
-
// Act
|
|
42
|
-
const result = MUGlobal.adjustWithTheme(160, paddings, updateFunc);
|
|
43
|
-
|
|
44
|
-
// Assert
|
|
45
|
-
expect(paddings).toHaveProperty('sx', 2);
|
|
46
|
-
expect(result).toHaveProperty('sx', '144px');
|
|
47
|
-
expect(result).toHaveProperty('sm', '136px');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('updateWithTheme tests', () => {
|
|
51
|
-
// Act
|
|
52
|
-
const result = MUGlobal.updateWithTheme(paddings, updateFunc);
|
|
53
|
-
|
|
54
|
-
// Assert
|
|
55
|
-
expect(paddings).toHaveProperty('sx', 2);
|
|
56
|
-
expect(result).toHaveProperty('sx', '16px');
|
|
57
|
-
expect(result).toHaveProperty('sm', '24px');
|
|
58
|
-
});
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import { act } from 'react-dom/test-utils';
|
|
4
|
-
import { INotification, NotificationMessageType, NotifierMU } from '../../src';
|
|
5
|
-
|
|
6
|
-
// Without it will popup error:
|
|
7
|
-
// The current testing environment is not configured to support act
|
|
8
|
-
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
|
|
9
|
-
|
|
10
|
-
// Root
|
|
11
|
-
const root = document.body;
|
|
12
|
-
const container: HTMLElement = document.createElement('div');
|
|
13
|
-
root.append(container);
|
|
14
|
-
|
|
15
|
-
// The state provider
|
|
16
|
-
const Provider = NotifierMU.setup();
|
|
17
|
-
const reactRoot = createRoot(container);
|
|
18
|
-
|
|
19
|
-
act(() => {
|
|
20
|
-
// Concorrent renderer needs act block
|
|
21
|
-
reactRoot.render(<Provider />);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Notifier
|
|
25
|
-
const notifier = NotifierMU.instance;
|
|
26
|
-
|
|
27
|
-
// Timer mock
|
|
28
|
-
// https://jestjs.io/docs/en/timer-mocks
|
|
29
|
-
jest.useFakeTimers();
|
|
30
|
-
|
|
31
|
-
test('Alert tests', async () => {
|
|
32
|
-
// Click
|
|
33
|
-
const handleClick = jest.fn();
|
|
34
|
-
|
|
35
|
-
act(() => {
|
|
36
|
-
// Add the notification
|
|
37
|
-
notifier.alert('Alert message', handleClick);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Button
|
|
41
|
-
const button = root.getElementsByTagName('button');
|
|
42
|
-
|
|
43
|
-
expect(button.length).toBe(1);
|
|
44
|
-
expect(button[0].innerHTML).toContain('OK');
|
|
45
|
-
|
|
46
|
-
await act(async () => {
|
|
47
|
-
button[0].click();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
expect(handleClick).toBeCalled();
|
|
51
|
-
|
|
52
|
-
// Fast forward
|
|
53
|
-
jest.runOnlyPendingTimers();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('Confirm tests', async () => {
|
|
57
|
-
// Click
|
|
58
|
-
const handleClick = jest.fn();
|
|
59
|
-
|
|
60
|
-
act(() => {
|
|
61
|
-
// Add the notification
|
|
62
|
-
notifier.confirm('Confirm message', undefined, handleClick);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Button
|
|
66
|
-
const button = root.getElementsByTagName('button');
|
|
67
|
-
|
|
68
|
-
expect(button.length).toBe(2);
|
|
69
|
-
expect(button[0].innerHTML).toContain('Cancel');
|
|
70
|
-
|
|
71
|
-
await act(async () => {
|
|
72
|
-
button[0].click();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
expect(handleClick).toBeCalled();
|
|
76
|
-
|
|
77
|
-
// Fast forward
|
|
78
|
-
jest.runOnlyPendingTimers();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('Confirm tests without cancel button', async () => {
|
|
82
|
-
// Click
|
|
83
|
-
const handleClick = jest.fn();
|
|
84
|
-
|
|
85
|
-
act(() => {
|
|
86
|
-
// Add the notification
|
|
87
|
-
notifier.confirm('Confirm message', undefined, handleClick, {
|
|
88
|
-
cancelButton: false
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// Button
|
|
93
|
-
const button = root.getElementsByTagName('button');
|
|
94
|
-
|
|
95
|
-
expect(button.length).toBe(1);
|
|
96
|
-
expect(button[0].innerHTML).toContain('OK');
|
|
97
|
-
|
|
98
|
-
await act(async () => {
|
|
99
|
-
button[0].click();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
expect(handleClick).toBeCalled();
|
|
103
|
-
|
|
104
|
-
// Fast forward
|
|
105
|
-
jest.runOnlyPendingTimers();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
test('Prompt tests', async () => {
|
|
109
|
-
// Click
|
|
110
|
-
const handleClick = jest.fn((result: boolean) => {
|
|
111
|
-
expect(result).toBeTruthy();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
act(() => {
|
|
115
|
-
// Add the notification
|
|
116
|
-
notifier.prompt<boolean>('Prompt message', handleClick, undefined, {
|
|
117
|
-
type: 'switch',
|
|
118
|
-
required: false
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Button
|
|
123
|
-
const button = root.getElementsByTagName('button');
|
|
124
|
-
|
|
125
|
-
expect(button.length).toBe(2); // Switch will generate a button
|
|
126
|
-
expect(button[1].innerHTML).toContain('OK');
|
|
127
|
-
|
|
128
|
-
await act(async () => {
|
|
129
|
-
button[1].click();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
expect(handleClick).toBeCalled();
|
|
133
|
-
|
|
134
|
-
jest.runOnlyPendingTimers();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test('Prompt tests with form submit', async () => {
|
|
138
|
-
// Click
|
|
139
|
-
const handleClick = jest.fn((result: boolean) => {
|
|
140
|
-
expect(result).toBeTruthy();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
act(() => {
|
|
144
|
-
// Add the notification
|
|
145
|
-
notifier.prompt<boolean>('Prompt message', handleClick, undefined, {
|
|
146
|
-
type: 'switch',
|
|
147
|
-
required: false
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
await act(async () => {
|
|
152
|
-
(
|
|
153
|
-
root
|
|
154
|
-
.getElementsByTagName('form')[0]
|
|
155
|
-
.elements.namedItem('okButton') as HTMLButtonElement
|
|
156
|
-
)?.click();
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
expect(handleClick).toBeCalled();
|
|
160
|
-
|
|
161
|
-
jest.runOnlyPendingTimers();
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test('Message tests', (done) => {
|
|
165
|
-
// Callback
|
|
166
|
-
const callback = jest.fn(() => done());
|
|
167
|
-
|
|
168
|
-
let n: INotification<React.ReactNode, any> | undefined;
|
|
169
|
-
act(() => {
|
|
170
|
-
// Add the notification
|
|
171
|
-
n = notifier.message(
|
|
172
|
-
NotificationMessageType.Danger,
|
|
173
|
-
'Error Message',
|
|
174
|
-
undefined,
|
|
175
|
-
{
|
|
176
|
-
callback
|
|
177
|
-
}
|
|
178
|
-
);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
expect(n?.timespan).toBe(5);
|
|
182
|
-
|
|
183
|
-
expect(root.innerHTML).toContain('Error Message');
|
|
184
|
-
|
|
185
|
-
act(() => {
|
|
186
|
-
// Here is the bug need further study...
|
|
187
|
-
n?.dismiss();
|
|
188
|
-
|
|
189
|
-
// Fast forward
|
|
190
|
-
jest.runOnlyPendingTimers();
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
expect(root.innerHTML).not.toContain('Error Message');
|
|
194
|
-
expect(callback).toBeCalled();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test('Loading tests', () => {
|
|
198
|
-
act(() => {
|
|
199
|
-
// Add the notification
|
|
200
|
-
notifier.showLoading('Loading');
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
expect(root.innerHTML).toContain('Loading');
|
|
204
|
-
|
|
205
|
-
act(() => {
|
|
206
|
-
notifier.hideLoading();
|
|
207
|
-
|
|
208
|
-
// Fast forward
|
|
209
|
-
jest.runOnlyPendingTimers();
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
expect(root.innerHTML).not.toContain('Loading');
|
|
213
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SelectEx } from '../../src';
|
|
3
|
-
import { findByText, fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
-
|
|
6
|
-
it('Render SelectEx', async () => {
|
|
7
|
-
// Arrange
|
|
8
|
-
type T = { id: number; name: string };
|
|
9
|
-
const options: T[] = [
|
|
10
|
-
{ id: 1, name: 'Name 1' },
|
|
11
|
-
{ id: 2, name: 'Name 2' }
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
// Render component
|
|
15
|
-
const { baseElement } = render(
|
|
16
|
-
<SelectEx<T> options={options} name="test" search labelField="name" />
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
// Act, click to show the list
|
|
20
|
-
const button = screen.getByRole('button');
|
|
21
|
-
fireEvent.mouseDown(button); // Not click
|
|
22
|
-
|
|
23
|
-
// Get list item
|
|
24
|
-
const item = await findByText(baseElement, 'Name 2');
|
|
25
|
-
expect(item.nodeName).toBe('SPAN');
|
|
26
|
-
});
|
package/lib/app/CommonApp.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { IAppSettings, IUser, RefreshTokenProps } from '@etsoo/appscript';
|
|
2
|
-
import { IPageData } from '../states/PageState';
|
|
3
|
-
import { ReactApp } from './ReactApp';
|
|
4
|
-
import { RefreshTokenRQ } from './RefreshTokenRQ';
|
|
5
|
-
/**
|
|
6
|
-
* Common independent application
|
|
7
|
-
* 通用独立程序
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class CommonApp<U extends IUser = IUser, P extends IPageData = IPageData, S extends IAppSettings = IAppSettings> extends ReactApp<S, U, P> {
|
|
10
|
-
/**
|
|
11
|
-
* Override persistedFields
|
|
12
|
-
*/
|
|
13
|
-
protected get persistedFields(): string[];
|
|
14
|
-
/**
|
|
15
|
-
* Init call update fields in local storage
|
|
16
|
-
* @returns Fields
|
|
17
|
-
*/
|
|
18
|
-
protected initCallEncryptedUpdateFields(): string[];
|
|
19
|
-
/**
|
|
20
|
-
* Do user login
|
|
21
|
-
* @param data User data
|
|
22
|
-
* @param refreshToken Refresh token
|
|
23
|
-
* @param keep Keep login
|
|
24
|
-
* @returns Success data
|
|
25
|
-
*/
|
|
26
|
-
protected doUserLogin(data: U, refreshToken: string, keep: boolean): string | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Refresh token
|
|
29
|
-
* @param props Props
|
|
30
|
-
*/
|
|
31
|
-
refreshToken<D extends object = RefreshTokenRQ>(props?: RefreshTokenProps<D>): Promise<boolean>;
|
|
32
|
-
/**
|
|
33
|
-
* Try login
|
|
34
|
-
* @param data Additional data
|
|
35
|
-
* @param showLoading Show loading bar or not
|
|
36
|
-
* @returns Result
|
|
37
|
-
*/
|
|
38
|
-
tryLogin<D extends object = RefreshTokenRQ>(data?: D, showLoading?: boolean): Promise<boolean>;
|
|
39
|
-
}
|