@etsoo/materialui 1.6.89 → 1.6.91

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.
@@ -12,10 +12,7 @@ import {
12
12
  } from "../src";
13
13
  import TextField from "@mui/material/TextField";
14
14
  import { screen } from "@testing-library/react";
15
-
16
- // Without it will popup error:
17
- // The current testing environment is not configured to support act
18
- (globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
15
+ import "@testing-library/jest-dom/vitest";
19
16
 
20
17
  // Root
21
18
  const root = document.body;
@@ -34,258 +31,257 @@ act(() => {
34
31
  // Notifier
35
32
  const notifier = NotifierMU.instance;
36
33
 
37
- // Timer mock
38
- // https://jestjs.io/docs/en/timer-mocks
39
- vi.useFakeTimers();
40
-
41
- test("Alert tests", async () => {
42
- // Click
43
- const handleClick = vi.fn();
44
-
45
- act(() => {
46
- // Add the notification
47
- notifier.alert("Alert message", handleClick);
34
+ describe("NotifierMU Tests", () => {
35
+ beforeEach(() => {
36
+ // Timer mock
37
+ // https://jestjs.io/docs/en/timer-mocks
38
+ vi.useFakeTimers();
48
39
  });
49
40
 
50
- // Button
51
- const button = root.getElementsByTagName("button");
52
-
53
- expect(button.length).toBe(1);
54
- expect(button[0].innerHTML).toContain("OK");
55
-
56
- await act(async () => {
57
- button[0].click();
41
+ afterEach(() => {
42
+ //vi.useRealTimers();
43
+ vi.runOnlyPendingTimers();
58
44
  });
59
45
 
60
- expect(handleClick).toHaveBeenCalled();
46
+ it("Alert tests", async () => {
47
+ // Click
48
+ const handleClick = vi.fn();
61
49
 
62
- // Fast forward
63
- vi.runOnlyPendingTimers();
64
- });
65
-
66
- test("Confirm tests", async () => {
67
- // Click
68
- const handleClick = vi.fn();
50
+ act(() => {
51
+ // Add the notification
52
+ notifier.alert("Alert message", handleClick);
53
+ });
69
54
 
70
- act(() => {
71
- // Add the notification
72
- notifier.confirm("Confirm message", undefined, handleClick);
73
- });
55
+ // Button
56
+ const button = root.getElementsByTagName("button");
74
57
 
75
- // Button
76
- const button = root.getElementsByTagName("button");
58
+ expect(button.length).toBe(1);
59
+ expect(button[0].innerHTML).toContain("OK");
77
60
 
78
- expect(button.length).toBe(2);
79
- expect(button[0].innerHTML).toContain("Cancel");
61
+ await act(async () => {
62
+ button[0].click();
63
+ });
80
64
 
81
- await act(async () => {
82
- button[0].click();
65
+ expect(handleClick).toHaveBeenCalled();
83
66
  });
84
67
 
85
- expect(handleClick).toHaveBeenCalled();
68
+ it("Confirm tests", async () => {
69
+ // Click
70
+ const handleClick = vi.fn();
86
71
 
87
- // Fast forward
88
- vi.runOnlyPendingTimers();
89
- });
72
+ act(() => {
73
+ // Add the notification
74
+ notifier.confirm("Confirm message", undefined, handleClick);
75
+ });
90
76
 
91
- test("Confirm tests without cancel button", async () => {
92
- // Click
93
- const handleClick = vi.fn();
77
+ // Button
78
+ const button = root.getElementsByTagName("button");
94
79
 
95
- act(() => {
96
- // Add the notification
97
- notifier.confirm("Confirm message", undefined, handleClick, {
98
- cancelButton: false
80
+ expect(button.length).toBe(2);
81
+ expect(button[0].innerHTML).toContain("Cancel");
82
+
83
+ await act(async () => {
84
+ button[0].click();
99
85
  });
86
+
87
+ expect(handleClick).toHaveBeenCalled();
100
88
  });
101
89
 
102
- // Button
103
- const button = root.getElementsByTagName("button");
90
+ it("Confirm tests without cancel button", async () => {
91
+ // Click
92
+ const handleClick = vi.fn();
104
93
 
105
- expect(button.length).toBe(1);
106
- expect(button[0].innerHTML).toContain("OK");
94
+ act(() => {
95
+ // Add the notification
96
+ notifier.confirm("Confirm message", undefined, handleClick, {
97
+ cancelButton: false
98
+ });
99
+ });
107
100
 
108
- await act(async () => {
109
- button[0].click();
110
- });
101
+ // Button
102
+ const button = root.getElementsByTagName("button");
111
103
 
112
- expect(handleClick).toHaveBeenCalled();
104
+ expect(button.length).toBe(1);
105
+ expect(button[0].innerHTML).toContain("OK");
113
106
 
114
- // Fast forward
115
- vi.runOnlyPendingTimers();
116
- });
107
+ await act(async () => {
108
+ button[0].click();
109
+ });
117
110
 
118
- test("Prompt tests", async () => {
119
- // Click
120
- const handleClick = vi.fn((result: boolean) => {
121
- expect(result).toBeTruthy();
111
+ expect(handleClick).toHaveBeenCalled();
122
112
  });
123
113
 
124
- act(() => {
125
- // Add the notification
126
- notifier.prompt<boolean>("Prompt message", handleClick, undefined, {
127
- type: "switch",
128
- inputProps: { required: false }
114
+ it("Prompt tests", async () => {
115
+ // Click
116
+ const handleClick = vi.fn((result: boolean) => {
117
+ expect(result).toBeTruthy();
129
118
  });
130
- });
131
119
 
132
- // Button
133
- const button = root.getElementsByTagName("button");
120
+ act(() => {
121
+ // Add the notification
122
+ notifier.prompt<boolean>("Prompt message", handleClick, undefined, {
123
+ type: "switch",
124
+ inputProps: { required: false }
125
+ });
126
+ });
127
+
128
+ // Button
129
+ const button = root.getElementsByTagName("button");
130
+
131
+ expect(button.length).toBe(2); // Switch will generate a button
132
+ expect(button[1].innerHTML).toContain("OK");
134
133
 
135
- expect(button.length).toBe(2); // Switch will generate a button
136
- expect(button[1].innerHTML).toContain("OK");
134
+ await act(async () => {
135
+ button[1].click();
136
+ });
137
137
 
138
- await act(async () => {
139
- button[1].click();
138
+ expect(handleClick).toHaveBeenCalled();
140
139
  });
141
140
 
142
- expect(handleClick).toHaveBeenCalled();
141
+ type DataType = {
142
+ name: string;
143
+ age: number;
144
+ };
143
145
 
144
- vi.runOnlyPendingTimers();
145
- });
146
+ function DataCollector(props: NotificationMUDataProps) {
147
+ const { mRef } = props;
148
+ const nameRef = React.createRef<HTMLInputElement>();
149
+ const ageRef = React.createRef<HTMLInputElement>();
146
150
 
147
- type DataType = {
148
- name: string;
149
- age: number;
150
- };
151
+ function getValue(): DataType | undefined {
152
+ if (!nameRef.current?.value) {
153
+ nameRef.current?.focus();
154
+ return undefined;
155
+ }
151
156
 
152
- function DataCollector(props: NotificationMUDataProps) {
153
- const { mRef } = props;
154
- const nameRef = React.createRef<HTMLInputElement>();
155
- const ageRef = React.createRef<HTMLInputElement>();
157
+ if (!ageRef.current?.valueAsNumber) {
158
+ ageRef.current?.focus();
159
+ return undefined;
160
+ }
156
161
 
157
- function getValue(): DataType | undefined {
158
- if (!nameRef.current?.value) {
159
- nameRef.current?.focus();
160
- return undefined;
162
+ return {
163
+ name: nameRef.current.value,
164
+ age: ageRef.current.valueAsNumber
165
+ };
161
166
  }
162
167
 
163
- if (!ageRef.current?.valueAsNumber) {
164
- ageRef.current?.focus();
165
- return undefined;
166
- }
168
+ React.useImperativeHandle(mRef, () => ({
169
+ getValue
170
+ }));
167
171
 
168
- return {
169
- name: nameRef.current.value,
170
- age: ageRef.current.valueAsNumber
171
- };
172
+ return (
173
+ <VBox>
174
+ <TextField name="name" required inputRef={nameRef} />
175
+ <TextField name="age" type="number" required inputRef={ageRef} />
176
+ </VBox>
177
+ );
172
178
  }
173
179
 
174
- React.useImperativeHandle(mRef, () => ({
175
- getValue
176
- }));
177
-
178
- return (
179
- <VBox>
180
- <TextField name="name" required inputRef={nameRef} />
181
- <TextField name="age" type="number" required inputRef={ageRef} />
182
- </VBox>
183
- );
184
- }
185
-
186
- test("Data tests", async () => {
187
- const name = "John Doe";
188
- const age = 30;
189
-
190
- act(() => {
191
- // Add the notification
192
- notifier.data<DataType>(
193
- <DataCollector mRef={React.createRef<NotificationMUDataMethods>()} />,
194
- (result) => {
195
- expect(result).toEqual({ name, age });
196
- return true;
197
- },
198
- "Data Modal"
199
- );
200
- });
180
+ it("Data tests", async () => {
181
+ const name = "John Doe";
182
+ const age = 30;
183
+
184
+ act(() => {
185
+ // Add the notification
186
+ notifier.data<DataType>(
187
+ <DataCollector mRef={React.createRef<NotificationMUDataMethods>()} />,
188
+ (result) => {
189
+ expect(result).toEqual({ name, age });
190
+ return true;
191
+ },
192
+ "Data Modal"
193
+ );
194
+ });
201
195
 
202
- const button = screen.getByText("OK");
203
- expect(button).toBeInTheDocument();
196
+ const button = screen.getByText("OK");
197
+ expect(button).toBeInTheDocument();
204
198
 
205
- const nameInput = root.querySelector<HTMLInputElement>('input[name="name"]');
206
- expect(nameInput).not.toBeNull();
207
- nameInput!.value = name;
199
+ const nameInput =
200
+ root.querySelector<HTMLInputElement>('input[name="name"]');
201
+ expect(nameInput).not.toBeNull();
202
+ nameInput!.value = name;
208
203
 
209
- const ageInput = root.querySelector<HTMLInputElement>('input[name="age"]');
210
- expect(ageInput).not.toBeNull();
211
- ageInput!.value = age.toString();
204
+ const ageInput = root.querySelector<HTMLInputElement>('input[name="age"]');
205
+ expect(ageInput).not.toBeNull();
206
+ ageInput!.value = age.toString();
212
207
 
213
- await act(async () => {
214
- button.click();
208
+ await act(async () => {
209
+ button.click();
210
+ });
215
211
  });
216
- });
217
212
 
218
- test("Prompt tests with form submit", async () => {
219
- // Click
220
- const handleClick = vi.fn((result: boolean) => {
221
- expect(result).toBeTruthy();
222
- });
213
+ it("Prompt tests with form submit", async () => {
214
+ // Click
215
+ const handleClick = vi.fn((result: boolean) => {
216
+ expect(result).toBeTruthy();
217
+ });
223
218
 
224
- act(() => {
225
- // Add the notification
226
- notifier.prompt<boolean>("Prompt message", handleClick, undefined, {
227
- type: "switch",
228
- inputProps: { required: false }
219
+ act(() => {
220
+ // Add the notification
221
+ notifier.prompt<boolean>("Prompt message", handleClick, undefined, {
222
+ type: "switch",
223
+ inputProps: { required: false }
224
+ });
229
225
  });
230
- });
231
226
 
232
- const button = screen.getByText("OK");
233
- expect(button).toBeInTheDocument();
227
+ const button = screen.getByText("OK");
228
+ expect(button).toBeInTheDocument();
229
+
230
+ await act(async () => {
231
+ button.click();
232
+ });
234
233
 
235
- await act(async () => {
236
- button.click();
234
+ expect(handleClick).toHaveBeenCalled();
237
235
  });
238
236
 
239
- expect(handleClick).toHaveBeenCalled();
240
- });
237
+ it("Message tests", () => {
238
+ // Callback
239
+ const callback = vi.fn();
240
+
241
+ let n: INotification<React.ReactNode, any> | undefined;
242
+ act(() => {
243
+ // Add the notification
244
+ n = notifier.message(
245
+ NotificationMessageType.Danger,
246
+ "Error Message",
247
+ undefined,
248
+ {
249
+ callback
250
+ }
251
+ );
252
+ });
241
253
 
242
- test("Message tests", () => {
243
- // Callback
244
- const callback = vi.fn();
245
-
246
- let n: INotification<React.ReactNode, any> | undefined;
247
- act(() => {
248
- // Add the notification
249
- n = notifier.message(
250
- NotificationMessageType.Danger,
251
- "Error Message",
252
- undefined,
253
- {
254
- callback
255
- }
256
- );
257
- });
254
+ expect(n?.timespan).toBe(5);
258
255
 
259
- expect(n?.timespan).toBe(5);
256
+ expect(root.innerHTML).toContain("Error Message");
260
257
 
261
- expect(root.innerHTML).toContain("Error Message");
258
+ act(() => {
259
+ // Here is the bug need further study...
260
+ n?.dismiss();
262
261
 
263
- act(() => {
264
- // Here is the bug need further study...
265
- n?.dismiss();
262
+ // Fast forward
263
+ vi.runOnlyPendingTimers();
264
+ });
266
265
 
267
- // Fast forward
268
- vi.runOnlyPendingTimers();
266
+ expect(root.innerHTML).not.toContain("Error Message");
267
+ expect(callback).toHaveBeenCalled();
269
268
  });
270
269
 
271
- expect(root.innerHTML).not.toContain("Error Message");
272
- expect(callback).toHaveBeenCalled();
273
- });
270
+ it("Loading tests", () => {
271
+ act(() => {
272
+ // Add the notification
273
+ notifier.showLoading("Loading");
274
+ });
274
275
 
275
- test("Loading tests", () => {
276
- act(() => {
277
- // Add the notification
278
- notifier.showLoading("Loading");
279
- });
276
+ expect(root.innerHTML).toContain("Loading");
280
277
 
281
- expect(root.innerHTML).toContain("Loading");
278
+ act(() => {
279
+ notifier.hideLoading();
282
280
 
283
- act(() => {
284
- notifier.hideLoading();
281
+ // Fast forward
282
+ vi.runOnlyPendingTimers();
283
+ });
285
284
 
286
- // Fast forward
287
- vi.runOnlyPendingTimers();
285
+ expect(root.innerHTML).not.toContain("Loading");
288
286
  });
289
-
290
- expect(root.innerHTML).not.toContain("Loading");
291
287
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ES2022",
3
+ "target": "ES2025",
4
+ "module": "esnext",
5
5
  "moduleResolution": "bundler",
6
6
  "allowJs": false,
7
7
  "skipLibCheck": false,
@@ -11,6 +11,7 @@ const react_2 = require("@etsoo/react");
11
11
  const InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
12
12
  const IconButton_1 = __importDefault(require("@mui/material/IconButton"));
13
13
  const Edit_1 = __importDefault(require("@mui/icons-material/Edit"));
14
+ const ReactApp_1 = require("./app/ReactApp");
14
15
  /**
15
16
  * HTML Description component base
16
17
  * HTML 描述组件属性基础
@@ -18,8 +19,10 @@ const Edit_1 = __importDefault(require("@mui/icons-material/Edit"));
18
19
  * @returns Component
19
20
  */
20
21
  function HtmlDescriptionBase(props) {
22
+ // Global app
23
+ const app = (0, ReactApp_1.useAppContext)();
21
24
  // Destruct
22
- const { fullWidth = true, inputRef, label, maxLength = 1280, name = "description", onEdit, rows = 3, ...rest } = props;
25
+ const { fullWidth = true, inputRef, label = app?.get("description"), maxLength = 1280, name = "description", onEdit, rows = 3, ...rest } = props;
23
26
  const localRef = react_1.default.useRef(null);
24
27
  const refs = (0, react_2.useCombinedRefs)(localRef, inputRef);
25
28
  return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { fullWidth: fullWidth, inputRef: refs, name: name, slotProps: {
@@ -110,7 +110,7 @@ class NotificationMU extends react_2.NotificationReact {
110
110
  return true;
111
111
  };
112
112
  const base = () => primaryButton && ((0, jsx_runtime_1.jsx)(LoadingButton_1.LoadingButton, { ...setupProps, onClick: callback, autoFocus: true, ...primaryButtonProps, children: okLabel }));
113
- return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [icon, (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), inputs] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
113
+ return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, disableRestoreFocus: true, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [icon, (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), inputs] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
114
114
  }
115
115
  // Create confirm
116
116
  createConfirm(_props, className) {
@@ -124,7 +124,7 @@ class NotificationMU extends react_2.NotificationReact {
124
124
  return true;
125
125
  };
126
126
  const base = () => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [cancelButton && ((0, jsx_runtime_1.jsx)(LoadingButton_1.LoadingButton, { color: "secondary", onClick: async (event) => await callback(event, false), children: cancelLabel })), primaryButton && ((0, jsx_runtime_1.jsx)(LoadingButton_1.LoadingButton, { color: "primary", onClick: async (event) => await callback(event, true), autoFocus: true, ...primaryButtonProps, children: okLabel }))] }));
127
- return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Help_1.default, { color: "action" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), inputs] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
127
+ return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, disableRestoreFocus: true, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Help_1.default, { color: "action" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), inputs] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
128
128
  }
129
129
  createMessageColor() {
130
130
  if (this.type === notificationbase_1.NotificationMessageType.Danger)
@@ -190,7 +190,7 @@ class NotificationMU extends react_2.NotificationReact {
190
190
  this.onReturn(undefined);
191
191
  this.dismiss();
192
192
  }, children: cancelLabel })), primaryButton && ((0, jsx_runtime_1.jsx)(LoadingButton_1.LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, name: "okButton", ...primaryButtonProps, children: okLabel }))] }));
193
- return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Info_1.default, { color: "primary" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { ...inputProps, children: [content, (0, jsx_runtime_1.jsx)(Typography_1.default, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
193
+ return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", disableRestoreFocus: true, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Info_1.default, { color: "primary" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { ...inputProps, children: [content, (0, jsx_runtime_1.jsx)(Typography_1.default, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
194
194
  }
195
195
  // Create prompt
196
196
  createPrompt(_props, className) {
@@ -277,7 +277,7 @@ class NotificationMU extends react_2.NotificationReact {
277
277
  overflow: "hidden"
278
278
  }
279
279
  }
280
- }, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Info_1.default, { color: "primary" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { dividers: true, children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), localInputs, (0, jsx_runtime_1.jsx)(Typography_1.default, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
280
+ }, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", disableRestoreFocus: true, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Info_1.default, { color: "primary" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { dividers: true, children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), localInputs, (0, jsx_runtime_1.jsx)(Typography_1.default, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
281
281
  }
282
282
  createPopup(_props, className) {
283
283
  // Destruct
@@ -22,9 +22,7 @@ var SVGUtils;
22
22
  function createIcon(icon, filterColor) {
23
23
  if (!icon)
24
24
  return undefined;
25
- if (icon.startsWith("/"))
26
- icon = "https://localhost:9002/" + icon;
27
- else if (icon.startsWith("<path "))
25
+ if (icon.startsWith("<path "))
28
26
  icon = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">${icon}</svg>`;
29
27
  if (icon.startsWith("<svg "))
30
28
  icon = `data:image/svg+xml;utf8,${encodeURIComponent(icon)}`;
@@ -5,6 +5,7 @@ import { useCombinedRefs } from "@etsoo/react";
5
5
  import InputAdornment from "@mui/material/InputAdornment";
6
6
  import IconButton from "@mui/material/IconButton";
7
7
  import EditIcon from "@mui/icons-material/Edit";
8
+ import { useAppContext } from "./app/ReactApp";
8
9
  /**
9
10
  * HTML Description component base
10
11
  * HTML 描述组件属性基础
@@ -12,8 +13,10 @@ import EditIcon from "@mui/icons-material/Edit";
12
13
  * @returns Component
13
14
  */
14
15
  export function HtmlDescriptionBase(props) {
16
+ // Global app
17
+ const app = useAppContext();
15
18
  // Destruct
16
- const { fullWidth = true, inputRef, label, maxLength = 1280, name = "description", onEdit, rows = 3, ...rest } = props;
19
+ const { fullWidth = true, inputRef, label = app?.get("description"), maxLength = 1280, name = "description", onEdit, rows = 3, ...rest } = props;
17
20
  const localRef = React.useRef(null);
18
21
  const refs = useCombinedRefs(localRef, inputRef);
19
22
  return (_jsx(InputField, { fullWidth: fullWidth, inputRef: refs, name: name, slotProps: {
@@ -104,7 +104,7 @@ export class NotificationMU extends NotificationReact {
104
104
  return true;
105
105
  };
106
106
  const base = () => primaryButton && (_jsx(LoadingButton, { ...setupProps, onClick: callback, autoFocus: true, ...primaryButtonProps, children: okLabel }));
107
- return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [icon, _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), inputs] }), _jsx(DialogActions, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
107
+ return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, disableRestoreFocus: true, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [icon, _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), inputs] }), _jsx(DialogActions, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
108
108
  }
109
109
  // Create confirm
110
110
  createConfirm(_props, className) {
@@ -118,7 +118,7 @@ export class NotificationMU extends NotificationReact {
118
118
  return true;
119
119
  };
120
120
  const base = () => (_jsxs(React.Fragment, { children: [cancelButton && (_jsx(LoadingButton, { color: "secondary", onClick: async (event) => await callback(event, false), children: cancelLabel })), primaryButton && (_jsx(LoadingButton, { color: "primary", onClick: async (event) => await callback(event, true), autoFocus: true, ...primaryButtonProps, children: okLabel }))] }));
121
- return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(HelpIcon, { color: "action" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), inputs] }), _jsx(DialogActions, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
121
+ return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, disableRestoreFocus: true, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(HelpIcon, { color: "action" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), inputs] }), _jsx(DialogActions, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
122
122
  }
123
123
  createMessageColor() {
124
124
  if (this.type === NotificationMessageType.Danger)
@@ -184,7 +184,7 @@ export class NotificationMU extends NotificationReact {
184
184
  this.onReturn(undefined);
185
185
  this.dismiss();
186
186
  }, children: cancelLabel })), primaryButton && (_jsx(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, name: "okButton", ...primaryButtonProps, children: okLabel }))] }));
187
- return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(InfoIcon, { color: "primary" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { ...inputProps, children: [content, _jsx(Typography, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), _jsx(DialogActions, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
187
+ return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", disableRestoreFocus: true, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(InfoIcon, { color: "primary" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { ...inputProps, children: [content, _jsx(Typography, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), _jsx(DialogActions, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
188
188
  }
189
189
  // Create prompt
190
190
  createPrompt(_props, className) {
@@ -271,7 +271,7 @@ export class NotificationMU extends NotificationReact {
271
271
  overflow: "hidden"
272
272
  }
273
273
  }
274
- }, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(InfoIcon, { color: "primary" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { dividers: true, children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), localInputs, _jsx(Typography, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), _jsx(DialogActions, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
274
+ }, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", disableRestoreFocus: true, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(InfoIcon, { color: "primary" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { dividers: true, children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), localInputs, _jsx(Typography, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), _jsx(DialogActions, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
275
275
  }
276
276
  createPopup(_props, className) {
277
277
  // Destruct
@@ -16,9 +16,7 @@ export var SVGUtils;
16
16
  function createIcon(icon, filterColor) {
17
17
  if (!icon)
18
18
  return undefined;
19
- if (icon.startsWith("/"))
20
- icon = "https://localhost:9002/" + icon;
21
- else if (icon.startsWith("<path "))
19
+ if (icon.startsWith("<path "))
22
20
  icon = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">${icon}</svg>`;
23
21
  if (icon.startsWith("<svg "))
24
22
  icon = `data:image/svg+xml;utf8,${encodeURIComponent(icon)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.6.89",
3
+ "version": "1.6.91",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,13 +40,13 @@
40
40
  "@dnd-kit/react": "^0.5.0",
41
41
  "@emotion/react": "^11.14.0",
42
42
  "@emotion/styled": "^11.14.1",
43
- "@etsoo/appscript": "^1.6.78",
43
+ "@etsoo/appscript": "^1.6.79",
44
44
  "@etsoo/notificationbase": "^1.1.75",
45
- "@etsoo/react": "^1.9.4",
45
+ "@etsoo/react": "^1.9.5",
46
46
  "@etsoo/shared": "^1.2.91",
47
47
  "@mui/icons-material": "^9.4.0",
48
48
  "@mui/material": "^9.4.0",
49
- "@mui/x-data-grid": "^9.13.0",
49
+ "@mui/x-data-grid": "^9.14.0",
50
50
  "chart.js": "^4.5.1",
51
51
  "chartjs-plugin-datalabels": "^2.2.0",
52
52
  "css-filter-converter": "^1.0.115",
@@ -58,7 +58,7 @@
58
58
  "react-avatar-editor": "^15.1.0",
59
59
  "react-chartjs-2": "^5.3.1",
60
60
  "react-dom": "^19.3.0",
61
- "react-draggable": "^4.7.1",
61
+ "react-draggable": "^4.7.2",
62
62
  "react-imask": "7.6.1",
63
63
  "signature_pad": "^5.1.4"
64
64
  },
@@ -80,7 +80,5 @@
80
80
  "typescript": "^7.0.2",
81
81
  "vitest": "^5.0.0"
82
82
  },
83
- "allowScripts": {
84
- "core-js-pure@3.49.0": true
85
- }
83
+ "allowScripts": {}
86
84
  }
@@ -4,6 +4,7 @@ import { useCombinedRefs } from "@etsoo/react";
4
4
  import InputAdornment from "@mui/material/InputAdornment";
5
5
  import IconButton from "@mui/material/IconButton";
6
6
  import EditIcon from "@mui/icons-material/Edit";
7
+ import { useAppContext } from "./app/ReactApp";
7
8
 
8
9
  /**
9
10
  * HTML Description component base props
@@ -30,11 +31,14 @@ export type HtmlDescriptionBaseProps = Omit<InputFieldProps, "multiline"> & {
30
31
  * @returns Component
31
32
  */
32
33
  export function HtmlDescriptionBase(props: HtmlDescriptionBaseProps) {
34
+ // Global app
35
+ const app = useAppContext();
36
+
33
37
  // Destruct
34
38
  const {
35
39
  fullWidth = true,
36
40
  inputRef,
37
- label,
41
+ label = app?.get("description"),
38
42
  maxLength = 1280,
39
43
  name = "description",
40
44
  onEdit,
@@ -177,6 +177,7 @@ export class NotificationMU extends NotificationReact {
177
177
  fullWidth={fullWidth}
178
178
  maxWidth={maxWidth}
179
179
  fullScreen={fullScreen}
180
+ disableRestoreFocus
180
181
  {...options}
181
182
  >
182
183
  <IconDialogTitle
@@ -273,6 +274,7 @@ export class NotificationMU extends NotificationReact {
273
274
  fullWidth={fullWidth}
274
275
  maxWidth={maxWidth}
275
276
  fullScreen={fullScreen}
277
+ disableRestoreFocus
276
278
  {...options}
277
279
  >
278
280
  <IconDialogTitle
@@ -453,6 +455,7 @@ export class NotificationMU extends NotificationReact {
453
455
  maxWidth={maxWidth}
454
456
  fullScreen={fullScreen}
455
457
  scroll="paper"
458
+ disableRestoreFocus
456
459
  {...options}
457
460
  >
458
461
  <IconDialogTitle
@@ -656,6 +659,7 @@ export class NotificationMU extends NotificationReact {
656
659
  maxWidth={maxWidth}
657
660
  fullScreen={fullScreen}
658
661
  scroll="paper"
662
+ disableRestoreFocus
659
663
  {...options}
660
664
  >
661
665
  <IconDialogTitle
@@ -18,8 +18,7 @@ export namespace SVGUtils {
18
18
  ) {
19
19
  if (!icon) return undefined;
20
20
 
21
- if (icon.startsWith("/")) icon = "https://localhost:9002/" + icon;
22
- else if (icon.startsWith("<path "))
21
+ if (icon.startsWith("<path "))
23
22
  icon = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">${icon}</svg>`;
24
23
 
25
24
  if (icon.startsWith("<svg "))