@etsoo/materialui 1.5.10 → 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.
@@ -15,9 +15,9 @@ export interface TabBoxPanel extends Omit<TabProps, "value" | "children"> {
15
15
  */
16
16
  panelProps?: Omit<BoxProps, "hidden">;
17
17
  /**
18
- * To URL
18
+ * Tab action
19
19
  */
20
- to?: string;
20
+ action?: () => void;
21
21
  }
22
22
  /**
23
23
  * Tabs with box props
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
- setValue(newValue);
33
- if (onChange)
34
- onChange(event, newValue);
35
- }, ...rest, children: tabs.map(({ children, panelProps, ...tabRest }, index) => ((0, jsx_runtime_1.jsx)(Tab_1.default, { value: index, LinkComponent: tabRest.to ? react_router_1.Link : undefined, ...tabRest }, index))) }) }), tabs.map(({ children, panelProps }, index) => ((0, jsx_runtime_1.jsx)(Box_1.default, { hidden: value !== index, ...tabProps, ...panelProps, children: shared_1.Utils.getResult(children, value === index) }, index)))] }));
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
  }
@@ -6,7 +6,7 @@ import { ViewContainerProps } from "../ViewContainer";
6
6
  /**
7
7
  * View page props
8
8
  */
9
- export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, "children">, Omit<ViewContainerProps<T>, "data"> {
9
+ export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, "children">, Omit<ViewContainerProps<T>, "data" | "refresh"> {
10
10
  /**
11
11
  * Actions
12
12
  */
@@ -15,9 +15,9 @@ export interface TabBoxPanel extends Omit<TabProps, "value" | "children"> {
15
15
  */
16
16
  panelProps?: Omit<BoxProps, "hidden">;
17
17
  /**
18
- * To URL
18
+ * Tab action
19
19
  */
20
- to?: string;
20
+ action?: () => void;
21
21
  }
22
22
  /**
23
23
  * Tabs with box props
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
- setValue(newValue);
27
- if (onChange)
28
- onChange(event, newValue);
29
- }, ...rest, children: tabs.map(({ children, panelProps, ...tabRest }, index) => (_jsx(Tab, { value: index, LinkComponent: tabRest.to ? Link : undefined, ...tabRest }, index))) }) }), tabs.map(({ children, panelProps }, index) => (_jsx(Box, { hidden: value !== index, ...tabProps, ...panelProps, children: Utils.getResult(children, value === index) }, index)))] }));
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
  }
@@ -6,7 +6,7 @@ import { ViewContainerProps } from "../ViewContainer";
6
6
  /**
7
7
  * View page props
8
8
  */
9
- export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, "children">, Omit<ViewContainerProps<T>, "data"> {
9
+ export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, "children">, Omit<ViewContainerProps<T>, "data" | "refresh"> {
10
10
  /**
11
11
  * Actions
12
12
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.10",
3
+ "version": "1.5.12",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -46,7 +46,7 @@
46
46
  "@etsoo/shared": "^1.2.66",
47
47
  "@mui/icons-material": "^7.0.1",
48
48
  "@mui/material": "^7.0.1",
49
- "@mui/x-data-grid": "^7.28.2",
49
+ "@mui/x-data-grid": "^7.28.3",
50
50
  "chart.js": "^4.4.8",
51
51
  "chartjs-plugin-datalabels": "^2.2.0",
52
52
  "eventemitter3": "^5.0.1",
@@ -72,12 +72,12 @@
72
72
  "@babel/preset-react": "^7.26.3",
73
73
  "@babel/preset-typescript": "^7.27.0",
74
74
  "@babel/runtime-corejs3": "^7.27.0",
75
- "@testing-library/react": "^16.2.0",
75
+ "@testing-library/react": "^16.3.0",
76
76
  "@types/pica": "^9.0.5",
77
77
  "@types/pulltorefreshjs": "^0.1.7",
78
78
  "@types/react": "^18.3.20",
79
79
  "@types/react-avatar-editor": "^13.0.4",
80
- "@types/react-dom": "^18.3.5",
80
+ "@types/react-dom": "^18.3.6",
81
81
  "@types/react-input-mask": "^3.0.6",
82
82
  "@types/react-window": "^1.8.8",
83
83
  "@vitejs/plugin-react": "^4.3.4",
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
- * To URL
22
+ * Tab action
24
23
  */
25
- to?: string;
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
- setValue(newValue);
103
- if (onChange) onChange(event, newValue);
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
- {Utils.getResult(children, value === index)}
117
+ {action ? (
118
+ <React.Fragment />
119
+ ) : (
120
+ Utils.getResult(children, value === index)
121
+ )}
120
122
  </Box>
121
123
  ))}
122
124
  </React.Fragment>
@@ -18,7 +18,7 @@ import Stack from "@mui/material/Stack";
18
18
  */
19
19
  export interface ViewPageProps<T extends DataTypes.StringRecord>
20
20
  extends Omit<CommonPageProps, "children">,
21
- Omit<ViewContainerProps<T>, "data"> {
21
+ Omit<ViewContainerProps<T>, "data" | "refresh"> {
22
22
  /**
23
23
  * Actions
24
24
  */