@etsoo/materialui 1.4.74 → 1.4.75

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 (110) hide show
  1. package/__tests__/ResponsePage.tsx +34 -31
  2. package/lib/cjs/AddresSelector.js +4 -2
  3. package/lib/cjs/AuditDisplay.js +11 -11
  4. package/lib/cjs/BridgeCloseButton.js +3 -1
  5. package/lib/cjs/ComboBox.js +3 -1
  6. package/lib/cjs/ComboBoxMultiple.js +3 -1
  7. package/lib/cjs/ComboBoxPro.js +4 -2
  8. package/lib/cjs/CultureDataTable.js +3 -1
  9. package/lib/cjs/DataSteps.js +3 -6
  10. package/lib/cjs/DataTable.js +3 -1
  11. package/lib/cjs/InputField.d.ts +3 -3
  12. package/lib/cjs/InputTipField.js +15 -8
  13. package/lib/cjs/ListMoreDisplay.js +3 -1
  14. package/lib/cjs/OptionBool.js +3 -1
  15. package/lib/cjs/QuickList.js +4 -2
  16. package/lib/cjs/SelectBool.js +4 -2
  17. package/lib/cjs/ShowDataComparison.js +2 -5
  18. package/lib/cjs/SwitchAnt.js +3 -1
  19. package/lib/cjs/TagList.js +3 -1
  20. package/lib/cjs/TagListPro.js +4 -2
  21. package/lib/cjs/TextFieldEx.d.ts +3 -3
  22. package/lib/cjs/TextFieldEx.js +3 -1
  23. package/lib/cjs/Tiplist.js +5 -3
  24. package/lib/cjs/TiplistPro.js +3 -1
  25. package/lib/cjs/UserAvatar.js +3 -1
  26. package/lib/cjs/app/CommonApp.d.ts +1 -2
  27. package/lib/cjs/app/IServiceApp.d.ts +1 -6
  28. package/lib/cjs/app/IServiceApp.js +0 -9
  29. package/lib/cjs/app/ReactApp.d.ts +18 -74
  30. package/lib/cjs/app/ReactApp.js +40 -82
  31. package/lib/cjs/app/ServiceApp.d.ts +1 -2
  32. package/lib/cjs/custom/CustomFieldWindow.js +3 -6
  33. package/lib/cjs/index.d.ts +0 -1
  34. package/lib/cjs/index.js +0 -1
  35. package/lib/cjs/pages/CommonPage.js +3 -1
  36. package/lib/cjs/pages/LeftDrawer.js +4 -2
  37. package/lib/cjs/pages/ViewPage.js +12 -12
  38. package/lib/mjs/AddresSelector.js +4 -2
  39. package/lib/mjs/AuditDisplay.js +11 -11
  40. package/lib/mjs/BridgeCloseButton.js +4 -2
  41. package/lib/mjs/ComboBox.js +4 -2
  42. package/lib/mjs/ComboBoxMultiple.js +4 -2
  43. package/lib/mjs/ComboBoxPro.js +4 -2
  44. package/lib/mjs/CultureDataTable.js +4 -2
  45. package/lib/mjs/DataSteps.js +3 -6
  46. package/lib/mjs/DataTable.js +4 -2
  47. package/lib/mjs/InputField.d.ts +3 -3
  48. package/lib/mjs/InputTipField.js +15 -8
  49. package/lib/mjs/ListMoreDisplay.js +4 -2
  50. package/lib/mjs/OptionBool.js +4 -2
  51. package/lib/mjs/QuickList.js +4 -2
  52. package/lib/mjs/SelectBool.js +4 -2
  53. package/lib/mjs/ShowDataComparison.js +3 -6
  54. package/lib/mjs/SwitchAnt.js +4 -2
  55. package/lib/mjs/TagList.js +4 -2
  56. package/lib/mjs/TagListPro.js +4 -2
  57. package/lib/mjs/TextFieldEx.d.ts +3 -3
  58. package/lib/mjs/TextFieldEx.js +4 -2
  59. package/lib/mjs/Tiplist.js +5 -3
  60. package/lib/mjs/TiplistPro.js +4 -2
  61. package/lib/mjs/UserAvatar.js +4 -2
  62. package/lib/mjs/app/CommonApp.d.ts +1 -2
  63. package/lib/mjs/app/IServiceApp.d.ts +1 -6
  64. package/lib/mjs/app/IServiceApp.js +1 -5
  65. package/lib/mjs/app/ReactApp.d.ts +18 -74
  66. package/lib/mjs/app/ReactApp.js +36 -83
  67. package/lib/mjs/app/ServiceApp.d.ts +1 -2
  68. package/lib/mjs/custom/CustomFieldWindow.js +3 -6
  69. package/lib/mjs/index.d.ts +0 -1
  70. package/lib/mjs/index.js +0 -1
  71. package/lib/mjs/pages/CommonPage.js +4 -2
  72. package/lib/mjs/pages/LeftDrawer.js +5 -3
  73. package/lib/mjs/pages/ViewPage.js +13 -13
  74. package/package.json +4 -4
  75. package/src/AddresSelector.tsx +5 -2
  76. package/src/AuditDisplay.tsx +14 -12
  77. package/src/BridgeCloseButton.tsx +5 -2
  78. package/src/ComboBox.tsx +5 -2
  79. package/src/ComboBoxMultiple.tsx +5 -2
  80. package/src/ComboBoxPro.tsx +5 -2
  81. package/src/CultureDataTable.tsx +6 -3
  82. package/src/DataSteps.tsx +3 -6
  83. package/src/DataTable.tsx +5 -2
  84. package/src/InputTipField.tsx +26 -17
  85. package/src/ListMoreDisplay.tsx +5 -3
  86. package/src/OptionBool.tsx +5 -3
  87. package/src/QuickList.tsx +5 -2
  88. package/src/SelectBool.tsx +5 -3
  89. package/src/ShowDataComparison.tsx +3 -6
  90. package/src/SwitchAnt.tsx +5 -2
  91. package/src/TagList.tsx +5 -2
  92. package/src/TagListPro.tsx +5 -2
  93. package/src/TextFieldEx.tsx +5 -3
  94. package/src/Tiplist.tsx +7 -4
  95. package/src/TiplistPro.tsx +5 -2
  96. package/src/UserAvatar.tsx +5 -3
  97. package/src/app/CommonApp.ts +2 -3
  98. package/src/app/IServiceApp.ts +1 -8
  99. package/src/app/ReactApp.ts +52 -151
  100. package/src/app/ServiceApp.ts +1 -3
  101. package/src/custom/CustomFieldWindow.tsx +3 -6
  102. package/src/index.ts +0 -1
  103. package/src/pages/CommonPage.tsx +5 -4
  104. package/src/pages/LeftDrawer.tsx +6 -3
  105. package/src/pages/ViewPage.tsx +17 -12
  106. package/lib/cjs/app/IServicePage.d.ts +0 -6
  107. package/lib/cjs/app/IServicePage.js +0 -2
  108. package/lib/mjs/app/IServicePage.d.ts +0 -6
  109. package/lib/mjs/app/IServicePage.js +0 -1
  110. package/src/app/IServicePage.ts +0 -6
@@ -24,15 +24,12 @@ import {
24
24
  CultureState,
25
25
  INotificationReact,
26
26
  InputDialogProps,
27
- IPageData,
28
27
  IStateProps,
29
28
  NotificationReactCallProps,
30
- PageAction,
31
- PageActionType,
32
- PageState,
33
29
  UserAction,
34
30
  UserActionType,
35
31
  UserCalls,
32
+ useRequiredContext,
36
33
  UserState
37
34
  } from "@etsoo/react";
38
35
  import { NavigateFunction, NavigateOptions } from "react-router";
@@ -42,67 +39,25 @@ import { NavigateFunction, NavigateOptions } from "react-router";
42
39
  */
43
40
  export type ReactAppType = IApp & IReactAppBase;
44
41
 
45
- /**
46
- * React application data
47
- */
48
- export type ReactAppData<A extends ReactAppType> = {
49
- /**
50
- * Current application
51
- */
52
- app: A;
53
- };
54
-
55
42
  /**
56
43
  * React application context
57
44
  */
58
- export const ReactAppContext =
59
- React.createContext<ReactAppData<ReactAppType> | null>(null);
45
+ export const ReactAppContext = React.createContext<ReactAppType | null>(null);
60
46
 
61
47
  /**
62
- * Global application
48
+ * Get React application context hook
49
+ * @returns React application
63
50
  */
64
- export let globalApp: ReactAppType | null;
51
+ export function useAppContext() {
52
+ return React.useContext(ReactAppContext);
53
+ }
65
54
 
66
55
  /**
67
- * React app state detector
68
- * Case 1: undefined, when refresh the whole page
69
- * Case 2: false, unauthorized
70
- * Case 3: true, authorized or considered as authorized (maynot, like token expiry)
71
- * Case 4: property or properties changed
72
- * @param props Props
73
- * @returns Component
56
+ * Get React application context hook
57
+ * @returns React application
74
58
  */
75
- export function ReactAppStateDetector(props: IStateProps) {
76
- // Destruct
77
- const { targetFields, update } = props;
78
-
79
- // Context
80
- const { state } =
81
- globalApp == null
82
- ? ({} as UserCalls<IUser>)
83
- : React.useContext(globalApp.userState.context);
84
-
85
- // Ready
86
- React.useEffect(() => {
87
- // Match fields
88
- const changedFields = state.lastChangedFields;
89
- let matchedFields: string[] | undefined;
90
- if (targetFields == null || changedFields == null) {
91
- matchedFields = changedFields;
92
- } else {
93
- matchedFields = [];
94
- targetFields.forEach((targetField) => {
95
- if (changedFields.includes(targetField))
96
- matchedFields?.push(targetField);
97
- });
98
- }
99
-
100
- // Callback
101
- update(state.authorized, matchedFields);
102
- }, [state]);
103
-
104
- // return
105
- return React.createElement(React.Fragment);
59
+ export function useRequiredAppContext() {
60
+ return useRequiredContext(ReactAppContext);
106
61
  }
107
62
 
108
63
  /**
@@ -114,11 +69,6 @@ export interface IReactAppBase {
114
69
  */
115
70
  readonly notifier: INotifier<React.ReactNode, NotificationReactCallProps>;
116
71
 
117
- /**
118
- * User state
119
- */
120
- readonly userState: UserState<any>;
121
-
122
72
  /**
123
73
  * Is screen size down 'sm'
124
74
  */
@@ -142,25 +92,6 @@ export interface IReactAppBase {
142
92
  */
143
93
  getMoneyFormatProps(currency?: string): object;
144
94
 
145
- /**
146
- * Set page data
147
- * @param data Page data
148
- */
149
- setPageData(data: IPageData): void;
150
-
151
- /**
152
- * Set page title and subtitle
153
- * @param title Page title
154
- * @param subtitle Page subtitle
155
- */
156
- setPageTitle(title: string, subtitle?: string): void;
157
-
158
- /**
159
- * Set page title and data
160
- * @param title Page title
161
- */
162
- setPageTitle(title: string): void;
163
-
164
95
  /**
165
96
  * Show input dialog
166
97
  * @param props Props
@@ -171,39 +102,32 @@ export interface IReactAppBase {
171
102
  callback,
172
103
  ...rest
173
104
  }: InputDialogProps): INotificationReact;
105
+
106
+ /**
107
+ * State detector component
108
+ * @param props Props
109
+ */
110
+ stateDetector(props: IStateProps): React.ReactNode;
174
111
  }
175
112
 
176
113
  /**
177
114
  * Core application interface
178
115
  */
179
- export interface IReactApp<
180
- S extends IAppSettings,
181
- D extends IUser,
182
- P extends IPageData
183
- > extends ICoreApp<D, S, React.ReactNode, NotificationReactCallProps>,
184
- IReactAppBase {
116
+ export interface IReactApp<S extends IAppSettings, D extends IUser>
117
+ extends ICoreApp<D, S, React.ReactNode, NotificationReactCallProps>,
118
+ Omit<IReactAppBase, "userState"> {
185
119
  /**
186
120
  * User state
187
121
  */
188
122
  readonly userState: UserState<D>;
189
-
190
- /**
191
- * Set page data
192
- * @param data Page data
193
- */
194
- setPageData(data: P): void;
195
123
  }
196
124
 
197
125
  /**
198
126
  * React application
199
127
  */
200
- export class ReactApp<
201
- S extends IAppSettings,
202
- D extends IUser,
203
- P extends IPageData
204
- >
128
+ export class ReactApp<S extends IAppSettings, D extends IUser>
205
129
  extends CoreApp<D, S, React.ReactNode, NotificationReactCallProps>
206
- implements IReactApp<S, D, P>
130
+ implements IReactApp<S, D>
207
131
  {
208
132
  private static _notifierProvider: React.FunctionComponent<NotificationRenderProps>;
209
133
 
@@ -225,11 +149,6 @@ export class ReactApp<
225
149
  */
226
150
  readonly cultureState: CultureState;
227
151
 
228
- /**
229
- * Page state
230
- */
231
- readonly pageState: PageState<P>;
232
-
233
152
  /**
234
153
  * User state
235
154
  */
@@ -250,11 +169,6 @@ export class ReactApp<
250
169
  */
251
170
  navigateFunction?: NavigateFunction;
252
171
 
253
- /**
254
- * Page state dispatch
255
- */
256
- pageStateDispatch?: React.Dispatch<PageAction<P>>;
257
-
258
172
  /**
259
173
  * User state dispatch
260
174
  */
@@ -287,9 +201,6 @@ export class ReactApp<
287
201
  }
288
202
 
289
203
  this.cultureState = new CultureState(settings.currentCulture);
290
- this.pageState = new PageState<P>();
291
-
292
- globalApp = this;
293
204
  }
294
205
 
295
206
  /**
@@ -494,38 +405,6 @@ export class ReactApp<
494
405
  else return false;
495
406
  }
496
407
 
497
- /**
498
- * Set page data
499
- * @param data Page data
500
- */
501
- setPageData(data: P): void {
502
- // Dispatch the change
503
- if (this.pageStateDispatch != null) {
504
- this.pageStateDispatch({
505
- type: PageActionType.Data,
506
- data
507
- });
508
- }
509
- }
510
-
511
- /**
512
- * Set page title and subtitle
513
- * @param title Page title
514
- * @param subtitle Page subtitle
515
- */
516
- setPageTitle(title: string, subtitle?: string): void {
517
- // Data
518
- const data = { title, subtitle } as P;
519
-
520
- // Dispatch the change
521
- if (this.pageStateDispatch != null) {
522
- this.pageStateDispatch({
523
- type: PageActionType.Title,
524
- data
525
- });
526
- }
527
- }
528
-
529
408
  /**
530
409
  * Navigate to Url or delta
531
410
  * @param url Url or delta
@@ -540,14 +419,6 @@ export class ReactApp<
540
419
  else this.navigateFunction(to, options);
541
420
  }
542
421
 
543
- /**
544
- * Set page title and data
545
- * @param key Page title resource key
546
- */
547
- setPageKey(key: string): void {
548
- this.setPageTitle(this.get<string>(key) ?? "");
549
- }
550
-
551
422
  /**
552
423
  * Show input dialog
553
424
  * @param props Props
@@ -566,6 +437,36 @@ export class ReactApp<
566
437
  );
567
438
  }
568
439
 
440
+ stateDetector(props: IStateProps) {
441
+ // Destruct
442
+ const { targetFields, update } = props;
443
+
444
+ // Context
445
+ const { state } = React.useContext(this.userState.context);
446
+
447
+ // Ready
448
+ React.useEffect(() => {
449
+ // Match fields
450
+ const changedFields = state.lastChangedFields;
451
+ let matchedFields: string[] | undefined;
452
+ if (targetFields == null || changedFields == null) {
453
+ matchedFields = changedFields;
454
+ } else {
455
+ matchedFields = [];
456
+ targetFields.forEach((targetField) => {
457
+ if (changedFields.includes(targetField))
458
+ matchedFields?.push(targetField);
459
+ });
460
+ }
461
+
462
+ // Callback
463
+ update(state.authorized, matchedFields);
464
+ }, [state]);
465
+
466
+ // return
467
+ return React.createElement(React.Fragment);
468
+ }
469
+
569
470
  /**
570
471
  * User login extended
571
472
  * @param user New user
@@ -10,7 +10,6 @@ import {
10
10
  } from "@etsoo/appscript";
11
11
  import { IServiceApp } from "./IServiceApp";
12
12
  import { IServiceAppSettings } from "./IServiceAppSettings";
13
- import { IServicePageData } from "./IServicePage";
14
13
  import { IServiceUser, ServiceUserToken } from "./IServiceUser";
15
14
  import { ReactApp } from "./ReactApp";
16
15
  import { IActionResult } from "@etsoo/shared";
@@ -27,10 +26,9 @@ const tryLoginKey = "tryLogin";
27
26
  */
28
27
  export class ServiceApp<
29
28
  U extends IServiceUser = IServiceUser,
30
- P extends IServicePageData = IServicePageData,
31
29
  S extends IServiceAppSettings = IServiceAppSettings
32
30
  >
33
- extends ReactApp<S, U, P>
31
+ extends ReactApp<S, U>
34
32
  implements IServiceApp
35
33
  {
36
34
  /**
@@ -3,9 +3,9 @@ import { CustomFieldReactCollection } from "@etsoo/react";
3
3
  import { Utils } from "@etsoo/shared";
4
4
  import { Grid2, Grid2Props, Stack } from "@mui/material";
5
5
  import React from "react";
6
- import { globalApp } from "../app/ReactApp";
7
6
  import { MUGlobal } from "../MUGlobal";
8
7
  import { CustomFieldUtils } from "./CustomFieldUtils";
8
+ import { useRequiredAppContext } from "../app/ReactApp";
9
9
 
10
10
  function calculateKeys(data: Record<string, unknown>) {
11
11
  let count = 0;
@@ -100,11 +100,8 @@ export type CustomFieldWindowProps<D extends CustomFieldData> = {
100
100
  export function CustomFieldWindow<D extends CustomFieldData = CustomFieldData>(
101
101
  props: CustomFieldWindowProps<D>
102
102
  ) {
103
- // Validate app
104
- const app = globalApp;
105
- if (app == null) {
106
- throw new Error("No globalApp");
107
- }
103
+ // Global app
104
+ const app = useRequiredAppContext();
108
105
 
109
106
  const {
110
107
  children,
package/src/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from "./app/CommonApp";
2
2
  export * from "./app/IServiceApp";
3
3
  export * from "./app/IServiceAppSettings";
4
- export * from "./app/IServicePage";
5
4
  export * from "./app/IServiceUser";
6
5
  export * from "./app/ISmartERPUser";
7
6
  export * from "./app/Labels";
@@ -7,10 +7,10 @@ import { Container, ContainerProps, Fab, Theme, useTheme } from "@mui/material";
7
7
  import RefreshIcon from "@mui/icons-material/Refresh";
8
8
  import { BackButton } from "../BackButton";
9
9
  import { Labels } from "../app/Labels";
10
- import { ReactAppStateDetector } from "../app/ReactApp";
11
10
  import type { CustomFabSize } from "../CustomFabProps";
12
11
  import type { IStateUpdate, ListItemReact } from "@etsoo/react";
13
12
  import type { UserKey } from "@etsoo/appscript";
13
+ import { useAppContext } from "../app/ReactApp";
14
14
 
15
15
  /**
16
16
  * Common page props
@@ -93,6 +93,9 @@ export interface CommonPageProps extends Omit<ContainerProps, "id"> {
93
93
  * @param props Props
94
94
  */
95
95
  export function CommonPage(props: CommonPageProps) {
96
+ // Global app
97
+ const app = useAppContext();
98
+
96
99
  // Destruct
97
100
  const {
98
101
  children,
@@ -166,9 +169,7 @@ export function CommonPage(props: CommonPageProps) {
166
169
  // Return the UI
167
170
  return (
168
171
  <React.Fragment>
169
- {update && (
170
- <ReactAppStateDetector targetFields={targetFields} update={update} />
171
- )}
172
+ {update && app?.stateDetector({ targetFields, update })}
172
173
  <Container
173
174
  disableGutters={disableGutters}
174
175
  maxWidth={maxWidth}
@@ -9,7 +9,7 @@ import {
9
9
  import React from "react";
10
10
  import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
11
11
  import { DrawerHeader } from "./DrawerHeader";
12
- import { globalApp } from "../app/ReactApp";
12
+ import { useAppContext } from "../app/ReactApp";
13
13
 
14
14
  /**
15
15
  * Left drawer props
@@ -52,11 +52,14 @@ export type LeftDrawerProps = React.PropsWithRef<{
52
52
  }>;
53
53
 
54
54
  export function LeftDrawer(props: React.PropsWithChildren<LeftDrawerProps>) {
55
+ // Global app
56
+ const app = useAppContext();
57
+
55
58
  // Destruct
56
59
  const {
57
60
  mdUp,
58
61
  width,
59
- appName = globalApp?.get("appName"),
62
+ appName = app?.get("appName"),
60
63
  logoUrl = "/logo192.png",
61
64
  onMinimize,
62
65
  open = mdUp,
@@ -99,7 +102,7 @@ export function LeftDrawer(props: React.PropsWithChildren<LeftDrawerProps>) {
99
102
  <DrawerHeader>
100
103
  <a
101
104
  href="https://www.etsoo.com"
102
- title={globalApp?.get("etsoo") ?? "ETSOO"}
105
+ title={app?.get("etsoo") ?? "ETSOO"}
103
106
  target="_blank"
104
107
  rel="noreferrer"
105
108
  >
@@ -3,7 +3,7 @@ import {
3
3
  GridDataType,
4
4
  ScrollRestoration
5
5
  } from "@etsoo/react";
6
- import { DataTypes, DateUtils, Utils } from "@etsoo/shared";
6
+ import { DataTypes, Utils } from "@etsoo/shared";
7
7
  import {
8
8
  Grid2,
9
9
  Grid2Props,
@@ -13,7 +13,6 @@ import {
13
13
  } from "@mui/material";
14
14
  import React from "react";
15
15
  import { Labels } from "../app/Labels";
16
- import { globalApp } from "../app/ReactApp";
17
16
  import { GridDataFormat } from "../GridDataFormat";
18
17
  import { MUGlobal } from "../MUGlobal";
19
18
  import { PullToRefreshUI } from "../PullToRefreshUI";
@@ -22,6 +21,7 @@ import type { OperationMessageHandlerAll } from "../messages/OperationMessageHan
22
21
  import { MessageUtils } from "../messages/MessageUtils";
23
22
  import type { RefreshHandler } from "../messages/RefreshHandler";
24
23
  import { OperationMessageContainer } from "../messages/OperationMessageContainer";
24
+ import { ReactAppType, useRequiredAppContext } from "../app/ReactApp";
25
25
 
26
26
  /**
27
27
  * View page grid item properties
@@ -170,13 +170,13 @@ export interface ViewPageProps<T extends DataTypes.StringRecord>
170
170
  | { id: number; types: string[] };
171
171
  }
172
172
 
173
- function formatItemData(fieldData: unknown): string | undefined {
173
+ function formatItemData(
174
+ app: ReactAppType,
175
+ fieldData: unknown
176
+ ): string | undefined {
174
177
  if (fieldData == null) return undefined;
175
178
  if (typeof fieldData === "string") return fieldData;
176
- if (fieldData instanceof Date)
177
- return globalApp
178
- ? globalApp.formatDate(fieldData, "d")
179
- : DateUtils.format(fieldData, "d");
179
+ if (fieldData instanceof Date) return app.formatDate(fieldData, "d");
180
180
  return `${fieldData}`;
181
181
  }
182
182
 
@@ -199,6 +199,7 @@ function getResp(singleRow: ViewPageRowType) {
199
199
  }
200
200
 
201
201
  function getItemField<T extends object>(
202
+ app: ReactAppType,
202
203
  field: ViewPageFieldTypeNarrow<T>,
203
204
  data: T
204
205
  ): [React.ReactNode, React.ReactNode, Grid2Props] {
@@ -210,7 +211,7 @@ function getItemField<T extends object>(
210
211
  if (Array.isArray(field)) {
211
212
  const [fieldData, fieldType, renderProps, singleRow = "small"] = field;
212
213
  itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
213
- itemLabel = globalApp?.get<string>(fieldData) ?? fieldData;
214
+ itemLabel = app.get<string>(fieldData) ?? fieldData;
214
215
  gridProps = { ...getResp(singleRow) };
215
216
  } else if (typeof field === "object") {
216
217
  // Destruct
@@ -230,7 +231,7 @@ function getItemField<T extends object>(
230
231
 
231
232
  // Field data
232
233
  if (typeof fieldData === "function") itemData = fieldData(data);
233
- else if (dataType == null) itemData = formatItemData(data[fieldData]);
234
+ else if (dataType == null) itemData = formatItemData(app, data[fieldData]);
234
235
  else itemData = GridDataFormat(data[fieldData], dataType, renderProps);
235
236
 
236
237
  // Field label
@@ -238,11 +239,11 @@ function getItemField<T extends object>(
238
239
  typeof fieldLabel === "function"
239
240
  ? fieldLabel(data)
240
241
  : fieldLabel != null
241
- ? globalApp?.get<string>(fieldLabel) ?? fieldLabel
242
+ ? app.get<string>(fieldLabel) ?? fieldLabel
242
243
  : fieldLabel;
243
244
  } else {
244
- itemData = formatItemData(data[field]);
245
- itemLabel = globalApp?.get<string>(field) ?? field;
245
+ itemData = formatItemData(app, data[field]);
246
+ itemLabel = app.get<string>(field) ?? field;
246
247
  }
247
248
 
248
249
  return [itemData, itemLabel, gridProps];
@@ -255,6 +256,9 @@ function getItemField<T extends object>(
255
256
  export function ViewPage<T extends DataTypes.StringRecord>(
256
257
  props: ViewPageProps<T>
257
258
  ) {
259
+ // Global app
260
+ const app = useRequiredAppContext();
261
+
258
262
  // Destruct
259
263
  const {
260
264
  actions,
@@ -348,6 +352,7 @@ export function ViewPage<T extends DataTypes.StringRecord>(
348
352
  }
349
353
 
350
354
  const [itemData, itemLabel, gridProps] = getItemField(
355
+ app,
351
356
  field,
352
357
  data
353
358
  );
@@ -1,6 +0,0 @@
1
- import { IPageData } from "@etsoo/react";
2
- /**
3
- * Service page data interface
4
- */
5
- export interface IServicePageData extends IPageData {
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- import { IPageData } from "@etsoo/react";
2
- /**
3
- * Service page data interface
4
- */
5
- export interface IServicePageData extends IPageData {
6
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import { IPageData } from "@etsoo/react";
2
-
3
- /**
4
- * Service page data interface
5
- */
6
- export interface IServicePageData extends IPageData {}