@etsoo/materialui 1.4.74 → 1.4.76

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 (115) 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/ButtonPopover.d.ts +5 -0
  6. package/lib/cjs/ButtonPopover.js +5 -4
  7. package/lib/cjs/ComboBox.js +3 -1
  8. package/lib/cjs/ComboBoxMultiple.js +3 -1
  9. package/lib/cjs/ComboBoxPro.js +4 -2
  10. package/lib/cjs/CultureDataTable.js +3 -1
  11. package/lib/cjs/DataSteps.js +3 -6
  12. package/lib/cjs/DataTable.js +3 -1
  13. package/lib/cjs/InputField.d.ts +3 -3
  14. package/lib/cjs/InputTipField.js +15 -8
  15. package/lib/cjs/ListMoreDisplay.js +3 -1
  16. package/lib/cjs/OptionBool.js +3 -1
  17. package/lib/cjs/QuickList.js +4 -2
  18. package/lib/cjs/SelectBool.js +4 -2
  19. package/lib/cjs/ShowDataComparison.js +2 -5
  20. package/lib/cjs/SwitchAnt.js +3 -1
  21. package/lib/cjs/TagList.js +3 -1
  22. package/lib/cjs/TagListPro.js +4 -2
  23. package/lib/cjs/TextFieldEx.d.ts +3 -3
  24. package/lib/cjs/TextFieldEx.js +3 -1
  25. package/lib/cjs/Tiplist.js +5 -3
  26. package/lib/cjs/TiplistPro.js +3 -1
  27. package/lib/cjs/UserAvatar.js +3 -1
  28. package/lib/cjs/app/CommonApp.d.ts +1 -2
  29. package/lib/cjs/app/IServiceApp.d.ts +1 -6
  30. package/lib/cjs/app/IServiceApp.js +0 -9
  31. package/lib/cjs/app/ReactApp.d.ts +18 -74
  32. package/lib/cjs/app/ReactApp.js +40 -82
  33. package/lib/cjs/app/ServiceApp.d.ts +1 -2
  34. package/lib/cjs/custom/CustomFieldWindow.js +3 -6
  35. package/lib/cjs/index.d.ts +0 -1
  36. package/lib/cjs/index.js +0 -1
  37. package/lib/cjs/pages/CommonPage.js +3 -1
  38. package/lib/cjs/pages/LeftDrawer.js +4 -2
  39. package/lib/cjs/pages/ViewPage.js +13 -14
  40. package/lib/mjs/AddresSelector.js +4 -2
  41. package/lib/mjs/AuditDisplay.js +11 -11
  42. package/lib/mjs/BridgeCloseButton.js +4 -2
  43. package/lib/mjs/ButtonPopover.d.ts +5 -0
  44. package/lib/mjs/ButtonPopover.js +5 -4
  45. package/lib/mjs/ComboBox.js +4 -2
  46. package/lib/mjs/ComboBoxMultiple.js +4 -2
  47. package/lib/mjs/ComboBoxPro.js +4 -2
  48. package/lib/mjs/CultureDataTable.js +4 -2
  49. package/lib/mjs/DataSteps.js +3 -6
  50. package/lib/mjs/DataTable.js +4 -2
  51. package/lib/mjs/InputField.d.ts +3 -3
  52. package/lib/mjs/InputTipField.js +15 -8
  53. package/lib/mjs/ListMoreDisplay.js +4 -2
  54. package/lib/mjs/OptionBool.js +4 -2
  55. package/lib/mjs/QuickList.js +4 -2
  56. package/lib/mjs/SelectBool.js +4 -2
  57. package/lib/mjs/ShowDataComparison.js +3 -6
  58. package/lib/mjs/SwitchAnt.js +4 -2
  59. package/lib/mjs/TagList.js +4 -2
  60. package/lib/mjs/TagListPro.js +4 -2
  61. package/lib/mjs/TextFieldEx.d.ts +3 -3
  62. package/lib/mjs/TextFieldEx.js +4 -2
  63. package/lib/mjs/Tiplist.js +5 -3
  64. package/lib/mjs/TiplistPro.js +4 -2
  65. package/lib/mjs/UserAvatar.js +4 -2
  66. package/lib/mjs/app/CommonApp.d.ts +1 -2
  67. package/lib/mjs/app/IServiceApp.d.ts +1 -6
  68. package/lib/mjs/app/IServiceApp.js +1 -5
  69. package/lib/mjs/app/ReactApp.d.ts +18 -74
  70. package/lib/mjs/app/ReactApp.js +36 -83
  71. package/lib/mjs/app/ServiceApp.d.ts +1 -2
  72. package/lib/mjs/custom/CustomFieldWindow.js +3 -6
  73. package/lib/mjs/index.d.ts +0 -1
  74. package/lib/mjs/index.js +0 -1
  75. package/lib/mjs/pages/CommonPage.js +4 -2
  76. package/lib/mjs/pages/LeftDrawer.js +5 -3
  77. package/lib/mjs/pages/ViewPage.js +14 -15
  78. package/package.json +11 -11
  79. package/src/AddresSelector.tsx +5 -2
  80. package/src/AuditDisplay.tsx +14 -12
  81. package/src/BridgeCloseButton.tsx +5 -2
  82. package/src/ButtonPopover.tsx +13 -6
  83. package/src/ComboBox.tsx +5 -2
  84. package/src/ComboBoxMultiple.tsx +5 -2
  85. package/src/ComboBoxPro.tsx +5 -2
  86. package/src/CultureDataTable.tsx +6 -3
  87. package/src/DataSteps.tsx +3 -6
  88. package/src/DataTable.tsx +5 -2
  89. package/src/InputTipField.tsx +26 -17
  90. package/src/ListMoreDisplay.tsx +5 -3
  91. package/src/OptionBool.tsx +5 -3
  92. package/src/QuickList.tsx +5 -2
  93. package/src/SelectBool.tsx +5 -3
  94. package/src/ShowDataComparison.tsx +3 -6
  95. package/src/SwitchAnt.tsx +5 -2
  96. package/src/TagList.tsx +5 -2
  97. package/src/TagListPro.tsx +5 -2
  98. package/src/TextFieldEx.tsx +5 -3
  99. package/src/Tiplist.tsx +7 -4
  100. package/src/TiplistPro.tsx +5 -2
  101. package/src/UserAvatar.tsx +5 -3
  102. package/src/app/CommonApp.ts +2 -3
  103. package/src/app/IServiceApp.ts +1 -8
  104. package/src/app/ReactApp.ts +52 -151
  105. package/src/app/ServiceApp.ts +1 -3
  106. package/src/custom/CustomFieldWindow.tsx +3 -6
  107. package/src/index.ts +0 -1
  108. package/src/pages/CommonPage.tsx +5 -4
  109. package/src/pages/LeftDrawer.tsx +6 -3
  110. package/src/pages/ViewPage.tsx +18 -13
  111. package/lib/cjs/app/IServicePage.d.ts +0 -6
  112. package/lib/cjs/app/IServicePage.js +0 -2
  113. package/lib/mjs/app/IServicePage.d.ts +0 -6
  114. package/lib/mjs/app/IServicePage.js +0 -1
  115. package/src/app/IServicePage.ts +0 -6
@@ -1,10 +1,10 @@
1
1
  import { Utils } from "@etsoo/shared";
2
2
  import { Button, Divider, Theme, Typography, useTheme } from "@mui/material";
3
3
  import React, { CSSProperties } from "react";
4
- import { globalApp } from "./app/ReactApp";
5
4
  import { ListMoreDisplay, ListMoreDisplayProps } from "./ListMoreDisplay";
6
5
  import { ShowDataComparison } from "./ShowDataComparison";
7
6
  import { AuditLineDto } from "@etsoo/appscript";
7
+ import { useAppContext } from "./app/ReactApp";
8
8
 
9
9
  /**
10
10
  * Audit display props
@@ -32,17 +32,6 @@ export interface AuditDisplayProps
32
32
  itemRenderer?: (data: AuditLineDto, index: number) => React.ReactNode;
33
33
  }
34
34
 
35
- // Get label
36
- const getLabel = (key: string) => {
37
- return globalApp?.get(Utils.formatInitial(key)) ?? key;
38
- };
39
-
40
- // Format date
41
- const formatDate = (date: Date) => {
42
- if (globalApp) return globalApp.formatDate(date, "ds");
43
- return date.toUTCString();
44
- };
45
-
46
35
  /**
47
36
  * Audit display
48
37
  * @param props Props
@@ -52,6 +41,19 @@ export function AuditDisplay(props: AuditDisplayProps) {
52
41
  // Theme
53
42
  const theme = useTheme();
54
43
 
44
+ // Global app
45
+ const app = useAppContext();
46
+
47
+ // Get label
48
+ const getLabel = (key: string) => {
49
+ return app?.get(Utils.formatInitial(key)) ?? key;
50
+ };
51
+
52
+ // Format date
53
+ const formatDate = (date: Date) => {
54
+ return app?.formatDate(date, "ds") ?? date.toUTCString();
55
+ };
56
+
55
57
  // Title
56
58
  var title = getLabel("dataComparison");
57
59
 
@@ -2,7 +2,7 @@ import { BridgeUtils, IBridgeHost } from "@etsoo/appscript";
2
2
  import CloseIcon from "@mui/icons-material/Close";
3
3
  import { Box, BoxProps, IconButton, IconButtonProps } from "@mui/material";
4
4
  import React from "react";
5
- import { globalApp } from "./app/ReactApp";
5
+ import { useAppContext } from "./app/ReactApp";
6
6
 
7
7
  /**
8
8
  * Bridge close button props
@@ -26,11 +26,14 @@ export interface BridgeCloseButtonProps extends IconButtonProps {
26
26
  * @returns Component
27
27
  */
28
28
  export function BridgeCloseButton(props: BridgeCloseButtonProps) {
29
+ // Global app
30
+ const app = useAppContext();
31
+
29
32
  // Destruct
30
33
  const {
31
34
  boxProps,
32
35
  onClick,
33
- title = globalApp?.get("close") ?? "Close",
36
+ title = app?.get("close") ?? "Close",
34
37
  validate,
35
38
  ...rest
36
39
  } = props;
@@ -1,4 +1,4 @@
1
- import { Popover } from "@mui/material";
1
+ import { Popover, PopoverOrigin } from "@mui/material";
2
2
  import React from "react";
3
3
 
4
4
  /**
@@ -24,6 +24,11 @@ export type ButtonPopoverProps<T> = {
24
24
  * @returns Data promise
25
25
  */
26
26
  loadData?: () => Promise<T | undefined>;
27
+
28
+ /**
29
+ * Position
30
+ */
31
+ position?: PopoverOrigin["horizontal"];
27
32
  };
28
33
 
29
34
  /**
@@ -33,7 +38,7 @@ export type ButtonPopoverProps<T> = {
33
38
  */
34
39
  export function ButtonPopover<T>(props: ButtonPopoverProps<T>) {
35
40
  // Destruct
36
- const { button, children, loadData } = props;
41
+ const { button, children, loadData, position = "right" } = props;
37
42
 
38
43
  // States
39
44
  const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null);
@@ -61,6 +66,8 @@ export function ButtonPopover<T>(props: ButtonPopoverProps<T>) {
61
66
  setAnchorEl(null);
62
67
  };
63
68
 
69
+ const styles = position === "left" ? { left: 14 } : { right: 14 };
70
+
64
71
  // Layout
65
72
  return (
66
73
  <React.Fragment>
@@ -70,8 +77,8 @@ export function ButtonPopover<T>(props: ButtonPopoverProps<T>) {
70
77
  open={open}
71
78
  onClose={handleClose}
72
79
  onClick={handleClose}
73
- transformOrigin={{ horizontal: "right", vertical: "top" }}
74
- anchorOrigin={{ horizontal: "right", vertical: "bottom" }}
80
+ transformOrigin={{ horizontal: position, vertical: "top" }}
81
+ anchorOrigin={{ horizontal: position, vertical: "bottom" }}
75
82
  slotProps={{
76
83
  paper: {
77
84
  elevation: 0,
@@ -84,12 +91,12 @@ export function ButtonPopover<T>(props: ButtonPopoverProps<T>) {
84
91
  display: "block",
85
92
  position: "absolute",
86
93
  top: 0,
87
- right: 14,
88
94
  width: 10,
89
95
  height: 10,
90
96
  bgcolor: "background.paper",
91
97
  transform: "translateY(-50%) rotate(45deg)",
92
- zIndex: 0
98
+ zIndex: 0,
99
+ ...styles
93
100
  }
94
101
  }
95
102
  }
package/src/ComboBox.tsx CHANGED
@@ -18,7 +18,7 @@ import AddIcon from "@mui/icons-material/Add";
18
18
  import type { AutocompleteExtendedProps } from "./AutocompleteExtendedProps";
19
19
  import { SearchField } from "./SearchField";
20
20
  import { InputField } from "./InputField";
21
- import { globalApp } from "./app/ReactApp";
21
+ import { useAppContext } from "./app/ReactApp";
22
22
 
23
23
  /**
24
24
  * ComboBox props
@@ -79,8 +79,11 @@ export function ComboBox<
79
79
  D extends DataTypes.Keys<T> = IdDefaultType<T>,
80
80
  L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
81
81
  >(props: ComboBoxProps<T, D, L>) {
82
+ // Global app
83
+ const app = useAppContext();
84
+
82
85
  // Labels
83
- const labels = globalApp?.getLabels("noOptions", "loading", "open", "add");
86
+ const labels = app?.getLabels("noOptions", "loading", "open", "add");
84
87
 
85
88
  // Destruct
86
89
  const {
@@ -19,7 +19,7 @@ import CheckBoxIcon from "@mui/icons-material/CheckBox";
19
19
  import type { AutocompleteExtendedProps } from "./AutocompleteExtendedProps";
20
20
  import { SearchField } from "./SearchField";
21
21
  import { InputField } from "./InputField";
22
- import { globalApp } from "./app/ReactApp";
22
+ import { useAppContext } from "./app/ReactApp";
23
23
 
24
24
  const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
25
25
  const checkedIcon = <CheckBoxIcon fontSize="small" />;
@@ -78,8 +78,11 @@ export function ComboBoxMultiple<
78
78
  D extends DataTypes.Keys<T> = IdDefaultType<T>,
79
79
  L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
80
80
  >(props: ComboBoxMultipleProps<T, D, L>) {
81
+ // Global app
82
+ const app = useAppContext();
83
+
81
84
  // Labels
82
- const labels = globalApp?.getLabels("noOptions", "loading");
85
+ const labels = app?.getLabels("noOptions", "loading");
83
86
 
84
87
  // Destruct
85
88
  const {
@@ -1,8 +1,8 @@
1
1
  import { Autocomplete, AutocompleteProps } from "@mui/material";
2
2
  import React from "react";
3
- import { globalApp } from "./app/ReactApp";
4
3
  import { InputField, InputFieldProps } from "./InputField";
5
4
  import { DataTypes, ListType2 } from "@etsoo/shared";
5
+ import { useAppContext } from "./app/ReactApp";
6
6
 
7
7
  export type ComboBoxProProps<D extends ListType2 = ListType2> = Omit<
8
8
  AutocompleteProps<D, false, false, true>,
@@ -43,12 +43,15 @@ export type ComboBoxProProps<D extends ListType2 = ListType2> = Omit<
43
43
  export function ComboBoxPro<D extends ListType2 = ListType2>(
44
44
  props: ComboBoxProProps<D>
45
45
  ) {
46
+ // Global app
47
+ const app = useAppContext();
48
+
46
49
  // Labels
47
50
  const {
48
51
  noOptions,
49
52
  loading: loadingLabel,
50
53
  open: openDefault
51
- } = globalApp?.getLabels("noOptions", "loading", "open") ?? {};
54
+ } = app?.getLabels("noOptions", "loading", "open") ?? {};
52
55
 
53
56
  // Destruct
54
57
  const {
@@ -1,8 +1,8 @@
1
1
  import { DataTable, DataTableProps } from "./DataTable";
2
2
  import React from "react";
3
- import { globalApp } from "./app/ReactApp";
4
3
  import { ListType1 } from "@etsoo/shared";
5
4
  import { GridRenderCellParams } from "@mui/x-data-grid";
5
+ import { useAppContext } from "./app/ReactApp";
6
6
 
7
7
  /**
8
8
  * Culture table props
@@ -22,14 +22,17 @@ export type CultureDataTableProps = Omit<DataTableProps, "columns"> & {
22
22
  * @returns Component
23
23
  */
24
24
  export function CultureDataTable(props: CultureDataTableProps) {
25
+ // Global app
26
+ const app = useAppContext();
27
+
25
28
  // Destruct
26
29
  const {
27
30
  cultures,
28
- cultureLabel = globalApp?.get("culture"),
31
+ cultureLabel = app?.get("culture"),
29
32
  editable = true,
30
33
  titleLabel,
31
34
  hasDescription = false,
32
- descriptionLabel = globalApp?.get("description"),
35
+ descriptionLabel = app?.get("description"),
33
36
  ...rest
34
37
  } = props;
35
38
 
package/src/DataSteps.tsx CHANGED
@@ -13,8 +13,8 @@ import StartIcon from "@mui/icons-material/Start";
13
13
  import { InputDialogProps } from "@etsoo/react";
14
14
  import React from "react";
15
15
  import { HBox } from "./FlexBox";
16
- import { globalApp } from "./app/ReactApp";
17
16
  import { MUGlobal } from "./MUGlobal";
17
+ import { useRequiredAppContext } from "./app/ReactApp";
18
18
 
19
19
  /**
20
20
  * Data step
@@ -60,11 +60,8 @@ export type DataStepsProps<T extends object> = Omit<
60
60
  * @returns Component
61
61
  */
62
62
  export function DataSteps<T extends object>(props: DataStepsProps<T>) {
63
- // App
64
- const app = globalApp;
65
- if (app == null) {
66
- throw new Error("No globalApp");
67
- }
63
+ // Global app
64
+ const app = useRequiredAppContext();
68
65
 
69
66
  // Labels
70
67
  const labels = app.getLabels("close", "nextStep", "previousStep", "submit");
package/src/DataTable.tsx CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  } from "@mui/x-data-grid";
7
7
  import { DataGridProps } from "@mui/x-data-grid/models/props/DataGridProps";
8
8
  import React from "react";
9
- import { globalApp } from "./app/ReactApp";
9
+ import { useAppContext } from "./app/ReactApp";
10
10
 
11
11
  /**
12
12
  * Data table selected cell params
@@ -40,6 +40,9 @@ export type DataTableProps<R extends GridValidRowModel = any> = Omit<
40
40
  export function DataTable<R extends GridValidRowModel = any>(
41
41
  props: DataTableProps<R>
42
42
  ) {
43
+ // Global app
44
+ const app = useAppContext();
45
+
43
46
  // Destructor
44
47
  const {
45
48
  localeText = {},
@@ -51,7 +54,7 @@ export function DataTable<R extends GridValidRowModel = any>(
51
54
  } = props;
52
55
 
53
56
  // Labels
54
- const { noRows } = globalApp?.getLabels("noRows") ?? {};
57
+ const noRows = app?.get("noRows");
55
58
  if (noRows && !localeText.noRowsLabel) localeText.noRowsLabel = noRows;
56
59
 
57
60
  const [cellModesModel, setCellModesModel] =
@@ -2,8 +2,8 @@ import { DataTypes } from "@etsoo/shared";
2
2
  import { InputAdornment, List, ListItem, Popover } from "@mui/material";
3
3
  import Typography, { TypographyProps } from "@mui/material/Typography";
4
4
  import React from "react";
5
- import { globalApp } from "./app/ReactApp";
6
5
  import { InputField, InputFieldProps } from "./InputField";
6
+ import { useAppContext } from "./app/ReactApp";
7
7
 
8
8
  type ItemType = DataTypes.IdLabelItem<string | number>;
9
9
 
@@ -46,6 +46,9 @@ export type InputTipFieldProps<T extends ItemType = ItemType> =
46
46
  export function InputTipField<T extends ItemType = ItemType>(
47
47
  props: InputTipFieldProps<T>
48
48
  ) {
49
+ // Global app
50
+ const app = useAppContext();
51
+
49
52
  // State
50
53
  const [title, setTitle] = React.useState<string>();
51
54
  const [anchorEl, setAnchorEl] = React.useState<HTMLElement>();
@@ -54,31 +57,20 @@ export function InputTipField<T extends ItemType = ItemType>(
54
57
  // Destruct
55
58
  const {
56
59
  labelProps = {
57
- title: globalApp?.get("clickForDetails"),
60
+ title: app?.get("clickForDetails"),
58
61
  sx: { color: (theme) => theme.palette.error.main, cursor: "pointer" }
59
62
  },
60
- InputProps = {
61
- endAdornment: title ? (
62
- <InputAdornment position="end">
63
- <Typography
64
- onClick={(event) => {
65
- setAnchorEl(event.currentTarget);
66
- }}
67
- {...labelProps}
68
- >
69
- {title}
70
- </Typography>
71
- </InputAdornment>
72
- ) : undefined
73
- },
74
63
  changeDelay = 480,
75
64
  onChangeDelay,
76
65
  loadData,
77
66
  itemLabel = (item) => item.label,
78
67
  renderItem = (item) => <ListItem key={item.id}>{itemLabel(item)}</ListItem>,
68
+ slotProps = {},
79
69
  ...rest
80
70
  } = props;
81
71
 
72
+ const { input, ...slotRests } = slotProps;
73
+
82
74
  const load = (value: string) => {
83
75
  if (value.length < 2) {
84
76
  setTitle(undefined);
@@ -110,7 +102,24 @@ export function InputTipField<T extends ItemType = ItemType>(
110
102
  load(event.target.value);
111
103
  if (onChangeDelay) onChangeDelay(event);
112
104
  }}
113
- InputProps={InputProps}
105
+ slotProps={{
106
+ input: {
107
+ endAdornment: title ? (
108
+ <InputAdornment position="end">
109
+ <Typography
110
+ onClick={(event) => {
111
+ setAnchorEl(event.currentTarget);
112
+ }}
113
+ {...labelProps}
114
+ >
115
+ {title}
116
+ </Typography>
117
+ </InputAdornment>
118
+ ) : undefined,
119
+ ...input
120
+ },
121
+ ...slotRests
122
+ }}
114
123
  {...rest}
115
124
  />
116
125
  </React.Fragment>
@@ -1,4 +1,3 @@
1
- import { DataTypes } from "@etsoo/shared";
2
1
  import {
3
2
  Card,
4
3
  CardActions,
@@ -16,7 +15,7 @@ import {
16
15
  GridLoaderStates
17
16
  } from "@etsoo/react";
18
17
  import { LoadingButton } from "./LoadingButton";
19
- import { globalApp } from "./app/ReactApp";
18
+ import { useAppContext } from "./app/ReactApp";
20
19
 
21
20
  /**
22
21
  * ListMoreDisplay props
@@ -68,6 +67,9 @@ type states<T> = {
68
67
  export function ListMoreDisplay<T extends object>(
69
68
  props: ListMoreDisplayProps<T>
70
69
  ) {
70
+ // Global app
71
+ const app = useAppContext();
72
+
71
73
  // Destruct
72
74
  const {
73
75
  batchSize = 6,
@@ -78,7 +80,7 @@ export function ListMoreDisplay<T extends object>(
78
80
  headerTitle,
79
81
  loadBatchSize,
80
82
  loadData,
81
- moreLabel = globalApp ? globalApp.get("more") + "..." : undefined,
83
+ moreLabel = app?.get("more1"),
82
84
  fieldTemplate,
83
85
  threshold,
84
86
  ...rest
@@ -1,6 +1,5 @@
1
1
  import { ListType1 } from "@etsoo/shared";
2
- import React from "react";
3
- import { globalApp } from "./app/ReactApp";
2
+ import { useAppContext } from "./app/ReactApp";
4
3
  import { OptionGroup, OptionGroupProps } from "./OptionGroup";
5
4
 
6
5
  /**
@@ -17,8 +16,11 @@ export type OptionBoolProps = Omit<
17
16
  * @returns Component
18
17
  */
19
18
  export function OptionBool(props: OptionBoolProps) {
19
+ // Global app
20
+ const app = useAppContext();
21
+
20
22
  // Options
21
- const options = globalApp?.getBools() ?? [];
23
+ const options = app?.getBools() ?? [];
22
24
 
23
25
  // Layout
24
26
  return (
package/src/QuickList.tsx CHANGED
@@ -11,8 +11,8 @@ import {
11
11
  } from "@mui/material";
12
12
  import React from "react";
13
13
  import { InputField, InputFieldProps } from "./InputField";
14
- import { globalApp } from "./app/ReactApp";
15
14
  import { VBox } from "./FlexBox";
15
+ import { useAppContext } from "./app/ReactApp";
16
16
 
17
17
  /**
18
18
  * Quick list props
@@ -77,6 +77,9 @@ export type QuickListProps<T extends ListType2 = ListType2> = StackProps & {
77
77
  export function QuickList<T extends ListType2 = ListType2>(
78
78
  props: QuickListProps<T>
79
79
  ) {
80
+ // Global app
81
+ const app = useAppContext();
82
+
80
83
  // Destruct
81
84
  const {
82
85
  buttonProps = {},
@@ -86,7 +89,7 @@ export function QuickList<T extends ListType2 = ListType2>(
86
89
  itemRenderer = (item: T) => itemLabel(item),
87
90
  itemProps,
88
91
  loadData,
89
- noMatchesLabel = globalApp?.get("noMatches"),
92
+ noMatchesLabel = app?.get("noMatches"),
90
93
  gap = 1,
91
94
  height = "480px",
92
95
  onItemClick,
@@ -1,7 +1,6 @@
1
1
  import { ListType1, Utils } from "@etsoo/shared";
2
- import React from "react";
3
- import { globalApp } from "./app/ReactApp";
4
2
  import { SelectEx, SelectExProps } from "./SelectEx";
3
+ import { useAppContext } from "./app/ReactApp";
5
4
 
6
5
  /**
7
6
  * SelectBool props
@@ -17,11 +16,14 @@ export type SelectBoolProps = Omit<
17
16
  * @returns Component
18
17
  */
19
18
  export function SelectBool(props: SelectBoolProps) {
19
+ // Global app
20
+ const app = useAppContext();
21
+
20
22
  // Destruct
21
23
  const { search = true, autoAddBlankItem = search, ...rest } = props;
22
24
 
23
25
  // Options
24
- const options = globalApp?.getBools() ?? [];
26
+ const options = app?.getBools() ?? [];
25
27
 
26
28
  if (autoAddBlankItem) Utils.addBlankItem(options);
27
29
 
@@ -8,7 +8,7 @@ import {
8
8
  TableHead,
9
9
  TableRow
10
10
  } from "@mui/material";
11
- import { globalApp } from "./app/ReactApp";
11
+ import { useRequiredAppContext } from "./app/ReactApp";
12
12
 
13
13
  /**
14
14
  * Check obj is instance of AuditLineChangesDto
@@ -45,11 +45,8 @@ export const ShowDataComparison = (
45
45
  getLabel?: (field: string) => string,
46
46
  equalCheck: boolean = true
47
47
  ) => {
48
- // Validate app
49
- const app = globalApp;
50
- if (app == null) {
51
- throw new Error("No globalApp");
52
- }
48
+ // Global app
49
+ const app = useRequiredAppContext();
53
50
 
54
51
  // Labels
55
52
  const { dataComparison, field, newValue, oldValue } = app.getLabels(
package/src/SwitchAnt.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Stack, Typography } from "@mui/material";
2
2
  import Switch, { SwitchProps } from "@mui/material/Switch";
3
3
  import React from "react";
4
- import { globalApp } from "./app/ReactApp";
4
+ import { useAppContext } from "./app/ReactApp";
5
5
 
6
6
  /**
7
7
  * Ant style switch props
@@ -29,8 +29,11 @@ export interface SwitchAntProps extends SwitchProps {
29
29
  * @returns Component
30
30
  */
31
31
  export function SwitchAnt(props: SwitchAntProps) {
32
+ // Global app
33
+ const app = useAppContext();
34
+
32
35
  // Labels
33
- const { yes = "Yes", no = "No" } = globalApp?.getLabels("yes", "no") ?? {};
36
+ const { yes = "Yes", no = "No" } = app?.getLabels("yes", "no") ?? {};
34
37
 
35
38
  // Destruct
36
39
  const {
package/src/TagList.tsx CHANGED
@@ -3,7 +3,7 @@ import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
3
3
  import CheckBoxIcon from "@mui/icons-material/CheckBox";
4
4
  import React from "react";
5
5
  import { InputField, InputFieldProps } from "./InputField";
6
- import { globalApp } from "./app/ReactApp";
6
+ import { useAppContext } from "./app/ReactApp";
7
7
 
8
8
  export type TagListProps = Omit<
9
9
  AutocompleteProps<string, true, false, true>,
@@ -34,13 +34,16 @@ export type TagListProps = Omit<
34
34
  };
35
35
 
36
36
  export function TagList(props: TagListProps) {
37
+ // Global app
38
+ const app = useAppContext();
39
+
37
40
  // Labels
38
41
  const {
39
42
  noOptions,
40
43
  loading: loadingLabel,
41
44
  more = "More",
42
45
  open: openDefault
43
- } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
46
+ } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
44
47
 
45
48
  const moreLabel = more + "...";
46
49
 
@@ -3,8 +3,8 @@ import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
3
3
  import CheckBoxIcon from "@mui/icons-material/CheckBox";
4
4
  import React from "react";
5
5
  import { InputField, InputFieldProps } from "./InputField";
6
- import { globalApp } from "./app/ReactApp";
7
6
  import { DataTypes, ListType2 } from "@etsoo/shared";
7
+ import { useAppContext } from "./app/ReactApp";
8
8
 
9
9
  export type TagListProProps<D extends ListType2 = ListType2> = Omit<
10
10
  AutocompleteProps<D, true, false, false>,
@@ -37,13 +37,16 @@ export type TagListProProps<D extends ListType2 = ListType2> = Omit<
37
37
  export function TagListPro<D extends ListType2 = ListType2>(
38
38
  props: TagListProProps<D>
39
39
  ) {
40
+ // Global app
41
+ const app = useAppContext();
42
+
40
43
  // Labels
41
44
  const {
42
45
  noOptions,
43
46
  loading: loadingLabel,
44
47
  more = "More",
45
48
  open: openDefault
46
- } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
49
+ } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
47
50
 
48
51
  const moreLabel = more + "...";
49
52
 
@@ -9,7 +9,7 @@ import { MUGlobal } from "./MUGlobal";
9
9
  import { Clear, Visibility } from "@mui/icons-material";
10
10
  import { Keyboard } from "@etsoo/shared";
11
11
  import { ReactUtils, useCombinedRefs, useDelayedExecutor } from "@etsoo/react";
12
- import { globalApp } from "./app/ReactApp";
12
+ import { useAppContext } from "./app/ReactApp";
13
13
 
14
14
  /**
15
15
  * Extended text field props
@@ -73,9 +73,11 @@ export const TextFieldEx = React.forwardRef<
73
73
  TextFieldExMethods,
74
74
  TextFieldExProps
75
75
  >((props, ref) => {
76
+ // Global app
77
+ const app = useAppContext();
78
+
76
79
  // Labels
77
- const { showIt, clearInput } =
78
- globalApp?.getLabels("showIt", "clearInput") ?? {};
80
+ const { showIt, clearInput } = app?.getLabels("showIt", "clearInput") ?? {};
79
81
 
80
82
  // Destructure
81
83
  const {
package/src/Tiplist.tsx CHANGED
@@ -3,9 +3,9 @@ import { DataTypes, IdDefaultType, ListType2 } from "@etsoo/shared";
3
3
  import { Autocomplete, AutocompleteRenderInputParams } from "@mui/material";
4
4
  import React from "react";
5
5
  import type { AutocompleteExtendedProps } from "./AutocompleteExtendedProps";
6
- import { globalApp } from "./app/ReactApp";
7
6
  import { SearchField } from "./SearchField";
8
7
  import { InputField } from "./InputField";
8
+ import { useAppContext } from "./app/ReactApp";
9
9
 
10
10
  /**
11
11
  * Tiplist props
@@ -56,13 +56,16 @@ export function Tiplist<
56
56
  T extends object = ListType2,
57
57
  D extends DataTypes.Keys<T> = IdDefaultType<T>
58
58
  >(props: TiplistProps<T, D>) {
59
+ // Global app
60
+ const app = useAppContext();
61
+
59
62
  // Labels
60
63
  const {
61
64
  noOptions,
62
65
  loading,
63
- more,
66
+ more1 = "More",
64
67
  open: openDefault
65
- } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
68
+ } = app?.getLabels("noOptions", "loading", "more1", "open") ?? {};
66
69
 
67
70
  // Destruct
68
71
  const {
@@ -378,7 +381,7 @@ export function Tiplist<
378
381
  }}
379
382
  getOptionLabel={(item) => {
380
383
  if (typeof item !== "object") return `${item}`;
381
- if (item[idField] === "n/a") return (more ?? "More") + "...";
384
+ if (item[idField] === "n/a") return more1;
382
385
  return getOptionLabel
383
386
  ? getOptionLabel(item)
384
387
  : DataTypes.getObjectItemLabel(item);
@@ -3,7 +3,7 @@ import { DataTypes, ListType2 } from "@etsoo/shared";
3
3
  import { Autocomplete, AutocompleteProps } from "@mui/material";
4
4
  import React, { ChangeEventHandler } from "react";
5
5
  import { InputField, InputFieldProps } from "./InputField";
6
- import { globalApp } from "./app/ReactApp";
6
+ import { useAppContext } from "./app/ReactApp";
7
7
 
8
8
  /**
9
9
  * TiplistPro props
@@ -89,13 +89,16 @@ interface States<T extends object> {
89
89
  export function TiplistPro<T extends ListType2 = ListType2>(
90
90
  props: TiplistProProps<T>
91
91
  ) {
92
+ // Global app
93
+ const app = useAppContext();
94
+
92
95
  // Labels
93
96
  const {
94
97
  noOptions,
95
98
  loading,
96
99
  more,
97
100
  open: openDefault
98
- } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
101
+ } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
99
102
 
100
103
  // Destruct
101
104
  const {