@etsoo/materialui 1.5.11 → 1.5.12
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/TabBox.d.ts +2 -2
- package/lib/cjs/TabBox.js +9 -5
- package/lib/mjs/TabBox.d.ts +2 -2
- package/lib/mjs/TabBox.js +9 -5
- package/package.json +1 -1
- package/src/TabBox.tsx +16 -14
package/lib/cjs/TabBox.d.ts
CHANGED
package/lib/cjs/TabBox.js
CHANGED
|
@@ -10,7 +10,6 @@ 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
|
-
const react_router_1 = require("react-router");
|
|
14
13
|
/**
|
|
15
14
|
* Tabs with box
|
|
16
15
|
* @param props Props
|
|
@@ -29,8 +28,13 @@ function TabBox(props) {
|
|
|
29
28
|
}, [index]);
|
|
30
29
|
// Layout
|
|
31
30
|
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) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
if (tabs[newValue].action) {
|
|
32
|
+
tabs[newValue].action();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
setValue(newValue);
|
|
36
|
+
if (onChange)
|
|
37
|
+
onChange(event, newValue);
|
|
38
|
+
}
|
|
39
|
+
}, ...rest, children: tabs.map(({ action, children, panelProps, ...tabRest }, index) => ((0, jsx_runtime_1.jsx)(Tab_1.default, { value: index, ...tabRest }, index))) }) }), tabs.map(({ action, children, panelProps }, index) => ((0, jsx_runtime_1.jsx)(Box_1.default, { hidden: value !== index, ...tabProps, ...panelProps, children: action ? ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, {})) : (shared_1.Utils.getResult(children, value === index)) }, index)))] }));
|
|
36
40
|
}
|
package/lib/mjs/TabBox.d.ts
CHANGED
package/lib/mjs/TabBox.js
CHANGED
|
@@ -4,7 +4,6 @@ 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
|
-
import { Link } from "react-router";
|
|
8
7
|
/**
|
|
9
8
|
* Tabs with box
|
|
10
9
|
* @param props Props
|
|
@@ -23,8 +22,13 @@ export function TabBox(props) {
|
|
|
23
22
|
}, [index]);
|
|
24
23
|
// Layout
|
|
25
24
|
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) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (tabs[newValue].action) {
|
|
26
|
+
tabs[newValue].action();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
setValue(newValue);
|
|
30
|
+
if (onChange)
|
|
31
|
+
onChange(event, newValue);
|
|
32
|
+
}
|
|
33
|
+
}, ...rest, children: tabs.map(({ action, children, panelProps, ...tabRest }, index) => (_jsx(Tab, { value: index, ...tabRest }, index))) }) }), tabs.map(({ action, children, panelProps }, index) => (_jsx(Box, { hidden: value !== index, ...tabProps, ...panelProps, children: action ? (_jsx(React.Fragment, {})) : (Utils.getResult(children, value === index)) }, index)))] }));
|
|
30
34
|
}
|
package/package.json
CHANGED
package/src/TabBox.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import Box, { BoxProps } from "@mui/material/Box";
|
|
|
3
3
|
import Tab, { TabProps } from "@mui/material/Tab";
|
|
4
4
|
import Tabs, { TabsProps } from "@mui/material/Tabs";
|
|
5
5
|
import React from "react";
|
|
6
|
-
import { Link } from "react-router";
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Tab with box panel props
|
|
@@ -20,9 +19,9 @@ export interface TabBoxPanel extends Omit<TabProps, "value" | "children"> {
|
|
|
20
19
|
panelProps?: Omit<BoxProps, "hidden">;
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
22
|
+
* Tab action
|
|
24
23
|
*/
|
|
25
|
-
|
|
24
|
+
action?: () => void;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
/**
|
|
@@ -99,24 +98,27 @@ export function TabBox(props: TabBoxPros) {
|
|
|
99
98
|
<Tabs
|
|
100
99
|
value={value}
|
|
101
100
|
onChange={(event, newValue) => {
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
if (tabs[newValue].action) {
|
|
102
|
+
tabs[newValue].action();
|
|
103
|
+
} else {
|
|
104
|
+
setValue(newValue);
|
|
105
|
+
if (onChange) onChange(event, newValue);
|
|
106
|
+
}
|
|
104
107
|
}}
|
|
105
108
|
{...rest}
|
|
106
109
|
>
|
|
107
|
-
{tabs.map(({ children, panelProps, ...tabRest }, index) => (
|
|
108
|
-
<Tab
|
|
109
|
-
key={index}
|
|
110
|
-
value={index}
|
|
111
|
-
LinkComponent={tabRest.to ? Link : undefined}
|
|
112
|
-
{...tabRest}
|
|
113
|
-
/>
|
|
110
|
+
{tabs.map(({ action, children, panelProps, ...tabRest }, index) => (
|
|
111
|
+
<Tab key={index} value={index} {...tabRest} />
|
|
114
112
|
))}
|
|
115
113
|
</Tabs>
|
|
116
114
|
</Box>
|
|
117
|
-
{tabs.map(({ children, panelProps }, index) => (
|
|
115
|
+
{tabs.map(({ action, children, panelProps }, index) => (
|
|
118
116
|
<Box key={index} hidden={value !== index} {...tabProps} {...panelProps}>
|
|
119
|
-
{
|
|
117
|
+
{action ? (
|
|
118
|
+
<React.Fragment />
|
|
119
|
+
) : (
|
|
120
|
+
Utils.getResult(children, value === index)
|
|
121
|
+
)}
|
|
120
122
|
</Box>
|
|
121
123
|
))}
|
|
122
124
|
</React.Fragment>
|