@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,3 +1,4 @@
1
+ import { PopoverOrigin } from "@mui/material";
1
2
  import React from "react";
2
3
  /**
3
4
  * Button popover props
@@ -20,6 +21,10 @@ export type ButtonPopoverProps<T> = {
20
21
  * @returns Data promise
21
22
  */
22
23
  loadData?: () => Promise<T | undefined>;
24
+ /**
25
+ * Position
26
+ */
27
+ position?: PopoverOrigin["horizontal"];
23
28
  };
24
29
  /**
25
30
  * Button popover component
@@ -8,7 +8,7 @@ import React from "react";
8
8
  */
9
9
  export function ButtonPopover(props) {
10
10
  // Destruct
11
- const { button, children, loadData } = props;
11
+ const { button, children, loadData, position = "right" } = props;
12
12
  // States
13
13
  const [anchorEl, setAnchorEl] = React.useState(null);
14
14
  const [data, setData] = React.useState(null);
@@ -31,8 +31,9 @@ export function ButtonPopover(props) {
31
31
  const handleClose = () => {
32
32
  setAnchorEl(null);
33
33
  };
34
+ const styles = position === "left" ? { left: 14 } : { right: 14 };
34
35
  // Layout
35
- return (_jsxs(React.Fragment, { children: [button((handler) => setAnchorEl(handler)), _jsx(Popover, { anchorEl: anchorEl, open: open, onClose: handleClose, onClick: handleClose, transformOrigin: { horizontal: "right", vertical: "top" }, anchorOrigin: { horizontal: "right", vertical: "bottom" }, slotProps: {
36
+ return (_jsxs(React.Fragment, { children: [button((handler) => setAnchorEl(handler)), _jsx(Popover, { anchorEl: anchorEl, open: open, onClose: handleClose, onClick: handleClose, transformOrigin: { horizontal: position, vertical: "top" }, anchorOrigin: { horizontal: position, vertical: "bottom" }, slotProps: {
36
37
  paper: {
37
38
  elevation: 0,
38
39
  sx: {
@@ -44,12 +45,12 @@ export function ButtonPopover(props) {
44
45
  display: "block",
45
46
  position: "absolute",
46
47
  top: 0,
47
- right: 14,
48
48
  width: 10,
49
49
  height: 10,
50
50
  bgcolor: "background.paper",
51
51
  transform: "translateY(-50%) rotate(45deg)",
52
- zIndex: 0
52
+ zIndex: 0,
53
+ ...styles
53
54
  }
54
55
  }
55
56
  }
@@ -7,15 +7,17 @@ import { ReactUtils } from "@etsoo/react";
7
7
  import AddIcon from "@mui/icons-material/Add";
8
8
  import { SearchField } from "./SearchField";
9
9
  import { InputField } from "./InputField";
10
- import { globalApp } from "./app/ReactApp";
10
+ import { useAppContext } from "./app/ReactApp";
11
11
  /**
12
12
  * ComboBox
13
13
  * @param props Props
14
14
  * @returns Component
15
15
  */
16
16
  export function ComboBox(props) {
17
+ // Global app
18
+ const app = useAppContext();
17
19
  // Labels
18
- const labels = globalApp?.getLabels("noOptions", "loading", "open", "add");
20
+ const labels = app?.getLabels("noOptions", "loading", "open", "add");
19
21
  // Destruct
20
22
  const { search = false, autoAddBlankItem = search, idField = "id", idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputReset, inputVariant, defaultValue, label, labelField = "label", loadData, onLoadData, name, inputAutoComplete = "off", options, dataReadonly = true, readOnly, onChange, onValueChange, openOnFocus = true, value, disableCloseOnSelect = false, getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: "150px", flexGrow: 2 }, noOptionsText = labels?.noOptions, loadingText = labels?.loading, openText = labels?.open, addLabel = labels?.add, onAdd, getOptionKey = (option) => `${option[idField]}`, ...rest } = props;
21
23
  // Value input ref
@@ -8,7 +8,7 @@ import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
8
8
  import CheckBoxIcon from "@mui/icons-material/CheckBox";
9
9
  import { SearchField } from "./SearchField";
10
10
  import { InputField } from "./InputField";
11
- import { globalApp } from "./app/ReactApp";
11
+ import { useAppContext } from "./app/ReactApp";
12
12
  const icon = _jsx(CheckBoxOutlineBlankIcon, { fontSize: "small" });
13
13
  const checkedIcon = _jsx(CheckBoxIcon, { fontSize: "small" });
14
14
  /**
@@ -17,8 +17,10 @@ const checkedIcon = _jsx(CheckBoxIcon, { fontSize: "small" });
17
17
  * @returns Component
18
18
  */
19
19
  export function ComboBoxMultiple(props) {
20
+ // Global app
21
+ const app = useAppContext();
20
22
  // Labels
21
- const labels = globalApp?.getLabels("noOptions", "loading");
23
+ const labels = app?.getLabels("noOptions", "loading");
22
24
  // Destruct
23
25
  const { search = false, autoAddBlankItem = search, idField = "id", idValue, idValues, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputReset, inputVariant, defaultValue, label, labelField = "label", loadData, onLoadData, name, inputAutoComplete = "off", options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, disableCloseOnSelect = true, renderOption = (props, option, { selected }) => (_jsxs("li", { ...props, children: [_jsx(Checkbox, { icon: icon, checkedIcon: checkedIcon, style: { marginRight: 8 }, checked: selected }), `${option[labelField]}`] })), getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: "150px" }, noOptionsText = labels?.noOptions, loadingText = labels?.loading, ...rest } = props;
24
26
  // Value input ref
@@ -1,12 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Autocomplete } from "@mui/material";
3
3
  import React from "react";
4
- import { globalApp } from "./app/ReactApp";
5
4
  import { InputField } from "./InputField";
6
5
  import { DataTypes } from "@etsoo/shared";
6
+ import { useAppContext } from "./app/ReactApp";
7
7
  export function ComboBoxPro(props) {
8
+ // Global app
9
+ const app = useAppContext();
8
10
  // Labels
9
- const { noOptions, loading: loadingLabel, open: openDefault } = globalApp?.getLabels("noOptions", "loading", "open") ?? {};
11
+ const { noOptions, loading: loadingLabel, open: openDefault } = app?.getLabels("noOptions", "loading", "open") ?? {};
10
12
  // Destruct
11
13
  const { noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, options, openOnFocus = true, label, inputProps, name, value, idValue, onChange, onValueChange, ...rest } = props;
12
14
  const [open, setOpen] = React.useState(false);
@@ -1,15 +1,17 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { DataTable } from "./DataTable";
3
3
  import React from "react";
4
- import { globalApp } from "./app/ReactApp";
4
+ import { useAppContext } from "./app/ReactApp";
5
5
  /**
6
6
  * Culture DataTable
7
7
  * @param props Props
8
8
  * @returns Component
9
9
  */
10
10
  export function CultureDataTable(props) {
11
+ // Global app
12
+ const app = useAppContext();
11
13
  // Destruct
12
- const { cultures, cultureLabel = globalApp?.get("culture"), editable = true, titleLabel, hasDescription = false, descriptionLabel = globalApp?.get("description"), ...rest } = props;
14
+ const { cultures, cultureLabel = app?.get("culture"), editable = true, titleLabel, hasDescription = false, descriptionLabel = app?.get("description"), ...rest } = props;
13
15
  const getCultureLabel = React.useCallback((value) => cultures.find((c) => c.id == value.id)?.label ?? `${value.value}`, [cultures]);
14
16
  return (_jsx(DataTable, { columns: [
15
17
  {
@@ -7,19 +7,16 @@ import CheckIcon from "@mui/icons-material/Check";
7
7
  import StartIcon from "@mui/icons-material/Start";
8
8
  import React from "react";
9
9
  import { HBox } from "./FlexBox";
10
- import { globalApp } from "./app/ReactApp";
11
10
  import { MUGlobal } from "./MUGlobal";
11
+ import { useRequiredAppContext } from "./app/ReactApp";
12
12
  /**
13
13
  * Data collecting steps component
14
14
  * @param props Props
15
15
  * @returns Component
16
16
  */
17
17
  export function DataSteps(props) {
18
- // App
19
- const app = globalApp;
20
- if (app == null) {
21
- throw new Error("No globalApp");
22
- }
18
+ // Global app
19
+ const app = useRequiredAppContext();
23
20
  // Labels
24
21
  const labels = app.getLabels("close", "nextStep", "previousStep", "submit");
25
22
  // Destruct
@@ -1,17 +1,19 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { DataGrid } from "@mui/x-data-grid";
3
3
  import React from "react";
4
- import { globalApp } from "./app/ReactApp";
4
+ import { useAppContext } from "./app/ReactApp";
5
5
  /**
6
6
  * Data table
7
7
  * @param props Props
8
8
  * @returns Component
9
9
  */
10
10
  export function DataTable(props) {
11
+ // Global app
12
+ const app = useAppContext();
11
13
  // Destructor
12
14
  const { localeText = {}, onCellSelection, onProcessRowUpdateError = (error) => console.log("onProcessRowUpdateError", error), slotProps, ...rest } = props;
13
15
  // Labels
14
- const { noRows } = globalApp?.getLabels("noRows") ?? {};
16
+ const noRows = app?.get("noRows");
15
17
  if (noRows && !localeText.noRowsLabel)
16
18
  localeText.noRowsLabel = noRows;
17
19
  const [cellModesModel, setCellModesModel] = React.useState({});
@@ -26,7 +26,7 @@ export type InputFieldProps = TextFieldProps & {
26
26
  * @param props Props
27
27
  * @returns Component
28
28
  */
29
- export declare const InputField: React.ForwardRefExoticComponent<(Omit<import("@mui/material").OutlinedTextFieldProps & {
29
+ export declare const InputField: React.ForwardRefExoticComponent<(Omit<import("@mui/material").StandardTextFieldProps & {
30
30
  /**
31
31
  * Change delay (ms) to avoid repeatly dispatch onChange
32
32
  */
@@ -43,7 +43,7 @@ export declare const InputField: React.ForwardRefExoticComponent<(Omit<import("@
43
43
  * Minimum characters to trigger the change event
44
44
  */
45
45
  minChars?: number;
46
- }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
46
+ }, "ref"> | Omit<import("@mui/material").OutlinedTextFieldProps & {
47
47
  /**
48
48
  * Change delay (ms) to avoid repeatly dispatch onChange
49
49
  */
@@ -60,7 +60,7 @@ export declare const InputField: React.ForwardRefExoticComponent<(Omit<import("@
60
60
  * Minimum characters to trigger the change event
61
61
  */
62
62
  minChars?: number;
63
- }, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
63
+ }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
64
64
  /**
65
65
  * Change delay (ms) to avoid repeatly dispatch onChange
66
66
  */
@@ -2,27 +2,26 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { InputAdornment, List, ListItem, Popover } from "@mui/material";
3
3
  import Typography from "@mui/material/Typography";
4
4
  import React from "react";
5
- import { globalApp } from "./app/ReactApp";
6
5
  import { InputField } from "./InputField";
6
+ import { useAppContext } from "./app/ReactApp";
7
7
  /**
8
8
  * InputField with tips
9
9
  * @param props Props
10
10
  * @returns Component
11
11
  */
12
12
  export function InputTipField(props) {
13
+ // Global app
14
+ const app = useAppContext();
13
15
  // State
14
16
  const [title, setTitle] = React.useState();
15
17
  const [anchorEl, setAnchorEl] = React.useState();
16
18
  const [data, setData] = React.useState();
17
19
  // Destruct
18
20
  const { labelProps = {
19
- title: globalApp?.get("clickForDetails"),
21
+ title: app?.get("clickForDetails"),
20
22
  sx: { color: (theme) => theme.palette.error.main, cursor: "pointer" }
21
- }, InputProps = {
22
- endAdornment: title ? (_jsx(InputAdornment, { position: "end", children: _jsx(Typography, { onClick: (event) => {
23
- setAnchorEl(event.currentTarget);
24
- }, ...labelProps, children: title }) })) : undefined
25
- }, changeDelay = 480, onChangeDelay, loadData, itemLabel = (item) => item.label, renderItem = (item) => _jsx(ListItem, { children: itemLabel(item) }, item.id), ...rest } = props;
23
+ }, changeDelay = 480, onChangeDelay, loadData, itemLabel = (item) => item.label, renderItem = (item) => _jsx(ListItem, { children: itemLabel(item) }, item.id), slotProps = {}, ...rest } = props;
24
+ const { input, ...slotRests } = slotProps;
26
25
  const load = (value) => {
27
26
  if (value.length < 2) {
28
27
  setTitle(undefined);
@@ -40,5 +39,13 @@ export function InputTipField(props) {
40
39
  load(event.target.value);
41
40
  if (onChangeDelay)
42
41
  onChangeDelay(event);
43
- }, InputProps: InputProps, ...rest })] }));
42
+ }, slotProps: {
43
+ input: {
44
+ endAdornment: title ? (_jsx(InputAdornment, { position: "end", children: _jsx(Typography, { onClick: (event) => {
45
+ setAnchorEl(event.currentTarget);
46
+ }, ...labelProps, children: title }) })) : undefined,
47
+ ...input
48
+ },
49
+ ...slotRests
50
+ }, ...rest })] }));
44
51
  }
@@ -3,15 +3,17 @@ import { Card, CardActions, CardContent, CardHeader, CircularProgress } from "@m
3
3
  import React from "react";
4
4
  import { GridDataGet } from "@etsoo/react";
5
5
  import { LoadingButton } from "./LoadingButton";
6
- import { globalApp } from "./app/ReactApp";
6
+ import { useAppContext } from "./app/ReactApp";
7
7
  /**
8
8
  * ListMoreDisplay
9
9
  * @param props Props
10
10
  * @returns Component
11
11
  */
12
12
  export function ListMoreDisplay(props) {
13
+ // Global app
14
+ const app = useAppContext();
13
15
  // Destruct
14
- const { batchSize = 6, children, defaultOrderBy, headerRenderer, autoLoad = headerRenderer == null, headerTitle, loadBatchSize, loadData, moreLabel = globalApp ? globalApp.get("more") + "..." : undefined, fieldTemplate, threshold, ...rest } = props;
16
+ const { batchSize = 6, children, defaultOrderBy, headerRenderer, autoLoad = headerRenderer == null, headerTitle, loadBatchSize, loadData, moreLabel = app?.get("more1"), fieldTemplate, threshold, ...rest } = props;
15
17
  // Refs
16
18
  const refs = React.useRef({
17
19
  queryPaging: {
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { globalApp } from "./app/ReactApp";
2
+ import { useAppContext } from "./app/ReactApp";
3
3
  import { OptionGroup } from "./OptionGroup";
4
4
  /**
5
5
  * OptionBool (yes/no)
@@ -7,8 +7,10 @@ import { OptionGroup } from "./OptionGroup";
7
7
  * @returns Component
8
8
  */
9
9
  export function OptionBool(props) {
10
+ // Global app
11
+ const app = useAppContext();
10
12
  // Options
11
- const options = globalApp?.getBools() ?? [];
13
+ const options = app?.getBools() ?? [];
12
14
  // Layout
13
15
  return (_jsx(OptionGroup, { options: options, row: true, multiple: false, ...props }));
14
16
  }
@@ -3,16 +3,18 @@ import { DataTypes } from "@etsoo/shared";
3
3
  import { LinearProgress, List, ListItem, ListItemButton, Typography } from "@mui/material";
4
4
  import React from "react";
5
5
  import { InputField } from "./InputField";
6
- import { globalApp } from "./app/ReactApp";
7
6
  import { VBox } from "./FlexBox";
7
+ import { useAppContext } from "./app/ReactApp";
8
8
  /**
9
9
  * Quick list
10
10
  * @param props Props
11
11
  * @returns Component
12
12
  */
13
13
  export function QuickList(props) {
14
+ // Global app
15
+ const app = useAppContext();
14
16
  // Destruct
15
- const { buttonProps = {}, label, inputProps, itemLabel = DataTypes.getListItemLabel, itemRenderer = (item) => itemLabel(item), itemProps, loadData, noMatchesLabel = globalApp?.get("noMatches"), gap = 1, height = "480px", onItemClick, ...rest } = props;
17
+ const { buttonProps = {}, label, inputProps, itemLabel = DataTypes.getListItemLabel, itemRenderer = (item) => itemLabel(item), itemProps, loadData, noMatchesLabel = app?.get("noMatches"), gap = 1, height = "480px", onItemClick, ...rest } = props;
16
18
  const { onClick, ...buttonRest } = buttonProps;
17
19
  // States
18
20
  const [loading, setLoading] = React.useState(false);
@@ -1,17 +1,19 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Utils } from "@etsoo/shared";
3
- import { globalApp } from "./app/ReactApp";
4
3
  import { SelectEx } from "./SelectEx";
4
+ import { useAppContext } from "./app/ReactApp";
5
5
  /**
6
6
  * SelectBool (yes/no)
7
7
  * @param props Props
8
8
  * @returns Component
9
9
  */
10
10
  export function SelectBool(props) {
11
+ // Global app
12
+ const app = useAppContext();
11
13
  // Destruct
12
14
  const { search = true, autoAddBlankItem = search, ...rest } = props;
13
15
  // Options
14
- const options = globalApp?.getBools() ?? [];
16
+ const options = app?.getBools() ?? [];
15
17
  if (autoAddBlankItem)
16
18
  Utils.addBlankItem(options);
17
19
  // Layout
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { NotificationMessageType } from "@etsoo/notificationbase";
3
3
  import { Utils } from "@etsoo/shared";
4
4
  import { Table, TableBody, TableCell, TableHead, TableRow } from "@mui/material";
5
- import { globalApp } from "./app/ReactApp";
5
+ import { useRequiredAppContext } from "./app/ReactApp";
6
6
  /**
7
7
  * Check obj is instance of AuditLineChangesDto
8
8
  * @param obj Input
@@ -31,11 +31,8 @@ const formatValue = (value, app) => {
31
31
  * @param equalCheck Equal check for properties
32
32
  */
33
33
  export const ShowDataComparison = (data, modelTitle, getLabel, equalCheck = true) => {
34
- // Validate app
35
- const app = globalApp;
36
- if (app == null) {
37
- throw new Error("No globalApp");
38
- }
34
+ // Global app
35
+ const app = useRequiredAppContext();
39
36
  // Labels
40
37
  const { dataComparison, field, newValue, oldValue } = app.getLabels("dataComparison", "field", "newValue", "oldValue");
41
38
  modelTitle ??= dataComparison;
@@ -2,15 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Stack, Typography } from "@mui/material";
3
3
  import Switch from "@mui/material/Switch";
4
4
  import React from "react";
5
- import { globalApp } from "./app/ReactApp";
5
+ import { useAppContext } from "./app/ReactApp";
6
6
  /**
7
7
  * Ant style switch
8
8
  * @param props Props
9
9
  * @returns Component
10
10
  */
11
11
  export function SwitchAnt(props) {
12
+ // Global app
13
+ const app = useAppContext();
12
14
  // Labels
13
- const { yes = "Yes", no = "No" } = globalApp?.getLabels("yes", "no") ?? {};
15
+ const { yes = "Yes", no = "No" } = app?.getLabels("yes", "no") ?? {};
14
16
  // Destruct
15
17
  const { activeColor, checked, defaultChecked, defaultValue, endLabel = yes, startLabel = no, onChange, value = "true", ...rest } = props;
16
18
  // Checked state
@@ -4,10 +4,12 @@ import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
4
4
  import CheckBoxIcon from "@mui/icons-material/CheckBox";
5
5
  import React from "react";
6
6
  import { InputField } from "./InputField";
7
- import { globalApp } from "./app/ReactApp";
7
+ import { useAppContext } from "./app/ReactApp";
8
8
  export function TagList(props) {
9
+ // Global app
10
+ const app = useAppContext();
9
11
  // Labels
10
- const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
12
+ const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
11
13
  const moreLabel = more + "...";
12
14
  // Destruct
13
15
  const { renderOption = (props, option, { selected }) => (_jsxs("li", { ...props, children: [_jsx(Checkbox, { icon: _jsx(CheckBoxOutlineBlankIcon, { fontSize: "small" }), checkedIcon: _jsx(CheckBoxIcon, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), option] })), renderTags = (value, getTagProps) => value.map((option, index) => (_jsx(Chip, { variant: "outlined", label: option, ...getTagProps({ index }) }))), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
@@ -4,11 +4,13 @@ import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
4
4
  import CheckBoxIcon from "@mui/icons-material/CheckBox";
5
5
  import React from "react";
6
6
  import { InputField } from "./InputField";
7
- import { globalApp } from "./app/ReactApp";
8
7
  import { DataTypes } from "@etsoo/shared";
8
+ import { useAppContext } from "./app/ReactApp";
9
9
  export function TagListPro(props) {
10
+ // Global app
11
+ const app = useAppContext();
10
12
  // Labels
11
- const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
13
+ const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
12
14
  const moreLabel = more + "...";
13
15
  const getLabel = (item) => DataTypes.getListItemLabel(item);
14
16
  // Destruct
@@ -49,7 +49,7 @@ export interface TextFieldExMethods {
49
49
  */
50
50
  setError(error: React.ReactNode): void;
51
51
  }
52
- export declare const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("@mui/material").OutlinedTextFieldProps & {
52
+ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("@mui/material").StandardTextFieldProps & {
53
53
  /**
54
54
  * Change delay (ms) to avoid repeatly dispatch onChange
55
55
  */
@@ -84,7 +84,7 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("
84
84
  * Show password button
85
85
  */
86
86
  showPassword?: boolean;
87
- }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
87
+ }, "ref"> | Omit<import("@mui/material").OutlinedTextFieldProps & {
88
88
  /**
89
89
  * Change delay (ms) to avoid repeatly dispatch onChange
90
90
  */
@@ -119,7 +119,7 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("
119
119
  * Show password button
120
120
  */
121
121
  showPassword?: boolean;
122
- }, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
122
+ }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
123
123
  /**
124
124
  * Change delay (ms) to avoid repeatly dispatch onChange
125
125
  */
@@ -5,10 +5,12 @@ import { MUGlobal } from "./MUGlobal";
5
5
  import { Clear, Visibility } from "@mui/icons-material";
6
6
  import { Keyboard } from "@etsoo/shared";
7
7
  import { ReactUtils, useCombinedRefs, useDelayedExecutor } from "@etsoo/react";
8
- import { globalApp } from "./app/ReactApp";
8
+ import { useAppContext } from "./app/ReactApp";
9
9
  export const TextFieldEx = React.forwardRef((props, ref) => {
10
+ // Global app
11
+ const app = useAppContext();
10
12
  // Labels
11
- const { showIt, clearInput } = globalApp?.getLabels("showIt", "clearInput") ?? {};
13
+ const { showIt, clearInput } = app?.getLabels("showIt", "clearInput") ?? {};
12
14
  // Destructure
13
15
  const { changeDelay, clearLabel = clearInput, error, fullWidth = true, helperText, InputLabelProps = {}, InputProps = {}, onChange, onClear, onKeyDown, onEnter, onVisibility, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal.textFieldVariant, ...rest } = props;
14
16
  // Shrink
@@ -3,17 +3,19 @@ import { ReactUtils, useDelayedExecutor } from "@etsoo/react";
3
3
  import { DataTypes } from "@etsoo/shared";
4
4
  import { Autocomplete } from "@mui/material";
5
5
  import React from "react";
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
  * Tiplist
11
11
  * @param props Props
12
12
  * @returns Component
13
13
  */
14
14
  export function Tiplist(props) {
15
+ // Global app
16
+ const app = useAppContext();
15
17
  // Labels
16
- const { noOptions, loading, more, open: openDefault } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
18
+ const { noOptions, loading, more1 = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more1", "open") ?? {};
17
19
  // Destruct
18
20
  const { search = false, idField = "id", idValue, inputAutoComplete = "off", inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputReset, inputVariant, label, loadData, defaultValue, value, maxItems = 16, width = search ? 160 : undefined, name, readOnly, onChange, onValueChange, openOnFocus = true, noOptionsText = noOptions, loadingText = loading, openText = openDefault, getOptionLabel, getOptionDisabled, sx = {}, minChars, ...rest } = props;
19
21
  if (width && sx)
@@ -197,7 +199,7 @@ export function Tiplist(props) {
197
199
  if (typeof item !== "object")
198
200
  return `${item}`;
199
201
  if (item[idField] === "n/a")
200
- return (more ?? "More") + "...";
202
+ return more1;
201
203
  return getOptionLabel
202
204
  ? getOptionLabel(item)
203
205
  : DataTypes.getObjectItemLabel(item);
@@ -4,15 +4,17 @@ import { DataTypes } from "@etsoo/shared";
4
4
  import { Autocomplete } from "@mui/material";
5
5
  import React from "react";
6
6
  import { InputField } from "./InputField";
7
- import { globalApp } from "./app/ReactApp";
7
+ import { useAppContext } from "./app/ReactApp";
8
8
  /**
9
9
  * TiplistPro
10
10
  * @param props Props
11
11
  * @returns Component
12
12
  */
13
13
  export function TiplistPro(props) {
14
+ // Global app
15
+ const app = useAppContext();
14
16
  // Labels
15
- const { noOptions, loading, more, open: openDefault } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
17
+ const { noOptions, loading, more, open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
16
18
  // Destruct
17
19
  const { label, loadData, defaultValue, value, idValue, maxItems = 16, width, name, inputOnChange, inputProps, inputReset, sx, openOnFocus = true, noOptionsText = noOptions, loadingText = loading, openText = openDefault, getOptionDisabled, getOptionLabel, onChange, onValueChange, minChars, ...rest } = props;
18
20
  if (width && sx)
@@ -1,16 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Avatar } from "@mui/material";
3
3
  import { BusinessUtils } from "@etsoo/appscript";
4
- import { globalApp } from "./app/ReactApp";
4
+ import { useAppContext } from "./app/ReactApp";
5
5
  /**
6
6
  * User avatar
7
7
  * @param props Props
8
8
  * @returns Component
9
9
  */
10
10
  export function UserAvatar(props) {
11
+ // Global app
12
+ const app = useAppContext();
11
13
  // Destruct
12
14
  const { src, title, formatTitle = (title) => {
13
- return BusinessUtils.formatAvatarTitle(title, 3, globalApp?.get("me") ?? "ME");
15
+ return BusinessUtils.formatAvatarTitle(title, 3, app?.get("me") ?? "ME");
14
16
  } } = props;
15
17
  // Format
16
18
  const fTitle = formatTitle(title);
@@ -1,11 +1,10 @@
1
1
  import { IAppSettings, IUser } from "@etsoo/appscript";
2
- import { IPageData } from "@etsoo/react";
3
2
  import { ReactApp } from "./ReactApp";
4
3
  /**
5
4
  * Common independent application
6
5
  * 通用独立程序
7
6
  */
8
- export declare abstract class CommonApp<U extends IUser = IUser, P extends IPageData = IPageData, S extends IAppSettings = IAppSettings> extends ReactApp<S, U, P> {
7
+ export declare abstract class CommonApp<U extends IUser = IUser, S extends IAppSettings = IAppSettings> extends ReactApp<S, U> {
9
8
  /**
10
9
  * Constructor
11
10
  * @param settings Settings
@@ -1,12 +1,7 @@
1
1
  import { ApiRefreshTokenDto, IApi, IApiPayload } from "@etsoo/appscript";
2
- import { ReactAppData, ReactAppType } from "./ReactApp";
2
+ import { ReactAppType } from "./ReactApp";
3
3
  import { IServiceUser, ServiceUserToken } from "./IServiceUser";
4
4
  import { IActionResult } from "@etsoo/shared";
5
- import React from "react";
6
- /**
7
- * Service application context
8
- */
9
- export declare const ServiceAppContext: React.Context<ReactAppData<IServiceApp> | null>;
10
5
  /**
11
6
  * Service application interface
12
7
  */
@@ -1,5 +1 @@
1
- import React from "react";
2
- /**
3
- * Service application context
4
- */
5
- export const ServiceAppContext = React.createContext(null);
1
+ export {};