@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.
Files changed (259) 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 +3 -3
  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/states/UserState.d.ts +1 -1
  13. package/lib/uses/useWindowScroll.d.ts +10 -0
  14. package/lib/uses/useWindowScroll.js +46 -0
  15. package/lib/uses/useWindowSize.js +11 -5
  16. package/package.json +4 -16
  17. package/src/{mu → components}/DnDList.tsx +11 -34
  18. package/src/components/GridMethodRef.ts +12 -0
  19. package/src/components/ScrollerGrid.tsx +3 -3
  20. package/src/components/ScrollerList.tsx +5 -3
  21. package/src/index.ts +2 -78
  22. package/src/notifier/Notifier.ts +2 -3
  23. package/src/states/UserState.ts +7 -2
  24. package/src/uses/useWindowScroll.ts +60 -0
  25. package/src/uses/useWindowSize.ts +14 -5
  26. package/__tests__/mu/ComboBox.tsx +0 -30
  27. package/__tests__/mu/MUGlobalTests.tsx +0 -58
  28. package/__tests__/mu/NotifierMUTests.tsx +0 -213
  29. package/__tests__/mu/SelectEx.tsx +0 -26
  30. package/lib/app/CommonApp.d.ts +0 -39
  31. package/lib/app/CommonApp.js +0 -149
  32. package/lib/app/IServiceAppSettings.d.ts +0 -11
  33. package/lib/app/IServiceAppSettings.js +0 -1
  34. package/lib/app/IServicePage.d.ts +0 -6
  35. package/lib/app/IServicePage.js +0 -1
  36. package/lib/app/IServiceUser.d.ts +0 -14
  37. package/lib/app/IServiceUser.js +0 -1
  38. package/lib/app/ISmartERPUser.d.ts +0 -14
  39. package/lib/app/ISmartERPUser.js +0 -1
  40. package/lib/app/Labels.d.ts +0 -65
  41. package/lib/app/Labels.js +0 -62
  42. package/lib/app/ReactApp.d.ts +0 -194
  43. package/lib/app/ReactApp.js +0 -298
  44. package/lib/app/ServiceApp.d.ts +0 -78
  45. package/lib/app/ServiceApp.js +0 -244
  46. package/lib/components/ShowDataComparison.d.ts +0 -20
  47. package/lib/components/ShowDataComparison.js +0 -60
  48. package/lib/mu/AuditDisplay.d.ts +0 -33
  49. package/lib/mu/AuditDisplay.js +0 -52
  50. package/lib/mu/AutocompleteExtendedProps.d.ts +0 -64
  51. package/lib/mu/AutocompleteExtendedProps.js +0 -1
  52. package/lib/mu/BackButton.d.ts +0 -13
  53. package/lib/mu/BackButton.js +0 -33
  54. package/lib/mu/BridgeCloseButton.d.ts +0 -23
  55. package/lib/mu/BridgeCloseButton.js +0 -32
  56. package/lib/mu/ButtonLink.d.ts +0 -17
  57. package/lib/mu/ButtonLink.js +0 -19
  58. package/lib/mu/ComboBox.d.ts +0 -38
  59. package/lib/mu/ComboBox.js +0 -108
  60. package/lib/mu/CountdownButton.d.ts +0 -23
  61. package/lib/mu/CountdownButton.js +0 -81
  62. package/lib/mu/CustomFabProps.d.ts +0 -27
  63. package/lib/mu/CustomFabProps.js +0 -1
  64. package/lib/mu/DataGridEx.d.ts +0 -96
  65. package/lib/mu/DataGridEx.js +0 -331
  66. package/lib/mu/DataGridRenderers.d.ts +0 -22
  67. package/lib/mu/DataGridRenderers.js +0 -99
  68. package/lib/mu/DialogButton.d.ts +0 -54
  69. package/lib/mu/DialogButton.js +0 -45
  70. package/lib/mu/DraggablePaperComponent.d.ts +0 -8
  71. package/lib/mu/DraggablePaperComponent.js +0 -12
  72. package/lib/mu/EmailInput.d.ts +0 -11
  73. package/lib/mu/EmailInput.js +0 -15
  74. package/lib/mu/FabBox.d.ts +0 -21
  75. package/lib/mu/FabBox.js +0 -31
  76. package/lib/mu/FlexBox.d.ts +0 -14
  77. package/lib/mu/FlexBox.js +0 -18
  78. package/lib/mu/GridDataFormat.d.ts +0 -10
  79. package/lib/mu/GridDataFormat.js +0 -43
  80. package/lib/mu/GridMethodRef.d.ts +0 -11
  81. package/lib/mu/IconButtonLink.d.ts +0 -17
  82. package/lib/mu/IconButtonLink.js +0 -16
  83. package/lib/mu/InputField.d.ts +0 -21
  84. package/lib/mu/InputField.js +0 -39
  85. package/lib/mu/ItemList.d.ts +0 -56
  86. package/lib/mu/ItemList.js +0 -69
  87. package/lib/mu/ListItemRightIcon.d.ts +0 -4
  88. package/lib/mu/ListItemRightIcon.js +0 -8
  89. package/lib/mu/ListMoreDisplay.d.ts +0 -35
  90. package/lib/mu/ListMoreDisplay.js +0 -99
  91. package/lib/mu/LoadingButton.d.ts +0 -16
  92. package/lib/mu/LoadingButton.js +0 -41
  93. package/lib/mu/MUGlobal.d.ts +0 -102
  94. package/lib/mu/MUGlobal.js +0 -184
  95. package/lib/mu/MaskInput.d.ts +0 -34
  96. package/lib/mu/MaskInput.js +0 -43
  97. package/lib/mu/MobileListItemRenderer.d.ts +0 -17
  98. package/lib/mu/MobileListItemRenderer.js +0 -35
  99. package/lib/mu/MoreFab.d.ts +0 -45
  100. package/lib/mu/MoreFab.js +0 -95
  101. package/lib/mu/NotifierMU.d.ts +0 -47
  102. package/lib/mu/NotifierMU.js +0 -387
  103. package/lib/mu/NotifierPromptProps.d.ts +0 -22
  104. package/lib/mu/NotifierPromptProps.js +0 -1
  105. package/lib/mu/OptionGroup.d.ts +0 -58
  106. package/lib/mu/OptionGroup.js +0 -81
  107. package/lib/mu/PList.d.ts +0 -15
  108. package/lib/mu/PList.js +0 -12
  109. package/lib/mu/ProgressCount.d.ts +0 -44
  110. package/lib/mu/ProgressCount.js +0 -79
  111. package/lib/mu/PullToRefreshUI.d.ts +0 -9
  112. package/lib/mu/PullToRefreshUI.js +0 -18
  113. package/lib/mu/RLink.d.ts +0 -14
  114. package/lib/mu/RLink.js +0 -37
  115. package/lib/mu/ResponsibleContainer.d.ts +0 -89
  116. package/lib/mu/ResponsibleContainer.js +0 -159
  117. package/lib/mu/ScrollTopFab.d.ts +0 -7
  118. package/lib/mu/ScrollTopFab.js +0 -25
  119. package/lib/mu/ScrollerListEx.d.ts +0 -81
  120. package/lib/mu/ScrollerListEx.js +0 -167
  121. package/lib/mu/SearchBar.d.ts +0 -29
  122. package/lib/mu/SearchBar.js +0 -262
  123. package/lib/mu/SearchField.d.ts +0 -21
  124. package/lib/mu/SearchField.js +0 -39
  125. package/lib/mu/SearchOptionGroup.d.ts +0 -9
  126. package/lib/mu/SearchOptionGroup.js +0 -14
  127. package/lib/mu/SelectBool.d.ts +0 -13
  128. package/lib/mu/SelectBool.js +0 -22
  129. package/lib/mu/SelectEx.d.ts +0 -50
  130. package/lib/mu/SelectEx.js +0 -156
  131. package/lib/mu/Switch.d.ts +0 -29
  132. package/lib/mu/Switch.js +0 -34
  133. package/lib/mu/SwitchAnt.d.ts +0 -25
  134. package/lib/mu/SwitchAnt.js +0 -40
  135. package/lib/mu/TabBox.d.ts +0 -54
  136. package/lib/mu/TabBox.js +0 -31
  137. package/lib/mu/TableEx.d.ts +0 -66
  138. package/lib/mu/TableEx.js +0 -271
  139. package/lib/mu/TextFieldEx.d.ts +0 -101
  140. package/lib/mu/TextFieldEx.js +0 -127
  141. package/lib/mu/Tiplist.d.ts +0 -18
  142. package/lib/mu/Tiplist.js +0 -158
  143. package/lib/mu/TooltipClick.d.ts +0 -15
  144. package/lib/mu/TooltipClick.js +0 -40
  145. package/lib/mu/UserAvatar.d.ts +0 -24
  146. package/lib/mu/UserAvatar.js +0 -25
  147. package/lib/mu/UserAvatarEditor.d.ts +0 -53
  148. package/lib/mu/UserAvatarEditor.js +0 -129
  149. package/lib/mu/pages/CommonPage.d.ts +0 -11
  150. package/lib/mu/pages/CommonPage.js +0 -60
  151. package/lib/mu/pages/CommonPageProps.d.ts +0 -60
  152. package/lib/mu/pages/CommonPageProps.js +0 -1
  153. package/lib/mu/pages/DataGridPage.d.ts +0 -9
  154. package/lib/mu/pages/DataGridPage.js +0 -81
  155. package/lib/mu/pages/DataGridPageProps.d.ts +0 -17
  156. package/lib/mu/pages/DataGridPageProps.js +0 -1
  157. package/lib/mu/pages/EditPage.d.ts +0 -33
  158. package/lib/mu/pages/EditPage.js +0 -29
  159. package/lib/mu/pages/FixedListPage.d.ts +0 -15
  160. package/lib/mu/pages/FixedListPage.js +0 -72
  161. package/lib/mu/pages/ListPage.d.ts +0 -9
  162. package/lib/mu/pages/ListPage.js +0 -51
  163. package/lib/mu/pages/ListPageProps.d.ts +0 -7
  164. package/lib/mu/pages/ListPageProps.js +0 -1
  165. package/lib/mu/pages/ResponsivePage.d.ts +0 -9
  166. package/lib/mu/pages/ResponsivePage.js +0 -45
  167. package/lib/mu/pages/ResponsivePageProps.d.ts +0 -39
  168. package/lib/mu/pages/ResponsivePageProps.js +0 -1
  169. package/lib/mu/pages/SearchPageProps.d.ts +0 -30
  170. package/lib/mu/pages/SearchPageProps.js +0 -1
  171. package/lib/mu/pages/TablePage.d.ts +0 -9
  172. package/lib/mu/pages/TablePage.js +0 -71
  173. package/lib/mu/pages/TablePageProps.d.ts +0 -7
  174. package/lib/mu/pages/TablePageProps.js +0 -1
  175. package/lib/mu/pages/ViewPage.d.ts +0 -66
  176. package/lib/mu/pages/ViewPage.js +0 -105
  177. package/lib/mu/texts/DateText.d.ts +0 -34
  178. package/lib/mu/texts/DateText.js +0 -25
  179. package/lib/mu/texts/MoneyText.d.ts +0 -21
  180. package/lib/mu/texts/MoneyText.js +0 -14
  181. package/lib/mu/texts/NumberText.d.ts +0 -25
  182. package/lib/mu/texts/NumberText.js +0 -14
  183. package/src/app/CommonApp.ts +0 -225
  184. package/src/app/IServiceAppSettings.ts +0 -13
  185. package/src/app/IServicePage.ts +0 -6
  186. package/src/app/IServiceUser.ts +0 -17
  187. package/src/app/ISmartERPUser.ts +0 -16
  188. package/src/app/Labels.ts +0 -77
  189. package/src/app/ReactApp.ts +0 -500
  190. package/src/app/ServiceApp.ts +0 -353
  191. package/src/components/ShowDataComparison.tsx +0 -108
  192. package/src/mu/AuditDisplay.tsx +0 -117
  193. package/src/mu/AutocompleteExtendedProps.ts +0 -83
  194. package/src/mu/BackButton.tsx +0 -55
  195. package/src/mu/BridgeCloseButton.tsx +0 -69
  196. package/src/mu/ButtonLink.tsx +0 -32
  197. package/src/mu/ComboBox.tsx +0 -251
  198. package/src/mu/CountdownButton.tsx +0 -119
  199. package/src/mu/CustomFabProps.ts +0 -32
  200. package/src/mu/DataGridEx.tsx +0 -712
  201. package/src/mu/DataGridRenderers.tsx +0 -140
  202. package/src/mu/DialogButton.tsx +0 -163
  203. package/src/mu/DraggablePaperComponent.tsx +0 -19
  204. package/src/mu/EmailInput.tsx +0 -24
  205. package/src/mu/FabBox.tsx +0 -51
  206. package/src/mu/FlexBox.tsx +0 -20
  207. package/src/mu/GridDataFormat.tsx +0 -77
  208. package/src/mu/GridMethodRef.ts +0 -12
  209. package/src/mu/IconButtonLink.tsx +0 -29
  210. package/src/mu/InputField.tsx +0 -82
  211. package/src/mu/ItemList.tsx +0 -204
  212. package/src/mu/ListItemRightIcon.tsx +0 -9
  213. package/src/mu/ListMoreDisplay.tsx +0 -205
  214. package/src/mu/LoadingButton.tsx +0 -75
  215. package/src/mu/MUGlobal.ts +0 -220
  216. package/src/mu/MaskInput.tsx +0 -107
  217. package/src/mu/MobileListItemRenderer.tsx +0 -79
  218. package/src/mu/MoreFab.tsx +0 -211
  219. package/src/mu/NotifierMU.tsx +0 -654
  220. package/src/mu/NotifierPromptProps.ts +0 -26
  221. package/src/mu/OptionGroup.tsx +0 -223
  222. package/src/mu/PList.tsx +0 -27
  223. package/src/mu/ProgressCount.tsx +0 -166
  224. package/src/mu/PullToRefreshUI.tsx +0 -21
  225. package/src/mu/RLink.tsx +0 -64
  226. package/src/mu/ResponsibleContainer.tsx +0 -394
  227. package/src/mu/ScrollTopFab.tsx +0 -34
  228. package/src/mu/ScrollerListEx.tsx +0 -387
  229. package/src/mu/SearchBar.tsx +0 -398
  230. package/src/mu/SearchField.tsx +0 -82
  231. package/src/mu/SearchOptionGroup.tsx +0 -31
  232. package/src/mu/SelectBool.tsx +0 -33
  233. package/src/mu/SelectEx.tsx +0 -290
  234. package/src/mu/Switch.tsx +0 -94
  235. package/src/mu/SwitchAnt.tsx +0 -95
  236. package/src/mu/TabBox.tsx +0 -118
  237. package/src/mu/TableEx.tsx +0 -560
  238. package/src/mu/TextFieldEx.tsx +0 -250
  239. package/src/mu/Tiplist.tsx +0 -304
  240. package/src/mu/TooltipClick.tsx +0 -84
  241. package/src/mu/UserAvatar.tsx +0 -64
  242. package/src/mu/UserAvatarEditor.tsx +0 -287
  243. package/src/mu/pages/CommonPage.tsx +0 -128
  244. package/src/mu/pages/CommonPageProps.ts +0 -71
  245. package/src/mu/pages/DataGridPage.tsx +0 -137
  246. package/src/mu/pages/DataGridPageProps.ts +0 -24
  247. package/src/mu/pages/EditPage.tsx +0 -114
  248. package/src/mu/pages/FixedListPage.tsx +0 -135
  249. package/src/mu/pages/ListPage.tsx +0 -87
  250. package/src/mu/pages/ListPageProps.ts +0 -12
  251. package/src/mu/pages/ResponsivePage.tsx +0 -68
  252. package/src/mu/pages/ResponsivePageProps.ts +0 -57
  253. package/src/mu/pages/SearchPageProps.ts +0 -39
  254. package/src/mu/pages/TablePage.tsx +0 -120
  255. package/src/mu/pages/TablePageProps.ts +0 -12
  256. package/src/mu/pages/ViewPage.tsx +0 -285
  257. package/src/mu/texts/DateText.tsx +0 -74
  258. package/src/mu/texts/MoneyText.tsx +0 -49
  259. package/src/mu/texts/NumberText.tsx +0 -40
@@ -1,500 +0,0 @@
1
- import {
2
- ActionResultError,
3
- BridgeUtils,
4
- CoreApp,
5
- createClient,
6
- IActionResult,
7
- IAppSettings,
8
- ICoreApp,
9
- IUser
10
- } from '@etsoo/appscript';
11
- import {
12
- NotificationMessageType,
13
- NotificationRenderProps,
14
- NotificationReturn
15
- } from '@etsoo/notificationbase';
16
- import { DataTypes, WindowStorage } from '@etsoo/shared';
17
- import React from 'react';
18
- import { NotifierMU } from '../mu/NotifierMU';
19
- import { ProgressCount } from '../mu/ProgressCount';
20
- import {
21
- INotificationReact,
22
- NotificationReactCallProps
23
- } from '../notifier/Notifier';
24
- import { CultureAction, CultureState } from '../states/CultureState';
25
- import { IStateProps } from '../states/IState';
26
- import {
27
- IPageData,
28
- PageAction,
29
- PageActionType,
30
- PageState
31
- } from '../states/PageState';
32
- import {
33
- UserAction,
34
- UserActionType,
35
- UserCalls,
36
- UserState
37
- } from '../states/UserState';
38
- import { InputDialogProps } from './InputDialogProps';
39
- import { Labels } from './Labels';
40
- import { createBrowserHistory, createMemoryHistory, History } from 'history';
41
-
42
- /**
43
- * Global application
44
- */
45
- export let globalApp: IReactApp<IAppSettings, any, IPageData>;
46
-
47
- /**
48
- * React app state detector
49
- * Case 1: undefined, when refresh the whole page
50
- * Case 2: false, unauthorized
51
- * Case 3: true, authorized or considered as authorized (maynot, like token expiry)
52
- * Case 4: property or properties changed
53
- * @param props Props
54
- * @returns Component
55
- */
56
- export function ReactAppStateDetector(props: IStateProps) {
57
- // Destruct
58
- const { targetFields, update } = props;
59
-
60
- // Context
61
- const { state = {} } =
62
- globalApp == null
63
- ? ({} as UserCalls<IUser>)
64
- : React.useContext(globalApp.userState.context);
65
-
66
- // Ready
67
- React.useEffect(() => {
68
- // Match fields
69
- const changedFields = state.lastChangedFields;
70
- let matchedFields: string[] | undefined;
71
- if (targetFields == null || changedFields == null) {
72
- matchedFields = changedFields;
73
- } else {
74
- matchedFields = [];
75
- targetFields.forEach((targetField) => {
76
- if (changedFields.includes(targetField))
77
- matchedFields?.push(targetField);
78
- });
79
- }
80
-
81
- // Callback
82
- update(state.authorized, matchedFields);
83
- }, [state]);
84
-
85
- // return
86
- return React.createElement(React.Fragment);
87
- }
88
-
89
- /**
90
- * Core application interface
91
- */
92
- export interface IReactApp<
93
- S extends IAppSettings,
94
- D extends IUser,
95
- P extends IPageData
96
- > extends ICoreApp<D, S, React.ReactNode, NotificationReactCallProps> {
97
- /**
98
- * User state
99
- */
100
- readonly userState: UserState<D>;
101
-
102
- /**
103
- * Router history
104
- */
105
- readonly history: History;
106
-
107
- /**
108
- * Is screen size down 'sm'
109
- */
110
- smDown?: boolean;
111
-
112
- /**
113
- * Is screen size up 'md'
114
- */
115
- mdUp?: boolean;
116
-
117
- /**
118
- * Set page data
119
- * @param data Page data
120
- */
121
- setPageData(data: P): void;
122
-
123
- /**
124
- * Set page title and data
125
- * @param key Page title resource key
126
- */
127
- setPageKey(key: string): void;
128
-
129
- /**
130
- * Set page title and data
131
- * @param title Page title
132
- */
133
- setPageTitle(title: string): void;
134
- }
135
-
136
- /**
137
- * React application
138
- */
139
- export class ReactApp<
140
- S extends IAppSettings,
141
- D extends IUser,
142
- P extends IPageData
143
- >
144
- extends CoreApp<D, S, React.ReactNode, NotificationReactCallProps>
145
- implements IReactApp<S, D, P>
146
- {
147
- private static _notifierProvider: React.FunctionComponent<NotificationRenderProps>;
148
-
149
- /**
150
- * Get notifier provider
151
- */
152
- static get notifierProvider() {
153
- return this._notifierProvider;
154
- }
155
-
156
- private static createApi(settings: IAppSettings) {
157
- // API
158
- // Support to replace {hostname} with current hostname
159
- const api = createClient();
160
- api.baseUrl = settings.endpoint;
161
- return api;
162
- }
163
-
164
- private static createNotifier() {
165
- // Notifier
166
- ReactApp._notifierProvider = NotifierMU.setup();
167
-
168
- return NotifierMU.instance;
169
- }
170
-
171
- /**
172
- * Culture state
173
- */
174
- readonly cultureState: CultureState;
175
-
176
- /**
177
- * Router history
178
- */
179
- readonly history: History;
180
-
181
- /**
182
- * Page state
183
- */
184
- readonly pageState: PageState<P>;
185
-
186
- /**
187
- * User state
188
- */
189
- readonly userState = new UserState<D>();
190
-
191
- /**
192
- * Is screen size down 'sm'
193
- */
194
- smDown?: boolean;
195
-
196
- /**
197
- * Is screen size up 'md'
198
- */
199
- mdUp?: boolean;
200
-
201
- /**
202
- * Page state dispatch
203
- */
204
- pageStateDispatch?: React.Dispatch<PageAction<P>>;
205
-
206
- /**
207
- * User state dispatch
208
- */
209
- userStateDispatch?: React.Dispatch<UserAction<D>>;
210
-
211
- /**
212
- * Constructor
213
- * @param settings Settings
214
- * @param name Application name
215
- */
216
- constructor(settings: S, name: string) {
217
- super(
218
- settings,
219
- ReactApp.createApi(settings),
220
- ReactApp.createNotifier(),
221
- new WindowStorage(),
222
- name
223
- );
224
-
225
- if (BridgeUtils.host) {
226
- const startUrl = BridgeUtils.host.getStartUrl();
227
- this.history = createMemoryHistory({
228
- initialEntries: startUrl == null ? undefined : [startUrl]
229
- });
230
-
231
- BridgeUtils.host.onUpdate((app, version) => {
232
- this.notifier.message(
233
- NotificationMessageType.Success,
234
- this.get('updateTip') + `(${[app, version].join(', ')})`,
235
- this.get('updateReady')
236
- );
237
- });
238
- } else {
239
- this.history = createBrowserHistory();
240
- }
241
-
242
- this.cultureState = new CultureState(settings.currentCulture);
243
- this.pageState = new PageState<P>();
244
-
245
- globalApp = this;
246
- }
247
-
248
- /**
249
- * Override alert action result
250
- * @param result Action result
251
- * @param callback Callback
252
- */
253
- override alertResult(
254
- result: IActionResult,
255
- callback?: NotificationReturn<void>
256
- ) {
257
- const message = this.formatResult(result);
258
- if (message.endsWith(')')) {
259
- const startPos = message.lastIndexOf('(');
260
- if (startPos > 0) {
261
- const main = message.substring(0, startPos).trim();
262
- const tip = message.substring(startPos);
263
-
264
- const titleNode = React.createElement(
265
- React.Fragment,
266
- null,
267
- main,
268
- React.createElement('br'),
269
- React.createElement(
270
- 'span',
271
- { style: { fontSize: '9px' } },
272
- tip
273
- )
274
- );
275
- this.notifier.alert(titleNode, callback);
276
- return;
277
- }
278
- }
279
- this.notifier.alert(message, callback);
280
- }
281
-
282
- /**
283
- * Change culture
284
- * @param culture New culture definition
285
- */
286
- override changeCulture(culture: DataTypes.CultureDefinition) {
287
- // Super call to update cultrue
288
- super.changeCulture(culture);
289
-
290
- // Update component labels
291
- Labels.setLabels(culture.resources, {
292
- notificationMU: {
293
- alertTitle: 'warning',
294
- alertOK: 'ok',
295
- confirmTitle: 'confirm',
296
- confirmYes: 'ok',
297
- confirmNo: 'cancel',
298
- promptTitle: 'prompt',
299
- promptCancel: 'cancel',
300
- promptOK: 'ok'
301
- }
302
- });
303
-
304
- // Notify host
305
- BridgeUtils.host?.changeCulture(culture.name);
306
-
307
- // Document title
308
- document.title = this.get(this.name) ?? this.name;
309
- }
310
-
311
- /**
312
- * Change culture extended
313
- * @param dispatch Dispatch method
314
- * @param culture New culture definition
315
- */
316
- changeCultureEx(
317
- dispatch: React.Dispatch<CultureAction>,
318
- culture: DataTypes.CultureDefinition
319
- ): void {
320
- // Same?
321
- if (culture.name === this.culture) return;
322
-
323
- // Dispatch action
324
- dispatch(culture);
325
-
326
- // Super call
327
- this.changeCulture(culture);
328
- }
329
-
330
- /**
331
- * Get date format props
332
- * @returns Props
333
- */
334
- getDateFormatProps() {
335
- return { culture: this.culture, timeZone: this.getTimeZone() };
336
- }
337
-
338
- /**
339
- * Get money format props
340
- * @param currency Currency, if undefined, default currency applied
341
- * @returns Props
342
- */
343
- getMoneyFormatProps(currency?: string) {
344
- return { culture: this.culture, currency: currency ?? this.currency };
345
- }
346
-
347
- /**
348
- * Fresh countdown UI
349
- * @param callback Callback
350
- */
351
- freshCountdownUI(callback?: () => PromiseLike<unknown>) {
352
- // Labels
353
- const labels = this.getLabels('cancel', 'tokenExpiry');
354
-
355
- // Progress
356
- const progress = React.createElement(ProgressCount, {
357
- seconds: 30,
358
- valueUnit: 's',
359
- onComplete: () => {
360
- // Stop the progress
361
- return false;
362
- }
363
- });
364
-
365
- // Popup
366
- this.notifier.alert(
367
- labels.tokenExpiry,
368
- async () => {
369
- if (callback) await callback();
370
- else await this.tryLogin();
371
- },
372
- undefined,
373
- {
374
- okLabel: labels.cancel,
375
- primaryButton: { fullWidth: true, autoFocus: false },
376
- inputs: progress
377
- }
378
- );
379
- }
380
-
381
- /**
382
- * Redirect to the Url
383
- * @param url Url
384
- */
385
- override redirectTo(url: string) {
386
- this.history.push(url);
387
- }
388
-
389
- /**
390
- * Set page data
391
- * @param data Page data
392
- */
393
- setPageData(data: P): void {
394
- // Dispatch the change
395
- if (this.pageStateDispatch != null) {
396
- this.pageStateDispatch({
397
- type: PageActionType.Data,
398
- data
399
- });
400
- }
401
- }
402
-
403
- /**
404
- * Set page title and data
405
- * @param title Page title
406
- */
407
- setPageTitle(title: string): void {
408
- // Data
409
- const data = { title } as P;
410
-
411
- // Dispatch the change
412
- if (this.pageStateDispatch != null) {
413
- this.pageStateDispatch({
414
- type: PageActionType.Title,
415
- data
416
- });
417
- }
418
- }
419
-
420
- /**
421
- * Set page title and data
422
- * @param key Page title resource key
423
- */
424
- setPageKey(key: string): void {
425
- this.setPageTitle(this.get<string>(key) ?? '');
426
- }
427
-
428
- /**
429
- * Show input dialog
430
- * @param props Props
431
- */
432
- showInputDialog({
433
- title,
434
- message,
435
- callback,
436
- ...rest
437
- }: InputDialogProps): INotificationReact {
438
- return this.notifier.prompt<HTMLFormElement | undefined>(
439
- message,
440
- callback,
441
- title,
442
- rest
443
- );
444
- }
445
-
446
- /**
447
- * User login extended
448
- * @param user New user
449
- * @param refreshToken Refresh token
450
- * @param keep Keep in local storage or not
451
- * @param dispatch User state dispatch
452
- */
453
- override userLogin(
454
- user: D,
455
- refreshToken: string,
456
- keep?: boolean,
457
- dispatch?: boolean
458
- ): void {
459
- // Super call, set token
460
- super.userLogin(user, refreshToken, keep);
461
-
462
- // Dispatch action
463
- if (this.userStateDispatch != null && dispatch !== false)
464
- this.userStateDispatch({
465
- type: UserActionType.Login,
466
- user
467
- });
468
- }
469
-
470
- /**
471
- * User logout
472
- * @param clearToken Clear refresh token or not
473
- */
474
- override userLogout(clearToken: boolean = true): void {
475
- // Super call
476
- super.userLogout(clearToken);
477
-
478
- // Dispatch action
479
- if (this.userStateDispatch != null)
480
- this.userStateDispatch({
481
- type: UserActionType.Logout
482
- });
483
- }
484
-
485
- /**
486
- * User unauthorized
487
- */
488
- override userUnauthorized() {
489
- // Super call
490
- super.userUnauthorized();
491
-
492
- if (this.userStateDispatch != null) {
493
- // There is delay during state update
494
- // Not a good idea to try login multiple times with API calls
495
- this.userStateDispatch({
496
- type: UserActionType.Unauthorized
497
- });
498
- }
499
- }
500
- }