@etsoo/materialui 1.3.42 → 1.3.44
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.
- package/__tests__/NotifierMUTests.tsx +140 -140
- package/__tests__/ResponsePage.tsx +48 -0
- package/__tests__/SelectEx.tsx +2 -2
- package/__tests__/SwitchAnt.tsx +17 -17
- package/__tests__/tsconfig.json +17 -17
- package/lib/AddresSelector.js +1 -2
- package/lib/AuditDisplay.js +2 -3
- package/lib/BridgeCloseButton.js +1 -2
- package/lib/ComboBox.js +5 -5
- package/lib/ComboBoxMultiple.js +7 -8
- package/lib/ComboBoxPro.js +1 -2
- package/lib/CultureDataTable.js +2 -2
- package/lib/DataGridEx.d.ts +2 -3
- package/lib/DataGridEx.js +12 -14
- package/lib/DataGridRenderers.js +6 -6
- package/lib/DataSteps.js +1 -2
- package/lib/DataTable.js +1 -2
- package/lib/DialogButton.js +2 -3
- package/lib/DnDList.js +1 -1
- package/lib/EmailInput.js +1 -2
- package/lib/FileUploadButton.js +1 -1
- package/lib/GridDataFormat.js +5 -5
- package/lib/GridUtils.js +1 -2
- package/lib/HiSelector.js +1 -1
- package/lib/HiSelectorTL.js +1 -1
- package/lib/InputField.js +4 -5
- package/lib/InputTipField.js +1 -1
- package/lib/ItemList.js +2 -3
- package/lib/ListChooser.js +4 -5
- package/lib/LoadingButton.js +1 -2
- package/lib/MaskInput.js +2 -3
- package/lib/NotifierMU.js +14 -19
- package/lib/OptionBool.js +1 -2
- package/lib/OptionGroup.js +3 -4
- package/lib/OptionGroupFlag.js +1 -1
- package/lib/QuickList.js +2 -2
- package/lib/ResponsibleContainer.d.ts +3 -3
- package/lib/ResponsibleContainer.js +3 -3
- package/lib/ScrollerListEx.d.ts +6 -7
- package/lib/ScrollerListEx.js +30 -36
- package/lib/SearchField.js +3 -4
- package/lib/SelectBool.js +1 -2
- package/lib/SelectEx.js +6 -8
- package/lib/ShowDataComparison.js +3 -4
- package/lib/Switch.js +1 -2
- package/lib/SwitchAnt.js +6 -7
- package/lib/TableEx.js +5 -7
- package/lib/TagList.js +3 -5
- package/lib/TagListPro.js +3 -5
- package/lib/TextFieldEx.js +2 -2
- package/lib/Tiplist.js +6 -8
- package/lib/TiplistPro.js +9 -10
- package/lib/TooltipClick.js +2 -2
- package/lib/TwoFieldInput.js +1 -1
- package/lib/UserAvatar.js +1 -2
- package/lib/UserAvatarEditor.js +4 -6
- package/lib/app/CommonApp.js +1 -1
- package/lib/app/ReactApp.js +4 -6
- package/lib/app/ServiceApp.js +5 -7
- package/lib/pages/DataGridPage.d.ts +2 -2
- package/lib/pages/DataGridPage.js +2 -3
- package/lib/pages/DataGridPageProps.d.ts +2 -2
- package/lib/pages/FixedListPage.d.ts +2 -2
- package/lib/pages/FixedListPage.js +2 -3
- package/lib/pages/LeftDrawer.js +2 -3
- package/lib/pages/ListPage.d.ts +2 -2
- package/lib/pages/ListPage.js +2 -3
- package/lib/pages/ListPageProps.d.ts +1 -1
- package/lib/pages/ResponsivePage.d.ts +2 -2
- package/lib/pages/ResponsivePage.js +1 -2
- package/lib/pages/ResponsivePageProps.d.ts +2 -2
- package/lib/pages/TablePage.js +3 -5
- package/lib/pages/UserMenu.js +1 -2
- package/lib/pages/ViewPage.js +6 -7
- package/package.json +14 -12
- package/src/DataGridEx.tsx +6 -12
- package/src/ResponsibleContainer.tsx +7 -9
- package/src/ScrollerListEx.tsx +301 -311
- package/src/pages/DataGridPage.tsx +4 -5
- package/src/pages/DataGridPageProps.ts +3 -4
- package/src/pages/FixedListPage.tsx +4 -5
- package/src/pages/ListPage.tsx +4 -5
- package/src/pages/ListPageProps.ts +2 -3
- package/src/pages/ResponsivePage.tsx +4 -5
- package/src/pages/ResponsivePageProps.ts +3 -4
- package/tsconfig.json +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import React from
|
|
6
|
-
import { createRoot } from
|
|
7
|
-
import { act } from
|
|
8
|
-
import { NotifierMU } from
|
|
2
|
+
INotification,
|
|
3
|
+
NotificationMessageType
|
|
4
|
+
} from "@etsoo/notificationbase";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { createRoot } from "react-dom/client";
|
|
7
|
+
import { act } from "react-dom/test-utils";
|
|
8
|
+
import { NotifierMU } from "../src";
|
|
9
9
|
|
|
10
10
|
// Without it will popup error:
|
|
11
11
|
// The current testing environment is not configured to support act
|
|
@@ -13,7 +13,7 @@ import { NotifierMU } from '../src';
|
|
|
13
13
|
|
|
14
14
|
// Root
|
|
15
15
|
const root = document.body;
|
|
16
|
-
const container: HTMLElement = document.createElement(
|
|
16
|
+
const container: HTMLElement = document.createElement("div");
|
|
17
17
|
root.append(container);
|
|
18
18
|
|
|
19
19
|
// The state provider
|
|
@@ -21,8 +21,8 @@ const Provider = NotifierMU.setup();
|
|
|
21
21
|
const reactRoot = createRoot(container);
|
|
22
22
|
|
|
23
23
|
act(() => {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// Concorrent renderer needs act block
|
|
25
|
+
reactRoot.render(<Provider />);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// Notifier
|
|
@@ -32,186 +32,186 @@ const notifier = NotifierMU.instance;
|
|
|
32
32
|
// https://jestjs.io/docs/en/timer-mocks
|
|
33
33
|
jest.useFakeTimers();
|
|
34
34
|
|
|
35
|
-
test(
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
test("Alert tests", async () => {
|
|
36
|
+
// Click
|
|
37
|
+
const handleClick = jest.fn();
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
act(() => {
|
|
40
|
+
// Add the notification
|
|
41
|
+
notifier.alert("Alert message", handleClick);
|
|
42
|
+
});
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// Button
|
|
45
|
+
const button = root.getElementsByTagName("button");
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
expect(button.length).toBe(1);
|
|
48
|
+
expect(button[0].innerHTML).toContain("OK");
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
await act(async () => {
|
|
51
|
+
button[0].click();
|
|
52
|
+
});
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
expect(handleClick).toHaveBeenCalled();
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// Fast forward
|
|
57
|
+
jest.runOnlyPendingTimers();
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
test(
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
test("Confirm tests", async () => {
|
|
61
|
+
// Click
|
|
62
|
+
const handleClick = jest.fn();
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
act(() => {
|
|
65
|
+
// Add the notification
|
|
66
|
+
notifier.confirm("Confirm message", undefined, handleClick);
|
|
67
|
+
});
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// Button
|
|
70
|
+
const button = root.getElementsByTagName("button");
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
expect(button.length).toBe(2);
|
|
73
|
+
expect(button[0].innerHTML).toContain("Cancel");
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
await act(async () => {
|
|
76
|
+
button[0].click();
|
|
77
|
+
});
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
expect(handleClick).toHaveBeenCalled();
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
// Fast forward
|
|
82
|
+
jest.runOnlyPendingTimers();
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
test(
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
test("Confirm tests without cancel button", async () => {
|
|
86
|
+
// Click
|
|
87
|
+
const handleClick = jest.fn();
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
89
|
+
act(() => {
|
|
90
|
+
// Add the notification
|
|
91
|
+
notifier.confirm("Confirm message", undefined, handleClick, {
|
|
92
|
+
cancelButton: false
|
|
94
93
|
});
|
|
94
|
+
});
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
// Button
|
|
97
|
+
const button = root.getElementsByTagName("button");
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
expect(button.length).toBe(1);
|
|
100
|
+
expect(button[0].innerHTML).toContain("OK");
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
await act(async () => {
|
|
103
|
+
button[0].click();
|
|
104
|
+
});
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
expect(handleClick).toHaveBeenCalled();
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
// Fast forward
|
|
109
|
+
jest.runOnlyPendingTimers();
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
test(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
test("Prompt tests", async () => {
|
|
113
|
+
// Click
|
|
114
|
+
const handleClick = jest.fn((result: boolean) => {
|
|
115
|
+
expect(result).toBeTruthy();
|
|
116
|
+
});
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
118
|
+
act(() => {
|
|
119
|
+
// Add the notification
|
|
120
|
+
notifier.prompt<boolean>("Prompt message", handleClick, undefined, {
|
|
121
|
+
type: "switch",
|
|
122
|
+
inputProps: { required: false }
|
|
124
123
|
});
|
|
124
|
+
});
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
// Button
|
|
127
|
+
const button = root.getElementsByTagName("button");
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
expect(button.length).toBe(2); // Switch will generate a button
|
|
130
|
+
expect(button[1].innerHTML).toContain("OK");
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
await act(async () => {
|
|
133
|
+
button[1].click();
|
|
134
|
+
});
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
expect(handleClick).toHaveBeenCalled();
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
jest.runOnlyPendingTimers();
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
test(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
test("Prompt tests with form submit", async () => {
|
|
142
|
+
// Click
|
|
143
|
+
const handleClick = jest.fn((result: boolean) => {
|
|
144
|
+
expect(result).toBeTruthy();
|
|
145
|
+
});
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
147
|
+
act(() => {
|
|
148
|
+
// Add the notification
|
|
149
|
+
notifier.prompt<boolean>("Prompt message", handleClick, undefined, {
|
|
150
|
+
type: "switch",
|
|
151
|
+
inputProps: { required: false }
|
|
153
152
|
});
|
|
153
|
+
});
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
await act(async () => {
|
|
156
|
+
(
|
|
157
|
+
root
|
|
158
|
+
.getElementsByTagName("form")[0]
|
|
159
|
+
.elements.namedItem("okButton") as HTMLButtonElement
|
|
160
|
+
)?.click();
|
|
161
|
+
});
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
expect(handleClick).toHaveBeenCalled();
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
jest.runOnlyPendingTimers();
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
test(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
let n: INotification<React.ReactNode, any> | undefined;
|
|
173
|
-
act(() => {
|
|
174
|
-
// Add the notification
|
|
175
|
-
n = notifier.message(
|
|
176
|
-
NotificationMessageType.Danger,
|
|
177
|
-
'Error Message',
|
|
178
|
-
undefined,
|
|
179
|
-
{
|
|
180
|
-
callback
|
|
181
|
-
}
|
|
182
|
-
);
|
|
183
|
-
});
|
|
168
|
+
test("Message tests", (done) => {
|
|
169
|
+
// Callback
|
|
170
|
+
const callback = jest.fn(() => done());
|
|
184
171
|
|
|
185
|
-
|
|
172
|
+
let n: INotification<React.ReactNode, any> | undefined;
|
|
173
|
+
act(() => {
|
|
174
|
+
// Add the notification
|
|
175
|
+
n = notifier.message(
|
|
176
|
+
NotificationMessageType.Danger,
|
|
177
|
+
"Error Message",
|
|
178
|
+
undefined,
|
|
179
|
+
{
|
|
180
|
+
callback
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
});
|
|
186
184
|
|
|
187
|
-
|
|
185
|
+
expect(n?.timespan).toBe(5);
|
|
188
186
|
|
|
189
|
-
|
|
190
|
-
// Here is the bug need further study...
|
|
191
|
-
n?.dismiss();
|
|
187
|
+
expect(root.innerHTML).toContain("Error Message");
|
|
192
188
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
act(() => {
|
|
190
|
+
// Here is the bug need further study...
|
|
191
|
+
n?.dismiss();
|
|
196
192
|
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
// Fast forward
|
|
194
|
+
jest.runOnlyPendingTimers();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
expect(root.innerHTML).not.toContain("Error Message");
|
|
198
|
+
expect(callback).toHaveBeenCalled();
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
-
test(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
test("Loading tests", () => {
|
|
202
|
+
act(() => {
|
|
203
|
+
// Add the notification
|
|
204
|
+
notifier.showLoading("Loading");
|
|
205
|
+
});
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
expect(root.innerHTML).toContain("Loading");
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
act(() => {
|
|
210
|
+
notifier.hideLoading();
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
// Fast forward
|
|
213
|
+
jest.runOnlyPendingTimers();
|
|
214
|
+
});
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
expect(root.innerHTML).not.toContain("Loading");
|
|
217
217
|
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { act, render } from "@testing-library/react";
|
|
2
|
+
import { MUGlobal, MobileListItemRenderer, ResponsivePage } from "../src";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
global.ResizeObserver = jest.fn().mockImplementation(() => ({
|
|
6
|
+
observe: jest.fn(),
|
|
7
|
+
unobserve: jest.fn(),
|
|
8
|
+
disconnect: jest.fn()
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
type Data = { id: number; name: string };
|
|
12
|
+
|
|
13
|
+
// Timer mock
|
|
14
|
+
// https://jestjs.io/docs/en/timer-mocks
|
|
15
|
+
jest.useFakeTimers();
|
|
16
|
+
|
|
17
|
+
it("Render ResponsePage", async () => {
|
|
18
|
+
// Act
|
|
19
|
+
render(
|
|
20
|
+
<ResponsivePage<Data>
|
|
21
|
+
fields={[]}
|
|
22
|
+
columns={[
|
|
23
|
+
{ field: "id", header: "ID" },
|
|
24
|
+
{ field: "name", header: "Name" }
|
|
25
|
+
]}
|
|
26
|
+
itemSize={[118, MUGlobal.pagePaddings]}
|
|
27
|
+
loadData={(_data) =>
|
|
28
|
+
Promise.resolve([
|
|
29
|
+
{ id: 1, name: "Name 1" },
|
|
30
|
+
{ id: 2, name: "Name 2" }
|
|
31
|
+
])
|
|
32
|
+
}
|
|
33
|
+
innerItemRenderer={(props) =>
|
|
34
|
+
MobileListItemRenderer(props, (data) => {
|
|
35
|
+
return [data.name, undefined, [], <React.Fragment></React.Fragment>];
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
act(() => {
|
|
42
|
+
// Fast forward
|
|
43
|
+
jest.runOnlyPendingTimers();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Assert
|
|
47
|
+
expect(document.getElementById("page-container")).not.toBeNull();
|
|
48
|
+
});
|
package/__tests__/SelectEx.tsx
CHANGED
|
@@ -31,7 +31,7 @@ it("Render SelectEx", async () => {
|
|
|
31
31
|
/>
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
expect(itemChangeCallback).
|
|
34
|
+
expect(itemChangeCallback).toHaveBeenCalled();
|
|
35
35
|
|
|
36
36
|
// Act, click to show the list
|
|
37
37
|
const button = screen.getByRole("combobox");
|
|
@@ -110,5 +110,5 @@ it("Render multiple SelectEx", async () => {
|
|
|
110
110
|
|
|
111
111
|
expect(checkbox3?.checked).toBeTruthy();
|
|
112
112
|
|
|
113
|
-
expect(itemChangeCallback).
|
|
113
|
+
expect(itemChangeCallback).toHaveBeenCalledTimes(2);
|
|
114
114
|
});
|
package/__tests__/SwitchAnt.tsx
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { getByText, render } from
|
|
2
|
-
import React from
|
|
3
|
-
import { act } from
|
|
4
|
-
import { SwitchAnt } from
|
|
1
|
+
import { getByText, render } from "@testing-library/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { act } from "react-dom/test-utils";
|
|
4
|
+
import { SwitchAnt } from "../src/SwitchAnt";
|
|
5
5
|
|
|
6
|
-
it(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
it("SwitchAnt Tests", () => {
|
|
7
|
+
const onChange = jest.fn((event: React.ChangeEvent<HTMLInputElement>) =>
|
|
8
|
+
expect(event.target.checked).toBeTruthy()
|
|
9
|
+
);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
// Render component
|
|
12
|
+
const { baseElement } = render(
|
|
13
|
+
<SwitchAnt startLabel="No" endLabel="Yes" onChange={onChange} />
|
|
14
|
+
);
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const yes = getByText(baseElement, "Yes");
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
act(() => {
|
|
19
|
+
yes.click();
|
|
20
|
+
});
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
expect(onChange).toHaveBeenCalled();
|
|
23
23
|
});
|
package/__tests__/tsconfig.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Node10",
|
|
6
|
+
"allowJs": false,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"jsx": "react",
|
|
16
|
+
"declaration": true
|
|
17
|
+
},
|
|
18
|
+
"include": [".."]
|
|
19
19
|
}
|
package/lib/AddresSelector.js
CHANGED
|
@@ -18,9 +18,8 @@ export var AddressField;
|
|
|
18
18
|
* @param props Props
|
|
19
19
|
*/
|
|
20
20
|
export function AddressSelector(props) {
|
|
21
|
-
var _a;
|
|
22
21
|
// Labels
|
|
23
|
-
const { city: cityDefault = "City", district: districtDefault = "District", region: regionDefault = "Region", state: stateDefault = "State" } =
|
|
22
|
+
const { city: cityDefault = "City", district: districtDefault = "District", region: regionDefault = "Region", state: stateDefault = "State" } = globalApp?.getLabels("region", "state", "city", "district") ?? {};
|
|
24
23
|
// Destruct
|
|
25
24
|
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;
|
|
26
25
|
const isMounted = React.useRef(true);
|
package/lib/AuditDisplay.js
CHANGED
|
@@ -6,8 +6,7 @@ import { ListMoreDisplay } from "./ListMoreDisplay";
|
|
|
6
6
|
import { ShowDataComparison } from "./ShowDataComparison";
|
|
7
7
|
// Get label
|
|
8
8
|
const getLabel = (key) => {
|
|
9
|
-
|
|
10
|
-
return (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get(Utils.formatInitial(key))) !== null && _a !== void 0 ? _a : key;
|
|
9
|
+
return globalApp?.get(Utils.formatInitial(key)) ?? key;
|
|
11
10
|
};
|
|
12
11
|
// Format date
|
|
13
12
|
const formatDate = (date) => {
|
|
@@ -30,7 +29,7 @@ export function AuditDisplay(props) {
|
|
|
30
29
|
padding: [theme.spacing(1.5), theme.spacing(1)].join(" "),
|
|
31
30
|
background: index % 2 === 0 ? theme.palette.grey[100] : theme.palette.grey[50]
|
|
32
31
|
}), getColumnLabel, equalCheck, itemRenderer = (data) => {
|
|
33
|
-
const { newData, oldData, changes = { newData: newData
|
|
32
|
+
const { newData, oldData, changes = { newData: newData ?? {}, oldData: oldData ?? {} } } = data;
|
|
34
33
|
return (React.createElement(React.Fragment, null,
|
|
35
34
|
changes != null && (React.createElement(Button, { variant: "outlined", size: "small", onClick: () => ShowDataComparison(changes, title, getColumnLabel, equalCheck), sx: {
|
|
36
35
|
marginLeft: theme.spacing(1),
|
package/lib/BridgeCloseButton.js
CHANGED
|
@@ -9,9 +9,8 @@ import { globalApp } from "./app/ReactApp";
|
|
|
9
9
|
* @returns Component
|
|
10
10
|
*/
|
|
11
11
|
export function BridgeCloseButton(props) {
|
|
12
|
-
var _a;
|
|
13
12
|
// Destruct
|
|
14
|
-
const { boxProps, onClick, title =
|
|
13
|
+
const { boxProps, onClick, title = globalApp?.get("close") ?? "Close", validate, ...rest } = props;
|
|
15
14
|
// Host
|
|
16
15
|
const host = BridgeUtils.host;
|
|
17
16
|
if (host == null ||
|
package/lib/ComboBox.js
CHANGED
|
@@ -14,13 +14,13 @@ import { globalApp } from "./app/ReactApp";
|
|
|
14
14
|
*/
|
|
15
15
|
export function ComboBox(props) {
|
|
16
16
|
// Labels
|
|
17
|
-
const labels = globalApp
|
|
17
|
+
const labels = globalApp?.getLabels("noOptions", "loading", "open", "add");
|
|
18
18
|
// Destruct
|
|
19
|
-
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
|
|
19
|
+
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, ...rest } = props;
|
|
20
20
|
// Value input ref
|
|
21
21
|
const inputRef = React.createRef();
|
|
22
22
|
// Options state
|
|
23
|
-
const [localOptions, setOptions] = React.useState(options
|
|
23
|
+
const [localOptions, setOptions] = React.useState(options ?? []);
|
|
24
24
|
const isMounted = React.useRef(true);
|
|
25
25
|
// When options change
|
|
26
26
|
// [options] will cause infinite loop
|
|
@@ -37,7 +37,7 @@ export function ComboBox(props) {
|
|
|
37
37
|
// Local default value
|
|
38
38
|
const localValue = idValue != null
|
|
39
39
|
? localOptions.find((o) => o[idField] === idValue)
|
|
40
|
-
: defaultValue
|
|
40
|
+
: defaultValue ?? value;
|
|
41
41
|
// State
|
|
42
42
|
// null for controlled
|
|
43
43
|
const [stateValue, setStateValue] = React.useState(null);
|
|
@@ -113,7 +113,7 @@ export function ComboBox(props) {
|
|
|
113
113
|
}, []);
|
|
114
114
|
// Layout
|
|
115
115
|
return (React.createElement("div", null,
|
|
116
|
-
React.createElement("input", { ref: inputRef, "data-reset": inputReset
|
|
116
|
+
React.createElement("input", { ref: inputRef, "data-reset": inputReset ?? true, type: "text", style: { display: "none" }, name: name, value: getValue(stateValue), readOnly: true, onChange: inputOnChange }),
|
|
117
117
|
React.createElement(Stack, { gap: 0.5, direction: "row", width: "100%" },
|
|
118
118
|
React.createElement(Autocomplete, { value: stateValue, disableCloseOnSelect: disableCloseOnSelect, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option[idField] === value[idField], onChange: (event, value, reason, details) => {
|
|
119
119
|
// Set value
|
package/lib/ComboBoxMultiple.js
CHANGED
|
@@ -16,30 +16,29 @@ const checkedIcon = React.createElement(CheckBoxIcon, { fontSize: "small" });
|
|
|
16
16
|
* @returns Component
|
|
17
17
|
*/
|
|
18
18
|
export function ComboBoxMultiple(props) {
|
|
19
|
-
var _a;
|
|
20
19
|
// Labels
|
|
21
|
-
const labels = globalApp
|
|
20
|
+
const labels = globalApp?.getLabels("noOptions", "loading");
|
|
22
21
|
// Destruct
|
|
23
22
|
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 }) => (React.createElement("li", { ...props },
|
|
24
23
|
React.createElement(React.Fragment, null,
|
|
25
24
|
React.createElement(Checkbox, { icon: icon, checkedIcon: checkedIcon, style: { marginRight: 8 }, checked: selected }),
|
|
26
|
-
option[labelField]))), getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: "150px" }, noOptionsText = labels
|
|
25
|
+
option[labelField]))), getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: "150px" }, noOptionsText = labels?.noOptions, loadingText = labels?.loading, ...rest } = props;
|
|
27
26
|
// Value input ref
|
|
28
27
|
const inputRef = React.createRef();
|
|
29
28
|
// Options state
|
|
30
|
-
const [localOptions, setOptions] = React.useState(options
|
|
29
|
+
const [localOptions, setOptions] = React.useState(options ?? []);
|
|
31
30
|
const isMounted = React.useRef(true);
|
|
32
31
|
// Local default value
|
|
33
32
|
const localValue = idValue != null
|
|
34
33
|
? localOptions.filter((o) => o[idField] === idValue)
|
|
35
34
|
: idValues != null
|
|
36
|
-
? localOptions.filter((o) => idValues
|
|
37
|
-
:
|
|
35
|
+
? localOptions.filter((o) => idValues?.includes(o[idField]))
|
|
36
|
+
: defaultValue?.concat() ?? value?.concat();
|
|
38
37
|
// State
|
|
39
38
|
// null for controlled
|
|
40
39
|
const [stateValue, setStateValue] = React.useState(null);
|
|
41
40
|
React.useEffect(() => {
|
|
42
|
-
setStateValue(localValue
|
|
41
|
+
setStateValue(localValue ?? []);
|
|
43
42
|
}, [localValue]);
|
|
44
43
|
// When options change
|
|
45
44
|
// [options] will cause infinite loop
|
|
@@ -116,7 +115,7 @@ export function ComboBoxMultiple(props) {
|
|
|
116
115
|
}, []);
|
|
117
116
|
// Layout
|
|
118
117
|
return (React.createElement("div", null,
|
|
119
|
-
React.createElement("input", { ref: inputRef, "data-reset": inputReset
|
|
118
|
+
React.createElement("input", { ref: inputRef, "data-reset": inputReset ?? true, type: "text", style: { display: "none" }, name: name, value: getValue(stateValue), readOnly: true, onChange: inputOnChange }),
|
|
120
119
|
React.createElement(Autocomplete, { value: stateValue == null
|
|
121
120
|
? []
|
|
122
121
|
: Array.isArray(stateValue)
|
package/lib/ComboBoxPro.js
CHANGED
|
@@ -4,9 +4,8 @@ import { globalApp } from "./app/ReactApp";
|
|
|
4
4
|
import { InputField } from "./InputField";
|
|
5
5
|
import { DataTypes } from "@etsoo/shared";
|
|
6
6
|
export function ComboBoxPro(props) {
|
|
7
|
-
var _a;
|
|
8
7
|
// Labels
|
|
9
|
-
const { noOptions, loading: loadingLabel, open: openDefault } =
|
|
8
|
+
const { noOptions, loading: loadingLabel, open: openDefault } = globalApp?.getLabels("noOptions", "loading", "open") ?? {};
|
|
10
9
|
// Destruct
|
|
11
10
|
const { noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, options, openOnFocus = true, label, inputProps, name, value, idValue, onChange, onValueChange, ...rest } = props;
|
|
12
11
|
const [open, setOpen] = React.useState(false);
|