@etsoo/materialui 1.6.42 → 1.6.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/lib/cjs/DataGridEx.js +1 -1
- package/lib/cjs/DnDSortableList.d.ts +3 -3
- package/lib/cjs/NumberInputField.d.ts +4 -0
- package/lib/cjs/NumberInputField.js +5 -3
- package/lib/cjs/ResponsibleContainer.js +5 -4
- package/lib/cjs/SearchBar.d.ts +1 -1
- package/lib/cjs/SearchBar.js +4 -4
- package/lib/mjs/DataGridEx.js +1 -1
- package/lib/mjs/DnDSortableList.d.ts +3 -3
- package/lib/mjs/NumberInputField.d.ts +4 -0
- package/lib/mjs/NumberInputField.js +5 -3
- package/lib/mjs/ResponsibleContainer.js +5 -4
- package/lib/mjs/SearchBar.d.ts +1 -1
- package/lib/mjs/SearchBar.js +4 -4
- package/package.json +5 -5
- package/src/DataGridEx.tsx +1 -1
- package/src/DnDSortableList.tsx +6 -4
- package/src/NumberInputField.tsx +10 -1
- package/src/ResponsibleContainer.tsx +5 -3
- package/src/SearchBar.tsx +12 -5
package/lib/cjs/DataGridEx.js
CHANGED
|
@@ -135,7 +135,7 @@ function DataGridEx(props) {
|
|
|
135
135
|
alignItems: "center",
|
|
136
136
|
borderTop: thinBorder,
|
|
137
137
|
marginTop: "1px",
|
|
138
|
-
|
|
138
|
+
minWidth: widthCalculator.total,
|
|
139
139
|
height: bottomHeight - 1
|
|
140
140
|
}, children: columns.map((column, index) => {
|
|
141
141
|
// Destruct
|
|
@@ -2,7 +2,7 @@ import { DataTypes, IdType } from "@etsoo/shared";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { CSSProperties, Theme } from "@mui/material/styles";
|
|
4
4
|
import { useSortable } from "@dnd-kit/react/sortable";
|
|
5
|
-
import {
|
|
5
|
+
import { DragDropEventHandlers } from "@dnd-kit/react";
|
|
6
6
|
/**
|
|
7
7
|
* DnD sortable item default style
|
|
8
8
|
* @param index Item index
|
|
@@ -91,11 +91,11 @@ export type DnDSortableListProps<D extends object, E extends React.ElementType =
|
|
|
91
91
|
/**
|
|
92
92
|
* Drag start handler
|
|
93
93
|
*/
|
|
94
|
-
onDragStart?: (items: D[], event: Parameters<
|
|
94
|
+
onDragStart?: (items: D[], event: Parameters<DragDropEventHandlers["onDragStart"]>[0]) => void;
|
|
95
95
|
/**
|
|
96
96
|
* Drag end handler
|
|
97
97
|
*/
|
|
98
|
-
onDragEnd?: (items: D[], ...args: Parameters<
|
|
98
|
+
onDragEnd?: (items: D[], ...args: Parameters<DragDropEventHandlers["onDragEnd"]>) => void;
|
|
99
99
|
};
|
|
100
100
|
/**
|
|
101
101
|
* DnD sortable list component
|
|
@@ -9,6 +9,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
9
9
|
const InputField_1 = require("./InputField");
|
|
10
10
|
const shared_1 = require("@etsoo/shared");
|
|
11
11
|
const InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
|
|
12
|
+
const MUGlobal_1 = require("./MUGlobal");
|
|
12
13
|
/**
|
|
13
14
|
* Number input field, for controlled only components, please see IntInputField and MoneyInputField
|
|
14
15
|
* @param props Props
|
|
@@ -17,12 +18,13 @@ const InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment")
|
|
|
17
18
|
function NumberInputField(props) {
|
|
18
19
|
const { currency, inputStyle, min = 0, step = 1, symbol = currency
|
|
19
20
|
? `${currency} ${shared_1.NumberUtils.getCurrencySymbol(currency)}`
|
|
20
|
-
: undefined, endSymbol, max = 9999999, slotProps = {}, ...rest } = props;
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { type: "number", slotProps: Object.assign(slotProps, {
|
|
21
|
+
: undefined, endSymbol, max = 9999999, search = false, slotProps = {}, ...rest } = props;
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { type: "number", size: search ? MUGlobal_1.MUGlobal.searchFieldSize : undefined, slotProps: Object.assign(slotProps, {
|
|
22
23
|
input: {
|
|
23
24
|
startAdornment: symbol ? ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "start", children: symbol }) })) : undefined,
|
|
24
25
|
endAdornment: endSymbol ? ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "end", children: endSymbol })) : undefined
|
|
25
26
|
},
|
|
27
|
+
inputLabel: { shrink: search ? MUGlobal_1.MUGlobal.searchFieldShrink : undefined },
|
|
26
28
|
htmlInput: {
|
|
27
29
|
min,
|
|
28
30
|
step,
|
|
@@ -30,5 +32,5 @@ function NumberInputField(props) {
|
|
|
30
32
|
style: inputStyle,
|
|
31
33
|
inputMode: "numeric"
|
|
32
34
|
}
|
|
33
|
-
}), ...rest }));
|
|
35
|
+
}), variant: search ? MUGlobal_1.MUGlobal.searchFieldVariant : undefined, ...rest }));
|
|
34
36
|
}
|
|
@@ -73,8 +73,9 @@ function ResponsibleContainer(props) {
|
|
|
73
73
|
// Search data
|
|
74
74
|
const searchData = (0, react_2.useSearchParamsWithCache)(cacheKey);
|
|
75
75
|
// On submit callback
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// Current UI may be rendered but the search bar rerendered with new data, check init to avoid reset and load new data
|
|
77
|
+
const onSubmit = (data, _reset, init) => {
|
|
78
|
+
if (data == null || state.ref == null || (state.mounted && init))
|
|
78
79
|
return;
|
|
79
80
|
state.ref.reset({ data });
|
|
80
81
|
};
|
|
@@ -137,8 +138,8 @@ function ResponsibleContainer(props) {
|
|
|
137
138
|
if (!hasFields || rect?.width == null || rect.width < 20)
|
|
138
139
|
return;
|
|
139
140
|
const f = typeof fields == "function" ? fields(searchData) : fields;
|
|
140
|
-
return ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, width: rect.width, top: searchBarTop }));
|
|
141
|
-
}, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
|
|
141
|
+
return ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, width: rect.width, top: searchBarTop, autoSubmitDelay: rest.autoLoad === false ? 0 : undefined }));
|
|
142
|
+
}, [showDataGrid, hasFields, searchBarHeight, rect?.width, rest.autoLoad]);
|
|
142
143
|
// Pull container
|
|
143
144
|
const pullContainer = showDataGrid
|
|
144
145
|
? ".DataGridEx-Body"
|
package/lib/cjs/SearchBar.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface SearchBarProps {
|
|
|
26
26
|
/**
|
|
27
27
|
* On submit callback
|
|
28
28
|
*/
|
|
29
|
-
onSubmit: (data: FormData, reset: boolean) => void | PromiseLike<void>;
|
|
29
|
+
onSubmit: (data: FormData, reset: boolean, init: boolean) => void | PromiseLike<void>;
|
|
30
30
|
/**
|
|
31
31
|
* Top position, true means Toolbar's height
|
|
32
32
|
*/
|
package/lib/cjs/SearchBar.js
CHANGED
|
@@ -216,13 +216,13 @@ function SearchBar(props) {
|
|
|
216
216
|
delayed.call();
|
|
217
217
|
};
|
|
218
218
|
// Submit at once
|
|
219
|
-
const handleSubmitInstant = (reset = false) => {
|
|
219
|
+
const handleSubmitInstant = (reset = false, init = false) => {
|
|
220
220
|
// Prepare data
|
|
221
221
|
const data = new FormData(state.form);
|
|
222
222
|
if (state.moreForm != null) {
|
|
223
223
|
shared_1.DomUtils.mergeFormData(data, new FormData(state.moreForm));
|
|
224
224
|
}
|
|
225
|
-
onSubmit(data, reset);
|
|
225
|
+
onSubmit(data, reset, init);
|
|
226
226
|
};
|
|
227
227
|
const delayed = (0, react_2.useDelayedExecutor)(handleSubmitInstant, 480);
|
|
228
228
|
// Reset
|
|
@@ -237,8 +237,8 @@ function SearchBar(props) {
|
|
|
237
237
|
};
|
|
238
238
|
react_1.default.useEffect(() => {
|
|
239
239
|
// Delayed way
|
|
240
|
-
if (autoSubmitDelay >
|
|
241
|
-
delayed.call(autoSubmitDelay);
|
|
240
|
+
if (autoSubmitDelay > 10) {
|
|
241
|
+
delayed.call(autoSubmitDelay, false, true);
|
|
242
242
|
}
|
|
243
243
|
return () => {
|
|
244
244
|
delayed.clear();
|
package/lib/mjs/DataGridEx.js
CHANGED
|
@@ -128,7 +128,7 @@ export function DataGridEx(props) {
|
|
|
128
128
|
alignItems: "center",
|
|
129
129
|
borderTop: thinBorder,
|
|
130
130
|
marginTop: "1px",
|
|
131
|
-
|
|
131
|
+
minWidth: widthCalculator.total,
|
|
132
132
|
height: bottomHeight - 1
|
|
133
133
|
}, children: columns.map((column, index) => {
|
|
134
134
|
// Destruct
|
|
@@ -2,7 +2,7 @@ import { DataTypes, IdType } from "@etsoo/shared";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { CSSProperties, Theme } from "@mui/material/styles";
|
|
4
4
|
import { useSortable } from "@dnd-kit/react/sortable";
|
|
5
|
-
import {
|
|
5
|
+
import { DragDropEventHandlers } from "@dnd-kit/react";
|
|
6
6
|
/**
|
|
7
7
|
* DnD sortable item default style
|
|
8
8
|
* @param index Item index
|
|
@@ -91,11 +91,11 @@ export type DnDSortableListProps<D extends object, E extends React.ElementType =
|
|
|
91
91
|
/**
|
|
92
92
|
* Drag start handler
|
|
93
93
|
*/
|
|
94
|
-
onDragStart?: (items: D[], event: Parameters<
|
|
94
|
+
onDragStart?: (items: D[], event: Parameters<DragDropEventHandlers["onDragStart"]>[0]) => void;
|
|
95
95
|
/**
|
|
96
96
|
* Drag end handler
|
|
97
97
|
*/
|
|
98
|
-
onDragEnd?: (items: D[], ...args: Parameters<
|
|
98
|
+
onDragEnd?: (items: D[], ...args: Parameters<DragDropEventHandlers["onDragEnd"]>) => void;
|
|
99
99
|
};
|
|
100
100
|
/**
|
|
101
101
|
* DnD sortable list component
|
|
@@ -3,6 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { InputField } from "./InputField";
|
|
4
4
|
import { NumberUtils } from "@etsoo/shared";
|
|
5
5
|
import InputAdornment from "@mui/material/InputAdornment";
|
|
6
|
+
import { MUGlobal } from "./MUGlobal";
|
|
6
7
|
/**
|
|
7
8
|
* Number input field, for controlled only components, please see IntInputField and MoneyInputField
|
|
8
9
|
* @param props Props
|
|
@@ -11,12 +12,13 @@ import InputAdornment from "@mui/material/InputAdornment";
|
|
|
11
12
|
export function NumberInputField(props) {
|
|
12
13
|
const { currency, inputStyle, min = 0, step = 1, symbol = currency
|
|
13
14
|
? `${currency} ${NumberUtils.getCurrencySymbol(currency)}`
|
|
14
|
-
: undefined, endSymbol, max = 9999999, slotProps = {}, ...rest } = props;
|
|
15
|
-
return (_jsx(InputField, { type: "number", slotProps: Object.assign(slotProps, {
|
|
15
|
+
: undefined, endSymbol, max = 9999999, search = false, slotProps = {}, ...rest } = props;
|
|
16
|
+
return (_jsx(InputField, { type: "number", size: search ? MUGlobal.searchFieldSize : undefined, slotProps: Object.assign(slotProps, {
|
|
16
17
|
input: {
|
|
17
18
|
startAdornment: symbol ? (_jsx(React.Fragment, { children: _jsx(InputAdornment, { position: "start", children: symbol }) })) : undefined,
|
|
18
19
|
endAdornment: endSymbol ? (_jsx(InputAdornment, { position: "end", children: endSymbol })) : undefined
|
|
19
20
|
},
|
|
21
|
+
inputLabel: { shrink: search ? MUGlobal.searchFieldShrink : undefined },
|
|
20
22
|
htmlInput: {
|
|
21
23
|
min,
|
|
22
24
|
step,
|
|
@@ -24,5 +26,5 @@ export function NumberInputField(props) {
|
|
|
24
26
|
style: inputStyle,
|
|
25
27
|
inputMode: "numeric"
|
|
26
28
|
}
|
|
27
|
-
}), ...rest }));
|
|
29
|
+
}), variant: search ? MUGlobal.searchFieldVariant : undefined, ...rest }));
|
|
28
30
|
}
|
|
@@ -67,8 +67,9 @@ export function ResponsibleContainer(props) {
|
|
|
67
67
|
// Search data
|
|
68
68
|
const searchData = useSearchParamsWithCache(cacheKey);
|
|
69
69
|
// On submit callback
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
// Current UI may be rendered but the search bar rerendered with new data, check init to avoid reset and load new data
|
|
71
|
+
const onSubmit = (data, _reset, init) => {
|
|
72
|
+
if (data == null || state.ref == null || (state.mounted && init))
|
|
72
73
|
return;
|
|
73
74
|
state.ref.reset({ data });
|
|
74
75
|
};
|
|
@@ -131,8 +132,8 @@ export function ResponsibleContainer(props) {
|
|
|
131
132
|
if (!hasFields || rect?.width == null || rect.width < 20)
|
|
132
133
|
return;
|
|
133
134
|
const f = typeof fields == "function" ? fields(searchData) : fields;
|
|
134
|
-
return (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, width: rect.width, top: searchBarTop }));
|
|
135
|
-
}, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
|
|
135
|
+
return (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, width: rect.width, top: searchBarTop, autoSubmitDelay: rest.autoLoad === false ? 0 : undefined }));
|
|
136
|
+
}, [showDataGrid, hasFields, searchBarHeight, rect?.width, rest.autoLoad]);
|
|
136
137
|
// Pull container
|
|
137
138
|
const pullContainer = showDataGrid
|
|
138
139
|
? ".DataGridEx-Body"
|
package/lib/mjs/SearchBar.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface SearchBarProps {
|
|
|
26
26
|
/**
|
|
27
27
|
* On submit callback
|
|
28
28
|
*/
|
|
29
|
-
onSubmit: (data: FormData, reset: boolean) => void | PromiseLike<void>;
|
|
29
|
+
onSubmit: (data: FormData, reset: boolean, init: boolean) => void | PromiseLike<void>;
|
|
30
30
|
/**
|
|
31
31
|
* Top position, true means Toolbar's height
|
|
32
32
|
*/
|
package/lib/mjs/SearchBar.js
CHANGED
|
@@ -210,13 +210,13 @@ export function SearchBar(props) {
|
|
|
210
210
|
delayed.call();
|
|
211
211
|
};
|
|
212
212
|
// Submit at once
|
|
213
|
-
const handleSubmitInstant = (reset = false) => {
|
|
213
|
+
const handleSubmitInstant = (reset = false, init = false) => {
|
|
214
214
|
// Prepare data
|
|
215
215
|
const data = new FormData(state.form);
|
|
216
216
|
if (state.moreForm != null) {
|
|
217
217
|
DomUtils.mergeFormData(data, new FormData(state.moreForm));
|
|
218
218
|
}
|
|
219
|
-
onSubmit(data, reset);
|
|
219
|
+
onSubmit(data, reset, init);
|
|
220
220
|
};
|
|
221
221
|
const delayed = useDelayedExecutor(handleSubmitInstant, 480);
|
|
222
222
|
// Reset
|
|
@@ -231,8 +231,8 @@ export function SearchBar(props) {
|
|
|
231
231
|
};
|
|
232
232
|
React.useEffect(() => {
|
|
233
233
|
// Delayed way
|
|
234
|
-
if (autoSubmitDelay >
|
|
235
|
-
delayed.call(autoSubmitDelay);
|
|
234
|
+
if (autoSubmitDelay > 10) {
|
|
235
|
+
delayed.call(autoSubmitDelay, false, true);
|
|
236
236
|
}
|
|
237
237
|
return () => {
|
|
238
238
|
delayed.clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.44",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/ETSOO/ReactMU#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@base-ui/react": "^1.
|
|
40
|
-
"@dnd-kit/react": "^0.
|
|
39
|
+
"@base-ui/react": "^1.4.0",
|
|
40
|
+
"@dnd-kit/react": "^0.4.0",
|
|
41
41
|
"@emotion/react": "^11.14.0",
|
|
42
42
|
"@emotion/styled": "^11.14.1",
|
|
43
43
|
"@etsoo/appscript": "^1.6.60",
|
|
44
44
|
"@etsoo/notificationbase": "^1.1.69",
|
|
45
45
|
"@etsoo/react": "^1.8.84",
|
|
46
|
-
"@etsoo/shared": "^1.2.
|
|
46
|
+
"@etsoo/shared": "^1.2.83",
|
|
47
47
|
"@mui/icons-material": "^9.0.0",
|
|
48
48
|
"@mui/material": "^9.0.0",
|
|
49
49
|
"@mui/x-data-grid": "^9.0.1",
|
|
50
50
|
"chart.js": "^4.5.1",
|
|
51
51
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
52
|
-
"dompurify": "^3.
|
|
52
|
+
"dompurify": "^3.4.0",
|
|
53
53
|
"eventemitter3": "^5.0.4",
|
|
54
54
|
"pica": "^9.0.1",
|
|
55
55
|
"pulltorefreshjs": "^0.1.22",
|
package/src/DataGridEx.tsx
CHANGED
|
@@ -339,7 +339,7 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
|
|
|
339
339
|
alignItems: "center",
|
|
340
340
|
borderTop: thinBorder,
|
|
341
341
|
marginTop: "1px",
|
|
342
|
-
|
|
342
|
+
minWidth: widthCalculator.total,
|
|
343
343
|
height: bottomHeight - 1
|
|
344
344
|
}}
|
|
345
345
|
>
|
package/src/DnDSortableList.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { DataTypes, IdType } from "@etsoo/shared";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { CSSProperties, Theme, useTheme } from "@mui/material/styles";
|
|
4
4
|
import { isSortableOperation, useSortable } from "@dnd-kit/react/sortable";
|
|
5
|
-
import {
|
|
5
|
+
import { DragDropEventHandlers, DragDropProvider } from "@dnd-kit/react";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* DnD sortable item default style
|
|
@@ -126,7 +126,7 @@ export type DnDSortableListProps<
|
|
|
126
126
|
*/
|
|
127
127
|
onDragStart?: (
|
|
128
128
|
items: D[],
|
|
129
|
-
event: Parameters<
|
|
129
|
+
event: Parameters<DragDropEventHandlers["onDragStart"]>[0]
|
|
130
130
|
) => void;
|
|
131
131
|
|
|
132
132
|
/**
|
|
@@ -134,7 +134,7 @@ export type DnDSortableListProps<
|
|
|
134
134
|
*/
|
|
135
135
|
onDragEnd?: (
|
|
136
136
|
items: D[],
|
|
137
|
-
...args: Parameters<
|
|
137
|
+
...args: Parameters<DragDropEventHandlers["onDragEnd"]>
|
|
138
138
|
) => void;
|
|
139
139
|
};
|
|
140
140
|
|
|
@@ -293,7 +293,9 @@ export function DnDSortableList<
|
|
|
293
293
|
};
|
|
294
294
|
}, [items, labelFn, changeItems]);
|
|
295
295
|
|
|
296
|
-
function handleDragEnd(
|
|
296
|
+
function handleDragEnd(
|
|
297
|
+
...args: Parameters<DragDropEventHandlers["onDragEnd"]>
|
|
298
|
+
) {
|
|
297
299
|
// Event
|
|
298
300
|
const event = args[0];
|
|
299
301
|
|
package/src/NumberInputField.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { InputField, InputFieldProps } from "./InputField";
|
|
|
3
3
|
import { Currency } from "@etsoo/appscript";
|
|
4
4
|
import { NumberUtils } from "@etsoo/shared";
|
|
5
5
|
import InputAdornment from "@mui/material/InputAdornment";
|
|
6
|
-
import {
|
|
6
|
+
import { MUGlobal } from "./MUGlobal";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Number input field properties
|
|
@@ -42,6 +42,11 @@ export type NumberInputFieldProps = Omit<
|
|
|
42
42
|
*/
|
|
43
43
|
max?: number;
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Is search field?
|
|
47
|
+
*/
|
|
48
|
+
search?: boolean;
|
|
49
|
+
|
|
45
50
|
/**
|
|
46
51
|
* Step value
|
|
47
52
|
*/
|
|
@@ -64,6 +69,7 @@ export function NumberInputField(props: NumberInputFieldProps) {
|
|
|
64
69
|
: undefined,
|
|
65
70
|
endSymbol,
|
|
66
71
|
max = 9999999,
|
|
72
|
+
search = false,
|
|
67
73
|
slotProps = {},
|
|
68
74
|
...rest
|
|
69
75
|
} = props;
|
|
@@ -71,6 +77,7 @@ export function NumberInputField(props: NumberInputFieldProps) {
|
|
|
71
77
|
return (
|
|
72
78
|
<InputField
|
|
73
79
|
type="number"
|
|
80
|
+
size={search ? MUGlobal.searchFieldSize : undefined}
|
|
74
81
|
slotProps={Object.assign(slotProps, {
|
|
75
82
|
input: {
|
|
76
83
|
startAdornment: symbol ? (
|
|
@@ -82,6 +89,7 @@ export function NumberInputField(props: NumberInputFieldProps) {
|
|
|
82
89
|
<InputAdornment position="end">{endSymbol}</InputAdornment>
|
|
83
90
|
) : undefined
|
|
84
91
|
},
|
|
92
|
+
inputLabel: { shrink: search ? MUGlobal.searchFieldShrink : undefined },
|
|
85
93
|
htmlInput: {
|
|
86
94
|
min,
|
|
87
95
|
step,
|
|
@@ -90,6 +98,7 @@ export function NumberInputField(props: NumberInputFieldProps) {
|
|
|
90
98
|
inputMode: "numeric"
|
|
91
99
|
}
|
|
92
100
|
})}
|
|
101
|
+
variant={search ? MUGlobal.searchFieldVariant : undefined}
|
|
93
102
|
{...rest}
|
|
94
103
|
/>
|
|
95
104
|
);
|
|
@@ -252,8 +252,9 @@ export function ResponsibleContainer<T extends object, F>(
|
|
|
252
252
|
const searchData = useSearchParamsWithCache(cacheKey);
|
|
253
253
|
|
|
254
254
|
// On submit callback
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
// Current UI may be rendered but the search bar rerendered with new data, check init to avoid reset and load new data
|
|
256
|
+
const onSubmit = (data: FormData, _reset: boolean, init: boolean) => {
|
|
257
|
+
if (data == null || state.ref == null || (state.mounted && init)) return;
|
|
257
258
|
state.ref.reset({ data });
|
|
258
259
|
};
|
|
259
260
|
|
|
@@ -385,9 +386,10 @@ export function ResponsibleContainer<T extends object, F>(
|
|
|
385
386
|
className={`searchBar${showDataGrid ? "Grid" : "List"}`}
|
|
386
387
|
width={rect.width}
|
|
387
388
|
top={searchBarTop}
|
|
389
|
+
autoSubmitDelay={rest.autoLoad === false ? 0 : undefined}
|
|
388
390
|
/>
|
|
389
391
|
);
|
|
390
|
-
}, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
|
|
392
|
+
}, [showDataGrid, hasFields, searchBarHeight, rect?.width, rest.autoLoad]);
|
|
391
393
|
|
|
392
394
|
// Pull container
|
|
393
395
|
const pullContainer = showDataGrid
|
package/src/SearchBar.tsx
CHANGED
|
@@ -41,7 +41,11 @@ export interface SearchBarProps {
|
|
|
41
41
|
/**
|
|
42
42
|
* On submit callback
|
|
43
43
|
*/
|
|
44
|
-
onSubmit: (
|
|
44
|
+
onSubmit: (
|
|
45
|
+
data: FormData,
|
|
46
|
+
reset: boolean,
|
|
47
|
+
init: boolean
|
|
48
|
+
) => void | PromiseLike<void>;
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
* Top position, true means Toolbar's height
|
|
@@ -314,7 +318,10 @@ export function SearchBar(props: SearchBarProps) {
|
|
|
314
318
|
};
|
|
315
319
|
|
|
316
320
|
// Submit at once
|
|
317
|
-
const handleSubmitInstant = (
|
|
321
|
+
const handleSubmitInstant = (
|
|
322
|
+
reset: boolean = false,
|
|
323
|
+
init: boolean = false
|
|
324
|
+
) => {
|
|
318
325
|
// Prepare data
|
|
319
326
|
const data = new FormData(state.form);
|
|
320
327
|
|
|
@@ -322,7 +329,7 @@ export function SearchBar(props: SearchBarProps) {
|
|
|
322
329
|
DomUtils.mergeFormData(data, new FormData(state.moreForm));
|
|
323
330
|
}
|
|
324
331
|
|
|
325
|
-
onSubmit(data, reset);
|
|
332
|
+
onSubmit(data, reset, init);
|
|
326
333
|
};
|
|
327
334
|
|
|
328
335
|
const delayed = useDelayedExecutor(handleSubmitInstant, 480);
|
|
@@ -339,8 +346,8 @@ export function SearchBar(props: SearchBarProps) {
|
|
|
339
346
|
|
|
340
347
|
React.useEffect(() => {
|
|
341
348
|
// Delayed way
|
|
342
|
-
if (autoSubmitDelay >
|
|
343
|
-
delayed.call(autoSubmitDelay);
|
|
349
|
+
if (autoSubmitDelay > 10) {
|
|
350
|
+
delayed.call(autoSubmitDelay, false, true);
|
|
344
351
|
}
|
|
345
352
|
|
|
346
353
|
return () => {
|