@etsoo/react 1.5.78 → 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.
Files changed (255) hide show
  1. package/README.md +7 -2
  2. package/__tests__/ReactUtils.ts +6 -0
  3. package/lib/{mu → components}/DnDList.d.ts +1 -14
  4. package/lib/{mu → components}/DnDList.js +1 -24
  5. package/lib/components/GridMethodRef.d.ts +11 -0
  6. package/lib/{mu → components}/GridMethodRef.js +0 -0
  7. package/lib/components/ScrollerGrid.d.ts +6 -6
  8. package/lib/components/ScrollerList.d.ts +3 -3
  9. package/lib/index.d.ts +2 -74
  10. package/lib/index.js +2 -75
  11. package/lib/notifier/Notifier.d.ts +2 -3
  12. package/lib/uses/useWindowScroll.d.ts +10 -0
  13. package/lib/uses/useWindowScroll.js +46 -0
  14. package/lib/uses/useWindowSize.js +11 -5
  15. package/package.json +9 -21
  16. package/src/{mu → components}/DnDList.tsx +11 -34
  17. package/src/components/GridMethodRef.ts +12 -0
  18. package/src/components/ScrollerGrid.tsx +6 -6
  19. package/src/components/ScrollerList.tsx +5 -3
  20. package/src/index.ts +2 -78
  21. package/src/notifier/Notifier.ts +2 -3
  22. package/src/uses/useWindowScroll.ts +60 -0
  23. package/src/uses/useWindowSize.ts +14 -5
  24. package/__tests__/mu/MUGlobalTests.tsx +0 -58
  25. package/__tests__/mu/NotifierMUTests.tsx +0 -213
  26. package/lib/app/CommonApp.d.ts +0 -39
  27. package/lib/app/CommonApp.js +0 -149
  28. package/lib/app/IServiceAppSettings.d.ts +0 -11
  29. package/lib/app/IServiceAppSettings.js +0 -1
  30. package/lib/app/IServicePage.d.ts +0 -6
  31. package/lib/app/IServicePage.js +0 -1
  32. package/lib/app/IServiceUser.d.ts +0 -14
  33. package/lib/app/IServiceUser.js +0 -1
  34. package/lib/app/ISmartERPUser.d.ts +0 -14
  35. package/lib/app/ISmartERPUser.js +0 -1
  36. package/lib/app/Labels.d.ts +0 -65
  37. package/lib/app/Labels.js +0 -62
  38. package/lib/app/ReactApp.d.ts +0 -194
  39. package/lib/app/ReactApp.js +0 -298
  40. package/lib/app/ServiceApp.d.ts +0 -78
  41. package/lib/app/ServiceApp.js +0 -244
  42. package/lib/components/ShowDataComparison.d.ts +0 -20
  43. package/lib/components/ShowDataComparison.js +0 -60
  44. package/lib/mu/AuditDisplay.d.ts +0 -33
  45. package/lib/mu/AuditDisplay.js +0 -52
  46. package/lib/mu/AutocompleteExtendedProps.d.ts +0 -66
  47. package/lib/mu/AutocompleteExtendedProps.js +0 -1
  48. package/lib/mu/BackButton.d.ts +0 -13
  49. package/lib/mu/BackButton.js +0 -33
  50. package/lib/mu/BridgeCloseButton.d.ts +0 -23
  51. package/lib/mu/BridgeCloseButton.js +0 -32
  52. package/lib/mu/ButtonLink.d.ts +0 -17
  53. package/lib/mu/ButtonLink.js +0 -19
  54. package/lib/mu/ComboBox.d.ts +0 -40
  55. package/lib/mu/ComboBox.js +0 -108
  56. package/lib/mu/CountdownButton.d.ts +0 -23
  57. package/lib/mu/CountdownButton.js +0 -81
  58. package/lib/mu/CustomFabProps.d.ts +0 -27
  59. package/lib/mu/CustomFabProps.js +0 -1
  60. package/lib/mu/DataGridEx.d.ts +0 -96
  61. package/lib/mu/DataGridEx.js +0 -331
  62. package/lib/mu/DataGridRenderers.d.ts +0 -22
  63. package/lib/mu/DataGridRenderers.js +0 -99
  64. package/lib/mu/DialogButton.d.ts +0 -54
  65. package/lib/mu/DialogButton.js +0 -45
  66. package/lib/mu/DraggablePaperComponent.d.ts +0 -8
  67. package/lib/mu/DraggablePaperComponent.js +0 -12
  68. package/lib/mu/EmailInput.d.ts +0 -11
  69. package/lib/mu/EmailInput.js +0 -15
  70. package/lib/mu/FabBox.d.ts +0 -21
  71. package/lib/mu/FabBox.js +0 -31
  72. package/lib/mu/FlexBox.d.ts +0 -14
  73. package/lib/mu/FlexBox.js +0 -18
  74. package/lib/mu/GridDataFormat.d.ts +0 -10
  75. package/lib/mu/GridDataFormat.js +0 -43
  76. package/lib/mu/GridMethodRef.d.ts +0 -11
  77. package/lib/mu/IconButtonLink.d.ts +0 -17
  78. package/lib/mu/IconButtonLink.js +0 -16
  79. package/lib/mu/InputField.d.ts +0 -21
  80. package/lib/mu/InputField.js +0 -39
  81. package/lib/mu/ItemList.d.ts +0 -55
  82. package/lib/mu/ItemList.js +0 -77
  83. package/lib/mu/ListItemRightIcon.d.ts +0 -4
  84. package/lib/mu/ListItemRightIcon.js +0 -8
  85. package/lib/mu/ListMoreDisplay.d.ts +0 -35
  86. package/lib/mu/ListMoreDisplay.js +0 -99
  87. package/lib/mu/LoadingButton.d.ts +0 -16
  88. package/lib/mu/LoadingButton.js +0 -41
  89. package/lib/mu/MUGlobal.d.ts +0 -102
  90. package/lib/mu/MUGlobal.js +0 -184
  91. package/lib/mu/MaskInput.d.ts +0 -34
  92. package/lib/mu/MaskInput.js +0 -43
  93. package/lib/mu/MobileListItemRenderer.d.ts +0 -17
  94. package/lib/mu/MobileListItemRenderer.js +0 -35
  95. package/lib/mu/MoreFab.d.ts +0 -45
  96. package/lib/mu/MoreFab.js +0 -95
  97. package/lib/mu/NotifierMU.d.ts +0 -47
  98. package/lib/mu/NotifierMU.js +0 -387
  99. package/lib/mu/NotifierPromptProps.d.ts +0 -22
  100. package/lib/mu/NotifierPromptProps.js +0 -1
  101. package/lib/mu/OptionGroup.d.ts +0 -62
  102. package/lib/mu/OptionGroup.js +0 -81
  103. package/lib/mu/PList.d.ts +0 -15
  104. package/lib/mu/PList.js +0 -12
  105. package/lib/mu/ProgressCount.d.ts +0 -44
  106. package/lib/mu/ProgressCount.js +0 -79
  107. package/lib/mu/PullToRefreshUI.d.ts +0 -9
  108. package/lib/mu/PullToRefreshUI.js +0 -18
  109. package/lib/mu/RLink.d.ts +0 -14
  110. package/lib/mu/RLink.js +0 -37
  111. package/lib/mu/ResponsibleContainer.d.ts +0 -89
  112. package/lib/mu/ResponsibleContainer.js +0 -159
  113. package/lib/mu/ScrollTopFab.d.ts +0 -7
  114. package/lib/mu/ScrollTopFab.js +0 -25
  115. package/lib/mu/ScrollerListEx.d.ts +0 -81
  116. package/lib/mu/ScrollerListEx.js +0 -167
  117. package/lib/mu/SearchBar.d.ts +0 -29
  118. package/lib/mu/SearchBar.js +0 -262
  119. package/lib/mu/SearchField.d.ts +0 -21
  120. package/lib/mu/SearchField.js +0 -39
  121. package/lib/mu/SearchOptionGroup.d.ts +0 -9
  122. package/lib/mu/SearchOptionGroup.js +0 -14
  123. package/lib/mu/SelectBool.d.ts +0 -14
  124. package/lib/mu/SelectBool.js +0 -22
  125. package/lib/mu/SelectEx.d.ts +0 -54
  126. package/lib/mu/SelectEx.js +0 -156
  127. package/lib/mu/Switch.d.ts +0 -29
  128. package/lib/mu/Switch.js +0 -34
  129. package/lib/mu/SwitchAnt.d.ts +0 -25
  130. package/lib/mu/SwitchAnt.js +0 -40
  131. package/lib/mu/TabBox.d.ts +0 -54
  132. package/lib/mu/TabBox.js +0 -31
  133. package/lib/mu/TableEx.d.ts +0 -68
  134. package/lib/mu/TableEx.js +0 -271
  135. package/lib/mu/TextFieldEx.d.ts +0 -101
  136. package/lib/mu/TextFieldEx.js +0 -127
  137. package/lib/mu/Tiplist.d.ts +0 -18
  138. package/lib/mu/Tiplist.js +0 -158
  139. package/lib/mu/TooltipClick.d.ts +0 -15
  140. package/lib/mu/TooltipClick.js +0 -40
  141. package/lib/mu/UserAvatar.d.ts +0 -24
  142. package/lib/mu/UserAvatar.js +0 -25
  143. package/lib/mu/UserAvatarEditor.d.ts +0 -53
  144. package/lib/mu/UserAvatarEditor.js +0 -129
  145. package/lib/mu/pages/CommonPage.d.ts +0 -11
  146. package/lib/mu/pages/CommonPage.js +0 -60
  147. package/lib/mu/pages/CommonPageProps.d.ts +0 -60
  148. package/lib/mu/pages/CommonPageProps.js +0 -1
  149. package/lib/mu/pages/DataGridPage.d.ts +0 -9
  150. package/lib/mu/pages/DataGridPage.js +0 -81
  151. package/lib/mu/pages/DataGridPageProps.d.ts +0 -17
  152. package/lib/mu/pages/DataGridPageProps.js +0 -1
  153. package/lib/mu/pages/EditPage.d.ts +0 -33
  154. package/lib/mu/pages/EditPage.js +0 -29
  155. package/lib/mu/pages/FixedListPage.d.ts +0 -15
  156. package/lib/mu/pages/FixedListPage.js +0 -72
  157. package/lib/mu/pages/ListPage.d.ts +0 -9
  158. package/lib/mu/pages/ListPage.js +0 -51
  159. package/lib/mu/pages/ListPageProps.d.ts +0 -7
  160. package/lib/mu/pages/ListPageProps.js +0 -1
  161. package/lib/mu/pages/ResponsivePage.d.ts +0 -9
  162. package/lib/mu/pages/ResponsivePage.js +0 -45
  163. package/lib/mu/pages/ResponsivePageProps.d.ts +0 -39
  164. package/lib/mu/pages/ResponsivePageProps.js +0 -1
  165. package/lib/mu/pages/SearchPageProps.d.ts +0 -30
  166. package/lib/mu/pages/SearchPageProps.js +0 -1
  167. package/lib/mu/pages/TablePage.d.ts +0 -9
  168. package/lib/mu/pages/TablePage.js +0 -71
  169. package/lib/mu/pages/TablePageProps.d.ts +0 -7
  170. package/lib/mu/pages/TablePageProps.js +0 -1
  171. package/lib/mu/pages/ViewPage.d.ts +0 -66
  172. package/lib/mu/pages/ViewPage.js +0 -105
  173. package/lib/mu/texts/DateText.d.ts +0 -34
  174. package/lib/mu/texts/DateText.js +0 -25
  175. package/lib/mu/texts/MoneyText.d.ts +0 -21
  176. package/lib/mu/texts/MoneyText.js +0 -14
  177. package/lib/mu/texts/NumberText.d.ts +0 -25
  178. package/lib/mu/texts/NumberText.js +0 -14
  179. package/src/app/CommonApp.ts +0 -225
  180. package/src/app/IServiceAppSettings.ts +0 -13
  181. package/src/app/IServicePage.ts +0 -6
  182. package/src/app/IServiceUser.ts +0 -17
  183. package/src/app/ISmartERPUser.ts +0 -16
  184. package/src/app/Labels.ts +0 -77
  185. package/src/app/ReactApp.ts +0 -500
  186. package/src/app/ServiceApp.ts +0 -353
  187. package/src/components/ShowDataComparison.tsx +0 -108
  188. package/src/mu/AuditDisplay.tsx +0 -117
  189. package/src/mu/AutocompleteExtendedProps.ts +0 -84
  190. package/src/mu/BackButton.tsx +0 -55
  191. package/src/mu/BridgeCloseButton.tsx +0 -69
  192. package/src/mu/ButtonLink.tsx +0 -32
  193. package/src/mu/ComboBox.tsx +0 -244
  194. package/src/mu/CountdownButton.tsx +0 -119
  195. package/src/mu/CustomFabProps.ts +0 -32
  196. package/src/mu/DataGridEx.tsx +0 -712
  197. package/src/mu/DataGridRenderers.tsx +0 -140
  198. package/src/mu/DialogButton.tsx +0 -163
  199. package/src/mu/DraggablePaperComponent.tsx +0 -19
  200. package/src/mu/EmailInput.tsx +0 -24
  201. package/src/mu/FabBox.tsx +0 -51
  202. package/src/mu/FlexBox.tsx +0 -20
  203. package/src/mu/GridDataFormat.tsx +0 -77
  204. package/src/mu/GridMethodRef.ts +0 -12
  205. package/src/mu/IconButtonLink.tsx +0 -29
  206. package/src/mu/InputField.tsx +0 -82
  207. package/src/mu/ItemList.tsx +0 -201
  208. package/src/mu/ListItemRightIcon.tsx +0 -9
  209. package/src/mu/ListMoreDisplay.tsx +0 -205
  210. package/src/mu/LoadingButton.tsx +0 -75
  211. package/src/mu/MUGlobal.ts +0 -220
  212. package/src/mu/MaskInput.tsx +0 -107
  213. package/src/mu/MobileListItemRenderer.tsx +0 -79
  214. package/src/mu/MoreFab.tsx +0 -211
  215. package/src/mu/NotifierMU.tsx +0 -654
  216. package/src/mu/NotifierPromptProps.ts +0 -26
  217. package/src/mu/OptionGroup.tsx +0 -218
  218. package/src/mu/PList.tsx +0 -27
  219. package/src/mu/ProgressCount.tsx +0 -166
  220. package/src/mu/PullToRefreshUI.tsx +0 -21
  221. package/src/mu/RLink.tsx +0 -64
  222. package/src/mu/ResponsibleContainer.tsx +0 -394
  223. package/src/mu/ScrollTopFab.tsx +0 -34
  224. package/src/mu/ScrollerListEx.tsx +0 -387
  225. package/src/mu/SearchBar.tsx +0 -398
  226. package/src/mu/SearchField.tsx +0 -82
  227. package/src/mu/SearchOptionGroup.tsx +0 -25
  228. package/src/mu/SelectBool.tsx +0 -40
  229. package/src/mu/SelectEx.tsx +0 -285
  230. package/src/mu/Switch.tsx +0 -94
  231. package/src/mu/SwitchAnt.tsx +0 -95
  232. package/src/mu/TabBox.tsx +0 -118
  233. package/src/mu/TableEx.tsx +0 -561
  234. package/src/mu/TextFieldEx.tsx +0 -250
  235. package/src/mu/Tiplist.tsx +0 -304
  236. package/src/mu/TooltipClick.tsx +0 -84
  237. package/src/mu/UserAvatar.tsx +0 -64
  238. package/src/mu/UserAvatarEditor.tsx +0 -287
  239. package/src/mu/pages/CommonPage.tsx +0 -128
  240. package/src/mu/pages/CommonPageProps.ts +0 -71
  241. package/src/mu/pages/DataGridPage.tsx +0 -137
  242. package/src/mu/pages/DataGridPageProps.ts +0 -24
  243. package/src/mu/pages/EditPage.tsx +0 -114
  244. package/src/mu/pages/FixedListPage.tsx +0 -134
  245. package/src/mu/pages/ListPage.tsx +0 -86
  246. package/src/mu/pages/ListPageProps.ts +0 -11
  247. package/src/mu/pages/ResponsivePage.tsx +0 -68
  248. package/src/mu/pages/ResponsivePageProps.ts +0 -57
  249. package/src/mu/pages/SearchPageProps.ts +0 -39
  250. package/src/mu/pages/TablePage.tsx +0 -119
  251. package/src/mu/pages/TablePageProps.ts +0 -11
  252. package/src/mu/pages/ViewPage.tsx +0 -285
  253. package/src/mu/texts/DateText.tsx +0 -74
  254. package/src/mu/texts/MoneyText.tsx +0 -49
  255. package/src/mu/texts/NumberText.tsx +0 -40
@@ -1,149 +0,0 @@
1
- import { CoreConstants } from './CoreConstants';
2
- import { ReactApp } from './ReactApp';
3
- /**
4
- * Common independent application
5
- * 通用独立程序
6
- */
7
- export class CommonApp extends ReactApp {
8
- /**
9
- * Override persistedFields
10
- */
11
- get persistedFields() {
12
- return [...super.persistedFields, CoreConstants.FieldUserIdSaved];
13
- }
14
- /**
15
- * Init call update fields in local storage
16
- * @returns Fields
17
- */
18
- initCallEncryptedUpdateFields() {
19
- const fields = super.initCallEncryptedUpdateFields();
20
- fields.push(CoreConstants.FieldUserIdSaved);
21
- return fields;
22
- }
23
- /**
24
- * Do user login
25
- * @param data User data
26
- * @param refreshToken Refresh token
27
- * @param keep Keep login
28
- * @returns Success data
29
- */
30
- doUserLogin(data, refreshToken, keep) {
31
- this.userLogin(data, refreshToken, keep);
32
- return undefined;
33
- }
34
- /**
35
- * Refresh token
36
- * @param props Props
37
- */
38
- async refreshToken(props) {
39
- // Destruct
40
- const { callback, data, relogin = false, showLoading = false } = props !== null && props !== void 0 ? props : {};
41
- // Token
42
- const token = this.getCacheToken();
43
- if (token == null || token === '') {
44
- if (callback)
45
- callback(false);
46
- return false;
47
- }
48
- // Reqest data
49
- const rq = {
50
- deviceId: this.deviceId,
51
- timezone: this.getTimeZone(),
52
- ...data
53
- };
54
- // Payload
55
- const payload = {
56
- // No loading bar needed to avoid screen flicks
57
- showLoading,
58
- config: { headers: { [CoreConstants.TokenHeaderRefresh]: token } },
59
- onError: (error) => {
60
- if (callback)
61
- callback(error);
62
- // Prevent further processing
63
- return false;
64
- }
65
- };
66
- // Success callback
67
- const success = (result, failCallback) => {
68
- // Token
69
- const refreshToken = this.getResponseToken(payload.response);
70
- if (refreshToken == null || result.data == null) {
71
- if (failCallback)
72
- failCallback(this.get('noData'));
73
- return false;
74
- }
75
- // Keep
76
- const keep = this.storage.getData(CoreConstants.FieldLoginKeep, false);
77
- // User login
78
- var successData = this.doUserLogin(result.data, refreshToken, keep);
79
- // Callback
80
- if (failCallback)
81
- failCallback(true, successData);
82
- return true;
83
- };
84
- // Call API
85
- const result = await this.api.put('Auth/RefreshToken', rq, payload);
86
- if (result == null)
87
- return false;
88
- if (!result.ok) {
89
- if (result.type === 'TokenExpired' && relogin) {
90
- // Try login
91
- // Dialog to receive password
92
- var labels = this.getLabels('reloginTip', 'login');
93
- this.notifier.prompt(labels.reloginTip, async (pwd) => {
94
- if (pwd == null) {
95
- this.toLoginPage();
96
- return;
97
- }
98
- // Set password for the action
99
- rq.pwd = this.encrypt(this.hash(pwd));
100
- // Submit again
101
- const result = await this.api.put('Auth/RefreshToken', rq, payload);
102
- if (result == null)
103
- return;
104
- if (result.ok) {
105
- success(result, (loginResult) => {
106
- if (loginResult === true) {
107
- if (callback)
108
- callback(true);
109
- return;
110
- }
111
- const message = this.formatRefreshTokenResult(loginResult);
112
- if (message)
113
- this.notifier.alert(message);
114
- });
115
- return;
116
- }
117
- // Popup message
118
- this.alertResult(result);
119
- return false;
120
- }, labels.login, { type: 'password' });
121
- // Fake truth to avoid reloading
122
- return true;
123
- }
124
- if (callback)
125
- callback(result);
126
- return false;
127
- }
128
- return success(result, callback);
129
- }
130
- /**
131
- * Try login
132
- * @param data Additional data
133
- * @param showLoading Show loading bar or not
134
- * @returns Result
135
- */
136
- async tryLogin(data, showLoading) {
137
- // Reset user state
138
- const result = await super.tryLogin(data);
139
- if (!result)
140
- return false;
141
- // Refresh token
142
- return await this.refreshToken({
143
- callback: (result) => this.doRefreshTokenResult(result),
144
- data,
145
- showLoading,
146
- relogin: true
147
- });
148
- }
149
- }
@@ -1,11 +0,0 @@
1
- import { IAppSettings } from '@etsoo/appscript';
2
- import { DataTypes } from '@etsoo/shared';
3
- /**
4
- * Service app settings interface
5
- */
6
- export interface IServiceAppSettings<S extends DataTypes.IdType = number> extends IAppSettings {
7
- /**
8
- * Service id
9
- */
10
- readonly serviceId: S;
11
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import { IPageData } from '../states/PageState';
2
- /**
3
- * Service page data interface
4
- */
5
- export interface IServicePageData extends IPageData {
6
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import { IActionResult, IUser } from '@etsoo/appscript';
2
- /**
3
- * Service user interface
4
- */
5
- export interface IServiceUser extends IUser {
6
- /**
7
- * Service device id
8
- */
9
- serviceDeviceId: string;
10
- }
11
- /**
12
- * Service user login result
13
- */
14
- export declare type ServiceLoginResult<U extends IServiceUser = IServiceUser> = IActionResult<U>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import { IActionResult, IUser } from '@etsoo/appscript';
2
- /**
3
- * SmartERP user interface
4
- */
5
- export interface ISmartERPUser extends IUser {
6
- /**
7
- * Service refresh token
8
- */
9
- readonly serviceToken?: string;
10
- }
11
- /**
12
- * SmartERP user login result
13
- */
14
- export declare type SmartERPLoginResult = IActionResult<ISmartERPUser>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,65 +0,0 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- /**
3
- * Labels
4
- */
5
- export declare namespace Labels {
6
- /**
7
- * Common page labels
8
- */
9
- const CommonPage: {
10
- add: string;
11
- back: string;
12
- delete: string;
13
- more: string;
14
- pullToRefresh: string;
15
- refresh: string;
16
- refreshing: string;
17
- releaseToRefresh: string;
18
- reset: string;
19
- save: string;
20
- scrollTop: string;
21
- submit: string;
22
- };
23
- /**
24
- * Notification MU labels
25
- */
26
- const NotificationMU: {
27
- alertTitle: string;
28
- alertOK: string;
29
- confirmTitle: string;
30
- confirmYes: string;
31
- confirmNo: string;
32
- promptTitle: string;
33
- promptCancel: string;
34
- promptOK: string;
35
- loading: string;
36
- success: string;
37
- warning: string;
38
- info: string;
39
- };
40
- /**
41
- * UserAvatarEditor labels
42
- */
43
- const UserAvatarEditor: {
44
- done: string;
45
- reset: string;
46
- rotateLeft: string;
47
- rotateRight: string;
48
- upload: string;
49
- zoom: string;
50
- };
51
- /**
52
- * setLabelReference key reference
53
- */
54
- interface setLabelsReference {
55
- commonPage?: DataTypes.StringDictionary;
56
- notificationMU?: DataTypes.StringDictionary;
57
- userAvatarEditor?: DataTypes.StringDictionary;
58
- }
59
- /**
60
- * Set components' labels
61
- * @param labels Labels
62
- * @param reference Key reference
63
- */
64
- const setLabels: (labels: DataTypes.StringRecord, reference?: setLabelsReference) => void;
65
- }
package/lib/app/Labels.js DELETED
@@ -1,62 +0,0 @@
1
- import { Utils } from '@etsoo/shared';
2
- /**
3
- * Labels
4
- */
5
- export var Labels;
6
- (function (Labels) {
7
- /**
8
- * Common page labels
9
- */
10
- Labels.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
- * Notification MU labels
26
- */
27
- Labels.NotificationMU = {
28
- alertTitle: 'Warning',
29
- alertOK: 'OK',
30
- confirmTitle: 'Confirm',
31
- confirmYes: 'OK',
32
- confirmNo: 'Cancel',
33
- promptTitle: 'Input',
34
- promptCancel: 'Cancel',
35
- promptOK: 'OK',
36
- loading: 'Loading',
37
- success: 'Success',
38
- warning: 'Warning',
39
- info: 'Information'
40
- };
41
- /**
42
- * UserAvatarEditor labels
43
- */
44
- Labels.UserAvatarEditor = {
45
- done: 'Done',
46
- reset: 'Reset',
47
- rotateLeft: 'Rotate left 90°',
48
- rotateRight: 'Rotate right 90°',
49
- upload: 'Upload',
50
- zoom: 'Zoom'
51
- };
52
- /**
53
- * Set components' labels
54
- * @param labels Labels
55
- * @param reference Key reference
56
- */
57
- Labels.setLabels = (labels, reference = {}) => {
58
- Utils.setLabels(Labels.CommonPage, labels, reference.commonPage);
59
- Utils.setLabels(Labels.NotificationMU, labels, reference.notificationMU);
60
- Utils.setLabels(Labels.UserAvatarEditor, labels, reference.userAvatarEditor);
61
- };
62
- })(Labels || (Labels = {}));
@@ -1,194 +0,0 @@
1
- import { CoreApp, IActionResult, IAppSettings, ICoreApp, IUser } from '@etsoo/appscript';
2
- import { NotificationRenderProps, NotificationReturn } from '@etsoo/notificationbase';
3
- import { DataTypes } from '@etsoo/shared';
4
- import React from 'react';
5
- import { INotificationReact, NotificationReactCallProps } from '../notifier/Notifier';
6
- import { CultureAction, CultureState } from '../states/CultureState';
7
- import { IStateProps } from '../states/IState';
8
- import { IPageData, PageAction, PageState } from '../states/PageState';
9
- import { UserAction, UserState } from '../states/UserState';
10
- import { InputDialogProps } from './InputDialogProps';
11
- import { History } from 'history';
12
- /**
13
- * Global application
14
- */
15
- export declare let globalApp: IReactApp<IAppSettings, any, IPageData>;
16
- /**
17
- * React app state detector
18
- * Case 1: undefined, when refresh the whole page
19
- * Case 2: false, unauthorized
20
- * Case 3: true, authorized or considered as authorized (maynot, like token expiry)
21
- * Case 4: property or properties changed
22
- * @param props Props
23
- * @returns Component
24
- */
25
- export declare function ReactAppStateDetector(props: IStateProps): React.FunctionComponentElement<{
26
- children?: React.ReactNode;
27
- }>;
28
- /**
29
- * Core application interface
30
- */
31
- export interface IReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends ICoreApp<D, S, React.ReactNode, NotificationReactCallProps> {
32
- /**
33
- * User state
34
- */
35
- readonly userState: UserState<D>;
36
- /**
37
- * Router history
38
- */
39
- readonly history: History;
40
- /**
41
- * Is screen size down 'sm'
42
- */
43
- smDown?: boolean;
44
- /**
45
- * Is screen size up 'md'
46
- */
47
- mdUp?: boolean;
48
- /**
49
- * Set page data
50
- * @param data Page data
51
- */
52
- setPageData(data: P): void;
53
- /**
54
- * Set page title and data
55
- * @param key Page title resource key
56
- */
57
- setPageKey(key: string): void;
58
- /**
59
- * Set page title and data
60
- * @param title Page title
61
- */
62
- setPageTitle(title: string): void;
63
- }
64
- /**
65
- * React application
66
- */
67
- export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends CoreApp<D, S, React.ReactNode, NotificationReactCallProps> implements IReactApp<S, D, P> {
68
- private static _notifierProvider;
69
- /**
70
- * Get notifier provider
71
- */
72
- static get notifierProvider(): React.FunctionComponent<NotificationRenderProps>;
73
- private static createApi;
74
- private static createNotifier;
75
- /**
76
- * Culture state
77
- */
78
- readonly cultureState: CultureState;
79
- /**
80
- * Router history
81
- */
82
- readonly history: History;
83
- /**
84
- * Page state
85
- */
86
- readonly pageState: PageState<P>;
87
- /**
88
- * User state
89
- */
90
- readonly userState: UserState<D>;
91
- /**
92
- * Is screen size down 'sm'
93
- */
94
- smDown?: boolean;
95
- /**
96
- * Is screen size up 'md'
97
- */
98
- mdUp?: boolean;
99
- /**
100
- * Page state dispatch
101
- */
102
- pageStateDispatch?: React.Dispatch<PageAction<P>>;
103
- /**
104
- * User state dispatch
105
- */
106
- userStateDispatch?: React.Dispatch<UserAction<D>>;
107
- /**
108
- * Constructor
109
- * @param settings Settings
110
- * @param name Application name
111
- */
112
- constructor(settings: S, name: string);
113
- /**
114
- * Override alert action result
115
- * @param result Action result
116
- * @param callback Callback
117
- */
118
- alertResult(result: IActionResult, callback?: NotificationReturn<void>): void;
119
- /**
120
- * Change culture
121
- * @param culture New culture definition
122
- */
123
- changeCulture(culture: DataTypes.CultureDefinition): void;
124
- /**
125
- * Change culture extended
126
- * @param dispatch Dispatch method
127
- * @param culture New culture definition
128
- */
129
- changeCultureEx(dispatch: React.Dispatch<CultureAction>, culture: DataTypes.CultureDefinition): void;
130
- /**
131
- * Get date format props
132
- * @returns Props
133
- */
134
- getDateFormatProps(): {
135
- culture: string;
136
- timeZone: string | undefined;
137
- };
138
- /**
139
- * Get money format props
140
- * @param currency Currency, if undefined, default currency applied
141
- * @returns Props
142
- */
143
- getMoneyFormatProps(currency?: string): {
144
- culture: string;
145
- currency: string;
146
- };
147
- /**
148
- * Fresh countdown UI
149
- * @param callback Callback
150
- */
151
- freshCountdownUI(callback?: () => PromiseLike<unknown>): void;
152
- /**
153
- * Redirect to the Url
154
- * @param url Url
155
- */
156
- redirectTo(url: string): void;
157
- /**
158
- * Set page data
159
- * @param data Page data
160
- */
161
- setPageData(data: P): void;
162
- /**
163
- * Set page title and data
164
- * @param title Page title
165
- */
166
- setPageTitle(title: string): void;
167
- /**
168
- * Set page title and data
169
- * @param key Page title resource key
170
- */
171
- setPageKey(key: string): void;
172
- /**
173
- * Show input dialog
174
- * @param props Props
175
- */
176
- showInputDialog({ title, message, callback, ...rest }: InputDialogProps): INotificationReact;
177
- /**
178
- * User login extended
179
- * @param user New user
180
- * @param refreshToken Refresh token
181
- * @param keep Keep in local storage or not
182
- * @param dispatch User state dispatch
183
- */
184
- userLogin(user: D, refreshToken: string, keep?: boolean, dispatch?: boolean): void;
185
- /**
186
- * User logout
187
- * @param clearToken Clear refresh token or not
188
- */
189
- userLogout(clearToken?: boolean): void;
190
- /**
191
- * User unauthorized
192
- */
193
- userUnauthorized(): void;
194
- }