@etsoo/materialui 1.5.12 → 1.5.14
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/' +0 -0
- package/lib/cjs/ResponsibleContainer.js +2 -2
- package/lib/cjs/SearchField.js +8 -9
- package/lib/cjs/TabBox.d.ts +4 -5
- package/lib/cjs/TabBox.js +7 -3
- package/lib/cjs/pages/DataGridPage.js +1 -1
- package/lib/cjs/pages/FixedListPage.js +1 -1
- package/lib/cjs/pages/ListPage.js +1 -1
- package/lib/cjs/pages/TablePage.js +1 -1
- package/lib/mjs/ResponsibleContainer.js +3 -3
- package/lib/mjs/SearchField.js +8 -9
- package/lib/mjs/TabBox.d.ts +4 -5
- package/lib/mjs/TabBox.js +7 -3
- package/lib/mjs/pages/DataGridPage.js +2 -2
- package/lib/mjs/pages/FixedListPage.js +2 -2
- package/lib/mjs/pages/ListPage.js +2 -2
- package/lib/mjs/pages/TablePage.js +2 -2
- package/package.json +2 -2
- package/src/ResponsibleContainer.tsx +4 -3
- package/src/SearchField.tsx +8 -14
- package/src/TabBox.tsx +20 -11
- package/src/pages/DataGridPage.tsx +3 -2
- package/src/pages/FixedListPage.tsx +3 -2
- package/src/pages/ListPage.tsx +3 -2
- package/src/pages/TablePage.tsx +3 -2
package/'
ADDED
|
File without changes
|
|
@@ -59,7 +59,7 @@ function ResponsibleContainer(props) {
|
|
|
59
59
|
return loadData(GridUtils_1.GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
60
60
|
};
|
|
61
61
|
// Search data
|
|
62
|
-
const searchData =
|
|
62
|
+
const searchData = (0, react_2.useSearchParamsWithCache)(cacheKey);
|
|
63
63
|
// On submit callback
|
|
64
64
|
const onSubmit = (data, _reset) => {
|
|
65
65
|
if (data == null || state.ref == null)
|
|
@@ -177,7 +177,7 @@ function ResponsibleContainer(props) {
|
|
|
177
177
|
rect?.width == null ||
|
|
178
178
|
rect.width < 20)
|
|
179
179
|
return;
|
|
180
|
-
const f = typeof fields == "function" ? fields(searchData
|
|
180
|
+
const f = typeof fields == "function" ? fields(searchData) : fields;
|
|
181
181
|
return ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, width: rect.width, top: searchBarTop }));
|
|
182
182
|
}, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
|
|
183
183
|
// Pull container
|
package/lib/cjs/SearchField.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.SearchField = SearchField;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("@etsoo/react");
|
|
9
9
|
const react_2 = __importDefault(require("react"));
|
|
10
|
-
const MUGlobal_1 = require("./MUGlobal");
|
|
11
10
|
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
11
|
+
const MUGlobal_1 = require("./MUGlobal");
|
|
12
12
|
/**
|
|
13
13
|
* Search field
|
|
14
14
|
* @param props Props
|
|
@@ -16,14 +16,13 @@ const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
|
16
16
|
*/
|
|
17
17
|
function SearchField(props) {
|
|
18
18
|
// Destruct
|
|
19
|
-
const { changeDelay,
|
|
19
|
+
const { changeDelay, onChange, readOnly, slotProps = {}, size = MUGlobal_1.MUGlobal.searchFieldSize, variant = MUGlobal_1.MUGlobal.searchFieldVariant, minChars = 0, ...rest } = props;
|
|
20
20
|
// Shrink
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
inputProps["data-min-chars"] = minChars;
|
|
21
|
+
const defaultProps = {
|
|
22
|
+
input: { readOnly: readOnly },
|
|
23
|
+
inputLabel: { shrink: MUGlobal_1.MUGlobal.searchFieldShrink },
|
|
24
|
+
htmlInput: { "data-min-chars": minChars }
|
|
25
|
+
};
|
|
27
26
|
const isMounted = react_2.default.useRef(true);
|
|
28
27
|
const delayed = onChange != null && changeDelay != null && changeDelay >= 1
|
|
29
28
|
? (0, react_1.useDelayedExecutor)(onChange, changeDelay)
|
|
@@ -52,5 +51,5 @@ function SearchField(props) {
|
|
|
52
51
|
};
|
|
53
52
|
}, []);
|
|
54
53
|
// Layout
|
|
55
|
-
return ((0, jsx_runtime_1.jsx)(TextField_1.default, {
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(TextField_1.default, { slotProps: Object.assign(slotProps, defaultProps), onChange: onChangeEx, size: size, variant: variant, ...rest }));
|
|
56
55
|
}
|
package/lib/cjs/TabBox.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { BoxProps } from "@mui/material/Box";
|
|
|
2
2
|
import { TabProps } from "@mui/material/Tab";
|
|
3
3
|
import { TabsProps } from "@mui/material/Tabs";
|
|
4
4
|
import React from "react";
|
|
5
|
+
type TabBoxPanelActionType = () => void;
|
|
6
|
+
type TabBoxPanelChildrenType = TabBoxPanelActionType | ((visible: boolean) => React.ReactNode) | React.ReactNode;
|
|
5
7
|
/**
|
|
6
8
|
* Tab with box panel props
|
|
7
9
|
*/
|
|
@@ -9,15 +11,11 @@ export interface TabBoxPanel extends Omit<TabProps, "value" | "children"> {
|
|
|
9
11
|
/**
|
|
10
12
|
* Children
|
|
11
13
|
*/
|
|
12
|
-
children
|
|
14
|
+
children: TabBoxPanelChildrenType;
|
|
13
15
|
/**
|
|
14
16
|
* Panel box props
|
|
15
17
|
*/
|
|
16
18
|
panelProps?: Omit<BoxProps, "hidden">;
|
|
17
|
-
/**
|
|
18
|
-
* Tab action
|
|
19
|
-
*/
|
|
20
|
-
action?: () => void;
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
21
|
* Tabs with box props
|
|
@@ -58,3 +56,4 @@ export interface TabBoxPros extends BoxProps {
|
|
|
58
56
|
* @returns Component
|
|
59
57
|
*/
|
|
60
58
|
export declare function TabBox(props: TabBoxPros): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export {};
|
package/lib/cjs/TabBox.js
CHANGED
|
@@ -10,6 +10,9 @@ const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
|
10
10
|
const Tab_1 = __importDefault(require("@mui/material/Tab"));
|
|
11
11
|
const Tabs_1 = __importDefault(require("@mui/material/Tabs"));
|
|
12
12
|
const react_1 = __importDefault(require("react"));
|
|
13
|
+
function isActionTab(children) {
|
|
14
|
+
return typeof children === "function" && children.length === 0;
|
|
15
|
+
}
|
|
13
16
|
/**
|
|
14
17
|
* Tabs with box
|
|
15
18
|
* @param props Props
|
|
@@ -28,13 +31,14 @@ function TabBox(props) {
|
|
|
28
31
|
}, [index]);
|
|
29
32
|
// Layout
|
|
30
33
|
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [inputName && (0, jsx_runtime_1.jsx)("input", { type: "hidden", name: inputName, value: value }), (0, jsx_runtime_1.jsx)(Box_1.default, { ...root, children: (0, jsx_runtime_1.jsx)(Tabs_1.default, { value: value, onChange: (event, newValue) => {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
const { children } = tabs[newValue];
|
|
35
|
+
if (isActionTab(children)) {
|
|
36
|
+
children();
|
|
33
37
|
}
|
|
34
38
|
else {
|
|
35
39
|
setValue(newValue);
|
|
36
40
|
if (onChange)
|
|
37
41
|
onChange(event, newValue);
|
|
38
42
|
}
|
|
39
|
-
}, ...rest, children: tabs.map(({
|
|
43
|
+
}, ...rest, children: tabs.map(({ children, panelProps, ...tabRest }, index) => ((0, jsx_runtime_1.jsx)(Tab_1.default, { value: index, ...tabRest }, index))) }) }), tabs.map(({ children, panelProps }, index) => ((0, jsx_runtime_1.jsx)(Box_1.default, { hidden: value !== index, ...tabProps, ...panelProps, children: isActionTab(children) ? ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, {})) : (shared_1.Utils.getResult(children, value === index)) }, index)))] }));
|
|
40
44
|
}
|
|
@@ -44,7 +44,7 @@ function DataGridPage(props) {
|
|
|
44
44
|
return loadData(GridUtils_1.GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
45
45
|
};
|
|
46
46
|
// Search data
|
|
47
|
-
const searchData =
|
|
47
|
+
const searchData = (0, react_1.useSearchParamsWithCache)(cacheKey);
|
|
48
48
|
const onInitLoad = (ref) => {
|
|
49
49
|
// Avoid repeatedly load from cache
|
|
50
50
|
if (initLoadedRef.current || !cacheKey)
|
|
@@ -50,7 +50,7 @@ function FixedListPage(props) {
|
|
|
50
50
|
return loadData(GridUtils_1.GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
51
51
|
};
|
|
52
52
|
// Search data
|
|
53
|
-
const searchData =
|
|
53
|
+
const searchData = (0, react_1.useSearchParamsWithCache)(cacheKey);
|
|
54
54
|
const onInitLoad = (ref) => {
|
|
55
55
|
// Avoid repeatedly load from cache
|
|
56
56
|
if (initLoadedRef.current || !cacheKey)
|
|
@@ -51,7 +51,7 @@ function ListPage(props) {
|
|
|
51
51
|
const { dimensions } = (0, react_1.useDimensions)(1, undefined, sizeReadyMiliseconds);
|
|
52
52
|
const rect = dimensions[0][2];
|
|
53
53
|
// Search data
|
|
54
|
-
const searchData =
|
|
54
|
+
const searchData = (0, react_1.useSearchParamsWithCache)(cacheKey);
|
|
55
55
|
const onInitLoad = (ref) => {
|
|
56
56
|
// Avoid repeatedly load from cache
|
|
57
57
|
if (initLoadedRef.current || !cacheKey)
|
|
@@ -47,7 +47,7 @@ function TablePage(props) {
|
|
|
47
47
|
return loadData(GridUtils_1.GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
48
48
|
};
|
|
49
49
|
// Search data
|
|
50
|
-
const searchData =
|
|
50
|
+
const searchData = (0, react_1.useSearchParamsWithCache)(cacheKey);
|
|
51
51
|
// Total width
|
|
52
52
|
const totalWidth = react_2.default.useMemo(() => columns.reduce((previousValue, { width, minWidth }) => {
|
|
53
53
|
return previousValue + (width ?? minWidth ?? TableEx_1.TableExMinWidth);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { ReactUtils, useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
3
|
+
import { ReactUtils, useCombinedRefs, useDimensions, useSearchParamsWithCache } from "@etsoo/react";
|
|
4
4
|
import { DataGridEx } from "./DataGridEx";
|
|
5
5
|
import { MUGlobal } from "./MUGlobal";
|
|
6
6
|
import { PullToRefreshUI } from "./PullToRefreshUI";
|
|
@@ -53,7 +53,7 @@ export function ResponsibleContainer(props) {
|
|
|
53
53
|
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
54
54
|
};
|
|
55
55
|
// Search data
|
|
56
|
-
const searchData =
|
|
56
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
57
57
|
// On submit callback
|
|
58
58
|
const onSubmit = (data, _reset) => {
|
|
59
59
|
if (data == null || state.ref == null)
|
|
@@ -171,7 +171,7 @@ export function ResponsibleContainer(props) {
|
|
|
171
171
|
rect?.width == null ||
|
|
172
172
|
rect.width < 20)
|
|
173
173
|
return;
|
|
174
|
-
const f = typeof fields == "function" ? fields(searchData
|
|
174
|
+
const f = typeof fields == "function" ? fields(searchData) : fields;
|
|
175
175
|
return (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, width: rect.width, top: searchBarTop }));
|
|
176
176
|
}, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
|
|
177
177
|
// Pull container
|
package/lib/mjs/SearchField.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useDelayedExecutor } from "@etsoo/react";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { MUGlobal } from "./MUGlobal";
|
|
5
4
|
import TextField from "@mui/material/TextField";
|
|
5
|
+
import { MUGlobal } from "./MUGlobal";
|
|
6
6
|
/**
|
|
7
7
|
* Search field
|
|
8
8
|
* @param props Props
|
|
@@ -10,14 +10,13 @@ import TextField from "@mui/material/TextField";
|
|
|
10
10
|
*/
|
|
11
11
|
export function SearchField(props) {
|
|
12
12
|
// Destruct
|
|
13
|
-
const { changeDelay,
|
|
13
|
+
const { changeDelay, onChange, readOnly, slotProps = {}, size = MUGlobal.searchFieldSize, variant = MUGlobal.searchFieldVariant, minChars = 0, ...rest } = props;
|
|
14
14
|
// Shrink
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
inputProps["data-min-chars"] = minChars;
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
input: { readOnly: readOnly },
|
|
17
|
+
inputLabel: { shrink: MUGlobal.searchFieldShrink },
|
|
18
|
+
htmlInput: { "data-min-chars": minChars }
|
|
19
|
+
};
|
|
21
20
|
const isMounted = React.useRef(true);
|
|
22
21
|
const delayed = onChange != null && changeDelay != null && changeDelay >= 1
|
|
23
22
|
? useDelayedExecutor(onChange, changeDelay)
|
|
@@ -46,5 +45,5 @@ export function SearchField(props) {
|
|
|
46
45
|
};
|
|
47
46
|
}, []);
|
|
48
47
|
// Layout
|
|
49
|
-
return (_jsx(TextField, {
|
|
48
|
+
return (_jsx(TextField, { slotProps: Object.assign(slotProps, defaultProps), onChange: onChangeEx, size: size, variant: variant, ...rest }));
|
|
50
49
|
}
|
package/lib/mjs/TabBox.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { BoxProps } from "@mui/material/Box";
|
|
|
2
2
|
import { TabProps } from "@mui/material/Tab";
|
|
3
3
|
import { TabsProps } from "@mui/material/Tabs";
|
|
4
4
|
import React from "react";
|
|
5
|
+
type TabBoxPanelActionType = () => void;
|
|
6
|
+
type TabBoxPanelChildrenType = TabBoxPanelActionType | ((visible: boolean) => React.ReactNode) | React.ReactNode;
|
|
5
7
|
/**
|
|
6
8
|
* Tab with box panel props
|
|
7
9
|
*/
|
|
@@ -9,15 +11,11 @@ export interface TabBoxPanel extends Omit<TabProps, "value" | "children"> {
|
|
|
9
11
|
/**
|
|
10
12
|
* Children
|
|
11
13
|
*/
|
|
12
|
-
children
|
|
14
|
+
children: TabBoxPanelChildrenType;
|
|
13
15
|
/**
|
|
14
16
|
* Panel box props
|
|
15
17
|
*/
|
|
16
18
|
panelProps?: Omit<BoxProps, "hidden">;
|
|
17
|
-
/**
|
|
18
|
-
* Tab action
|
|
19
|
-
*/
|
|
20
|
-
action?: () => void;
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
21
|
* Tabs with box props
|
|
@@ -58,3 +56,4 @@ export interface TabBoxPros extends BoxProps {
|
|
|
58
56
|
* @returns Component
|
|
59
57
|
*/
|
|
60
58
|
export declare function TabBox(props: TabBoxPros): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export {};
|
package/lib/mjs/TabBox.js
CHANGED
|
@@ -4,6 +4,9 @@ import Box from "@mui/material/Box";
|
|
|
4
4
|
import Tab from "@mui/material/Tab";
|
|
5
5
|
import Tabs from "@mui/material/Tabs";
|
|
6
6
|
import React from "react";
|
|
7
|
+
function isActionTab(children) {
|
|
8
|
+
return typeof children === "function" && children.length === 0;
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
11
|
* Tabs with box
|
|
9
12
|
* @param props Props
|
|
@@ -22,13 +25,14 @@ export function TabBox(props) {
|
|
|
22
25
|
}, [index]);
|
|
23
26
|
// Layout
|
|
24
27
|
return (_jsxs(React.Fragment, { children: [inputName && _jsx("input", { type: "hidden", name: inputName, value: value }), _jsx(Box, { ...root, children: _jsx(Tabs, { value: value, onChange: (event, newValue) => {
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
const { children } = tabs[newValue];
|
|
29
|
+
if (isActionTab(children)) {
|
|
30
|
+
children();
|
|
27
31
|
}
|
|
28
32
|
else {
|
|
29
33
|
setValue(newValue);
|
|
30
34
|
if (onChange)
|
|
31
35
|
onChange(event, newValue);
|
|
32
36
|
}
|
|
33
|
-
}, ...rest, children: tabs.map(({
|
|
37
|
+
}, ...rest, children: tabs.map(({ children, panelProps, ...tabRest }, index) => (_jsx(Tab, { value: index, ...tabRest }, index))) }) }), tabs.map(({ children, panelProps }, index) => (_jsx(Box, { hidden: value !== index, ...tabProps, ...panelProps, children: isActionTab(children) ? (_jsx(React.Fragment, {})) : (Utils.getResult(children, value === index)) }, index)))] }));
|
|
34
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
2
|
+
import { useCombinedRefs, useDimensions, useSearchParamsWithCache } from "@etsoo/react";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { DataGridEx } from "../DataGridEx";
|
|
5
5
|
import { MUGlobal } from "../MUGlobal";
|
|
@@ -38,7 +38,7 @@ export function DataGridPage(props) {
|
|
|
38
38
|
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
39
39
|
};
|
|
40
40
|
// Search data
|
|
41
|
-
const searchData =
|
|
41
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
42
42
|
const onInitLoad = (ref) => {
|
|
43
43
|
// Avoid repeatedly load from cache
|
|
44
44
|
if (initLoadedRef.current || !cacheKey)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
2
|
+
import { useCombinedRefs, useDimensions, useSearchParamsWithCache } from "@etsoo/react";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { MUGlobal } from "../MUGlobal";
|
|
5
5
|
import { ScrollerListEx } from "../ScrollerListEx";
|
|
@@ -44,7 +44,7 @@ export function FixedListPage(props) {
|
|
|
44
44
|
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
45
45
|
};
|
|
46
46
|
// Search data
|
|
47
|
-
const searchData =
|
|
47
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
48
48
|
const onInitLoad = (ref) => {
|
|
49
49
|
// Avoid repeatedly load from cache
|
|
50
50
|
if (initLoadedRef.current || !cacheKey)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
2
|
+
import { useCombinedRefs, useDimensions, useSearchParamsWithCache } from "@etsoo/react";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { MUGlobal } from "../MUGlobal";
|
|
5
5
|
import { ScrollerListEx } from "../ScrollerListEx";
|
|
@@ -45,7 +45,7 @@ export function ListPage(props) {
|
|
|
45
45
|
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
|
|
46
46
|
const rect = dimensions[0][2];
|
|
47
47
|
// Search data
|
|
48
|
-
const searchData =
|
|
48
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
49
49
|
const onInitLoad = (ref) => {
|
|
50
50
|
// Avoid repeatedly load from cache
|
|
51
51
|
if (initLoadedRef.current || !cacheKey)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
2
|
+
import { useCombinedRefs, useDimensions, useSearchParamsWithCache } from "@etsoo/react";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { MUGlobal } from "../MUGlobal";
|
|
5
5
|
import { SearchBar } from "../SearchBar";
|
|
@@ -41,7 +41,7 @@ export function TablePage(props) {
|
|
|
41
41
|
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
42
42
|
};
|
|
43
43
|
// Search data
|
|
44
|
-
const searchData =
|
|
44
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
45
45
|
// Total width
|
|
46
46
|
const totalWidth = React.useMemo(() => columns.reduce((previousValue, { width, minWidth }) => {
|
|
47
47
|
return previousValue + (width ?? minWidth ?? TableExMinWidth);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.14",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@emotion/styled": "^11.14.0",
|
|
43
43
|
"@etsoo/appscript": "^1.6.21",
|
|
44
44
|
"@etsoo/notificationbase": "^1.1.60",
|
|
45
|
-
"@etsoo/react": "^1.8.
|
|
45
|
+
"@etsoo/react": "^1.8.37",
|
|
46
46
|
"@etsoo/shared": "^1.2.66",
|
|
47
47
|
"@mui/icons-material": "^7.0.1",
|
|
48
48
|
"@mui/material": "^7.0.1",
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
ReactUtils,
|
|
16
16
|
ScrollerListRef,
|
|
17
17
|
useCombinedRefs,
|
|
18
|
-
useDimensions
|
|
18
|
+
useDimensions,
|
|
19
|
+
useSearchParamsWithCache
|
|
19
20
|
} from "@etsoo/react";
|
|
20
21
|
import { DataGridEx, DataGridExProps } from "./DataGridEx";
|
|
21
22
|
import { MUGlobal } from "./MUGlobal";
|
|
@@ -252,7 +253,7 @@ export function ResponsibleContainer<T extends object, F>(
|
|
|
252
253
|
};
|
|
253
254
|
|
|
254
255
|
// Search data
|
|
255
|
-
const searchData =
|
|
256
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
256
257
|
|
|
257
258
|
// On submit callback
|
|
258
259
|
const onSubmit = (data: FormData, _reset: boolean) => {
|
|
@@ -437,7 +438,7 @@ export function ResponsibleContainer<T extends object, F>(
|
|
|
437
438
|
)
|
|
438
439
|
return;
|
|
439
440
|
|
|
440
|
-
const f = typeof fields == "function" ? fields(searchData
|
|
441
|
+
const f = typeof fields == "function" ? fields(searchData) : fields;
|
|
441
442
|
|
|
442
443
|
return (
|
|
443
444
|
<SearchBar
|
package/src/SearchField.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useDelayedExecutor } from "@etsoo/react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { MUGlobal } from "./MUGlobal";
|
|
4
3
|
import TextField, { TextFieldProps } from "@mui/material/TextField";
|
|
4
|
+
import { MUGlobal } from "./MUGlobal";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Search field props
|
|
@@ -32,11 +32,9 @@ export function SearchField(props: SearchFieldProps) {
|
|
|
32
32
|
// Destruct
|
|
33
33
|
const {
|
|
34
34
|
changeDelay,
|
|
35
|
-
InputLabelProps = {},
|
|
36
|
-
InputProps = {},
|
|
37
|
-
inputProps = {},
|
|
38
35
|
onChange,
|
|
39
36
|
readOnly,
|
|
37
|
+
slotProps = {},
|
|
40
38
|
size = MUGlobal.searchFieldSize,
|
|
41
39
|
variant = MUGlobal.searchFieldVariant,
|
|
42
40
|
minChars = 0,
|
|
@@ -44,13 +42,11 @@ export function SearchField(props: SearchFieldProps) {
|
|
|
44
42
|
} = props;
|
|
45
43
|
|
|
46
44
|
// Shrink
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// Min characters
|
|
53
|
-
inputProps["data-min-chars"] = minChars;
|
|
45
|
+
const defaultProps: typeof slotProps = {
|
|
46
|
+
input: { readOnly: readOnly },
|
|
47
|
+
inputLabel: { shrink: MUGlobal.searchFieldShrink },
|
|
48
|
+
htmlInput: { "data-min-chars": minChars }
|
|
49
|
+
};
|
|
54
50
|
|
|
55
51
|
const isMounted = React.useRef(true);
|
|
56
52
|
const delayed =
|
|
@@ -90,9 +86,7 @@ export function SearchField(props: SearchFieldProps) {
|
|
|
90
86
|
// Layout
|
|
91
87
|
return (
|
|
92
88
|
<TextField
|
|
93
|
-
|
|
94
|
-
InputProps={InputProps}
|
|
95
|
-
inputProps={inputProps}
|
|
89
|
+
slotProps={Object.assign(slotProps, defaultProps)}
|
|
96
90
|
onChange={onChangeEx}
|
|
97
91
|
size={size}
|
|
98
92
|
variant={variant}
|
package/src/TabBox.tsx
CHANGED
|
@@ -4,6 +4,19 @@ import Tab, { TabProps } from "@mui/material/Tab";
|
|
|
4
4
|
import Tabs, { TabsProps } from "@mui/material/Tabs";
|
|
5
5
|
import React from "react";
|
|
6
6
|
|
|
7
|
+
type TabBoxPanelActionType = () => void;
|
|
8
|
+
|
|
9
|
+
type TabBoxPanelChildrenType =
|
|
10
|
+
| TabBoxPanelActionType
|
|
11
|
+
| ((visible: boolean) => React.ReactNode)
|
|
12
|
+
| React.ReactNode;
|
|
13
|
+
|
|
14
|
+
function isActionTab(
|
|
15
|
+
children?: TabBoxPanelChildrenType
|
|
16
|
+
): children is TabBoxPanelActionType {
|
|
17
|
+
return typeof children === "function" && children.length === 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
/**
|
|
8
21
|
* Tab with box panel props
|
|
9
22
|
*/
|
|
@@ -11,17 +24,12 @@ export interface TabBoxPanel extends Omit<TabProps, "value" | "children"> {
|
|
|
11
24
|
/**
|
|
12
25
|
* Children
|
|
13
26
|
*/
|
|
14
|
-
children
|
|
27
|
+
children: TabBoxPanelChildrenType;
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* Panel box props
|
|
18
31
|
*/
|
|
19
32
|
panelProps?: Omit<BoxProps, "hidden">;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Tab action
|
|
23
|
-
*/
|
|
24
|
-
action?: () => void;
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
/**
|
|
@@ -98,8 +106,9 @@ export function TabBox(props: TabBoxPros) {
|
|
|
98
106
|
<Tabs
|
|
99
107
|
value={value}
|
|
100
108
|
onChange={(event, newValue) => {
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
const { children } = tabs[newValue];
|
|
110
|
+
if (isActionTab(children)) {
|
|
111
|
+
children();
|
|
103
112
|
} else {
|
|
104
113
|
setValue(newValue);
|
|
105
114
|
if (onChange) onChange(event, newValue);
|
|
@@ -107,14 +116,14 @@ export function TabBox(props: TabBoxPros) {
|
|
|
107
116
|
}}
|
|
108
117
|
{...rest}
|
|
109
118
|
>
|
|
110
|
-
{tabs.map(({
|
|
119
|
+
{tabs.map(({ children, panelProps, ...tabRest }, index) => (
|
|
111
120
|
<Tab key={index} value={index} {...tabRest} />
|
|
112
121
|
))}
|
|
113
122
|
</Tabs>
|
|
114
123
|
</Box>
|
|
115
|
-
{tabs.map(({
|
|
124
|
+
{tabs.map(({ children, panelProps }, index) => (
|
|
116
125
|
<Box key={index} hidden={value !== index} {...tabProps} {...panelProps}>
|
|
117
|
-
{
|
|
126
|
+
{isActionTab(children) ? (
|
|
118
127
|
<React.Fragment />
|
|
119
128
|
) : (
|
|
120
129
|
Utils.getResult(children, value === index)
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
ScrollerGridForwardRef,
|
|
6
6
|
VariableSizeGrid,
|
|
7
7
|
useCombinedRefs,
|
|
8
|
-
useDimensions
|
|
8
|
+
useDimensions,
|
|
9
|
+
useSearchParamsWithCache
|
|
9
10
|
} from "@etsoo/react";
|
|
10
11
|
import React from "react";
|
|
11
12
|
import { DataGridEx } from "../DataGridEx";
|
|
@@ -84,7 +85,7 @@ export function DataGridPage<T extends object, F>(
|
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
// Search data
|
|
87
|
-
const searchData =
|
|
88
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
88
89
|
|
|
89
90
|
const onInitLoad = (
|
|
90
91
|
ref: VariableSizeGrid<T>
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
ScrollerListForwardRef,
|
|
6
6
|
ScrollerListRef,
|
|
7
7
|
useCombinedRefs,
|
|
8
|
-
useDimensions
|
|
8
|
+
useDimensions,
|
|
9
|
+
useSearchParamsWithCache
|
|
9
10
|
} from "@etsoo/react";
|
|
10
11
|
import React from "react";
|
|
11
12
|
import { MUGlobal } from "../MUGlobal";
|
|
@@ -94,7 +95,7 @@ export function FixedListPage<T extends object, F>(
|
|
|
94
95
|
};
|
|
95
96
|
|
|
96
97
|
// Search data
|
|
97
|
-
const searchData =
|
|
98
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
98
99
|
|
|
99
100
|
const onInitLoad = (
|
|
100
101
|
ref: ScrollerListRef
|
package/src/pages/ListPage.tsx
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
ScrollerListForwardRef,
|
|
6
6
|
ScrollerListRef,
|
|
7
7
|
useCombinedRefs,
|
|
8
|
-
useDimensions
|
|
8
|
+
useDimensions,
|
|
9
|
+
useSearchParamsWithCache
|
|
9
10
|
} from "@etsoo/react";
|
|
10
11
|
import React from "react";
|
|
11
12
|
import { MUGlobal } from "../MUGlobal";
|
|
@@ -86,7 +87,7 @@ export function ListPage<T extends object, F>(props: ListPageProps<T, F>) {
|
|
|
86
87
|
const rect = dimensions[0][2];
|
|
87
88
|
|
|
88
89
|
// Search data
|
|
89
|
-
const searchData =
|
|
90
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
90
91
|
|
|
91
92
|
const onInitLoad = (
|
|
92
93
|
ref: ScrollerListRef
|
package/src/pages/TablePage.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GridLoadDataProps,
|
|
3
3
|
useCombinedRefs,
|
|
4
|
-
useDimensions
|
|
4
|
+
useDimensions,
|
|
5
|
+
useSearchParamsWithCache
|
|
5
6
|
} from "@etsoo/react";
|
|
6
7
|
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
7
8
|
import React from "react";
|
|
@@ -93,7 +94,7 @@ export function TablePage<
|
|
|
93
94
|
};
|
|
94
95
|
|
|
95
96
|
// Search data
|
|
96
|
-
const searchData =
|
|
97
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
97
98
|
|
|
98
99
|
// Total width
|
|
99
100
|
const totalWidth = React.useMemo(
|