@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
@@ -2,6 +2,7 @@ import { act, render } from "@testing-library/react";
2
2
  import {
3
3
  MUGlobal,
4
4
  MobileListItemRenderer,
5
+ ReactAppContext,
5
6
  ResponsivePage,
6
7
  SearchField
7
8
  } from "../src";
@@ -35,38 +36,40 @@ it("Render ResponsePage", async () => {
35
36
  act(() => {
36
37
  // Act
37
38
  render(
38
- <ResponsivePage<Data, typeof fieldTemplate>
39
- fields={[<SearchField label="Keyword" name="keyword" minChars={2} />]}
40
- height={200}
41
- itemSize={[118, MUGlobal.pagePaddings]}
42
- fieldTemplate={fieldTemplate}
43
- loadData={({ id }) =>
44
- Promise.resolve([
45
- { id: 1, name: "Name 1" },
46
- { id: 2, name: "Name 2" },
47
- { id: id ?? 0, name: "auto" }
48
- ])
49
- }
50
- columns={[
51
- { field: "id", header: "ID" },
52
- { field: "name", header: "Name" },
53
- {
54
- field: "deviceName",
55
- header: "Value",
56
- valueFormatter: ({ data }) => data?.deviceName ?? data?.name
39
+ <ReactAppContext.Provider value={null}>
40
+ <ResponsivePage<Data, typeof fieldTemplate>
41
+ fields={[<SearchField label="Keyword" name="keyword" minChars={2} />]}
42
+ height={200}
43
+ itemSize={[118, MUGlobal.pagePaddings]}
44
+ fieldTemplate={fieldTemplate}
45
+ loadData={({ id }) =>
46
+ Promise.resolve([
47
+ { id: 1, name: "Name 1" },
48
+ { id: 2, name: "Name 2" },
49
+ { id: id ?? 0, name: "auto" }
50
+ ])
57
51
  }
58
- ]}
59
- innerItemRenderer={(props) =>
60
- MobileListItemRenderer(props, (data) => {
61
- return [
62
- data.name,
63
- undefined,
64
- [],
65
- <React.Fragment></React.Fragment>
66
- ];
67
- })
68
- }
69
- />
52
+ columns={[
53
+ { field: "id", header: "ID" },
54
+ { field: "name", header: "Name" },
55
+ {
56
+ field: "deviceName",
57
+ header: "Value",
58
+ valueFormatter: ({ data }) => data?.deviceName ?? data?.name
59
+ }
60
+ ]}
61
+ innerItemRenderer={(props) =>
62
+ MobileListItemRenderer(props, (data) => {
63
+ return [
64
+ data.name,
65
+ undefined,
66
+ [],
67
+ <React.Fragment></React.Fragment>
68
+ ];
69
+ })
70
+ }
71
+ />
72
+ </ReactAppContext.Provider>
70
73
  );
71
74
 
72
75
  // Fast forward
@@ -8,9 +8,9 @@ exports.AddressSelector = AddressSelector;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const material_1 = require("@mui/material");
10
10
  const react_1 = __importDefault(require("react"));
11
- const ReactApp_1 = require("./app/ReactApp");
12
11
  const ComboBox_1 = require("./ComboBox");
13
12
  const Tiplist_1 = require("./Tiplist");
13
+ const ReactApp_1 = require("./app/ReactApp");
14
14
  /**
15
15
  * Address field
16
16
  */
@@ -26,8 +26,10 @@ var AddressField;
26
26
  * @param props Props
27
27
  */
28
28
  function AddressSelector(props) {
29
+ // Global app
30
+ const app = (0, ReactApp_1.useAppContext)();
29
31
  // Labels
30
- const { city: cityDefault = "City", district: districtDefault = "District", region: regionDefault = "Region", state: stateDefault = "State" } = ReactApp_1.globalApp?.getLabels("region", "state", "city", "district") ?? {};
32
+ const { city: cityDefault = "City", district: districtDefault = "District", region: regionDefault = "Region", state: stateDefault = "State" } = app?.getLabels("region", "state", "city", "district") ?? {};
31
33
  // Destruct
32
34
  const { api, city, cityLabel = cityDefault, district, districtLabel = districtDefault, error, favoredIds, helperText, hideRegion, label, onChange, region, regionLabel = regionDefault, required, search, state, stateLabel = stateDefault, breakPoints = { xs: 12, md: 6, lg: hideRegion ? 4 : 3 } } = props;
33
35
  const isMounted = react_1.default.useRef(true);
@@ -8,19 +8,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const shared_1 = require("@etsoo/shared");
9
9
  const material_1 = require("@mui/material");
10
10
  const react_1 = __importDefault(require("react"));
11
- const ReactApp_1 = require("./app/ReactApp");
12
11
  const ListMoreDisplay_1 = require("./ListMoreDisplay");
13
12
  const ShowDataComparison_1 = require("./ShowDataComparison");
14
- // Get label
15
- const getLabel = (key) => {
16
- return ReactApp_1.globalApp?.get(shared_1.Utils.formatInitial(key)) ?? key;
17
- };
18
- // Format date
19
- const formatDate = (date) => {
20
- if (ReactApp_1.globalApp)
21
- return ReactApp_1.globalApp.formatDate(date, "ds");
22
- return date.toUTCString();
23
- };
13
+ const ReactApp_1 = require("./app/ReactApp");
24
14
  /**
25
15
  * Audit display
26
16
  * @param props Props
@@ -29,6 +19,16 @@ const formatDate = (date) => {
29
19
  function AuditDisplay(props) {
30
20
  // Theme
31
21
  const theme = (0, material_1.useTheme)();
22
+ // Global app
23
+ const app = (0, ReactApp_1.useAppContext)();
24
+ // Get label
25
+ const getLabel = (key) => {
26
+ return app?.get(shared_1.Utils.formatInitial(key)) ?? key;
27
+ };
28
+ // Format date
29
+ const formatDate = (date) => {
30
+ return app?.formatDate(date, "ds") ?? date.toUTCString();
31
+ };
32
32
  // Title
33
33
  var title = getLabel("dataComparison");
34
34
  // Destruct
@@ -16,8 +16,10 @@ const ReactApp_1 = require("./app/ReactApp");
16
16
  * @returns Component
17
17
  */
18
18
  function BridgeCloseButton(props) {
19
+ // Global app
20
+ const app = (0, ReactApp_1.useAppContext)();
19
21
  // Destruct
20
- const { boxProps, onClick, title = ReactApp_1.globalApp?.get("close") ?? "Close", validate, ...rest } = props;
22
+ const { boxProps, onClick, title = app?.get("close") ?? "Close", validate, ...rest } = props;
21
23
  // Host
22
24
  const host = appscript_1.BridgeUtils.host;
23
25
  if (host == null ||
@@ -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
@@ -14,7 +14,7 @@ const react_1 = __importDefault(require("react"));
14
14
  */
15
15
  function ButtonPopover(props) {
16
16
  // Destruct
17
- const { button, children, loadData } = props;
17
+ const { button, children, loadData, position = "right" } = props;
18
18
  // States
19
19
  const [anchorEl, setAnchorEl] = react_1.default.useState(null);
20
20
  const [data, setData] = react_1.default.useState(null);
@@ -37,8 +37,9 @@ function ButtonPopover(props) {
37
37
  const handleClose = () => {
38
38
  setAnchorEl(null);
39
39
  };
40
+ const styles = position === "left" ? { left: 14 } : { right: 14 };
40
41
  // Layout
41
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [button((handler) => setAnchorEl(handler)), (0, jsx_runtime_1.jsx)(material_1.Popover, { anchorEl: anchorEl, open: open, onClose: handleClose, onClick: handleClose, transformOrigin: { horizontal: "right", vertical: "top" }, anchorOrigin: { horizontal: "right", vertical: "bottom" }, slotProps: {
42
+ return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [button((handler) => setAnchorEl(handler)), (0, jsx_runtime_1.jsx)(material_1.Popover, { anchorEl: anchorEl, open: open, onClose: handleClose, onClick: handleClose, transformOrigin: { horizontal: position, vertical: "top" }, anchorOrigin: { horizontal: position, vertical: "bottom" }, slotProps: {
42
43
  paper: {
43
44
  elevation: 0,
44
45
  sx: {
@@ -50,12 +51,12 @@ function ButtonPopover(props) {
50
51
  display: "block",
51
52
  position: "absolute",
52
53
  top: 0,
53
- right: 14,
54
54
  width: 10,
55
55
  height: 10,
56
56
  bgcolor: "background.paper",
57
57
  transform: "translateY(-50%) rotate(45deg)",
58
- zIndex: 0
58
+ zIndex: 0,
59
+ ...styles
59
60
  }
60
61
  }
61
62
  }
@@ -20,8 +20,10 @@ const ReactApp_1 = require("./app/ReactApp");
20
20
  * @returns Component
21
21
  */
22
22
  function ComboBox(props) {
23
+ // Global app
24
+ const app = (0, ReactApp_1.useAppContext)();
23
25
  // Labels
24
- const labels = ReactApp_1.globalApp?.getLabels("noOptions", "loading", "open", "add");
26
+ const labels = app?.getLabels("noOptions", "loading", "open", "add");
25
27
  // Destruct
26
28
  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;
27
29
  // Value input ref
@@ -23,8 +23,10 @@ const checkedIcon = (0, jsx_runtime_1.jsx)(CheckBox_1.default, { fontSize: "smal
23
23
  * @returns Component
24
24
  */
25
25
  function ComboBoxMultiple(props) {
26
+ // Global app
27
+ const app = (0, ReactApp_1.useAppContext)();
26
28
  // Labels
27
- const labels = ReactApp_1.globalApp?.getLabels("noOptions", "loading");
29
+ const labels = app?.getLabels("noOptions", "loading");
28
30
  // Destruct
29
31
  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 }) => ((0, jsx_runtime_1.jsxs)("li", { ...props, children: [(0, jsx_runtime_1.jsx)(material_1.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;
30
32
  // Value input ref
@@ -7,12 +7,14 @@ exports.ComboBoxPro = ComboBoxPro;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const material_1 = require("@mui/material");
9
9
  const react_1 = __importDefault(require("react"));
10
- const ReactApp_1 = require("./app/ReactApp");
11
10
  const InputField_1 = require("./InputField");
12
11
  const shared_1 = require("@etsoo/shared");
12
+ const ReactApp_1 = require("./app/ReactApp");
13
13
  function ComboBoxPro(props) {
14
+ // Global app
15
+ const app = (0, ReactApp_1.useAppContext)();
14
16
  // Labels
15
- const { noOptions, loading: loadingLabel, open: openDefault } = ReactApp_1.globalApp?.getLabels("noOptions", "loading", "open") ?? {};
17
+ const { noOptions, loading: loadingLabel, open: openDefault } = app?.getLabels("noOptions", "loading", "open") ?? {};
16
18
  // Destruct
17
19
  const { noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, options, openOnFocus = true, label, inputProps, name, value, idValue, onChange, onValueChange, ...rest } = props;
18
20
  const [open, setOpen] = react_1.default.useState(false);
@@ -14,8 +14,10 @@ const ReactApp_1 = require("./app/ReactApp");
14
14
  * @returns Component
15
15
  */
16
16
  function CultureDataTable(props) {
17
+ // Global app
18
+ const app = (0, ReactApp_1.useAppContext)();
17
19
  // Destruct
18
- const { cultures, cultureLabel = ReactApp_1.globalApp?.get("culture"), editable = true, titleLabel, hasDescription = false, descriptionLabel = ReactApp_1.globalApp?.get("description"), ...rest } = props;
20
+ const { cultures, cultureLabel = app?.get("culture"), editable = true, titleLabel, hasDescription = false, descriptionLabel = app?.get("description"), ...rest } = props;
19
21
  const getCultureLabel = react_1.default.useCallback((value) => cultures.find((c) => c.id == value.id)?.label ?? `${value.value}`, [cultures]);
20
22
  return ((0, jsx_runtime_1.jsx)(DataTable_1.DataTable, { columns: [
21
23
  {
@@ -13,19 +13,16 @@ const Check_1 = __importDefault(require("@mui/icons-material/Check"));
13
13
  const Start_1 = __importDefault(require("@mui/icons-material/Start"));
14
14
  const react_1 = __importDefault(require("react"));
15
15
  const FlexBox_1 = require("./FlexBox");
16
- const ReactApp_1 = require("./app/ReactApp");
17
16
  const MUGlobal_1 = require("./MUGlobal");
17
+ const ReactApp_1 = require("./app/ReactApp");
18
18
  /**
19
19
  * Data collecting steps component
20
20
  * @param props Props
21
21
  * @returns Component
22
22
  */
23
23
  function DataSteps(props) {
24
- // App
25
- const app = ReactApp_1.globalApp;
26
- if (app == null) {
27
- throw new Error("No globalApp");
28
- }
24
+ // Global app
25
+ const app = (0, ReactApp_1.useRequiredAppContext)();
29
26
  // Labels
30
27
  const labels = app.getLabels("close", "nextStep", "previousStep", "submit");
31
28
  // Destruct
@@ -14,10 +14,12 @@ const ReactApp_1 = require("./app/ReactApp");
14
14
  * @returns Component
15
15
  */
16
16
  function DataTable(props) {
17
+ // Global app
18
+ const app = (0, ReactApp_1.useAppContext)();
17
19
  // Destructor
18
20
  const { localeText = {}, onCellSelection, onProcessRowUpdateError = (error) => console.log("onProcessRowUpdateError", error), slotProps, ...rest } = props;
19
21
  // Labels
20
- const { noRows } = ReactApp_1.globalApp?.getLabels("noRows") ?? {};
22
+ const noRows = app?.get("noRows");
21
23
  if (noRows && !localeText.noRowsLabel)
22
24
  localeText.noRowsLabel = noRows;
23
25
  const [cellModesModel, setCellModesModel] = react_1.default.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
  */
@@ -8,27 +8,26 @@ const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const material_1 = require("@mui/material");
9
9
  const Typography_1 = __importDefault(require("@mui/material/Typography"));
10
10
  const react_1 = __importDefault(require("react"));
11
- const ReactApp_1 = require("./app/ReactApp");
12
11
  const InputField_1 = require("./InputField");
12
+ const ReactApp_1 = require("./app/ReactApp");
13
13
  /**
14
14
  * InputField with tips
15
15
  * @param props Props
16
16
  * @returns Component
17
17
  */
18
18
  function InputTipField(props) {
19
+ // Global app
20
+ const app = (0, ReactApp_1.useAppContext)();
19
21
  // State
20
22
  const [title, setTitle] = react_1.default.useState();
21
23
  const [anchorEl, setAnchorEl] = react_1.default.useState();
22
24
  const [data, setData] = react_1.default.useState();
23
25
  // Destruct
24
26
  const { labelProps = {
25
- title: ReactApp_1.globalApp?.get("clickForDetails"),
27
+ title: app?.get("clickForDetails"),
26
28
  sx: { color: (theme) => theme.palette.error.main, cursor: "pointer" }
27
- }, InputProps = {
28
- endAdornment: title ? ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", children: (0, jsx_runtime_1.jsx)(Typography_1.default, { onClick: (event) => {
29
- setAnchorEl(event.currentTarget);
30
- }, ...labelProps, children: title }) })) : undefined
31
- }, changeDelay = 480, onChangeDelay, loadData, itemLabel = (item) => item.label, renderItem = (item) => (0, jsx_runtime_1.jsx)(material_1.ListItem, { children: itemLabel(item) }, item.id), ...rest } = props;
29
+ }, changeDelay = 480, onChangeDelay, loadData, itemLabel = (item) => item.label, renderItem = (item) => (0, jsx_runtime_1.jsx)(material_1.ListItem, { children: itemLabel(item) }, item.id), slotProps = {}, ...rest } = props;
30
+ const { input, ...slotRests } = slotProps;
32
31
  const load = (value) => {
33
32
  if (value.length < 2) {
34
33
  setTitle(undefined);
@@ -46,5 +45,13 @@ function InputTipField(props) {
46
45
  load(event.target.value);
47
46
  if (onChangeDelay)
48
47
  onChangeDelay(event);
49
- }, InputProps: InputProps, ...rest })] }));
48
+ }, slotProps: {
49
+ input: {
50
+ endAdornment: title ? ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", children: (0, jsx_runtime_1.jsx)(Typography_1.default, { onClick: (event) => {
51
+ setAnchorEl(event.currentTarget);
52
+ }, ...labelProps, children: title }) })) : undefined,
53
+ ...input
54
+ },
55
+ ...slotRests
56
+ }, ...rest })] }));
50
57
  }
@@ -16,8 +16,10 @@ const ReactApp_1 = require("./app/ReactApp");
16
16
  * @returns Component
17
17
  */
18
18
  function ListMoreDisplay(props) {
19
+ // Global app
20
+ const app = (0, ReactApp_1.useAppContext)();
19
21
  // Destruct
20
- const { batchSize = 6, children, defaultOrderBy, headerRenderer, autoLoad = headerRenderer == null, headerTitle, loadBatchSize, loadData, moreLabel = ReactApp_1.globalApp ? ReactApp_1.globalApp.get("more") + "..." : undefined, fieldTemplate, threshold, ...rest } = props;
22
+ const { batchSize = 6, children, defaultOrderBy, headerRenderer, autoLoad = headerRenderer == null, headerTitle, loadBatchSize, loadData, moreLabel = app?.get("more1"), fieldTemplate, threshold, ...rest } = props;
21
23
  // Refs
22
24
  const refs = react_1.default.useRef({
23
25
  queryPaging: {
@@ -10,8 +10,10 @@ const OptionGroup_1 = require("./OptionGroup");
10
10
  * @returns Component
11
11
  */
12
12
  function OptionBool(props) {
13
+ // Global app
14
+ const app = (0, ReactApp_1.useAppContext)();
13
15
  // Options
14
- const options = ReactApp_1.globalApp?.getBools() ?? [];
16
+ const options = app?.getBools() ?? [];
15
17
  // Layout
16
18
  return ((0, jsx_runtime_1.jsx)(OptionGroup_1.OptionGroup, { options: options, row: true, multiple: false, ...props }));
17
19
  }
@@ -9,16 +9,18 @@ const shared_1 = require("@etsoo/shared");
9
9
  const material_1 = require("@mui/material");
10
10
  const react_1 = __importDefault(require("react"));
11
11
  const InputField_1 = require("./InputField");
12
- const ReactApp_1 = require("./app/ReactApp");
13
12
  const FlexBox_1 = require("./FlexBox");
13
+ const ReactApp_1 = require("./app/ReactApp");
14
14
  /**
15
15
  * Quick list
16
16
  * @param props Props
17
17
  * @returns Component
18
18
  */
19
19
  function QuickList(props) {
20
+ // Global app
21
+ const app = (0, ReactApp_1.useAppContext)();
20
22
  // Destruct
21
- const { buttonProps = {}, label, inputProps, itemLabel = shared_1.DataTypes.getListItemLabel, itemRenderer = (item) => itemLabel(item), itemProps, loadData, noMatchesLabel = ReactApp_1.globalApp?.get("noMatches"), gap = 1, height = "480px", onItemClick, ...rest } = props;
23
+ const { buttonProps = {}, label, inputProps, itemLabel = shared_1.DataTypes.getListItemLabel, itemRenderer = (item) => itemLabel(item), itemProps, loadData, noMatchesLabel = app?.get("noMatches"), gap = 1, height = "480px", onItemClick, ...rest } = props;
22
24
  const { onClick, ...buttonRest } = buttonProps;
23
25
  // States
24
26
  const [loading, setLoading] = react_1.default.useState(false);
@@ -3,18 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SelectBool = SelectBool;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const shared_1 = require("@etsoo/shared");
6
- const ReactApp_1 = require("./app/ReactApp");
7
6
  const SelectEx_1 = require("./SelectEx");
7
+ const ReactApp_1 = require("./app/ReactApp");
8
8
  /**
9
9
  * SelectBool (yes/no)
10
10
  * @param props Props
11
11
  * @returns Component
12
12
  */
13
13
  function SelectBool(props) {
14
+ // Global app
15
+ const app = (0, ReactApp_1.useAppContext)();
14
16
  // Destruct
15
17
  const { search = true, autoAddBlankItem = search, ...rest } = props;
16
18
  // Options
17
- const options = ReactApp_1.globalApp?.getBools() ?? [];
19
+ const options = app?.getBools() ?? [];
18
20
  if (autoAddBlankItem)
19
21
  shared_1.Utils.addBlankItem(options);
20
22
  // Layout
@@ -35,11 +35,8 @@ const formatValue = (value, app) => {
35
35
  * @param equalCheck Equal check for properties
36
36
  */
37
37
  const ShowDataComparison = (data, modelTitle, getLabel, equalCheck = true) => {
38
- // Validate app
39
- const app = ReactApp_1.globalApp;
40
- if (app == null) {
41
- throw new Error("No globalApp");
42
- }
38
+ // Global app
39
+ const app = (0, ReactApp_1.useRequiredAppContext)();
43
40
  // Labels
44
41
  const { dataComparison, field, newValue, oldValue } = app.getLabels("dataComparison", "field", "newValue", "oldValue");
45
42
  modelTitle ??= dataComparison;
@@ -15,8 +15,10 @@ const ReactApp_1 = require("./app/ReactApp");
15
15
  * @returns Component
16
16
  */
17
17
  function SwitchAnt(props) {
18
+ // Global app
19
+ const app = (0, ReactApp_1.useAppContext)();
18
20
  // Labels
19
- const { yes = "Yes", no = "No" } = ReactApp_1.globalApp?.getLabels("yes", "no") ?? {};
21
+ const { yes = "Yes", no = "No" } = app?.getLabels("yes", "no") ?? {};
20
22
  // Destruct
21
23
  const { activeColor, checked, defaultChecked, defaultValue, endLabel = yes, startLabel = no, onChange, value = "true", ...rest } = props;
22
24
  // Checked state
@@ -12,8 +12,10 @@ const react_1 = __importDefault(require("react"));
12
12
  const InputField_1 = require("./InputField");
13
13
  const ReactApp_1 = require("./app/ReactApp");
14
14
  function TagList(props) {
15
+ // Global app
16
+ const app = (0, ReactApp_1.useAppContext)();
15
17
  // Labels
16
- const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = ReactApp_1.globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
18
+ const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
17
19
  const moreLabel = more + "...";
18
20
  // Destruct
19
21
  const { renderOption = (props, option, { selected }) => ((0, jsx_runtime_1.jsxs)("li", { ...props, children: [(0, jsx_runtime_1.jsx)(material_1.Checkbox, { icon: (0, jsx_runtime_1.jsx)(CheckBoxOutlineBlank_1.default, { fontSize: "small" }), checkedIcon: (0, jsx_runtime_1.jsx)(CheckBox_1.default, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), option] })), renderTags = (value, getTagProps) => value.map((option, index) => ((0, jsx_runtime_1.jsx)(material_1.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;
@@ -10,11 +10,13 @@ const CheckBoxOutlineBlank_1 = __importDefault(require("@mui/icons-material/Chec
10
10
  const CheckBox_1 = __importDefault(require("@mui/icons-material/CheckBox"));
11
11
  const react_1 = __importDefault(require("react"));
12
12
  const InputField_1 = require("./InputField");
13
- const ReactApp_1 = require("./app/ReactApp");
14
13
  const shared_1 = require("@etsoo/shared");
14
+ const ReactApp_1 = require("./app/ReactApp");
15
15
  function TagListPro(props) {
16
+ // Global app
17
+ const app = (0, ReactApp_1.useAppContext)();
16
18
  // Labels
17
- const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = ReactApp_1.globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
19
+ const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
18
20
  const moreLabel = more + "...";
19
21
  const getLabel = (item) => shared_1.DataTypes.getListItemLabel(item);
20
22
  // 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
  */
@@ -13,8 +13,10 @@ const shared_1 = require("@etsoo/shared");
13
13
  const react_2 = require("@etsoo/react");
14
14
  const ReactApp_1 = require("./app/ReactApp");
15
15
  exports.TextFieldEx = react_1.default.forwardRef((props, ref) => {
16
+ // Global app
17
+ const app = (0, ReactApp_1.useAppContext)();
16
18
  // Labels
17
- const { showIt, clearInput } = ReactApp_1.globalApp?.getLabels("showIt", "clearInput") ?? {};
19
+ const { showIt, clearInput } = app?.getLabels("showIt", "clearInput") ?? {};
18
20
  // Destructure
19
21
  const { changeDelay, clearLabel = clearInput, error, fullWidth = true, helperText, InputLabelProps = {}, InputProps = {}, onChange, onClear, onKeyDown, onEnter, onVisibility, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal_1.MUGlobal.textFieldVariant, ...rest } = props;
20
22
  // Shrink
@@ -9,17 +9,19 @@ const react_1 = require("@etsoo/react");
9
9
  const shared_1 = require("@etsoo/shared");
10
10
  const material_1 = require("@mui/material");
11
11
  const react_2 = __importDefault(require("react"));
12
- const ReactApp_1 = require("./app/ReactApp");
13
12
  const SearchField_1 = require("./SearchField");
14
13
  const InputField_1 = require("./InputField");
14
+ const ReactApp_1 = require("./app/ReactApp");
15
15
  /**
16
16
  * Tiplist
17
17
  * @param props Props
18
18
  * @returns Component
19
19
  */
20
20
  function Tiplist(props) {
21
+ // Global app
22
+ const app = (0, ReactApp_1.useAppContext)();
21
23
  // Labels
22
- const { noOptions, loading, more, open: openDefault } = ReactApp_1.globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
24
+ const { noOptions, loading, more1 = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more1", "open") ?? {};
23
25
  // Destruct
24
26
  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;
25
27
  if (width && sx)
@@ -203,7 +205,7 @@ function Tiplist(props) {
203
205
  if (typeof item !== "object")
204
206
  return `${item}`;
205
207
  if (item[idField] === "n/a")
206
- return (more ?? "More") + "...";
208
+ return more1;
207
209
  return getOptionLabel
208
210
  ? getOptionLabel(item)
209
211
  : shared_1.DataTypes.getObjectItemLabel(item);
@@ -17,8 +17,10 @@ const ReactApp_1 = require("./app/ReactApp");
17
17
  * @returns Component
18
18
  */
19
19
  function TiplistPro(props) {
20
+ // Global app
21
+ const app = (0, ReactApp_1.useAppContext)();
20
22
  // Labels
21
- const { noOptions, loading, more, open: openDefault } = ReactApp_1.globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
23
+ const { noOptions, loading, more, open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
22
24
  // Destruct
23
25
  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;
24
26
  if (width && sx)
@@ -11,9 +11,11 @@ const ReactApp_1 = require("./app/ReactApp");
11
11
  * @returns Component
12
12
  */
13
13
  function UserAvatar(props) {
14
+ // Global app
15
+ const app = (0, ReactApp_1.useAppContext)();
14
16
  // Destruct
15
17
  const { src, title, formatTitle = (title) => {
16
- return appscript_1.BusinessUtils.formatAvatarTitle(title, 3, ReactApp_1.globalApp?.get("me") ?? "ME");
18
+ return appscript_1.BusinessUtils.formatAvatarTitle(title, 3, app?.get("me") ?? "ME");
17
19
  } } = props;
18
20
  // Format
19
21
  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